https://github.com/rdavid/ptable
The C++ template for printing table of string and numeric data.
https://github.com/rdavid/ptable
c-plus-plus pretty-printer
Last synced: about 1 month ago
JSON representation
The C++ template for printing table of string and numeric data.
- Host: GitHub
- URL: https://github.com/rdavid/ptable
- Owner: rdavid
- License: 0bsd
- Created: 2015-12-02T10:03:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-08T15:18:12.000Z (6 months ago)
- Last Synced: 2025-04-08T16:26:39.984Z (6 months ago)
- Topics: c-plus-plus, pretty-printer
- Language: C++
- Homepage:
- Size: 61.5 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
// Settings:
:toc: macro
:!toc-title:
// URLs:
:img-hoc: https://hitsofcode.com/github/rdavid/ptable?branch=master&label=hits%20of%20code
:img-license: https://img.shields.io/github/license/rdavid/ptable?color=blue&labelColor=gray&logo=freebsd&logoColor=lightgray&style=flat
:img-test: https://github.com/rdavid/ptable/actions/workflows/test.yml/badge.svg
:url-actionlint: https://github.com/rhysd/actionlint
:url-base: https://github.com/rdavid/shellbase/blob/master/lib/base.sh
:url-checkmake: https://github.com/mrtazz/checkmake
:url-cv: http://cv.rabkin.co.il
:url-hadolint: https://github.com/hadolint/hadolint
:url-hoc: https://hitsofcode.com/view/github/rdavid/ptable?branch=master
:url-goredo: http://www.goredo.cypherpunks.su/Install.html
:url-license: https://github.com/rdavid/ptable/blob/master/LICENSES/0BSD.txt
:url-redo: http://cr.yp.to/redo.html
:url-reuse: https://github.com/fsfe/reuse-action
:url-shellcheck: https://github.com/koalaman/shellcheck
:url-shfmt: https://github.com/mvdan/sh
:url-test: https://github.com/rdavid/ptable/actions/workflows/test.yml
:url-typos: https://github.com/crate-ci/typos
:url-vale: https://vale.sh
:url-yamllint: https://github.com/adrienverge/yamllint= Pretty Table
image:{img-test}[test,link={url-test}]
image:{img-hoc}[hits of code,link={url-hoc}]
image:{img-license}[license,link={url-license}]toc::[]
== 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:[,c++]
----
CPrettyTable 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.
[,sh]
----
+-----+[ 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 {url-redo}[`redo`].
You can install Sergey Matveev's {url-goredo}[`goredo`] implementation.== Test
`redo test` runs unit tests.
`redo lint` applies the following linters to the source files:
{url-actionlint}[`actionlint`],
{url-checkmake}[`checkmake`],
{url-reuse}[`reuse`],
{url-shellcheck}[`shellcheck`],
{url-shfmt}[`shfmt`],
{url-typos}[`typos`],
{url-yamllint}[`yamllint`].== License
`ptable` is copyright {url-cv}[David Rabkin] and available under a
{url-license}[Zero-Clause BSD license].