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

ColumnWriter Class Reference

Inheritance diagram for ColumnWriter:

DisplayWriter List of all members.

Public Types

typedef DisplayWriter put put

Public Member Functions

 this (IBuffer buffer, ColumnList columns)
void reset ()
override int getWidth ()
IWriter put (IWritable x)
IWriter put (char[] x)

Static Public Member Functions

 this ()

Private Types

typedef Number Radix Radix

Private Member Functions

final void pad ()
 this (IBuffer buffer)
 this (IConduit conduit)
void setPrecision (uint digits)
void setRadix (Radix radix)
void setFill (uint width, char fill= ' ')

Private Attributes

int output
ColumnList columns

Static Private Attributes

ubyte spaces [256]

Detailed Description

Print readable output to an IWriter, distributed across a set of columns. Columns start at zero rather than one, so adjust counts appropriately. All output is currently left-aligned.

This is how one might use ColumnWriter:

static int[] columns = [0, 4, 14, 24]; // map a ColumnWriter directly onto Stdout ColumnWriter write = new ColumnWriter (Stdout.getBuffer(), new ColumnList(columns)); // set 2 digits of precision write.setPrecision (2); // Mango style write (1) (20.34944) ("test") (CR); // iostream style write << 1 << 20.34944 << "test" << CR; // put() style write.put(1).put(20.34944).put("test").cr();

Note that ColumnWriter may be used with files, sockets, or any other buffer-oriented construct.

Definition at line 77 of file ColumnWriter.d.


Member Typedef Documentation

typedef DisplayWriter put put
 

Definition at line 79 of file ColumnWriter.d.

Referenced by Formatter::setTarget().

typedef Number Radix Radix [inherited]
 

Definition at line 63 of file DisplayWriter.d.

Referenced by DisplayWriter::setRadix().


Member Function Documentation

this IBuffer  buffer,
ColumnList  columns
[inline]
 

Construct a ColumnWriter upon the given IBuffer, with the specified set of columns.

Definition at line 92 of file ColumnWriter.d.

References assert(), and columns.

this  )  [inline, static]
 

Populate the space padding with valid spaces.

Reimplemented from AbstractWriter.

Definition at line 108 of file ColumnWriter.d.

References spaces.

void reset  )  [inline]
 

Reset everything back to zero. Typical usage will invoke this whenever a Newline is emitted.

Note that we maintain our own internal count of how many bytes have been output: this is because we cannot depend on the Buffer to provide that for us if (a) the buffer is very small, or (b) the buffer is flushed after each write (Stdout etc).

Definition at line 126 of file ColumnWriter.d.

References columns, and ColumnList::reset().

Referenced by put().

override int getWidth  )  [inline]
 

Definition at line 138 of file ColumnWriter.d.

References columns, and ColumnList::getWidth().

IWriter put IWritable  x  )  [inline]
 

Intercept the IWritable type so we can reset our columns when a newline is emitted.

Reimplemented from AbstractWriter.

Definition at line 150 of file ColumnWriter.d.

References IWriter::put(), and reset().

IWriter put char[]  x  )  [inline]
 

Intercept the output so we can write some spaces first. Note that our superclass (DisplayWriter) converts each of its arguments to a char[] first, so this override is able to catch everything emitted.

Todo:
  • add the equivalent intercepts for both wchar[] and dchar[] methods.

Reimplemented from AbstractWriter.

Definition at line 174 of file ColumnWriter.d.

References pad().

final void pad  )  [inline, private]
 

Pad the output with spaces to reach the next column position. This should be invoked before anything is written to the buffer.

Definition at line 189 of file ColumnWriter.d.

References columns, ColumnList::next(), and spaces.

Referenced by put().

this IBuffer  buffer  )  [inline, inherited]
 

Construct a DisplayWriter upon the specified IBuffer

Reimplemented from Writer.

Reimplemented in HttpWriter, and FlushWriter.

Definition at line 83 of file DisplayWriter.d.

References AbstractWriter::enableArrayPrefix().

this IConduit  conduit  )  [inline, inherited]
 

Construct a DisplayWriter upon the specified IConduit

Reimplemented from Writer.

Reimplemented in FlushWriter.

Definition at line 111 of file DisplayWriter.d.

void setPrecision uint  digits  )  [inline, inherited]
 

Set the number of floating point digits

Definition at line 122 of file DisplayWriter.d.

void setRadix Radix  radix  )  [inline, inherited]
 

Definition at line 131 of file DisplayWriter.d.

References DisplayWriter::Radix.

void setFill uint  width,
char  fill = ' '
[inline, inherited]
 

Definition at line 140 of file DisplayWriter.d.

References assert(), and DisplayWriter::tmp.


Member Data Documentation

int output [private]
 

Definition at line 81 of file ColumnWriter.d.

ColumnList columns [private]
 

Definition at line 82 of file ColumnWriter.d.

Referenced by getWidth(), pad(), reset(), and this().

ubyte spaces[256] [static, private]
 

Definition at line 83 of file ColumnWriter.d.

Referenced by pad(), and this().


The documentation for this class was generated from the following file:
Generated on Sat Apr 9 20:11:36 2005 for Mango by doxygen 1.3.6