Leviathan  0.8.0.0
Leviathan game engine
Leviathan::UTF8DataIterator Class Reference

Unicode iterator for utf8 on top of string. More...

#include <StringDataIterator.h>

+ Inheritance diagram for Leviathan::UTF8DataIterator:

Public Member Functions

DLLEXPORT UTF8DataIterator (const std::string &str)
 Wraps an utf8 encoded string for StringIterator. More...
 
- Public Member Functions inherited from Leviathan::UTF8PointerDataIterator
DLLEXPORT UTF8PointerDataIterator (const char *begin, const char *end)
 
DLLEXPORT UTF8PointerDataIterator (const std::string &fromstr)
 Helper for creating from strings. More...
 
virtual DLLEXPORT bool GetNextCharCode (int &codepointreceiver, size_t forward)
 Gets the next character unicode code point (usually an ascii value) More...
 
virtual DLLEXPORT bool GetPreviousCharacter (int &receiver)
 Gets the previous character code point. More...
 
virtual DLLEXPORT void MoveToNextCharacter ()
 Moves the iterator forward. More...
 
virtual DLLEXPORT size_t CurrentIteratorPosition () const
 Gets the position of the iterator, for use with ReturnSubString and others. More...
 
virtual DLLEXPORT bool IsPositionValid () const
 Returns true when the iterator is still valid. More...
 
virtual DLLEXPORT size_t GetLastValidIteratorPosition () const
 Gets the last valid index of the underlying string (not the last character but the last byte) More...
 
virtual DLLEXPORT bool ReturnSubString (size_t startpos, size_t endpos, std::string &receiver)
 
- Public Member Functions inherited from Leviathan::StringDataIterator
DLLEXPORT StringDataIterator ()
 
virtual DLLEXPORT ~StringDataIterator ()
 
virtual DLLEXPORT bool ReturnSubString (size_t startpos, size_t endpos, std::wstring &receiver)
 
virtual DLLEXPORT size_t GetCurrentCharacterNumber () const
 Returns the 0 based character number (NOT position, number of characters) More...
 
virtual DLLEXPORT size_t GetCurrentLineNumber () const
 Returns the 1 based line number. More...
 

Protected Attributes

std::string OurString
 
- Protected Attributes inherited from Leviathan::UTF8PointerDataIterator
const char * Current
 The current position of the iterator. More...
 
const char * End
 The end of the string. More...
 
const char * BeginPos
 The starting point for distance checking. More...
 
- Protected Attributes inherited from Leviathan::StringDataIterator
size_t CurrentCharacterNumber
 
size_t CurrentLineNumber
 The current line number, the amount of
characters. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Leviathan::StringDataIterator
DLLEXPORT void CheckLineChange ()
 Updates CurrentLineNumber if currently on a line break. More...
 

Detailed Description

Unicode iterator for utf8 on top of string.

Definition at line 286 of file StringDataIterator.h.

Constructor & Destructor Documentation

◆ UTF8DataIterator()

DLLEXPORT UTF8DataIterator::UTF8DataIterator ( const std::string &  str)

Wraps an utf8 encoded string for StringIterator.

Definition at line 216 of file StringDataIterator.cpp.

216  :
217  UTF8PointerDataIterator(nullptr, nullptr), OurString(str)
218 {
219  // This is a bit hacky
220  Current = OurString.c_str();
221  End = Current + OurString.size();
222  BeginPos = Current;
223 
224 
225  // If the first character is a newline the line number needs to be
226  // incremented immediately
227  CheckLineChange();
228 }
const char * Current
The current position of the iterator.
const char * End
The end of the string.
DLLEXPORT UTF8PointerDataIterator(const char *begin, const char *end)
DLLEXPORT void CheckLineChange()
Updates CurrentLineNumber if currently on a line break.
const char * BeginPos
The starting point for distance checking.

Member Data Documentation

◆ OurString

std::string Leviathan::UTF8DataIterator::OurString
protected

Definition at line 295 of file StringDataIterator.h.


The documentation for this class was generated from the following files: