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 HttpWriter TextWriter List of all members.

Public Member Functions

char[] toString ()
 this (IBuffer buffer)
IBuffer getBuffer ()
void setStringEncoder (IStringEncoder s)
IWriter flush ()
IWriter cr ()
void enableArrayPrefix (bool on)
IWriter put (IWritable x)
IWriter put (char x)
IWriter put (wchar x)
IWriter put (dchar x)
IWriter put (char[] x)
IWriter putw (wchar[] x)
IWriter putd (dchar[] x)
IWriter put (bool x)
IWriter put (ubyte x)
IWriter put (byte x)
IWriter put (ushort x)
IWriter put (short x)
IWriter put (uint x)
IWriter put (int x)
IWriter put (ulong x)
IWriter put (long x)
IWriter put (float x)
IWriter put (double x)
IWriter put (real x)

Static Public Member Functions

 this ()

Static Public Attributes

INewlineWriter newline

Protected Attributes

IBuffer buffer
StringEncoder string
NumericEncoder numeric

Static Protected Attributes

IOException ovf
EofException eof

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 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 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 Function Documentation

char [] toString  ) 
 

Return the name of this writer

Reimplemented in ColumnWriter, DisplayWriter, EndianWriter, TextWriter, and Writer.

this  )  [inline, static]
 

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

Reimplemented in ColumnWriter.

Definition at line 159 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, EndianWriter, and Writer.

Definition at line 174 of file AbstractWriter.d.

IBuffer getBuffer  )  [inline]
 

Return the associated buffer

Reimplemented from IWriter.

Definition at line 185 of file AbstractWriter.d.

void setStringEncoder IStringEncoder  s  )  [inline]
 

Set the configured IStringEncoder. 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 IStringEncoder.

Reimplemented from IWriter.

Definition at line 201 of file AbstractWriter.d.

References IStringEncoder::char16(), AbstractWriter::StringEncoder::char16, IStringEncoder::char32(), AbstractWriter::StringEncoder::char32, IStringEncoder::char8(), and AbstractWriter::StringEncoder::char8.

IWriter flush  )  [inline]
 

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

Reimplemented from IWriter.

Definition at line 215 of file AbstractWriter.d.

References IBuffer::flush().

Referenced by testRandomAccess().

IWriter cr  )  [inline]
 

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

Reimplemented from IWriter.

Definition at line 228 of file AbstractWriter.d.

References newline, and put().

void enableArrayPrefix bool  on  )  [inline]
 

Definition at line 237 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 248 of file AbstractWriter.d.

References prefixArray, and put().

IWriter put IWritable  x  )  [inline]
 

Write a class to the current buffer-position

Reimplemented from IWriter.

Reimplemented in ColumnWriter, and TextWriter.

Definition at line 261 of file AbstractWriter.d.

References IWritable::write().

Referenced by cr(), DisplayWriter::format(), length(), AbstractWriter::VersionUseShiftOperators::opShl(), testBuffer(), testConduitFilters(), and testRandomAccess().

IWriter put char  x  )  [inline]
 

Write a char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 274 of file AbstractWriter.d.

References AbstractWriter::StringEncoder::char8.

IWriter put wchar  x  )  [inline]
 

Write a wide char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 286 of file AbstractWriter.d.

References AbstractWriter::StringEncoder::char16.

IWriter put dchar  x  )  [inline]
 

Write a double char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 298 of file AbstractWriter.d.

References AbstractWriter::StringEncoder::char32.

IWriter put char[]  x  )  [inline]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Reimplemented in ColumnWriter, and TextWriter.

Definition at line 310 of file AbstractWriter.d.

References AbstractWriter::StringEncoder::char8.

IWriter putw wchar[]  x  )  [inline]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Definition at line 322 of file AbstractWriter.d.

References AbstractWriter::StringEncoder::char16.

Referenced by AbstractWriter::VersionUseShiftOperators::opShl().

IWriter putd dchar[]  x  )  [inline]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Definition at line 334 of file AbstractWriter.d.

References AbstractWriter::StringEncoder::char32.

Referenced by AbstractWriter::VersionUseShiftOperators::opShl().

IWriter put bool  x  )  [inline]
 

Write a boolean value to the current buffer-position

Reimplemented from IWriter.

Definition at line 346 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int1.

IWriter put ubyte  x  )  [inline]
 

Write an unsigned byte value to the current buffer-position

Reimplemented from IWriter.

Definition at line 358 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int8u.

IWriter put byte  x  )  [inline]
 

Write a byte value to the current buffer-position

Reimplemented from IWriter.

Definition at line 370 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int8.

IWriter put ushort  x  )  [inline]
 

Write an unsigned short value to the current buffer-position

Reimplemented from IWriter.

Definition at line 382 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int16u.

IWriter put short  x  )  [inline]
 

Write a short value to the current buffer-position

Reimplemented from IWriter.

Definition at line 394 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int16.

IWriter put uint  x  )  [inline]
 

Write a unsigned int value to the current buffer-position

Reimplemented from IWriter.

Definition at line 406 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int32u.

IWriter put int  x  )  [inline]
 

Write an int value to the current buffer-position

Reimplemented from IWriter.

Definition at line 418 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int32.

IWriter put ulong  x  )  [inline]
 

Write an unsigned long value to the current buffer-position

Reimplemented from IWriter.

Definition at line 430 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int64u.

IWriter put long  x  )  [inline]
 

Write a long value to the current buffer-position

Reimplemented from IWriter.

Definition at line 442 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::int64.

IWriter put float  x  )  [inline]
 

Write a float value to the current buffer-position

Reimplemented from IWriter.

Definition at line 454 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::float32.

IWriter put double  x  )  [inline]
 

Write a double value to the current buffer-position

Reimplemented from IWriter.

Definition at line 466 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::float64.

IWriter put real  x  )  [inline]
 

Write a real value to the current buffer-position

Reimplemented from IWriter.

Definition at line 478 of file AbstractWriter.d.

References AbstractWriter::NumericEncoder::float80.


Member Data Documentation

INewlineWriter newline [static]
 

Definition at line 130 of file AbstractWriter.d.

Referenced by cr(), and this().

IOException ovf [static, protected]
 

Definition at line 133 of file AbstractWriter.d.

Referenced by this().

EofException eof [static, protected]
 

Definition at line 134 of file AbstractWriter.d.

IBuffer buffer [protected]
 

Definition at line 136 of file AbstractWriter.d.

StringEncoder string [protected]
 

Definition at line 138 of file AbstractWriter.d.

NumericEncoder numeric [protected]
 

Definition at line 140 of file AbstractWriter.d.

bool prefixArray = true [private]
 

Definition at line 142 of file AbstractWriter.d.

Referenced by enableArrayPrefix(), and length().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:06:59 2004 for Mango by doxygen 1.3.6