1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <vector>
/// @file
/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
namespace pcpp
{
/**
* A class for printing tables in command-line
*/
class TablePrinter
{
public:
/**
* C'tor - get column names and column widths
* @param[in] columnNames A vector of strings containing column names
* @param[in] columnWidths A vector of integers containing column widths
*/
TablePrinter(std::vector<std::string> columnNames, std::vector<int> columnWidths);
/**
* A d'tor for this class. Closes the table if not closed
*/
virtual ~TablePrinter();
/**
* 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"
* @param[in] values A string delimited by a specified delimiter that contains values for all columns
* @param[in] delimiter A delimiter that separates between values of different columns in the values string
* @return True if row was printed successfully or false otherwise (in any case of error an appropriate message
* will be printed to log)
*/
bool printRow(const std::string& values, char delimiter);
/**
* Print a single row
* @param[in] values A vector of strings containing values for all columns
* @return True if row was printed successfully or false otherwise (in any case of error an appropriate message
* will be printed to log)
*/
bool printRow(std::vector<std::string> values);
/**
* Print a separator line
*/
void printSeparator();
/**
* 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
*/
void closeTable();
private:
std::vector<std::string> m_ColumnNames;
std::vector<int> m_ColumnWidths;
bool m_FirstRow;
bool m_TableClosed;
/**
* Print the table headline
*/
void printHeadline();
};
}