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

ReaderToken Class Reference

Inheritance diagram for ReaderToken:

BoundToken IReadable List of all members.

Public Member Functions

 this (ITokenizer tk)
void read (IReader r)

Private Member Functions

ITokenizer getTokenizer ()
bool next (IBuffer buf)

Static Private Member Functions

 this ()

Detailed Description

ReaderToken adapts a BoundToken such that it can be used directly with any IReader implementation. We just add the IReadable methods to the basic BoundToken.

Here's a contrived example of how to use ReaderToken:

// create a small buffer on the heap Buffer buf = new Buffer (256); // write items with a comma between each TextWriter tw = new TextWriter (buf, ","); // write some stuff to the buffer tw << "now is the time for all good men" << 3.14159; // bind a couple of tokens to a comma tokenizer ReaderToken text = new ReaderToken (Tokenizers.comma); ReaderToken number = new ReaderToken (Tokenizers.comma); // create any old reader since we only use it for handling tokens Reader r = new Reader (buf); // populate both tokens via reader r >> text >> number; // print them to the console Stdout << text << ':' << number << Stdout.newline;

Definition at line 159 of file TokenEx.d.


Member Function Documentation

this ITokenizer  tk  )  [inline]
 

Construct a ReaderToken using the provided Tokenizer.

Reimplemented from BoundToken.

Definition at line 167 of file TokenEx.d.

void read IReader  r  )  [inline]
 

Read the next delimited element into this token.

Reimplemented from IReadable.

Definition at line 178 of file TokenEx.d.

References IReader::getBuffer().

this  )  [inline, static, inherited]
 

Construct a static exception instance.

Definition at line 141 of file Token.d.

References Token::Error.

ITokenizer getTokenizer  )  [inline, inherited]
 

Return the associated tokenizer

Definition at line 92 of file TokenEx.d.

References BoundToken::tk.

bool next IBuffer  buf  )  [inline, inherited]
 

Extract the next token from the provided buffer.

Returns true if a token was isolated, false if no more tokens were found. Note that one last token may still be present when this return false; this may happen if (for example) the last delimiter is missing before an EOF condition is seen. Check token.getLength() when this method returns false.

For example:

while (token.next() || token.getLength()) // do something

Definition at line 118 of file TokenEx.d.

References ITokenizer::next(), and BoundToken::tk.

Referenced by StartLine::VersionUseTokenizer::parse(), HttpParams::parse(), HttpHeaders::parse(), ResponseLine::parse(), testFile2(), and testToken1().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:09 2004 for Mango by doxygen 1.3.6