PcapPlusPlus  19.12
pcpp::TablePrinter Class Reference

#include <TablePrinter.h>

Public Member Functions

 TablePrinter (std::vector< std::string > columnNames, std::vector< int > columnWidths)
 
virtual ~TablePrinter ()
 
bool printRow (std::string values, char delimiter)
 
bool printRow (std::vector< std::string > values)
 
void printSeparator ()
 
void closeTable ()
 

Detailed Description

A class for printing tables in command-line

Constructor & Destructor Documentation

◆ TablePrinter()

pcpp::TablePrinter::TablePrinter ( std::vector< std::string >  columnNames,
std::vector< int >  columnWidths 
)

C'tor - get column names and column widths

Parameters
[in]columnNamesA vector of strings containing column names
[in]columnWidthsA vector of integers containing column widths

◆ ~TablePrinter()

virtual pcpp::TablePrinter::~TablePrinter ( )
virtual

A d'tor for this class. Closes the table if not closed

Member Function Documentation

◆ 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 ( 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]valuesA string delimited by a specified delimiter that contains values for all columns
[in]delimiterA 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]valuesA 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)

◆ printSeparator()

void pcpp::TablePrinter::printSeparator ( )

Print a separator line