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

TextReader Class Reference

Inheritance diagram for TextReader:

Reader ConsoleReader List of all members.

Public Types

typedef Reader get get

Public Member Functions

 this (IBuffer buffer, ITokenizer tokenizer=Tokenizers.line)
 this (IConduit conduit, ITokenizer tokenizer=Tokenizers.line)
uint read (void *src, uint bytes, uint type)
IReader get (inout char[] x, uint elements=uint.max)
IReader get (inout wchar[] x, uint elements=uint.max)
IReader get (inout dchar[] x, uint elements=uint.max)

Private Member Functions

final Token nextToken ()
final Token next ()
 this (IBuffer buffer)
 this (IConduit conduit)
IBuffer getBuffer ()
IArrayAllocator getAllocator ()
void setAllocator (IArrayAllocator memory)
void setDecoder (IDecoder d)
void wait ()
IReader get (IReadable x)
IReader get (inout bool x)
IReader get (inout ubyte x)
IReader get (inout byte x)
IReader get (inout ushort x)
IReader get (inout short x)
IReader get (inout uint x)
IReader get (inout int x)
IReader get (inout ulong x)
IReader get (inout long x)
IReader get (inout float x)
IReader get (inout double x)
IReader get (inout real x)
IReader get (inout char x)
IReader get (inout wchar x)
IReader get (inout dchar x)
IReader get (inout ubyte[] x, uint elements=uint.max)
IReader get (inout byte[] x, uint elements=uint.max)
IReader get (inout ushort[] x, uint elements=uint.max)
IReader get (inout short[] x, uint elements=uint.max)
IReader get (inout uint[] x, uint elements=uint.max)
IReader get (inout int[] x, uint elements=uint.max)
IReader get (inout ulong[] x, uint elements=uint.max)
IReader get (inout long[] x, uint elements=uint.max)
IReader get (inout float[] x, uint elements=uint.max)
IReader get (inout double[] x, uint elements=uint.max)
IReader get (inout real[] x, uint elements=uint.max)

Static Private Member Functions

static void error (char[] msg=EOI)

Private Attributes

Token token
ITokenizer tokenizer
IBuffer buffer
Decoder decode

Static Private Attributes

static final char[] EOI = "unexpected end of input"

Detailed Description

Grok readable input from a stream. All input is tokenized from the associated buffer, and converted as necessary into the destination location. A SpaceTokenizer is used by default, but you can choose an alternative (such as a comma-delimiting tokenizer).

Definition at line 57 of file TextReader.d.


Member Typedef Documentation

typedef Reader get get
 

Definition at line 59 of file TextReader.d.


Member Function Documentation

this IBuffer  buffer,
ITokenizer  tokenizer = Tokenizers.line
[inline]
 

Construct a TextReader on the provided buffer, using the specified Tokenizer instead of the default one.

Definition at line 76 of file TextReader.d.

References tokenizer.

this IConduit  conduit,
ITokenizer  tokenizer = Tokenizers.line
[inline]
 

Construct a TextReader upon the buffer associated with the given conduit.

Definition at line 90 of file TextReader.d.

References tokenizer.

uint read void *  src,
uint  bytes,
uint  type
[inline]
 

Reimplemented from Reader.

Definition at line 99 of file TextReader.d.

References error(), next(), Token::toInt(), Token::toLong(), Token::toReal(), and Token::toString().

IReader get inout char[]  x,
uint  elements = uint.max
[inline]
 

Reimplemented from Reader.

Definition at line 163 of file TextReader.d.

References nextToken(), Token::toString(), and x.

IReader get inout wchar[]  x,
uint  elements = uint.max
[inline]
 

Todo:
  • Tokenizer needs to handle wchar[] before this will operate correctly

Reimplemented from Reader.

Definition at line 177 of file TextReader.d.

References assert().

IReader get inout dchar[]  x,
uint  elements = uint.max
[inline]
 

Todo:
  • Tokenizer needs to handle dchar[] before this will operate correctly

Reimplemented from Reader.

Definition at line 190 of file TextReader.d.

References assert().

static void error char[]  msg = EOI  )  [inline, static, private]
 

Throw an exception if the input requested is not available. Reader instances expect the input to be available, so you might think of them as being applied to a fixed-format file. Tokenizers, on the other hand, are more flexible in that they return true until no more tokens are available.

Readers take care of assignment to user-space variables, whereas Tokenizers just make the raw content available.

Definition at line 209 of file TextReader.d.

Referenced by next(), nextToken(), and read().

final Token nextToken  )  [inline, private]
 

Internal method to capture the next token.

Definition at line 220 of file TextReader.d.

References error(), ITokenizer::next(), token, and tokenizer.

Referenced by get(), and next().

final Token next  )  [inline, private]
 

Internal method to isolate the next token, and check its length. This is used when converting to non-char types, such as integers ~ an empty token is illegal, since we don't support default values.

Todo:
: should the empty-token rule be relaxed?

Definition at line 238 of file TextReader.d.

References error(), Token::getLength(), nextToken(), and token.

Referenced by read().

this IBuffer  buffer  )  [inline, inherited]
 

Construct a Reader upon the provided buffer

Reimplemented in HttpReader, and EndianReader.

Definition at line 164 of file Reader.d.

References Reader::buffer, Reader::Decoder::char16, Reader::Decoder::char32, Reader::Decoder::char8, Reader::decode, Reader::read(), and Reader::setAllocator().

this IConduit  conduit  )  [inline, inherited]
 

Construct a Reader upon the buffer associated with the given conduit.

Definition at line 182 of file Reader.d.

IBuffer getBuffer  )  [inline, inherited]
 

Return the buffer associated with this reader

Reimplemented from IReader.

Definition at line 193 of file Reader.d.

References Reader::buffer.

IArrayAllocator getAllocator  )  [inline, inherited]
 

Return the allocator associated with this reader. See ArrayAllocator for more information.

Reimplemented from IReader.

Definition at line 205 of file Reader.d.

References Reader::memory.

void setAllocator IArrayAllocator  memory  )  [inline, inherited]
 

Set the allocator to use for array management. Arrays are always allocated by the IReader. That is, you cannot read data into an array slice (for example). Instead, a number of IArrayAllocator classes are available to manage memory allocation when reading array content.

By default, an IReader will allocate each array from the heap. You can change that behavior by calling this method with an IArrayAllocator of choice. For instance, there is a BufferAllocator which will slice an array directly from the buffer where possible. Also available is the record-oriented SliceAllocator, which slices memory from within a pre-allocated heap area, and should be reset by the client code after each record has been read (to avoid unnecessary growth).

See ArrayAllocator for more information.

Reimplemented from IReader.

Definition at line 232 of file Reader.d.

References IArrayAllocator::bind().

Referenced by Reader::this().

void setDecoder IDecoder  d  )  [inline, inherited]
 

Bind an IDecoder to the writer. Decoders are intended to be used as a conversion mechanism between various character representations (encodings), or the translation of any data type from one representation to another. Each data type may be configured with a distinct decoder, covering all native types (15 in total).

An appropriate decoder set should be attached to each IReader, and thus be available for subsequent use. A raw binary implementation is attached by default (no encoding).

See module mango.icu.UMango for an example of decoder implementation -- those classes bind the ICU converters to this IO package.

Reimplemented from IReader.

Definition at line 257 of file Reader.d.

References IDecoder::bind(), Reader::decode, Reader::Decoder::decoders, and IDecoder::type().

void wait  )  [inline, inherited]
 

Wait for something to arrive in the buffer. This may stall the current thread forever, although usage of SocketConduit will take advantage of the timeout facilities provided there.

Reimplemented from IReader.

Definition at line 284 of file Reader.d.

References Reader::buffer, and IBuffer::get().

IReader get IReadable  x  )  [inline, inherited]
 

Extract a readable class from the current read-position

Reimplemented from IReader.

Definition at line 325 of file Reader.d.

References assert(), and x.

Referenced by Reader::count(), and testBuffer().

IReader get inout bool  x  )  [inline, inherited]
 

Extract a boolean value from the current read-position

Reimplemented from IReader.

Definition at line 338 of file Reader.d.

References Reader::read(), and x.

IReader get inout ubyte  x  )  [inline, inherited]
 

Extract an unsigned byte value from the current read-position

Reimplemented from IReader.

Definition at line 350 of file Reader.d.

References Reader::read(), and x.

IReader get inout byte  x  )  [inline, inherited]
 

Extract a byte value from the current read-position

Reimplemented from IReader.

Definition at line 362 of file Reader.d.

References Reader::read(), and x.

IReader get inout ushort  x  )  [inline, inherited]
 

Extract an unsigned short value from the current read-position

Reimplemented from IReader.

Definition at line 374 of file Reader.d.

References Reader::read(), and x.

IReader get inout short  x  )  [inline, inherited]
 

Extract a short value from the current read-position

Reimplemented from IReader.

Definition at line 386 of file Reader.d.

References Reader::read(), and x.

IReader get inout uint  x  )  [inline, inherited]
 

Extract a unsigned int value from the current read-position

Reimplemented from IReader.

Definition at line 398 of file Reader.d.

References Reader::read(), and x.

IReader get inout int  x  )  [inline, inherited]
 

Extract an int value from the current read-position

Reimplemented from IReader.

Definition at line 410 of file Reader.d.

References Reader::read(), and x.

IReader get inout ulong  x  )  [inline, inherited]
 

Extract an unsigned long value from the current read-position

Reimplemented from IReader.

Definition at line 422 of file Reader.d.

References Reader::read(), and x.

IReader get inout long  x  )  [inline, inherited]
 

Extract a long value from the current read-position

Reimplemented from IReader.

Definition at line 434 of file Reader.d.

References Reader::read(), and x.

IReader get inout float  x  )  [inline, inherited]
 

Extract a float value from the current read-position

Reimplemented from IReader.

Definition at line 446 of file Reader.d.

References Reader::read(), and x.

IReader get inout double  x  )  [inline, inherited]
 

Extract a double value from the current read-position

Reimplemented from IReader.

Definition at line 458 of file Reader.d.

References Reader::read(), and x.

IReader get inout real  x  )  [inline, inherited]
 

Extract a real value from the current read-position

Reimplemented from IReader.

Definition at line 470 of file Reader.d.

References Reader::read(), and x.

IReader get inout char  x  )  [inline, inherited]
 

Extract a char value from the current read-position

Reimplemented from IReader.

Definition at line 482 of file Reader.d.

References Reader::Decoder::char8, Reader::decode, and x.

IReader get inout wchar  x  )  [inline, inherited]
 

Extract a wide char value from the current read-position

Reimplemented from IReader.

Definition at line 494 of file Reader.d.

References Reader::Decoder::char16, Reader::decode, and x.

IReader get inout dchar  x  )  [inline, inherited]
 

Extract a double char value from the current read-position

Reimplemented from IReader.

Definition at line 506 of file Reader.d.

References Reader::Decoder::char32, Reader::decode, and x.

IReader get inout ubyte[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract an unsigned byte array from the current read-position

Reimplemented from IReader.

Definition at line 518 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout byte[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a byte array from the current read-position

Reimplemented from IReader.

Definition at line 531 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout ushort[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract an unsigned short array from the current read-position

Reimplemented from IReader.

Definition at line 544 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout short[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a short array from the current read-position

Reimplemented from IReader.

Definition at line 557 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout uint[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a unsigned int array from the current read-position

Reimplemented from IReader.

Definition at line 570 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout int[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract an int array from the current read-position

Reimplemented from IReader.

Definition at line 583 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout ulong[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract an unsigned long array from the current read-position

Reimplemented from IReader.

Definition at line 596 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout long[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a long array from the current read-position

Reimplemented from IReader.

Definition at line 609 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout float[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a float array from the current read-position

Reimplemented from IReader.

Definition at line 622 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout double[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a double array from the current read-position

Reimplemented from IReader.

Definition at line 635 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.

IReader get inout real[]  x,
uint  elements = uint.max
[inline, inherited]
 

Extract a real array from the current read-position

Reimplemented from IReader.

Definition at line 648 of file Reader.d.

References IArrayAllocator::allocate(), Reader::count(), Reader::memory, Reader::read(), and x.


Member Data Documentation

Token token [private]
 

Definition at line 62 of file TextReader.d.

Referenced by next(), and nextToken().

ITokenizer tokenizer [private]
 

Definition at line 65 of file TextReader.d.

Referenced by nextToken(), and this().

final char [] EOI = "unexpected end of input" [static, private]
 

Definition at line 67 of file TextReader.d.

IBuffer buffer [protected, inherited]
 

Definition at line 150 of file Reader.d.

Referenced by Reader::getBuffer(), Reader::read(), Reader::this(), and Reader::wait().

Decoder decode [protected, inherited]
 

Definition at line 153 of file Reader.d.

Referenced by Reader::get(), Reader::setDecoder(), and Reader::this().


The documentation for this class was generated from the following file:
Generated on Mon Nov 14 11:00:03 2005 for Mango by  doxygen 1.4.0