Skip to content

rdavid/ptable

Repository files navigation

Pretty Table

About

This C++ template formats and prints tabular data. It calculates column widths after all fields are known. The following snippet shows typical 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 output 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 |
+-----+--------+-------+

Build

The project uses Daniel J. Bernstein’s build system redo. Install Sergey Matveev’s goredo implementation.

Test

redo test runs unit tests. redo lint runs the following linters on the source files: actionlint, checkmake, reuse, shellcheck, shfmt, typos, yamllint.

License

ptable is copyrighted by David Rabkin and available under the Zero-Clause BSD license.

About

The C++ template for printing table of string and numeric data.

Topics

Resources

License

Stars

Watchers

Forks

Contributors