Class CCharacterReaderUTF8#
Defined in File character_reader_utf_8.h
Class Documentation#
-
class CCharacterReaderUTF8#
Reads a given input string, interprets bytes as UTF-8 and returns UTF-8 characters or strings in order of demand.
Public Functions
-
CCharacterReaderUTF8() = default#
Standard constructor for empty character reader.
-
CCharacterReaderUTF8(const std::string &rssString)#
Constructs a character reader from a given string.
- Parameters:
rssString – [in] UTF-8 input string.
- Throws:
XTOMLParseException – Throws an InvalidCharacterException if the input contains invalid UTF-8 characters.
XTOMLParseException – Throws an InvalidByteException if the input contains for UTF-8 invalid bytes.
-
void Feed(const std::string &rssString)#
Feed the character reader from the given string.
- Parameters:
rssString – [in] UTF-8 input string.
-
void Reset()#
Reset the character reader content.
-
std::string Peek(size_t nSkip = 0, size_t nAmount = 1) const#
Get the next n-th UTF-8 character without advancing the cursor.
- Parameters:
nSkip – [in] Amount of characters to skip.
nAmount – [in] The amount of characters to read.
- Returns:
Returns one or more characters starting at the requested position after the current cursor or an empty string if the requested position is behind the last character.
-
std::string PeekUntil(const std::vector<std::string> &lstCollection) const#
Get all upcoming UTF-8 characters until a terminating character without advancing the cursor.
- Parameters:
lstCollection – [in] A collection of terminating characters.
- Returns:
Returns a string of UTF-8 characters until (excluding) the first occurrence of one of the given characters.
-
std::string Consume(size_t nSkip = 0, size_t nAmount = 1)#
Get the next n-th UTF-8 character and advancing the cursor by n.
- Parameters:
nSkip – [in] Amount of characters to skip.
nAmount – [in] The amount of characters to read.
- Returns:
Returns one or more characters starting at the requested position after the current cursor or an empty string if the requested position is behind the last character.
-
std::string ConsumeUntil(const std::vector<std::string> &lstCollection)#
Get all upcoming UTF-8 characters until a terminating character and advancing the cursor by the number of characters in the returned string.
- Parameters:
lstCollection – [in] A collection of terminating characters.
- Returns:
Returns a string of UTF-8 characters until (excluding) the first occurrence of one of the given characters.
-
bool IsEOF() const#
Checks if the cursor is at the end of the data to read.
- Returns:
Returns true if the cursor is at the end of the readable data, false otherwise.
-
void SetBookmark()#
Set the bookmark at the current sursor position. This can be used to read the raw string.
-
std::string StringFromBookmark() const#
Get string from bookmark.
- Returns:
Returns the raw string from the last bookmark position (if set), or from the beginning of the string (if not set).
-
CCharacterReaderUTF8() = default#