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

AbstractWriter Class Reference

Inheritance diagram for AbstractWriter:

IWriter Writer DisplayWriter EndianWriter ColumnWriter FlushWriter HttpWriter TextWriter List of all members.

Public Types

typedef opShl put

Public Member Functions

 this (IBuffer buffer)
IBuffer getBuffer ()
void setEncoder (IEncoder e)
IWriter flush ()
IWriter cr ()
void enableArrayPrefix (bool on)
IWriter opShl (IWritable x)
IWriter opShl (bool x)
IWriter opShl (ubyte x)
IWriter opShl (byte x)
IWriter opShl (ushort x)
IWriter opShl (short x)
IWriter opShl (uint x)
IWriter opShl (int x)
IWriter opShl (ulong x)
IWriter opShl (long x)
IWriter opShl (float x)
IWriter opShl (double x)
IWriter opShl (real x)
IWriter opShl (char x)
IWriter opShl (wchar x)
IWriter opShl (dchar x)
IWriter opShl (byte[] x)
IWriter opShl (ubyte[] x)
IWriter opShl (short[] x)
IWriter opShl (ushort[] x)
IWriter opShl (int[] x)
IWriter opShl (uint[] x)
IWriter opShl (long[] x)
IWriter opShl (ulong[] x)
IWriter opShl (float[] x)
IWriter opShl (double[] x)
IWriter opShl (real[] x)
IWriter opShl (char[] x)
IWriter opShlw (wchar[] x)
IWriter opShld (dchar[] x)

Static Public Member Functions

 this ()

Static Public Attributes

INewlineWriter newline

Protected Attributes

IBuffer buffer
Encoder encode

Static Protected Attributes

IOException ovf

Private Member Functions

final uint length (uint len)

Private Attributes

bool prefixArray = true

Detailed Description

Writer base-class. Writers provide the means to append formatted data to an IBuffer, and expose a convenient method of handling a variety of data types. In addition to writing native types such as integer and char[], writers also process any class which has implemented the IWritable interface (one method).

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

All writers support the full set of native data types, plus a full selection of array types.

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 put() syntax instead w.put(c).put(i).put(j).put(d); r.get(c).get(i).get(j).get(d);

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

Definition at line 96 of file AbstractWriter.d.


Member Typedef Documentation

typedef opShl put
 

Reimplemented from IWriter.

Reimplemented in ColumnWriter, FlushWriter, and TextWriter.

Definition at line 98 of file AbstractWriter.d.

Referenced by cr(), DisplayWriter::fformat(), DisplayWriter::format(), length(), testBuffer(), testConduitFilters(), and testRandomAccess().


Member Function Documentation

this  )  [inline, static]
 

Construct some static exception instances, and create the public 'newline' instance.

Reimplemented in ColumnWriter.

Definition at line 145 of file AbstractWriter.d.

References newline, and ovf.

this IBuffer  buffer  )  [inline]
 

Construct a Writer upon the provided IBuffer. All formatted output will be appended to this buffer.

Reimplemented in HttpWriter, DisplayWriter, FlushWriter, EndianWriter, and Writer.

Definition at line 159 of file AbstractWriter.d.

IBuffer getBuffer  )  [inline]
 

Return the associated buffer

Reimplemented from IWriter.

Definition at line 170 of file AbstractWriter.d.

void setEncoder IEncoder  e  )  [inline]
 

Bind an IEncoder to the writer. Encoders 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 encoder, covering all native types (15 in total).

An appropriate encoder set should be attached to each IWriter, 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 encoder implementation -- those classes bind the ICU converters to this IO package.

Reimplemented from IWriter.

Definition at line 194 of file AbstractWriter.d.

References IEncoder::bind(), encode, AbstractWriter::Encoder::encoders, and IEncoder::type().

IWriter flush  )  [inline]
 

Flush the output of this writer. Returns false if the operation failed, true otherwise.

Reimplemented from IWriter.

Definition at line 206 of file AbstractWriter.d.

References IBuffer::flush().

Referenced by FlushWriter::opShl(), and testRandomAccess().

IWriter cr  )  [inline]
 

Output a newline. Do this indirectly so that it can be intercepted by subclasses.

Reimplemented from IWriter.

Definition at line 219 of file AbstractWriter.d.

References newline, and put.

void enableArrayPrefix bool  on  )  [inline]
 

Definition at line 228 of file AbstractWriter.d.

References prefixArray.

Referenced by DisplayWriter::this().

final uint length uint  len  )  [inline, private]
 

Write a class to the current buffer-position

Definition at line 239 of file AbstractWriter.d.

References prefixArray, and put.

IWriter opShl IWritable  x  )  [inline]
 

Write a class to the current buffer-position

Reimplemented from IWriter.

Reimplemented in ColumnWriter, FlushWriter, and TextWriter.

Definition at line 252 of file AbstractWriter.d.

References IWritable::write().

IWriter opShl bool  x  )  [inline]
 

Write a boolean value to the current buffer-position

Reimplemented from IWriter.

Definition at line 265 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int1.

IWriter opShl ubyte  x  )  [inline]
 

Write an unsigned byte value to the current buffer-position

Reimplemented from IWriter.

Definition at line 277 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int8u.

IWriter opShl byte  x  )  [inline]
 

Write a byte value to the current buffer-position

Reimplemented from IWriter.

Definition at line 289 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int8.

IWriter opShl ushort  x  )  [inline]
 

Write an unsigned short value to the current buffer-position

Reimplemented from IWriter.

Definition at line 301 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int16u.

IWriter opShl short  x  )  [inline]
 

Write a short value to the current buffer-position

Reimplemented from IWriter.

Definition at line 313 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int16.

IWriter opShl uint  x  )  [inline]
 

Write a unsigned int value to the current buffer-position

Reimplemented from IWriter.

Definition at line 325 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int32u.

IWriter opShl int  x  )  [inline]
 

Write an int value to the current buffer-position

Reimplemented from IWriter.

Definition at line 337 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int32.

IWriter opShl ulong  x  )  [inline]
 

Write an unsigned long value to the current buffer-position

Reimplemented from IWriter.

Definition at line 349 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int64u.

IWriter opShl long  x  )  [inline]
 

Write a long value to the current buffer-position

Reimplemented from IWriter.

Definition at line 361 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int64.

IWriter opShl float  x  )  [inline]
 

Write a float value to the current buffer-position

Reimplemented from IWriter.

Definition at line 373 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::float32.

IWriter opShl double  x  )  [inline]
 

Write a double value to the current buffer-position

Reimplemented from IWriter.

Definition at line 385 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::float64.

IWriter opShl real  x  )  [inline]
 

Write a real value to the current buffer-position

Reimplemented from IWriter.

Definition at line 397 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::float80.

IWriter opShl char  x  )  [inline]
 

Write a char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 409 of file AbstractWriter.d.

References AbstractWriter::Encoder::char8, and encode.

IWriter opShl wchar  x  )  [inline]
 

Write a wide char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 421 of file AbstractWriter.d.

References AbstractWriter::Encoder::char16, and encode.

IWriter opShl dchar  x  )  [inline]
 

Write a double char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 433 of file AbstractWriter.d.

References AbstractWriter::Encoder::char32, and encode.

IWriter opShl byte[]  x  )  [inline]
 

Write a byte array to the current buffer-position

Reimplemented from IWriter.

Definition at line 445 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int8.

IWriter opShl ubyte[]  x  )  [inline]
 

Write an unsigned byte array to the current buffer-position

Reimplemented from IWriter.

Definition at line 457 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int8u.

IWriter opShl short[]  x  )  [inline]
 

Write a short array to the current buffer-position

Reimplemented from IWriter.

Definition at line 469 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int16.

IWriter opShl ushort[]  x  )  [inline]
 

Write an unsigned short array to the current buffer-position

Reimplemented from IWriter.

Definition at line 481 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int16u.

IWriter opShl int[]  x  )  [inline]
 

Write an int array to the current buffer-position

Reimplemented from IWriter.

Definition at line 493 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int32.

IWriter opShl uint[]  x  )  [inline]
 

Write an unsigned int array to the current buffer-position

Reimplemented from IWriter.

Definition at line 505 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int32u.

IWriter opShl long[]  x  )  [inline]
 

Write a long array to the current buffer-position

Reimplemented from IWriter.

Definition at line 517 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int64.

IWriter opShl ulong[]  x  )  [inline]
 

Write an unsigned long array to the current buffer-position

Reimplemented from IWriter.

Definition at line 529 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::int64u.

IWriter opShl float[]  x  )  [inline]
 

Write a float array to the current buffer-position

Reimplemented from IWriter.

Definition at line 541 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::float32.

IWriter opShl double[]  x  )  [inline]
 

Write a double array to the current buffer-position

Reimplemented from IWriter.

Definition at line 553 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::float64.

IWriter opShl real[]  x  )  [inline]
 

Write a real array to the current buffer-position

Reimplemented from IWriter.

Definition at line 565 of file AbstractWriter.d.

References encode, and AbstractWriter::Encoder::float80.

IWriter opShl char[]  x  )  [inline]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Reimplemented in ColumnWriter, and TextWriter.

Definition at line 577 of file AbstractWriter.d.

References AbstractWriter::Encoder::char8, and encode.

IWriter opShlw wchar[]  x  )  [inline]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Reimplemented in TextWriter.

Definition at line 589 of file AbstractWriter.d.

References AbstractWriter::Encoder::char16, and encode.

IWriter opShld dchar[]  x  )  [inline]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Reimplemented in TextWriter.

Definition at line 601 of file AbstractWriter.d.

References AbstractWriter::Encoder::char32, and encode.


Member Data Documentation

INewlineWriter newline [static]
 

Definition at line 127 of file AbstractWriter.d.

Referenced by cr(), and this().

IOException ovf [static, protected]
 

Definition at line 130 of file AbstractWriter.d.

Referenced by this().

IBuffer buffer [protected]
 

Definition at line 132 of file AbstractWriter.d.

Encoder encode [protected]
 

Definition at line 134 of file AbstractWriter.d.

Referenced by opShl(), opShld(), opShlw(), and setEncoder().

bool prefixArray = true [private]
 

Definition at line 136 of file AbstractWriter.d.

Referenced by enableArrayPrefix(), and length().


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