ZeroErr
zeroerr::Table Class Reference

Table is used to generate a table with configurable style. More...

#include <table.h>

Inheritance diagram for zeroerr::Table:
Collaboration diagram for zeroerr::Table:

Classes

struct  Config
 Config is used to configure the table style how it is displayed. More...
 
struct  Style
 Style is used to define the border style of the table. More...
 

Public Member Functions

 Table ()
 
 Table (std::string title)
 
 Table (unsigned width, unsigned height)
 
 Table (std::string title, unsigned width, unsigned height)
 
 ~Table ()
 
std::string str (Config config=Config(), Style style=Table::getStyle("square_double_head"))
 str is used to generate the table string. More...
 
void set_header (std::vector< std::string > _header)
 
void add_row (std::initializer_list< std::string > _row)
 
template<typename T , typename... Args>
void push_back (std::vector< std::string > &row, T &&t, Args &&... args)
 
template<typename T >
void push_back (std::vector< std::string > &row, T &&t)
 
template<typename... Args>
void add_row (Args &&... args)
 
template<typename T , typename... Args>
void add_rows (T &&t, Args &&... args)
 
template<typename T >
void add_rows (T &&t)
 
- Public Member Functions inherited from zeroerr::Card
 Card ()
 
 Card (std::string title)
 
 Card (unsigned width, unsigned height)
 
 Card (std::string title, unsigned width, unsigned height)
 
void show (std::ostream &os, std::string str)
 

Static Public Member Functions

static void registerStyle (std::string name, Style style)
 
static Style getStyle (std::string name)
 getStyle can load predefined style from the StyleManager. More...
 

Protected Member Functions

 _push_back (rank< 0 >, std::vector< std::string > &row, T &&t)
 
 _push_back (rank< 2 >, std::vector< std::string > &row, T t)
 
 _push_back (rank< 1 >, std::vector< std::string > &row, const T &t)
 

Protected Attributes

std::vector< unsigned > col_width
 
std::vector< std::string > header
 
std::vector< std::string > footer
 
std::vector< std::vector< std::string > > cells
 

Additional Inherited Members

- Public Attributes inherited from zeroerr::Card
std::string title
 
unsigned width
 
unsigned height
 

Detailed Description

Table is used to generate a table with configurable style.

Constructor & Destructor Documentation

◆ Table() [1/4]

zeroerr::Table::Table ( )
inline

◆ Table() [2/4]

zeroerr::Table::Table ( std::string  title)
inline

◆ Table() [3/4]

zeroerr::Table::Table ( unsigned  width,
unsigned  height 
)
inline

◆ Table() [4/4]

zeroerr::Table::Table ( std::string  title,
unsigned  width,
unsigned  height 
)
inline

◆ ~Table()

zeroerr::Table::~Table ( )
inline

Member Function Documentation

◆ _push_back() [1/3]

zeroerr::Table::_push_back ( rank< 0 >  ,
std::vector< std::string > &  row,
T &&  t 
)
inlineprotected

◆ _push_back() [2/3]

zeroerr::Table::_push_back ( rank< 1 >  ,
std::vector< std::string > &  row,
const T &  t 
)
inlineprotected

◆ _push_back() [3/3]

zeroerr::Table::_push_back ( rank< 2 >  ,
std::vector< std::string > &  row,
t 
)
inlineprotected

◆ add_row() [1/2]

template<typename... Args>
void zeroerr::Table::add_row ( Args &&...  args)
inline

◆ add_row() [2/2]

void zeroerr::Table::add_row ( std::initializer_list< std::string >  _row)
inline

◆ add_rows() [1/2]

template<typename T >
void zeroerr::Table::add_rows ( T &&  t)
inline

◆ add_rows() [2/2]

template<typename T , typename... Args>
void zeroerr::Table::add_rows ( T &&  t,
Args &&...  args 
)
inline

◆ getStyle()

Table::Style zeroerr::Table::getStyle ( std::string  name)
static

getStyle can load predefined style from the StyleManager.

Parameters
nameis the name of the style. Available styles: "ascii" "ascii2" "ascii_double_head" "square" "square_double_head" "simple" "simple_head" "simple_heavy" "horizontal" "rounded" "heavy" "heavy_edge" "heavy_head" "double" "double_edge" "minimal" "minimal_heavy_head" "minimal_double_hea

◆ push_back() [1/2]

template<typename T >
void zeroerr::Table::push_back ( std::vector< std::string > &  row,
T &&  t 
)
inline

◆ push_back() [2/2]

template<typename T , typename... Args>
void zeroerr::Table::push_back ( std::vector< std::string > &  row,
T &&  t,
Args &&...  args 
)
inline

◆ registerStyle()

void zeroerr::Table::registerStyle ( std::string  name,
Table::Style  style 
)
static

◆ set_header()

void zeroerr::Table::set_header ( std::vector< std::string >  _header)
inline

◆ str()

std::string zeroerr::Table::str ( Config  config = Config(),
Table::Style  s = Table::getStyle("square_double_head") 
)

str is used to generate the table string.

Parameters
configdecides how the table is displayed.
styledecides the border style of the table.

Member Data Documentation

◆ cells

std::vector<std::vector<std::string> > zeroerr::Table::cells
protected

◆ col_width

std::vector<unsigned> zeroerr::Table::col_width
protected

◆ footer

std::vector<std::string> zeroerr::Table::footer
protected

◆ header

std::vector<std::string> zeroerr::Table::header
protected

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