Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

SimpleTokenizer Class Reference

Inheritance diagram for SimpleTokenizer:

Scanner ITokenizer List of all members.

Public Member Functions

 this (char delimiter)
bool next (IBuffer buffer, Token token)

Private Member Functions

bool next (IBuffer buffer, uint(*scan)(char[]))
uint notFound (Token token, char[] content)

Private Attributes

char delimiter

Detailed Description

A simple delimiting tokenizer. Use this to tokenize simple streams such as comma-seperated text.

Definition at line 151 of file Tokenizer.d.


Member Function Documentation

this char  delimiter  )  [inline]
 

Construct a SimpleTokenizer with the given delimiter char. More sophisticated delimiters can be constructed by using a RegexTokenizer instead.

Definition at line 163 of file Tokenizer.d.

References delimiter.

bool next IBuffer  buffer,
Token  token
[inline]
 

Locate the next token from the provided buffer, and map a buffer reference into token. Returns true if a token was located, false otherwise.

Note that the buffer content is not duplicated. Instead, a slice of the buffer is referenced by the token. You can use Token.clone() or Token.toString().dup() to copy content per your application needs.

Note also that there may still be one token left in a buffer that was not terminated correctly (as in eof conditions). In such cases, tokens are mapped onto remaining content and the buffer will have no more readable content.

Reimplemented from ITokenizer.

Definition at line 187 of file Tokenizer.d.

References buffer, delimiter, Scanner::notFound(), and Token::set().

bool next IBuffer  buffer,
uint(*)(char[])  scan
[inline, inherited]
 

Scan the given IBuffer for another token, and place the results in the provided token. Note that this should be completely thread-safe so one can instantiate singleton tokenizers without issue.

Each Token is expected to be stripped of the delimiter. An end-of-file condition causes trailing content to be placed into the token. Requests made beyond Eof result in empty tokens (length == zero).

Returns true if a token was isolated, false otherwise.

Definition at line 78 of file Tokenizer.d.

References buffer, and IConduit.

uint notFound Token  token,
char[]  content
[inline, inherited]
 

Clean up after we fail to find a token. Trailing content is placed into the token, and the scanner is told to try and load some more content (where available).

Definition at line 120 of file Tokenizer.d.

References IConduit, and Token::set().

Referenced by LineTokenizer::next(), PunctTokenizer::next(), SpaceTokenizer::next(), and next().


Member Data Documentation

char delimiter [private]
 

Definition at line 153 of file Tokenizer.d.

Referenced by next(), and this().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:42 2005 for Mango by  doxygen 1.4.0