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 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)
bool isTextBased ()

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 (AbstractDecoder 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)
IReader decode (void *x, uint bytes, uint type)
IReader decodeArray (void[]*x, uint bytes, uint width, uint type)
uint count (uint elements)
final void reset ()
final void bind (IReader reader)
final bool isMutable (void *x)
final void allocate (void[]*x, uint bytes, uint width, uint type, IBuffer.Converter decoder)

Static Private Member Functions

static void error (char[] msg=EOI)

Private Attributes

Token token
ITokenizer tokenizer
IBuffer buffer

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 Copy of TextReader.d.


Member Typedef Documentation

typedef Reader get get
 

Definition at line 59 of file Copy of 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 Copy of 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 Copy of TextReader.d.

References Buffer, and tokenizer.

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

Reimplemented from Reader.

Definition at line 99 of file Copy of TextReader.d.

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

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

Reimplemented from Reader.

Definition at line 163 of file Copy of TextReader.d.

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

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 Copy of 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 189 of file Copy of 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 207 of file Copy of TextReader.d.

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

final Token nextToken  )  [inline, private]
 

Internal method to capture the next token.

Definition at line 218 of file Copy of 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 236 of file Copy of TextReader.d.

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

Referenced by read().

bool isTextBased  )  [inline]
 

Is this Reader text oriented?

Reimplemented from Reader.

Definition at line 250 of file Copy of TextReader.d.

this IBuffer  buffer  )  [inline, inherited]
 

Construct a Reader upon the provided buffer

Reimplemented in HttpReader, and EndianReader.

Definition at line 158 of file Reader.d.

References Reader::buffer, IBuffer::error(), IBuffer::getStyle(), Reader::isTextBased(), Reader::read(), Reader::setAllocator(), and Reader::textDecoder.

this IConduit  conduit  )  [inline, inherited]
 

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

Definition at line 178 of file Reader.d.

References Buffer.

IBuffer getBuffer  )  [inline, inherited]
 

Return the buffer associated with this reader

Reimplemented from IReader.

Definition at line 189 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 212 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 239 of file Reader.d.

References IArrayAllocator::bind().

Referenced by Reader::this().

void setDecoder AbstractDecoder  d  )  [inline, inherited]
 

Bind an IDecoder to the writer. Decoders are intended to be used as a conversion mechanism between various character representations (encodings).

Reimplemented from IReader.

Definition at line 253 of file Reader.d.

References AbstractDecoder::bind(), Reader::buffer, and AbstractDecoder::decoder().

Referenced by this().

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 267 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 278 of file Reader.d.

References assert(), and IReadable::read().

Referenced by Reader::count().

IReader get inout bool  x  )  [inline, inherited]
 

Extract a boolean value from the current read-position

Reimplemented from IReader.

Definition at line 291 of file Reader.d.

References Reader::read().

IReader get inout ubyte  x  )  [inline, inherited]
 

Extract an unsigned byte value from the current read-position

Reimplemented from IReader.

Definition at line 303 of file Reader.d.

References Reader::read().

IReader get inout byte  x  )  [inline, inherited]
 

Extract a byte value from the current read-position

Reimplemented from IReader.

Definition at line 315 of file Reader.d.

References Reader::read().

IReader get inout ushort  x  )  [inline, inherited]
 

Extract an unsigned short value from the current read-position

Reimplemented from IReader.

Definition at line 327 of file Reader.d.

References Reader::read().

IReader get inout short  x  )  [inline, inherited]
 

Extract a short value from the current read-position

Reimplemented from IReader.

Definition at line 339 of file Reader.d.

References Reader::read().

IReader get inout uint  x  )  [inline, inherited]
 

Extract a unsigned int value from the current read-position

Reimplemented from IReader.

Definition at line 351 of file Reader.d.

References Reader::read().

IReader get inout int  x  )  [inline, inherited]
 

Extract an int value from the current read-position

Reimplemented from IReader.

Definition at line 363 of file Reader.d.

References Reader::read().

IReader get inout ulong  x  )  [inline, inherited]
 

Extract an unsigned long value from the current read-position

Reimplemented from IReader.

Definition at line 375 of file Reader.d.

References Reader::read().

IReader get inout long  x  )  [inline, inherited]
 

Extract a long value from the current read-position

Reimplemented from IReader.

Definition at line 387 of file Reader.d.

References Reader::read().

IReader get inout float  x  )  [inline, inherited]
 

Extract a float value from the current read-position

Reimplemented from IReader.

Definition at line 399 of file Reader.d.

References Reader::read().

IReader get inout double  x  )  [inline, inherited]
 

Extract a double value from the current read-position

Reimplemented from IReader.

Definition at line 411 of file Reader.d.

References Reader::read().

IReader get inout real  x  )  [inline, inherited]
 

Extract a real value from the current read-position

Reimplemented from IReader.

Definition at line 423 of file Reader.d.

References Reader::read().

IReader get inout char  x  )  [inline, inherited]
 

Extract a char value from the current read-position

Reimplemented from IReader.

Definition at line 435 of file Reader.d.

References Reader::decode().

IReader get inout wchar  x  )  [inline, inherited]
 

Extract a wide char value from the current read-position

Reimplemented from IReader.

Definition at line 446 of file Reader.d.

References Reader::decode().

IReader get inout dchar  x  )  [inline, inherited]
 

Extract a double char value from the current read-position

Reimplemented from IReader.

Definition at line 457 of file Reader.d.

References Reader::decode().

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 468 of file Reader.d.

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

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 481 of file Reader.d.

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

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 494 of file Reader.d.

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

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 507 of file Reader.d.

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

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 520 of file Reader.d.

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

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 533 of file Reader.d.

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

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 546 of file Reader.d.

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

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 559 of file Reader.d.

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

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 572 of file Reader.d.

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

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 585 of file Reader.d.

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

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 598 of file Reader.d.

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

IReader decode void *  x,
uint  bytes,
uint  type
[inline, protected, inherited]
 

Definition at line 639 of file Reader.d.

References Reader::textDecoder, and type().

Referenced by Reader::get(), and TextReaderTemplate().

IReader decodeArray void *[]  x,
uint  bytes,
uint  width,
uint  type
[inline, protected, inherited]
 

Definition at line 649 of file Reader.d.

References IArrayAllocator::allocate(), Reader::memory, Reader::textDecoder, and type().

Referenced by Reader::get().

uint count uint  elements  )  [inline, protected, inherited]
 

Read and return an integer from the input stream. This is used to extract the element count of a subsequent array.

Definition at line 693 of file Reader.d.

References Reader::get().

Referenced by Reader::get(), and TextReaderTemplate().

final void reset  )  [inline, protected, inherited]
 

IArrayAllocator method

Reimplemented from IArrayAllocator.

Definition at line 706 of file Reader.d.

final void bind IReader  reader  )  [inline, protected, inherited]
 

IArrayAllocator method

Reimplemented from IArrayAllocator.

Definition at line 716 of file Reader.d.

final bool isMutable void *  x  )  [inline, protected, inherited]
 

IArrayAllocator method

Reimplemented from IArrayAllocator.

Definition at line 726 of file Reader.d.

final void allocate void *[]  x,
uint  bytes,
uint  width,
uint  type,
IBuffer.Converter  decoder
[inline, protected, inherited]
 

IArrayAllocator method

Reimplemented from IArrayAllocator.

Definition at line 737 of file Reader.d.

References type().


Member Data Documentation

Token token [private]
 

Definition at line 62 of file Copy of TextReader.d.

Referenced by next(), and nextToken().

ITokenizer tokenizer [private]
 

Definition at line 65 of file Copy of TextReader.d.

Referenced by nextToken(), and this().

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

Definition at line 67 of file Copy of TextReader.d.

IBuffer buffer [protected, inherited]
 

Definition at line 144 of file Reader.d.

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


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