Classes to draw auto-formatted tables to the console.
The number of columns in the table must be specified either at construction,
or by calling the init() method. Rows can be be added using the firstRow() &
nextRow() methods. (firstRow() is essentially a reset method.)
Usage example:
// A table with 3 columnsscopetable = newTable(3);
// First row is just a dividertable.firstRow.setDivider();
// Next row contains the headings, a series of stringstable.nextRow.set(
Table.Cell.String("Address"),
Table.Cell.String("Port"),
Table.Cell.String("Connections"));
// Next row is another dividertable.nextRow.setDivider();
// Now we add one row for each of a set of 'nodes'foreach ( node; this.nodes )
{
table.nextRow.set(
Table.Cell.String(node.address),
Table.Cell.Integer(node.port),
Table.Cell.Integer(node.connections));
}
// The last row is another dividertable.nextRow.setDivider();
// Display the table to Stdouttable.display();
It's also possible to draw smart tables where certain cells in some rows
are merged together, something like this, for example:
In this example, columns 0 & 1 and 2 & 3 in row 1 are merged.
Merged cells usage example:
// A table with 4 columnsscopetable = newTable(4);
// First row is just a dividertable.firstRow.setDivider();
// Next row contains a hash range occupying two (merged) cells. Note// that this is the widest column -- the other columns adapt to allow it// to fit.table.nextRow.set(Table.Cell.Merged, Table.Cell.String("0xdb6db6e4 .. 0xedb6db76"),
Table.Cell.Merged, Table.Cell.String("0xedb6db77 .. 0xffffffff"));
// Next row is another dividertable.nextRow.setDivider();
// Next row contains the headings, a series of stringstable.nextRow.set(Table.Cell.String("Records"), Table.Cell.String("Bytes"),
Table.Cell.String("Records"), Table.Cell.String("Bytes"));
// Next row is another dividertable.nextRow.setDivider();
// Now we add one row for each of a set of 'nodes'foreach ( node; this.nodes )
{
table.nextRow.set(Table.Cell.Integer(node.records1), Table.Cell.Integer(node.bytes1),
Table.Cell.Integer(node.records2), Table.Cell.Integer(node.bytes2));
}
// The last row is another dividertable.nextRow.setDivider();
// Display the table to Stdouttable.display();
Boost Software License Version 1.0. See LICENSE_BOOST.txt for details.
Alternatively, this file may be distributed under the terms of the Tango
3-Clause BSD License (see LICENSE_BSD.txt for details).
Classes to draw auto-formatted tables to the console.
The number of columns in the table must be specified either at construction, or by calling the init() method. Rows can be be added using the firstRow() & nextRow() methods. (firstRow() is essentially a reset method.)
Usage example:
It's also possible to draw smart tables where certain cells in some rows are merged together, something like this, for example:
In this example, columns 0 & 1 and 2 & 3 in row 1 are merged.
Merged cells usage example: