MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::RuneIterator< char32_t > Struct Reference

Iterates over runes of utf32 sequences Also handles flipping endianness to native endian. More...

#include <byte_endian.hpp>

Inheritance diagram for mtcore::RuneIterator< char32_t >:
Collaboration diagram for mtcore::RuneIterator< char32_t >:

Public Types

using IterElem = char32_t
 
using IterElem
 

Public Member Functions

Optional< char32_t > next ()
 
Optional< Runenext ()
 Gets the next Rune, if present.
 

Public Attributes

Slice< const char32_t > data
 
size_t strIndex = 0
 
bool reverseBom = false
 
Slice< const char32_t > data
 
size_t strIndex
 

Detailed Description

Iterates over runes of utf32 sequences Also handles flipping endianness to native endian.

Definition at line 915 of file byte_endian.hpp.

Member Typedef Documentation

◆ IterElem [1/2]

using mtcore::RuneIterator< char32_t >::IterElem

Definition at line 873 of file byte_endian.hpp.

◆ IterElem [2/2]

using mtcore::RuneIterator< char32_t >::IterElem = char32_t

Definition at line 916 of file byte_endian.hpp.

Member Function Documentation

◆ next() [1/2]

Optional< Rune > mtcore::RuneIterator< char32_t >::next ( )
inline

Gets the next Rune, if present.

Definition at line 878 of file byte_endian.hpp.

878 {
879 if (strIndex >= data.size()) {
880 return nullopt;
881 }
882 auto curIndex = strIndex;
883 char32_t currentRune = 0;
885
886 if (numBytes < 0) {
887 ++strIndex;
888 }
889 else if (curIndex + numBytes - 1 >= data.size()) {
890 strIndex = data.size();
891 }
892 else {
894 for (size_t index = curIndex; index < strIndex; ++index) {
897 strIndex = curIndex + index - 1;
898 currentRune = 0;
899 break;
900 }
902 currentRune <<= 6;
904 }
905 }
906 return currentRune;
907 }
Slice< const char32_t > data
Iterates over runes of utf8 sequences (char, char_t)

◆ next() [2/2]

Optional< char32_t > mtcore::RuneIterator< char32_t >::next ( )
inline

Definition at line 921 of file byte_endian.hpp.

921 {
922 if (strIndex >= data.len) {
923 return nullopt;
924 }
925 const auto res = data[strIndex++];
926 if (reverseBom) {
927 return flip_endian_ch32(res);
928 }
929 return res;
930 }
constexpr char32_t flip_endian_ch32(const char32_t ch)
Flips the endianness of a char32.
Here is the call graph for this function:

Member Data Documentation

◆ data [1/2]

Slice<const char32_t> mtcore::RuneIterator< char32_t >::data

Definition at line 874 of file byte_endian.hpp.

◆ data [2/2]

Slice<const char32_t> mtcore::RuneIterator< char32_t >::data

Definition at line 917 of file byte_endian.hpp.

◆ reverseBom

bool mtcore::RuneIterator< char32_t >::reverseBom = false

Definition at line 919 of file byte_endian.hpp.

◆ strIndex [1/2]

size_t mtcore::RuneIterator< char32_t >::strIndex

Definition at line 875 of file byte_endian.hpp.

◆ strIndex [2/2]

size_t mtcore::RuneIterator< char32_t >::strIndex = 0

Definition at line 918 of file byte_endian.hpp.


The documentation for this struct was generated from the following file: