#include <cstrtokenizer.h>
Example usage:
const char *str = "34 42 13 46 72 41"; // input std::vector<int> numbers; // array to hold result
cStringTokenizer tokenizer(str); const char *token; while ((token = tokenizer.nextToken())!=NULL) numbers.push_back(atoi(token));
Public Member Functions | |
cStringTokenizer (const char *str, const char *delimiters=" ") | |
~cStringTokenizer () | |
void | setDelimiter (const char *s) |
bool | hasMoreTokens () |
const char * | nextToken () |
std::vector< std::string > | asVector () |
|
Constructor. The class will make its own copy of the input string and of the delimiters string. |
|
Destructor.
|
|
Utility function: tokenizes the full input string at once, and returns the tokens in a string vector.
|
|
Returns true if there're more tokens (i.e. the next nextToken() call won't return NULL). |
|
Returns the next token. The returned pointers will stay valid as long as the tokenizer object exists. If there're no more tokens, a NULL pointer will be returned. |
|
Change delimiters. This allows for switching delimiters during tokenization. |