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 Member Functions

char[] toString ()
 this (IBuffer buffer)
IBuffer getBuffer ()
IArrayAllocator getAllocator ()
void setAllocator (IArrayAllocator memory)
void setStringDecoder (IStringDecoder s)
IReader push (uint size)
uint length ()
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 int[] x)
IReader get (inout char[] x)
IReader get (inout wchar[] x)
IReader get (inout dchar[] x)

Static Public Member Functions

 this ()

Protected Attributes

IBuffer buffer
StringDecoder string
NumericDecoder numeric

Private Member Functions

 this (IReader reader)
void reset ()
void allocate (void[]*x, BufferConverter decoder)

Private Attributes

IArrayAllocator memory
uint pushed = uint.max

Static Private Attributes

EofException eof
IOException udf

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 integral data types, plus a selection of array types. The latter can be configured to produce either a copy (.dup) of the buffer content, or a slice. See method setMapped() 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 Reader r = new Reader(buf); Writer w = new Writer(buf); int i = 10; long j = 20; double d = 3.14159; // write data types out w << i << j << d; // read them back again r >> i >> j >> d; // reset buf.clear(); // same thing again, but using get() syntax instead w.put(i).put(j).put(d); r.get(i).get(j).get(d);

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

Definition at line 94 of file AbstractReader.d.


Member Function Documentation

char [] toString  ) 
 

Return the name of this reader

Reimplemented in EndianReader, Reader, and TextReader.

this  )  [inline, static]
 

Construct a couple of static exception instances.

Definition at line 163 of file AbstractReader.d.

References eof, and udf.

this IBuffer  buffer  )  [inline]
 

Return the buffer associated with this reader

Reimplemented in HttpReader, EndianReader, Reader, and TextReader.

Definition at line 175 of file AbstractReader.d.

IBuffer getBuffer  )  [inline]
 

Return the buffer associated with this reader

Reimplemented from IReader.

Definition at line 188 of file AbstractReader.d.

IArrayAllocator getAllocator  )  [inline]
 

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

Definition at line 200 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 227 of file AbstractReader.d.

void setStringDecoder IStringDecoder  s  )  [inline]
 

Set the configured IStringDecoder. These are intended to be used as a conversion mechanism between various character representations. They are also expected to be used for the process of applying character encodings.

See IStringDecoder.

Reimplemented from IReader.

Definition at line 245 of file AbstractReader.d.

References IStringDecoder::char16(), AbstractReader::StringDecoder::char16, IStringDecoder::char32(), AbstractReader::StringDecoder::char32, IStringDecoder::char8(), AbstractReader::StringDecoder::char8, and string.

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

References get(), and pushed.

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

References IBuffer::get().

IReader get IReadable  x  )  [inline]
 

Extract a readable class from the current read-position

Reimplemented from IReader.

Definition at line 315 of file AbstractReader.d.

References IReadable::read().

Referenced by length(), AbstractReader::VersionUseShiftOperators::opShr(), testBuffer(), testConduitFilters(), testHttpClient(), and testRandomAccess().

IReader get inout bool  x  )  [inline]
 

Extract a boolean value from the current read-position

Reimplemented from IReader.

Definition at line 328 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int1, and numeric.

IReader get inout ubyte  x  )  [inline]
 

Extract an unsigned byte value from the current read-position

Reimplemented from IReader.

Definition at line 340 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int8u, and numeric.

IReader get inout byte  x  )  [inline]
 

Extract a byte value from the current read-position

Reimplemented from IReader.

Definition at line 352 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int8, and numeric.

IReader get inout ushort  x  )  [inline]
 

Extract an unsigned short value from the current read-position

Reimplemented from IReader.

Definition at line 364 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int16u, and numeric.

IReader get inout short  x  )  [inline]
 

Extract a short value from the current read-position

Reimplemented from IReader.

Definition at line 376 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int16, and numeric.

IReader get inout uint  x  )  [inline]
 

Extract a unsigned int value from the current read-position

Reimplemented from IReader.

Definition at line 388 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int32u, and numeric.

IReader get inout int  x  )  [inline]
 

Extract an int value from the current read-position

Reimplemented from IReader.

Definition at line 400 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int32, and numeric.

IReader get inout ulong  x  )  [inline]
 

Extract an unsigned long value from the current read-position

Reimplemented from IReader.

Definition at line 412 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int64u, and numeric.

IReader get inout long  x  )  [inline]
 

Extract a long value from the current read-position

Reimplemented from IReader.

Definition at line 424 of file AbstractReader.d.

References AbstractReader::NumericDecoder::int64, and numeric.

IReader get inout float  x  )  [inline]
 

Extract a float value from the current read-position

Reimplemented from IReader.

Definition at line 436 of file AbstractReader.d.

References AbstractReader::NumericDecoder::float32, and numeric.

IReader get inout double  x  )  [inline]
 

Extract a double value from the current read-position

Reimplemented from IReader.

Definition at line 448 of file AbstractReader.d.

References AbstractReader::NumericDecoder::float64, and numeric.

IReader get inout real  x  )  [inline]
 

Extract a real value from the current read-position

Reimplemented from IReader.

Definition at line 460 of file AbstractReader.d.

References AbstractReader::NumericDecoder::float80, and numeric.

IReader get inout char  x  )  [inline]
 

Extract a char value from the current read-position

Reimplemented from IReader.

Definition at line 472 of file AbstractReader.d.

References AbstractReader::StringDecoder::char8, and string.

IReader get inout wchar  x  )  [inline]
 

Extract a wide char value from the current read-position

Reimplemented from IReader.

Definition at line 484 of file AbstractReader.d.

References AbstractReader::StringDecoder::char16, and string.

IReader get inout dchar  x  )  [inline]
 

Extract a double char value from the current read-position

Reimplemented from IReader.

Definition at line 496 of file AbstractReader.d.

References AbstractReader::StringDecoder::char32, and string.

IReader get inout int[]  x  )  [inline]
 

Definition at line 506 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::StringDecoder::char8, memory, and string.

IReader get inout char[]  x  )  [inline]
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 516 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::StringDecoder::char8, memory, and string.

IReader get inout wchar[]  x  )  [inline]
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 526 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::StringDecoder::char16, memory, and string.

IReader get inout dchar[]  x  )  [inline]
 

Reimplemented from IReader.

Reimplemented in TextReader.

Definition at line 536 of file AbstractReader.d.

References IArrayAllocator::allocate(), AbstractReader::StringDecoder::char32, memory, and string.

this IReader  reader  )  [inline, inherited]
 

Definition at line 57 of file ArrayAllocator.d.

void reset  )  [inline, inherited]
 

Reimplemented from IArrayAllocator.

Definition at line 66 of file ArrayAllocator.d.

void allocate void *[]  x,
BufferConverter  decoder
[inline, inherited]
 

Reimplemented from IArrayAllocator.

Definition at line 74 of file ArrayAllocator.d.

References BufferConverter, and IReader::length().


Member Data Documentation

EofException eof [static, private]
 

Definition at line 128 of file AbstractReader.d.

Referenced by this().

IOException udf [static, private]
 

Definition at line 129 of file AbstractReader.d.

Referenced by this().

IBuffer buffer [protected]
 

Definition at line 135 of file AbstractReader.d.

StringDecoder string [protected]
 

Definition at line 138 of file AbstractReader.d.

Referenced by get(), and setStringDecoder().

NumericDecoder numeric [protected]
 

Definition at line 141 of file AbstractReader.d.

Referenced by get().

IArrayAllocator memory [private]
 

Definition at line 144 of file AbstractReader.d.

Referenced by get(), and getAllocator().

uint pushed = uint.max [private]
 

Definition at line 147 of file AbstractReader.d.

Referenced by length(), and push().


The documentation for this class was generated from the following file:
Generated on Sun Oct 24 22:31:20 2004 for Mango by doxygen 1.3.6