Wraps a char array, providing a set of methods for parsing data from it.
More...
#include <CharArrayParser.h>
|
|
void | Reset () |
| | Sets the position and limit to zero.
|
| |
| void | Reset (const char *data, int limit) |
| | Updates the instance to wrap the specified data and resets the position to zero. More...
|
| |
|
int | CharsLeft () |
| | Return the number of chars yet to be read.
|
| |
|
int | GetPosition () |
| | Returns the current offset in the array.
|
| |
| bool | SetPosition (int position) |
| | Set the reading offset in the array. More...
|
| |
| bool | SkipChars (int nChars) |
| | Skip a specified number of chars. More...
|
| |
| uint8_t | ReadNextUnsignedChar () |
| | Reads the next unsigned char (it is assumed that the caller has already checked the availability of the data for its length) More...
|
| |
| uint16_t | ReadNextUnsignedShort () |
| | Reads the next two chars as unsigned short value (it is assumed that the caller has already checked the availability of the data for its length) More...
|
| |
| uint32_t | ReadNextUnsignedInt () |
| | Reads the next four chars as unsigned int value (it is assumed that the caller has already checked the availability of the data for its length) More...
|
| |
| std::string | ReadNextString (int length) |
| | Reads the next string of specified length (it is assumed that the caller has already checked the availability of the data for its length) More...
|
| |
| bool | ReadNextArray (int length, char *data) |
| | Reads the next chars array of specified length (it is assumed that the caller has already checked the availability of the data for its length) More...
|
| |
| bool | ReadNextLine (std::string &line) |
| | Reads a line of text. A line is considered to be terminated by any one of a carriage return ('\r'), a line feed ('\n'), or a carriage return followed by a line feed ('\r\n'), this method discards leading UTF-8 byte order marks, if present. More...
|
| |
| const char * | GetData () |
| | Get the current data. More...
|
| |
Wraps a char array, providing a set of methods for parsing data from it.
◆ GetData()
| const char* CCharArrayParser::GetData |
( |
| ) |
|
|
inline |
Get the current data.
- Returns
- The char pointer to the current data
◆ ReadNextArray()
| bool CCharArrayParser::ReadNextArray |
( |
int |
length, |
|
|
char * |
data |
|
) |
| |
Reads the next chars array of specified length (it is assumed that the caller has already checked the availability of the data for its length)
- Parameters
-
| length | The length to be read |
| data[OUT] | The data read |
- Returns
- True if success, otherwise false
◆ ReadNextLine()
| bool CCharArrayParser::ReadNextLine |
( |
std::string & |
line | ) |
|
Reads a line of text. A line is considered to be terminated by any one of a carriage return ('\r'), a line feed ('\n'), or a carriage return followed by a line feed ('\r\n'), this method discards leading UTF-8 byte order marks, if present.
- Parameters
-
| line | [OUT] The line read without line-termination characters |
- Returns
- True if read, otherwise false if the end of the data has already been reached
◆ ReadNextString()
| std::string CCharArrayParser::ReadNextString |
( |
int |
length | ) |
|
Reads the next string of specified length (it is assumed that the caller has already checked the availability of the data for its length)
- Parameters
-
| length | The length to be read |
- Returns
- The string value
◆ ReadNextUnsignedChar()
| uint8_t CCharArrayParser::ReadNextUnsignedChar |
( |
| ) |
|
Reads the next unsigned char (it is assumed that the caller has already checked the availability of the data for its length)
- Returns
- The unsigned char value
◆ ReadNextUnsignedInt()
| uint32_t CCharArrayParser::ReadNextUnsignedInt |
( |
| ) |
|
Reads the next four chars as unsigned int value (it is assumed that the caller has already checked the availability of the data for its length)
- Returns
- The unsigned int value
◆ ReadNextUnsignedShort()
| uint16_t CCharArrayParser::ReadNextUnsignedShort |
( |
| ) |
|
Reads the next two chars as unsigned short value (it is assumed that the caller has already checked the availability of the data for its length)
- Returns
- The unsigned short value
◆ Reset()
| void CCharArrayParser::Reset |
( |
const char * |
data, |
|
|
int |
limit |
|
) |
| |
Updates the instance to wrap the specified data and resets the position to zero.
- Parameters
-
| data | The data |
| limit | The limit of length of the data |
◆ SetPosition()
| bool CCharArrayParser::SetPosition |
( |
int |
position | ) |
|
Set the reading offset in the array.
- Parameters
-
| position | The new offset position |
- Returns
- True if success, otherwise false
◆ SkipChars()
| bool CCharArrayParser::SkipChars |
( |
int |
nChars | ) |
|
Skip a specified number of chars.
- Parameters
-
| nChars | The number of chars |
- Returns
- True if success, otherwise false
The documentation for this class was generated from the following files: