XBotInterface  2.4.1
XBotInterface provides a generic API to model and control a robot.
Public Member Functions | List of all members
bprinter::TablePrinter Class Reference

#include <table_printer.h>

+ Collaboration diagram for bprinter::TablePrinter:

Public Member Functions

 TablePrinter (std::ostream *output, const std::string &separator="|")
 
 ~TablePrinter ()
 
int get_num_columns () const
 
int get_table_width () const
 
void set_separator (const std::string &separator)
 
void set_flush_left ()
 
void set_flush_right ()
 
void AddColumn (const std::string &header_name, int column_width)
 Add a column to our table. More...
 
void PrintHeader ()
 
void PrintFooter ()
 
TablePrinteroperator<< (endl input)
 
TablePrinteroperator<< (float input)
 
TablePrinteroperator<< (double input)
 
template<typename T >
TablePrinteroperator<< (T input)
 

Detailed Description

Print a pretty table into your output of choice.

Usage: TablePrinter tp(&std::cout); tp.AddColumn("Name", 25); tp.AddColumn("Age", 3); tp.AddColumn("Position", 30);

tp.PrintHeader(); tp << "Dat Chu" << 25 << "Research Assistant"; tp << "John Doe" << 26 << "Professional Anonymity"; tp << "Jane Doe" << tp.SkipToNextLine(); tp << "Tom Doe" << 7 << "Student"; tp.PrintFooter();

Todo:
Add support for padding in each table cell

Constructor & Destructor Documentation

◆ TablePrinter()

bprinter::TablePrinter::TablePrinter ( std::ostream *  output,
const std::string &  separator = "|" 
)

◆ ~TablePrinter()

bprinter::TablePrinter::~TablePrinter ( )

Member Function Documentation

◆ AddColumn()

void bprinter::TablePrinter::AddColumn ( const std::string &  header_name,
int  column_width 
)

Add a column to our table.

Parameters
header_nameName to be print for the header
column_widththe width of the column (has to be >=5)

◆ get_num_columns()

int bprinter::TablePrinter::get_num_columns ( ) const

◆ get_table_width()

int bprinter::TablePrinter::get_table_width ( ) const

◆ operator<<() [1/4]

TablePrinter & bprinter::TablePrinter::operator<< ( double  input)

◆ operator<<() [2/4]

TablePrinter& bprinter::TablePrinter::operator<< ( endl  input)
inline

◆ operator<<() [3/4]

TablePrinter & bprinter::TablePrinter::operator<< ( float  input)

◆ operator<<() [4/4]

template<typename T >
TablePrinter& bprinter::TablePrinter::operator<< ( input)
inline

◆ PrintFooter()

void bprinter::TablePrinter::PrintFooter ( )

◆ PrintHeader()

void bprinter::TablePrinter::PrintHeader ( )

◆ set_flush_left()

void bprinter::TablePrinter::set_flush_left ( )

◆ set_flush_right()

void bprinter::TablePrinter::set_flush_right ( )

◆ set_separator()

void bprinter::TablePrinter::set_separator ( const std::string &  separator)

The documentation for this class was generated from the following files: