Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pretty print a table in C++

I am looking for a library similar to prettytable but in C++

http://code.google.com/p/prettytable/

I know how to generate one myself using either printf or iostream. However, I would like to know if there is a library for this.

I am interested only in writing this ASCII table to the console.

Preferably something like:

std::vector<std::string> headers;
headers.push_back("My Awesome Header 1");
headers.push_back("My Awesome Header 2");
headers.push_back("My Awesome Header 3");


PrettyTablePrinter ptp;
ptp.SetHeaders(headers);
// Set some other options here
ptp.AddRow(data[0]);
ptp.AddRow(data[1]);
ptp.AddRow(data[2]);

ptp.Print(&std::cout);
like image 464
Dat Chu Avatar asked Dec 17 '10 15:12

Dat Chu


2 Answers

Since I have not found a good C++ solution, I have written one for you all

https://github.com/dattanchu/bprinter/wiki

like image 68
Dat Chu Avatar answered Sep 28 '22 04:09

Dat Chu


LibFort

It's Fantastic, they have Several cool table styles too.

https://github.com/seleznevae/libfort

like image 28
Attaullah Khan Avatar answered Sep 28 '22 04:09

Attaullah Khan