Formatter

the formatter collects format parameters and prints the table

Constructors

this
this(AsciiTable newTable)
Undocumented in source.

Members

Functions

columnSeparator
auto columnSeparator(string s)

change the separator between columns, use null for no separator

columnWidths
auto columnWidths(ulong[] widths)
Undocumented in source. Be warned that the author may not have intended to support it.
headerSeparator
auto headerSeparator(string s)
Undocumented in source. Be warned that the author may not have intended to support it.
prefix
auto prefix(string newPrefix)

change the prefix that is printed in front of each row

rowSeparator
auto rowSeparator(string s)

change the separator between rows, use null for no separator

toString
string toString()

Convert to tabular presentation

Examples

import unit_threaded;
import std.conv;

auto table = new AsciiTable(2)
  .row.add("1").add("2")
  .row.add("3").add("4")
  .table;
auto f1 = table.format.to!string;
f1.shouldEqual("12\n34");

auto f2 = table.format.prefix("  ").rowSeparator("-").to!string;
f2.shouldEqual("  --\n  12\n  --\n  34\n  --");

auto f3 = table.format.prefix("  ").columnSeparator("|").to!string;
f3.shouldEqual("  |1|2|\n  |3|4|");

auto f4 = table.format.prefix("  ").columnSeparator("|").rowSeparator("-").to!string;
f4.shouldEqual("  -----\n  |1|2|\n  -----\n  |3|4|\n  -----");
import unit_threaded;
auto table = new AsciiTable(2)
  .row.add("1\n2").add("3")
  .row.add("4").add("5\n6")
  .table;
auto f = table.format.prefix("test:").to!string;
f.shouldEqual("test:13\ntest:2 \ntest:45\ntest: 6");
import unit_threaded;
auto table = new AsciiTable(1)
  .header.add("1")
  .row.add(2)
  .table;
auto f1 = table.format.headerSeparator("=").rowSeparator("-").to!string;
f1.shouldEqual("-\n1\n=\n2\n-");

Meta