
#include <cascade/util/CascadeTokenArray.h>
Inheritance diagram for CascadeTokenArray:

Public Member Functions | |
| CascadeTokenArray (const char *pStringToSplit, const char *pTokenSeparators) | |
| virtual | ~CascadeTokenArray () |
| u32 | GetNumTokens () |
| const char * | TokenAt (u32 nIndex) |
CascadeTokenArray provides an easy method for splitting a string into tokens.
Example: splitting a sentence into words
const char * pString = "This is the string I wish to split into tokens.";
CascadeTokenArray tokenArray(pString, " ");
for (u32 i = 0; i < tokenArray.GetNumTokens(); i++)
{
printf("Token %%02d: %%s\\n", i, tokenArray.TokenAt(i));
} Output:
Token 00: This
Token 01: is
Token 02: the
Token 03: string
Token 04: I
Token 05: wish
Token 06: to
Token 07: split
Token 08: into
Token 09: tokens.
|
||||||||||||
|
splits a string into an array of tokens This constructor constructs the token array splitting a copy of pStringToSplit into tokens using the characters in *pTokenSeparators as the set of characters that cause a split.
|
|
|
destructor This is the CascadeTokenArray destructor. It frees the internal copy of the string to split that was copied in the constructor. |
|
|
returns the number of tokens GetNumTokens() gets the number of tokens in the token array.
|
|
|
returns the token at the specified index TokenAt() returns the token located at a specific index. Valid values for nIndex are [0..GetNumTokens() - 1]. If an invalid nIndex value is specified TokenAt() returns NULL.
|
1.4.1