Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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)

Static Public Member Functions

static this ()

Protected Member Functions

override IWriter encode (void *src, uint bytes, int type)

Private Member Functions

final void pad ()
typedef FormatStructTemplate (char) Format
 this (IBuffer buffer, char[] workspace=null, Format.DblFormat df=&Double.format)
 this (IConduit conduit)
 this (IBuffer buffer)
int print (char[] s, TypeInfo[] ti, va_list args)
DisplayWriter print (char[] s,...)
DisplayWriter println (char[] s,...)
bool isTextBased ()
override IWriter write (void *src, uint bytes, int type)
IWriter put ()
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)
IWriter put (char x)
IWriter put (wchar x)
IWriter put (dchar x)
IWriter put (byte[] x)
IWriter put (ubyte[] x)
IWriter put (short[] x)
IWriter put (ushort[] x)
IWriter put (int[] x)
IWriter put (uint[] x)
IWriter put (long[] x)
IWriter put (ulong[] x)
IWriter put (float[] x)
IWriter put (double[] x)
IWriter put (real[] x)
IWriter put (char[] x)
IWriter put (wchar[] x)
IWriter put (dchar[] x)

Private Attributes

int output
ColumnList columns

Static Private Attributes

static 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 79 of file ColumnWriter.d.


Member Typedef Documentation

typedef DisplayWriter put put
 

Definition at line 81 of file ColumnWriter.d.


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 94 of file ColumnWriter.d.

References assert(), buffer, and columns.

static this  )  [inline, static]
 

Populate the space padding with valid spaces.

Definition at line 110 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 128 of file ColumnWriter.d.

References columns, output, and ColumnList::reset().

Referenced by put().

override int getWidth  )  [inline]
 

Definition at line 140 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 Writer.

Definition at line 152 of file ColumnWriter.d.

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

override IWriter encode void *  src,
uint  bytes,
int  type
[inline, protected]
 

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 Writer.

Definition at line 176 of file ColumnWriter.d.

References buffer, output, pad(), RawCodec1::type(), and type().

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 203 of file ColumnWriter.d.

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

Referenced by encode().

typedef FormatStructTemplate char   )  [inherited]
 

this IBuffer  buffer,
char[]  workspace = null,
Format.DblFormat  df = &Double.format
[inline, inherited]
 

Construct a DisplayWriter upon the specified IBuffer. One can override the default floating-point formatting by providing an appropriate handler to this constructor. For example, one might configure the DGDouble.format() function instead.

Definition at line 100 of file DisplayWriter.d.

References Double, DisplayWriter::emit(), DisplayWriter::format, Format, and DisplayWriter::workspace.

this IConduit  conduit  )  [inline, inherited]
 

Construct a DisplayWriter upon the specified IConduit

Reimplemented from Writer.

Reimplemented in FlushWriter.

Definition at line 118 of file DisplayWriter.d.

References Buffer.

this IBuffer  buffer  )  [inline, inherited]
 

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

Reimplemented in HttpWriter, EndianWriter, and FlushWriter.

Definition at line 147 of file Writer.d.

References Writer::buffer, Writer::error(), IBuffer::getStyle(), Writer::isTextBased(), and Writer::prefixArray.

int print char[]  s,
TypeInfo[]  ti,
va_list  args
[inline, inherited]
 

Format a set of arguments a la printf(). Please see module mango.convert.Format for details

Definition at line 130 of file DisplayWriter.d.

References DisplayWriter::format.

Referenced by DisplayWriter::print(), and DisplayWriter::println().

DisplayWriter print char[]  s,
  ...
[inline, inherited]
 

Format a set of arguments a la printf(). Please see module mango.convert.Format for details

Definition at line 142 of file DisplayWriter.d.

References DisplayWriter::print().

DisplayWriter println char[]  s,
  ...
[inline, inherited]
 

Format a set of arguments a la printf(). Please see module mango.convert.Format for details

Definition at line 155 of file DisplayWriter.d.

References DisplayWriter::print(), and Writer::put().

bool isTextBased  )  [inline, inherited]
 

Is this Writer text oriented?

Reimplemented from Writer.

Definition at line 168 of file DisplayWriter.d.

override IWriter write void *  src,
uint  bytes,
int  type
[inline, protected, inherited]
 

Intercept discrete output and convert it to printable form

Reimplemented from Writer.

Definition at line 179 of file DisplayWriter.d.

References DisplayWriter::format, and type().

IWriter put  )  [inline, inherited]
 

Flush this writer. This is a convenience method used by the "whisper" syntax.

Reimplemented from IWriter.

Definition at line 257 of file Writer.d.

References Writer::flush().

Referenced by Writer::cr(), Writer::length(), and DisplayWriter::println().

IWriter put bool  x  )  [inline, inherited]
 

Write a boolean value to the current buffer-position

Reimplemented from IWriter.

Definition at line 281 of file Writer.d.

References Writer::write().

IWriter put ubyte  x  )  [inline, inherited]
 

Write an unsigned byte value to the current buffer-position

Reimplemented from IWriter.

Definition at line 292 of file Writer.d.

References Writer::write().

IWriter put byte  x  )  [inline, inherited]
 

Write a byte value to the current buffer-position

Reimplemented from IWriter.

Definition at line 303 of file Writer.d.

References Writer::write().

IWriter put ushort  x  )  [inline, inherited]
 

Write an unsigned short value to the current buffer-position

Reimplemented from IWriter.

Definition at line 314 of file Writer.d.

References Writer::write().

IWriter put short  x  )  [inline, inherited]
 

Write a short value to the current buffer-position

Reimplemented from IWriter.

Definition at line 325 of file Writer.d.

References Writer::write().

IWriter put uint  x  )  [inline, inherited]
 

Write a unsigned int value to the current buffer-position

Reimplemented from IWriter.

Definition at line 336 of file Writer.d.

References Writer::write().

IWriter put int  x  )  [inline, inherited]
 

Write an int value to the current buffer-position

Reimplemented from IWriter.

Definition at line 347 of file Writer.d.

References Writer::write().

IWriter put ulong  x  )  [inline, inherited]
 

Write an unsigned long value to the current buffer-position

Reimplemented from IWriter.

Definition at line 358 of file Writer.d.

References Writer::write().

IWriter put long  x  )  [inline, inherited]
 

Write a long value to the current buffer-position

Reimplemented from IWriter.

Definition at line 369 of file Writer.d.

References Writer::write().

IWriter put float  x  )  [inline, inherited]
 

Write a float value to the current buffer-position

Reimplemented from IWriter.

Definition at line 380 of file Writer.d.

References Writer::write().

IWriter put double  x  )  [inline, inherited]
 

Write a double value to the current buffer-position

Reimplemented from IWriter.

Definition at line 391 of file Writer.d.

References Writer::write().

IWriter put real  x  )  [inline, inherited]
 

Write a real value to the current buffer-position

Reimplemented from IWriter.

Definition at line 402 of file Writer.d.

References Writer::write().

IWriter put char  x  )  [inline, inherited]
 

Write a char value to the current buffer-position

Reimplemented from IWriter.

Definition at line 413 of file Writer.d.

References Writer::encode().

IWriter put wchar  x  )  [inline, inherited]
 

Write a wchar value to the current buffer-position

Reimplemented from IWriter.

Definition at line 424 of file Writer.d.

References Writer::encode().

IWriter put dchar  x  )  [inline, inherited]
 

Write a dchar value to the current buffer-position

Reimplemented from IWriter.

Definition at line 435 of file Writer.d.

References Writer::encode().

IWriter put byte[]  x  )  [inline, inherited]
 

Write a byte array to the current buffer-position

Reimplemented from IWriter.

Definition at line 446 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put ubyte[]  x  )  [inline, inherited]
 

Write an unsigned byte array to the current buffer-position

Reimplemented from IWriter.

Definition at line 457 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put short[]  x  )  [inline, inherited]
 

Write a short array to the current buffer-position

Reimplemented from IWriter.

Definition at line 468 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put ushort[]  x  )  [inline, inherited]
 

Write an unsigned short array to the current buffer-position

Reimplemented from IWriter.

Definition at line 479 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put int[]  x  )  [inline, inherited]
 

Write an int array to the current buffer-position

Reimplemented from IWriter.

Definition at line 490 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put uint[]  x  )  [inline, inherited]
 

Write an unsigned int array to the current buffer-position

Reimplemented from IWriter.

Definition at line 501 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put long[]  x  )  [inline, inherited]
 

Write a long array to the current buffer-position

Reimplemented from IWriter.

Definition at line 512 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put ulong[]  x  )  [inline, inherited]
 

Write an unsigned long array to the current buffer-position

Reimplemented from IWriter.

Definition at line 523 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put float[]  x  )  [inline, inherited]
 

Write a float array to the current buffer-position

Reimplemented from IWriter.

Definition at line 534 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put double[]  x  )  [inline, inherited]
 

Write a double array to the current buffer-position

Reimplemented from IWriter.

Definition at line 545 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put real[]  x  )  [inline, inherited]
 

Write a real array to the current buffer-position

Reimplemented from IWriter.

Definition at line 556 of file Writer.d.

References Writer::length(), and Writer::write().

IWriter put char[]  x  )  [inline, inherited]
 

Write a char array to the current buffer-position

Reimplemented from IWriter.

Definition at line 567 of file Writer.d.

References Writer::encode(), and Writer::length().

IWriter put wchar[]  x  )  [inline, inherited]
 

Write a wchar array to the current buffer-position

Reimplemented from IWriter.

Definition at line 578 of file Writer.d.

References Writer::encode(), and Writer::length().

IWriter put dchar[]  x  )  [inline, inherited]
 

Write a dchar array to the current buffer-position

Reimplemented from IWriter.

Definition at line 589 of file Writer.d.

References Writer::encode(), and Writer::length().


Member Data Documentation

int output [private]
 

Definition at line 83 of file ColumnWriter.d.

Referenced by encode(), pad(), and reset().

ColumnList columns [private]
 

Definition at line 84 of file ColumnWriter.d.

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

ubyte spaces[256] [static, private]
 

Definition at line 85 of file ColumnWriter.d.

Referenced by pad(), and this().


The documentation for this class was generated from the following file:
Generated on Sat Dec 24 17:28:37 2005 for Mango by  doxygen 1.4.0