Easy3D 2.6.1
|
A utility class for splitting strings into tokens based on delimiters. More...
#include <easy3d/util/tokenizer.h>
Public Member Functions | |
Tokenizer (const char *src, const char *delims=nullptr) | |
Constructor that initializes the tokenizer with a source string and optional delimiters. | |
void | setConsumeWS (bool ws) |
Sets whether to consume whitespace characters. | |
bool | isWhitespace (const char c) |
Checks if the given character is a whitespace character. | |
bool | isQuote (const char c) |
Checks if the given character is a quote character. | |
bool | isEOL (const char c) |
Checks if the given character is an end-of-line character. | |
bool | isTerm (const char c) |
Checks if the given character is a termination character. | |
bool | isDelim (const char c) |
Checks if the given character is a delimiter. | |
bool | atEOF () |
Checks if the tokenizer has reached the end of the source string. | |
char | consumeWhitespace () |
Consumes whitespace characters from the source string. | |
char | consumeOneDelim () |
Consumes one delimiter character from the source string. | |
void | consumeToEOL () |
Consumes characters up to the end of the line. | |
bool | readToken () |
Reads the next token from the source string. | |
bool | requireToken (const char *find) |
Checks if the next token matches the given string. | |
bool | requireTokenDelim (const char *find) |
Checks if the next token matches the given string and consumes a delimiter. | |
char | getTermChar () const |
Gets the character that caused the stop of the last token read. | |
bool | getLastToken (std::string &returnTok) |
Gets the last read token as a std::string. | |
const char * | getLastTokenPtr () |
Gets the last read token as a const char*. | |
uint32_t | getLastTokenLen () const |
Gets the length of the last read token. | |
bool | getTokenString (std::string &returnTok) |
Gets the next token as a std::string. | |
bool | getTokenString (char out[], const uint32_t outmax) |
Gets the next token as a char array with a maximum size. | |
bool | getTokenFloat (float &out) |
Gets the next token as a floating-point number. | |
uint32_t | getTokenFloatArray (float out[], uint32_t size) |
Gets the next tokens as an array of floating-point numbers. | |
uint32_t | getTokenIntArray (int32_t out[], uint32_t size) |
Gets the next tokens as an array of integer numbers. | |
bool | getTokenInt (int32_t &out) |
Gets the next token as an integer. | |
bool | getTokenUint (uint32_t &out) |
Gets the next token as an unsigned integer. | |
bool | getTokenBool (bool &out) |
Gets the next token as a boolean value. | |
A utility class for splitting strings into tokens based on delimiters.
This class provides methods to tokenize a given string based on a set of delimiters. It can handle empty tokens and allows for retrieving individual tokens by index.
|
inlineexplicit |
Constructor that initializes the tokenizer with a source string and optional delimiters.
src | The source string to tokenize. |
delims | The delimiters to use for tokenizing. If nullptr, default delimiters are used. |
|
inline |
Checks if the tokenizer has reached the end of the source string.
|
inline |
Consumes one delimiter character from the source string.
|
inline |
Consumes whitespace characters from the source string.
|
inline |
Gets the last read token as a std::string.
returnTok | The string to store the last read token. |
|
inline |
Gets the length of the last read token.
|
inline |
Gets the last read token as a const char*.
|
inline |
Gets the character that caused the stop of the last token read.
|
inline |
Gets the next token as a boolean value.
out | The boolean value to store the next token. |
|
inline |
Gets the next token as a floating-point number.
out | The floating-point number to store the next token. |
|
inline |
Gets the next tokens as an array of floating-point numbers.
out | The array to store the floating-point numbers. |
size | The size of the array. |
|
inline |
Gets the next token as an integer.
out | The integer to store the next token. |
|
inline |
Gets the next tokens as an array of integer numbers.
out | The array to store the integer numbers. |
size | The size of the array. |
|
inline |
Gets the next token as a char array with a maximum size.
out | The char array to store the next token. |
outmax | The maximum size of the char array. |
|
inline |
Gets the next token as a std::string.
returnTok | The string to store the next token. |
|
inline |
Gets the next token as an unsigned integer.
out | The unsigned integer to store the next token. |
|
inline |
Checks if the given character is a delimiter.
c | The character to check. |
|
inline |
Checks if the given character is an end-of-line character.
c | The character to check. |
|
inline |
Checks if the given character is a quote character.
c | The character to check. |
|
inline |
Checks if the given character is a termination character.
c | The character to check. |
|
inline |
Checks if the given character is a whitespace character.
c | The character to check. |
|
inline |
Reads the next token from the source string.
|
inline |
Checks if the next token matches the given string.
find | The string to match. |
|
inline |
Checks if the next token matches the given string and consumes a delimiter.
find | The string to match. |
|
inline |
Sets whether to consume whitespace characters.
ws | True to consume whitespace, false otherwise. |