Skip to content
/ ptable Public

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

License

Notifications You must be signed in to change notification settings

rdavid/ptable

Repository files navigation

PTable

About

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 |
+-----+--------+-------+

Build

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

Test

redo test runs unit tests. redo lint applies the following linters to the source files: checkmake, shellcheck, shfmt, typos, yamllint.

License

ptable is copyright David Rabkin and available under a Zero-Clause BSD license.

About

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

Topics

Resources

License

Stars

Watchers

Forks