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

AbstractReader Class Reference

Inheritance diagram for AbstractReader:

SimpleAllocator IReader Reader TextReader EndianReader HttpReader List of all members.

Public Types

typedef opShr get

Public Member Functions

 this (IBuffer buffer)
IBuffer getBuffer ()
IArrayAllocator getAllocator ()
void setAllocator (IArrayAllocator memory)
void setDecoder (IDecoder d)
IReader push (uint size)
uint length ()
void wait ()
IReader opShr (IReadable x)
IReader opShr (inout bool x)
IReader opShr (inout ubyte x)
IReader opShr (inout byte x)
IReader opShr (inout ushort x)
IReader opShr (inout short x)
IReader opShr (inout uint x)
IReader opShr (inout int x)
IReader opShr (inout ulong x)
IReader opShr (inout long x)
IReader opShr (inout float x)
IReader opShr (inout double x)
IReader opShr (inout real x)
IReader opShr (inout char x)
IReader opShr (inout wchar x)
IReader opShr (inout dchar x)
IReader opShr (inout ubyte[] x)
IReader opShr (inout byte[] x)
IReader opShr (inout ushort[] x)
IReader opShr (inout short[] x)
IReader opShr (inout uint[] x)
IReader opShr (inout int[] x)
IReader opShr (inout ulong[] x)
IReader opShr (inout long[] x)
IReader opShr (inout float[] x)
IReader opShr (inout double[] x)
IReader opShr (inout real[] x)
IReader opShr (inout char[] x)
IReader opShr (inout wchar[] x)
IReader opShr (inout dchar[] x)

Protected Attributes

IBuffer buffer
Decoder decode

Private Member Functions

void reset ()
void bind (IReader reader)
bool isMutable (void *x)
void allocate (void[]*x, uint count, uint width, BufferDecoder decoder)

Private Attributes

IArrayAllocator memory
uint pushed = uint.max

Detailed Description

Reader base-class. Each reader operates upon an IBuffer, which is provided at construction time. Said buffer is intended to remain consistent over the reader lifetime.

Readers support both a C++ iostream type syntax, along with a get() syntax. Operations may be chained back-to-back.

All readers support the full set of native data types, plus a full selection of array types. The latter can be configured to produce either a copy (.dup) of the buffer content, or a slice. See class SimpleAllocator, BufferAllocator and SliceAllocator for more on this topic.

The code below illustrates basic operation upon a memory buffer:

Buffer buf = new Buffer (256); // map same buffer into both reader and writer IReader r = new Reader(buf); IWriter w = new Writer(buf); int i = 10; long j = 20; double d = 3.14159; char[] c = "fred"; // write data types out w << c << i << j << d; // read them back again r >> c >> i >> j >> d; // reset buf.clear(); // same thing again, but using get() syntax instead w.put(c).put(i).put(j).put(d); r.get(c).get(i).get(j).get(d);

Readers may also be used with any class implementing the IReadable interface. See PickleReader for an example of how this can be put to good use.

Definition at line 99 of file AbstractReader.d.


Member Typedef Documentation

typedef opShr get
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 101 of file AbstractReader.d.

Referenced by length(), testBuffer(), testConduitFilters(), testHttpClient(), and testRandomAccess().


Member Function Documentation

this IBuffer  buffer  )  [inline]
 

Return the buffer associated with this reader

Reimplemented in HttpReader, EndianReader, and Reader.

Definition at line 150 of file AbstractReader.d.

References setAllocator().

IBuffer getBuffer  )  [inline]
 

Return the buffer associated with this reader

Reimplemented from IReader.

Definition at line 162 of file AbstractReader.d.

IArrayAllocator getAllocator  )  [inline]
 

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

Reimplemented from IReader.

Definition at line 174 of file AbstractReader.d.

References memory.

void setAllocator IArrayAllocator  memory  )  [inline]
 

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 201 of file AbstractReader.d.

References IArrayAllocator::bind().

Referenced by this().

void setDecoder IDecoder  d  )  [inline]
 

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 226 of file AbstractReader.d.

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

IReader push uint  size  )  [inline]
 

Push the size (in bytes) to use for the next array-read. By default, array sizes are read from the input stream, so this is the means by which one may specify the size where the stream is not formatted in such a manner.

char[] x; int size; IReader reader; reader.push(size).get(x);

Reimplemented from IReader.

Definition at line 248 of file AbstractReader.d.

References pushed.

uint length  )  [inline]
 

Read and return an integer from the input stream. This can be used to extract the length of a subsequent array.

Reimplemented from IReader.

Definition at line 264 of file AbstractReader.d.

References get, and pushed.

Referenced by opShr().

void wait  )  [inline]
 

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 283 of file AbstractReader.d.

References IBuffer::get().

IReader opShr IReadable  x  )  [inline]
 

Extract a readable class from the current read-position

Reimplemented from IReader.

Definition at line 294 of file AbstractReader.d.

References IReadable::read().

IReader opShr inout bool  x  )  [inline]
 

Extract a boolean value from the current read-position

Reimplemented from IReader.

Definition at line 307 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int1.

IReader opShr inout ubyte  x  )  [inline]
 

Extract an unsigned byte value from the current read-position

Reimplemented from IReader.

Definition at line 319 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int8u.

IReader opShr inout byte  x  )  [inline]
 

Extract a byte value from the current read-position

Reimplemented from IReader.

Definition at line 331 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int8.

IReader opShr inout ushort  x  )  [inline]
 

Extract an unsigned short value from the current read-position

Reimplemented from IReader.

Definition at line 343 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int16u.

IReader opShr inout short  x  )  [inline]
 

Extract a short value from the current read-position

Reimplemented from IReader.

Definition at line 356 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int16.

IReader opShr inout uint  x  )  [inline]
 

Extract a unsigned int value from the current read-position

Reimplemented from IReader.

Definition at line 368 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int32u.

IReader opShr inout int  x  )  [inline]
 

Extract an int value from the current read-position

Reimplemented from IReader.

Definition at line 380 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int32.

IReader opShr inout ulong  x  )  [inline]
 

Extract an unsigned long value from the current read-position

Reimplemented from IReader.

Definition at line 392 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int64u.

IReader opShr inout long  x  )  [inline]
 

Extract a long value from the current read-position

Reimplemented from IReader.

Definition at line 404 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::int64.

IReader opShr inout float  x  )  [inline]
 

Extract a float value from the current read-position

Reimplemented from IReader.

Definition at line 416 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::float32.

IReader opShr inout double  x  )  [inline]
 

Extract a double value from the current read-position

Reimplemented from IReader.

Definition at line 428 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::float64.

IReader opShr inout real  x  )  [inline]
 

Extract a real value from the current read-position

Reimplemented from IReader.

Definition at line 440 of file AbstractReader.d.

References decode, and AbstractReader::Decoder::float80.

IReader opShr inout char  x  )  [inline]
 

Extract a char value from the current read-position

Reimplemented from IReader.

Definition at line 452 of file AbstractReader.d.

References AbstractReader::Decoder::char8, and decode.

IReader opShr inout wchar  x  )  [inline]
 

Extract a wide char value from the current read-position

Reimplemented from IReader.

Definition at line 464 of file AbstractReader.d.

References AbstractReader::Decoder::char16, and decode.

IReader opShr inout dchar  x  )  [inline]
 

Extract a double char value from the current read-position

Reimplemented from IReader.

Definition at line 476 of file AbstractReader.d.

References AbstractReader::Decoder::char32, and decode.

IReader opShr inout ubyte[]  x  )  [inline]
 

Extract an unsigned byte value from the current read-position

Reimplemented from IReader.

Definition at line 488 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int8u, length(), and memory.

IReader opShr inout byte[]  x  )  [inline]
 

Extract a byte value from the current read-position

Reimplemented from IReader.

Definition at line 500 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int8, length(), and memory.

IReader opShr inout ushort[]  x  )  [inline]
 

Extract an unsigned short value from the current read-position

Reimplemented from IReader.

Definition at line 512 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int16u, length(), and memory.

IReader opShr inout short[]  x  )  [inline]
 

Extract a short value from the current read-position

Reimplemented from IReader.

Definition at line 524 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int16, length(), and memory.

IReader opShr inout uint[]  x  )  [inline]
 

Extract a unsigned int value from the current read-position

Reimplemented from IReader.

Definition at line 536 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int32u, length(), and memory.

IReader opShr inout int[]  x  )  [inline]
 

Extract an int value from the current read-position

Reimplemented from IReader.

Definition at line 548 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int32, length(), and memory.

IReader opShr inout ulong[]  x  )  [inline]
 

Extract an unsigned long value from the current read-position

Reimplemented from IReader.

Definition at line 560 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int64u, length(), and memory.

IReader opShr inout long[]  x  )  [inline]
 

Extract a long value from the current read-position

Reimplemented from IReader.

Definition at line 572 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::int64, length(), and memory.

IReader opShr inout float[]  x  )  [inline]
 

Extract a float value from the current read-position

Reimplemented from IReader.

Definition at line 584 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::float32, length(), and memory.

IReader opShr inout double[]  x  )  [inline]
 

Extract a double value from the current read-position

Reimplemented from IReader.

Definition at line 596 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::float64, length(), and memory.

IReader opShr inout real[]  x  )  [inline]
 

Extract a real value from the current read-position

Reimplemented from IReader.

Definition at line 608 of file AbstractReader.d.

References IArrayAllocator::allocate(), decode, AbstractReader::Decoder::float80, length(), and memory.

IReader opShr inout char[]  x  )  [inline]
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 618 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::Decoder::char8, decode, length(), and memory.

IReader opShr inout wchar[]  x  )  [inline]
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 628 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::Decoder::char16, decode, length(), and memory.

IReader opShr inout dchar[]  x  )  [inline]
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 638 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::Decoder::char32, decode, length(), and memory.

void reset  )  [inline, inherited]
 

Reimplemented from IArrayAllocator.

Reimplemented in BufferAllocator.

Definition at line 60 of file ArrayAllocator.d.

void bind IReader  reader  )  [inline, inherited]
 

Reimplemented from IArrayAllocator.

Reimplemented in BufferAllocator.

Definition at line 68 of file ArrayAllocator.d.

bool isMutable void *  x  )  [inline, inherited]
 

Reimplemented from IArrayAllocator.

Reimplemented in NativeAllocator, and BufferAllocator.

Definition at line 77 of file ArrayAllocator.d.

void allocate void *[]  x,
uint  count,
uint  width,
BufferDecoder  decoder
[inline, inherited]
 

Reimplemented from IArrayAllocator.

Reimplemented in NativeAllocator, and BufferAllocator.

Definition at line 86 of file ArrayAllocator.d.

References BufferDecoder.


Member Data Documentation

IBuffer buffer [protected]
 

Definition at line 133 of file AbstractReader.d.

Decoder decode [protected]
 

Definition at line 136 of file AbstractReader.d.

Referenced by opShr(), and setDecoder().

IArrayAllocator memory [private]
 

Definition at line 139 of file AbstractReader.d.

Referenced by getAllocator(), and opShr().

uint pushed = uint.max [private]
 

Definition at line 142 of file AbstractReader.d.

Referenced by length(), and push().


The documentation for this class was generated from the following file:
Generated on Tue Jan 25 21:18:30 2005 for Mango by doxygen 1.3.6