Class Table can be used to print values and text in the table. More...
#include <Table.hpp>
Public Member Functions | |
| Table () | |
| Default constructor. | |
| Table (const unsigned short nColumns, const int width=-1) | |
| Constructor with parameters. | |
| void | Begin (const std::string &name) |
| Prints the top part of the table with it's name. | |
| template<typename... Ts> | |
| void | PrintHeader (Ts... args) |
| Prints header of the table. | |
| template<typename... Ts> | |
| void | PrintRow (Ts... args) |
| Prints cells contents in the last row. | |
| void | End () |
| Prints the end of the table (bottom line that separates cell contents from other contents in terminal). | |
| virtual | ~Table () |
| Default desctructor. | |
Protected Attributes | |
| std::string | ULBorderCornerTable = "╔" |
| upper left border corner of the table | |
| std::string | URBorderCornerTable = "╗" |
| upper right border corner of the table | |
| std::string | horizontalBorderTable = "═" |
| horizontal border of the table | |
| std::string | verticalBorderTable = "║" |
| vertical border border of the table | |
| std::string | verticalBorderCell = "│" |
| vertical separator between cells of the table | |
| std::string | rightCellAdjLeftVerticalBorderTable = "╟" |
| std::string | leftCellAdjRightVerticalBorderTable = "╢" |
| std::string | rightTableAdjLeftVerticalBorderTable = "╠" |
| std::string | leftTableAdjRightVerticalBorderTable = "╣" |
| std::string | horizontalCellBorder = "─" |
| horizontal border of cells | |
| std::string | BLBorderCornerTable = "╚" |
| bottom left border of the table | |
| std::string | BRBorderCornerTable = "╝" |
| bottom right border of the table | |
| std::string | bottomCellAdjTopHorizontalBorderTable = "╤" |
| std::string | topCellAdjBottomHorizontalBorderTable = "╧" |
| std::string | cross = "┼" |
| cross between cells borders | |
| int | numberOfColumns |
| number of columns in a table | |
| int | tableWidth |
| lenght of a row, i.e. width of a table | |
| double | cellWidth |
| width of one cell | |
Class Table can be used to print values and text in the table.
Example:
Result:
╔═══════════════════════════════════════════════╗ ║ my table ║ ╠════════════════╤═══════════════╤══════════════╣ ║ name1 │ name2 │ name3 ║ ╟────────────────┼───────────────┼──────────────╢ ║ r1c1 │ r1c2 │ r1c3 ║ ║ r2c1 │ r2c2 │ r2c3 ║ ║ some value │ another value │ 1 ║ ╚════════════════╧═══════════════╧══════════════╝
| CppTools::Table::Table | ( | const unsigned short | nColumns, |
| const int | width = -1 ) |
Constructor with parameters.
| [in] | numberOfColumns | number of columns in the table |
| [in] | width | width of the table (negative value will result for the table to be printed with the width of a terminal). This width includes 2 empty spaces on the very left and right of the table |
| void CppTools::Table::Begin | ( | const std::string & | name | ) |
Prints the top part of the table with it's name.
| [in] | name | name of the table that will be printed |
|
inline |
Prints header of the table.
| [in] | args | parameter pack containing names of columns. Number of parameters passed must not exceed number of columns passed in the constructor |
|
inline |
Prints cells contents in the last row.
| [in] | args | parameter pack containing values of the cells in the latest row. Number of parameters passed must not exceed number of columns passed in the constructor |
|
protected |
top horizontal border of the table that is adjacent to vertical border of the cell to the bottom
|
protected |
right vertical border of the table that is adjacent to horizontal border of the cell to the left
|
protected |
right vertical border of the table that is adjacent to horizontal border of the tablle to the left
|
protected |
left vertical border of the table that is adjacent to horizontal border of the cell to the right
|
protected |
left vertical border of the table that is adjacent to horizontal border of the table to the right
|
protected |
bottom horizontal border of the table that is adjacent to vertical border of the cell to the top