![]() |
UtilsLite
Utilities for C++ programming
|
A utility class for tokenizing strings. More...
#include <Token.hxx>
Public Member Functions | |
Tokenizer (string str, string delimiters) | |
string const & | get_token () const |
bool | next_token () |
Protected Attributes | |
size_t | m_offset |
Current position in the string. | |
string const | m_string |
The original string to tokenize. | |
string | m_token |
The current token extracted. | |
string const | m_delimiters |
Characters used to separate tokens. | |
A utility class for tokenizing strings.
!
The Tokenizer
class provides a simple and efficient mechanism for breaking a string into smaller components (tokens) based on specified delimiter(s). It facilitates sequential token extraction from the input string and supports custom delimiters.
Usage Example:
Constructs a Tokenizer object with the provided string and delimiters.
str | The input string to tokenize. |
delimiters | A string containing delimiter characters. |
|
inline |
Retrieves the last extracted token.
next_token()
. bool Utils::Tokenizer::next_token | ( | ) |
Advances the tokenizer to the next token in the string.
This function searches the string for the next token, updating the internal state of the Tokenizer
object. If a token is found, it sets the m_token
member variable to the new token and returns true
. If no more tokens are available, it returns false
.
true
if a new token was found; false
if no more tokens are available.
|
protected |
Characters used to separate tokens.
|
protected |
Current position in the string.
|
protected |
The original string to tokenize.
|
protected |
The current token extracted.