The C++ template is used to print data in a formatted table. It calculates the proper indentations once all the fields are known. Here is an example code snippet to demonstrate its usage:
CPrettyTable<int, const char*, double> tbl("num", "name", "score");
for (int i = 0; i < 5; ++i) {
tbl.Add(i + 1, "FooBar", 2.5 * (i + 1));
}
tbl.SetCaption("FooBar");
tbl.Dump(std::cerr);
The code prints the following line to the standard error stream.
+-----+[ FooBar ]------+
| num | name | score |
+-----+--------+-------+
| 1 | FooBar | 2.5 |
| 2 | FooBar | 5 |
| 3 | FooBar | 7.5 |
| 4 | FooBar | 10 |
| 5 | FooBar | 12.5 |
+-----+--------+-------+
redo test
runs unit tests.
redo lint
applies the following linters to the source files:
checkmake
, shellcheck
,
shfmt
, typos
, yamllint
.
ptable
is copyright David Rabkin and available under a
Zero-Clause BSD license.