Class CCharacterReaderUTF8#

Class Documentation#

class CCharacterReaderUTF8#

Reads a given input string, interprets bytes as UTF-8 and returns UTF-8 characters or strings in order on demand.

Public Functions

CCharacterReaderUTF8()#

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:
  • InvalidCharacterException – Throws an InvalidCharacterException if the input contains invalid UTF-8 characters

  • InvalidByteException – 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()#

Gets the next UTF-8 character without advancing the cursor.

Returns:

Returns the next UTF-8 character after the current cursor or an empty string if the cursor is at the end

std::string Peek(std::size_t n)#

Gets the next n-th UTF-8 character without advancing the cursor.

Parameters:

n[in] Step size

Returns:

Returns the n-th UTF-8 character after the current cursor or an empty string if n<1 or it would read after the last character

std::string PeekUntil(const std::vector<std::string> &lstCollection)#

Gets 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()#

Gets the next UTF-8 character and advancing the cursor by one.

Returns:

Returns the next UTF-8 character after the current cursor or an empty string if the cursor is at the end

std::string Consume(std::size_t n)#

Gets the next n-th UTF-8 character and advancing the cursor by n.

Parameters:

n[in] Step size

Returns:

Returns the n-th UTF-8 character after the current cursor or an empty string if n<1 or it would read after the last character

std::string ConsumeUntil(const std::vector<std::string> &lstCollection)#

Gets 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 excludingg) 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