#include <util.h>
Public Member Functions | |
size_t | count () const |
Return the number of tokens still to be extracted from buffer. | |
const char * | get_original () const |
Return a const pointer to the whole string that is being tokenized. | |
const char * | get_remainder () const |
Return a const char pointer to the rest of buffer still to be tokenized. | |
bool | has_next () const |
Return true if there is at least one more token to be extracted from buffer. | |
const char * | next (char del) |
Extract next token and return a const pointer to it. | |
const char * | next () |
Extract next token and return a const pointer to it. | |
tokenizer (const char *buffer=NULL, char delim= '\t') | |
Constructor from an unmodifiable C string. | |
void | tokenizing (const char *buffer=NULL, char delim= '\t') |
Start tokenizing from an unmodifiable C string. | |
virtual | ~tokenizer () |
Destructor. | |
Private Attributes | |
const char * | buf |
Pointer to the portion of buffer still to tokenize. | |
const char * | buffer_start |
Pointer to beginning of buffer. | |
char | del |
Token separator. | |
char * | last_token |
Last extracted token. | |
char * | last_token_end |
End of last extracted token. | |
Static Private Attributes | |
static const char | EMPTY |
An empty buffer. |
The buffer is a const C string, i.e. a const char*.
util::tokenizer::tokenizer | ( | const char * | buffer = NULL , |
|
char | delim = '\t' | |||
) | [inline] |
Constructor from an unmodifiable C string.
buffer | a const C string. | |
delim | token separator. |
virtual util::tokenizer::~tokenizer | ( | ) | [inline, virtual] |
Destructor.
size_t util::tokenizer::count | ( | ) | const [inline] |
Return the number of tokens still to be extracted from buffer.
const char* util::tokenizer::get_original | ( | ) | const [inline] |
Return a const pointer to the whole string that is being tokenized.
const char* util::tokenizer::get_remainder | ( | ) | const [inline] |
Return a const char pointer to the rest of buffer still to be tokenized.
The buffer is stored locally and it is valid until next call to next_token().
bool util::tokenizer::has_next | ( | ) | const [inline] |
Return true if there is at least one more token to be extracted from buffer.
const char* util::tokenizer::next | ( | char | del | ) | [inline] |
Extract next token and return a const pointer to it.
The token is stored locally and it is valid until next call to next().
del | token delimiter |
const char* util::tokenizer::next | ( | ) | [inline] |
Extract next token and return a const pointer to it.
The token is stored locally and it is valid until next call to next().
void util::tokenizer::tokenizing | ( | const char * | buffer = NULL , |
|
char | delim = '\t' | |||
) | [inline] |
Start tokenizing from an unmodifiable C string.
buffer | a const C string. | |
delim | token separator. |
const char* util::tokenizer::buf [private] |
Pointer to the portion of buffer still to tokenize.
const char* util::tokenizer::buffer_start [private] |
Pointer to beginning of buffer.
char util::tokenizer::del [private] |
Token separator.
const char util::tokenizer::EMPTY [static, private] |
An empty buffer.
char* util::tokenizer::last_token [private] |
Last extracted token.
char* util::tokenizer::last_token_end [private] |
End of last extracted token.