A class for printing tables in command-line.
More...
#include <TablePrinter.h>
|
| TablePrinter (std::vector< std::string > columnNames, std::vector< int > columnWidths) |
|
virtual | ~TablePrinter () |
| A d'tor for this class. Closes the table if not closed.
|
|
bool | printRow (const std::string &values, char delimiter) |
|
bool | printRow (std::vector< std::string > values) |
|
void | printSeparator () |
| Print a separator line.
|
|
void | closeTable () |
|
A class for printing tables in command-line.
◆ TablePrinter()
pcpp::TablePrinter::TablePrinter |
( |
std::vector< std::string > |
columnNames, |
|
|
std::vector< int > |
columnWidths |
|
) |
| |
C'tor - get column names and column widths
- Parameters
-
[in] | columnNames | A vector of strings containing column names |
[in] | columnWidths | A vector of integers containing column widths |
◆ closeTable()
void pcpp::TablePrinter::closeTable |
( |
| ) |
|
Close the table - should be called after all rows were printed. Calling this method is not a must as it's called in the class d'tor
◆ printRow() [1/2]
bool pcpp::TablePrinter::printRow |
( |
const std::string & |
values, |
|
|
char |
delimiter |
|
) |
| |
Print a single row by providing a single string containing all values delimited by a specified character. For example: if specified delimiter is '|' and there are 3 columns an example input can be: "value for column1|value for column2|value for column3"
- Parameters
-
[in] | values | A string delimited by a specified delimiter that contains values for all columns |
[in] | delimiter | A delimiter that separates between values of different columns in the values string |
- Returns
- True if row was printed successfully or false otherwise (in any case of error an appropriate message will be printed to log)
◆ printRow() [2/2]
bool pcpp::TablePrinter::printRow |
( |
std::vector< std::string > |
values | ) |
|
Print a single row
- Parameters
-
[in] | values | A vector of strings containing values for all columns |
- Returns
- True if row was printed successfully or false otherwise (in any case of error an appropriate message will be printed to log)