Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeTokenArray Class Reference

an easy to use file class More...

#include <cascade/util/CascadeTokenArray.h>

Inheritance diagram for CascadeTokenArray:

CascadeObject List of all members.

Public Member Functions

 CascadeTokenArray (const char *pStringToSplit, const char *pTokenSeparators)
virtual ~CascadeTokenArray ()
u32 GetNumTokens ()
const char * TokenAt (u32 nIndex)

Detailed Description

an easy to use file class

Skip the description

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.

class CascadeTokenArray


Constructor & Destructor Documentation

CascadeTokenArray::CascadeTokenArray const char *  pStringToSplit,
const char *  pTokenSeparators
 

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.

Parameters:
pStringToSplit the string to split into tokens
pTokenSeparators the set of characters used as token separators

virtual CascadeTokenArray::~CascadeTokenArray  )  [virtual]
 

destructor

This is the CascadeTokenArray destructor. It frees the internal copy of the string to split that was copied in the constructor.


Member Function Documentation

u32 CascadeTokenArray::GetNumTokens  ) 
 

returns the number of tokens

GetNumTokens() gets the number of tokens in the token array.

Returns:
the number of tokens
See also:
TokenAt()

const char* CascadeTokenArray::TokenAt u32  nIndex  ) 
 

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.

See also:
GetNumTokens()


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:21 2005 for Cascade Library by  doxygen 1.4.1