Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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)

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 write = new TextWriter (buf, ",");

        // write some stuff to the buffer
        write ("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 read = new Reader (buf);

        // populate both tokens via reader 
        read (text) (number);

        // print them to the console
        Stdout (text) (':') (number) (CR);

Definition at line 376 of file Token.d.


Member Function Documentation

this ITokenizer  tk  )  [inline]
 

Construct a ReaderToken using the provided Tokenizer.

Reimplemented from BoundToken.

Definition at line 384 of file Token.d.

void read IReader  r  )  [inline]
 

Read the next delimited element into this token.

Reimplemented from IReadable.

Definition at line 395 of file Token.d.

References IReader::getBuffer(), and ITokenizer::next().

ITokenizer getTokenizer  )  [inline, inherited]
 

Return the associated tokenizer

Definition at line 309 of file Token.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 335 of file Token.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 Fri May 27 18:12:03 2005 for Mango by  doxygen 1.4.0