Inheritance diagram for Reader:
Public Member Functions | |
this (IBuffer buffer) | |
this (IConduit conduit) | |
IBuffer | getBuffer () |
IArrayAllocator | getAllocator () |
void | setAllocator (IArrayAllocator memory) |
void | setDecoder (IDecoder d) |
void | wait () |
uint | read (void *dst, uint bytes, uint type) |
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 | 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) |
Protected Attributes | |
IBuffer | buffer |
Decoder | decode |
Private Types | |
typedef get | opShr |
typedef get | opCall |
Private Member Functions | |
final uint | count (uint elements) |
void | reset () |
void | bind (IReader reader) |
bool | isMutable (void *x) |
void | allocate (void[]*x, uint bytes, uint width, uint type, BufferDecoder decoder) |
Private Attributes | |
IArrayAllocator | memory |
Classes | |
union | Decoder |
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.
Readers support a C++ iostream type syntax, along with Java-esque get() notation. However, the Mango style is to place IO elements within their own parenthesis, like so:
int count; char[] verse;
read (verse) (count);
Note that each element is distict; this enables "strong typing", which should catch any typo errors at compile-time.
The code below illustrates basic operation upon a memory buffer:
Buffer buf = new Buffer (256); // map same buffer into both reader and writer IReader read = new Reader (buf); IWriter write = new Writer (buf); int i = 10; long j = 20; double d = 3.14159; char[] c = "fred"; // write data types out write (c) (i) (j) (d); // read them back again read (c) (i) (j) (d); // reset buf.clear(); // same thing again, but using iostream syntax instead write << c << i << j << d; // read them back again read >> c >> i >> j >> d; // reset buf.clear(); // same thing again, but using put() syntax instead write.put(c).put(i).put(j).put(d); read.get(c).get(i).get(j).get(d);
Note that certain Readers, such as the basic binary implementation, expect to retrieve the number of array elements from the source. For example; when reading an array from a file, the number of elements is read from the file also. If the content is not arranged in such a manner, you may specify how many elements to read via a second argument:
read (myArray, 11);
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 130 of file Reader.d.
|
|
|
|
|
Construct a Reader upon the provided buffer Reimplemented in HttpReader, and EndianReader. Definition at line 164 of file Reader.d. References buffer, Reader::Decoder::char16, Reader::Decoder::char32, Reader::Decoder::char8, decode, read(), and setAllocator(). |
|
Construct a Reader upon the buffer associated with the given conduit. |
|
Return the buffer associated with this reader Reimplemented from IReader. Definition at line 193 of file Reader.d. References buffer. |
|
Return the allocator associated with this reader. See ArrayAllocator for more information. Reimplemented from IReader. Definition at line 205 of file Reader.d. References memory. |
|
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 this(). |
|
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(), decode, Reader::Decoder::decoders, and IDecoder::type(). |
|
Read and return an integer from the input stream. This is used to extract the element count of a subsequent array. Definition at line 269 of file Reader.d. References get(). Referenced by get(). |
|
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 buffer, and IBuffer::get(). |
|
Reimplemented in EndianReader, and TextReader. Definition at line 293 of file Reader.d. References buffer, IBuffer::get(), and IBuffer::readable(). Referenced by get(), HttpReader::getPostData(), and this(). |
|
Extract a readable class from the current read-position Reimplemented from IReader. Definition at line 325 of file Reader.d. Referenced by count(), and testBuffer(). |
|
Extract a boolean value from the current read-position Reimplemented from IReader. |
|
Extract an unsigned byte value from the current read-position Reimplemented from IReader. |
|
Extract a byte value from the current read-position Reimplemented from IReader. |
|
Extract an unsigned short value from the current read-position Reimplemented from IReader. |
|
Extract a short value from the current read-position Reimplemented from IReader. |
|
Extract a unsigned int value from the current read-position Reimplemented from IReader. |
|
Extract an int value from the current read-position Reimplemented from IReader. |
|
Extract an unsigned long value from the current read-position Reimplemented from IReader. |
|
Extract a long value from the current read-position Reimplemented from IReader. |
|
Extract a float value from the current read-position Reimplemented from IReader. |
|
Extract a double value from the current read-position Reimplemented from IReader. |
|
Extract a real value from the current read-position Reimplemented from IReader. |
|
Extract a char value from the current read-position Reimplemented from IReader. Definition at line 482 of file Reader.d. References Reader::Decoder::char8, decode, and x. |
|
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, decode, and x. |
|
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, decode, and x. |
|
Extract an unsigned byte array from the current read-position Reimplemented from IReader. Definition at line 518 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a byte array from the current read-position Reimplemented from IReader. Definition at line 531 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract an unsigned short array from the current read-position Reimplemented from IReader. Definition at line 544 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a short array from the current read-position Reimplemented from IReader. Definition at line 557 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a unsigned int array from the current read-position Reimplemented from IReader. Definition at line 570 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract an int array from the current read-position Reimplemented from IReader. Definition at line 583 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract an unsigned long array from the current read-position Reimplemented from IReader. Definition at line 596 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a long array from the current read-position Reimplemented from IReader. Definition at line 609 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a float array from the current read-position Reimplemented from IReader. Definition at line 622 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a double array from the current read-position Reimplemented from IReader. Definition at line 635 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Extract a real array from the current read-position Reimplemented from IReader. Definition at line 648 of file Reader.d. References IArrayAllocator::allocate(), count(), memory, read(), and x. |
|
Reimplemented from IReader. Reimplemented in TextReader. Definition at line 659 of file Reader.d. References IArrayAllocator::allocate(), Reader::Decoder::char8, count(), decode, memory, and x. |
|
Reimplemented from IReader. Reimplemented in TextReader. Definition at line 670 of file Reader.d. References IArrayAllocator::allocate(), Reader::Decoder::char16, count(), decode, memory, and x. |
|
Reimplemented from IReader. Reimplemented in TextReader. Definition at line 681 of file Reader.d. References IArrayAllocator::allocate(), Reader::Decoder::char32, count(), decode, memory, and x. |
|
Reimplemented from IArrayAllocator. Reimplemented in BufferAllocator. Definition at line 60 of file ArrayAllocator.d. |
|
Reimplemented from IArrayAllocator. Reimplemented in BufferAllocator. Definition at line 68 of file ArrayAllocator.d. |
|
Reimplemented from IArrayAllocator. Reimplemented in NativeAllocator, and BufferAllocator. Definition at line 77 of file ArrayAllocator.d. |
|
Reimplemented from IArrayAllocator. Reimplemented in NativeAllocator, and BufferAllocator. Definition at line 86 of file ArrayAllocator.d. References x. |
|
Definition at line 150 of file Reader.d. Referenced by getBuffer(), read(), this(), and wait(). |
|
Definition at line 153 of file Reader.d. Referenced by get(), setDecoder(), and this(). |
|
Definition at line 156 of file Reader.d. Referenced by get(), and getAllocator(). |