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

Iterates over runes of utf8 sequences (char, char_t) More...

#include <byte_endian.hpp>

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

Public Types

using IterElem = Rune
 

Public Member Functions

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

Public Attributes

Slice< const T > data
 
size_t strIndex = 0
 

Detailed Description

template<typename T>
struct mtcore::RuneIterator< T >

Iterates over runes of utf8 sequences (char, char_t)

Template Parameters
TCharacter type to iterate over

Definition at line 872 of file byte_endian.hpp.

Member Typedef Documentation

◆ IterElem

template<typename T>
using mtcore::RuneIterator< T >::IterElem = Rune

Definition at line 873 of file byte_endian.hpp.

Member Function Documentation

◆ next()

template<typename T>
Optional< Rune > mtcore::RuneIterator< 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 }
Iterates over runes of utf8 sequences (char, char_t)
Slice< const T > data

Member Data Documentation

◆ data

template<typename T>
Slice<const T> mtcore::RuneIterator< T >::data

Definition at line 874 of file byte_endian.hpp.

◆ strIndex

template<typename T>
size_t mtcore::RuneIterator< T >::strIndex = 0

Definition at line 875 of file byte_endian.hpp.


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