25 void show(std::ostream& os, std::string str);
44 Style(std::initializer_list<std::string> args) :
m_args(args) {}
47 operator bool()
const {
return !
m_args.empty(); }
75 static Style
getStyle(std::string name);
101 std::string
str(Config config = Config(), Style style =
Table::getStyle(
"square_double_head"));
104 void add_row(std::initializer_list<std::string> _row) {
cells.push_back(_row); }
106 template <
typename T,
typename... Args>
107 void push_back(std::vector<std::string>& row, T&& t, Args&&... args) {
109 push_back(row, std::forward<Args>(args)...);
112 template <
typename T>
118 template <
typename... Args>
120 std::vector<std::string> row;
121 push_back(row, std::forward<Args>(args)...);
122 cells.push_back(row);
125 template <
typename T,
typename... Args>
128 add_rows(std::forward<Args>(args)...);
131 template <
typename T>
143 print(std::forward<T>(t));
144 row.push_back(print.
str());
149 row.push_back(std::forward<std::string>(t));
154 for (
auto& ele : t) {
160 row.push_back(print.
str());
166 std::vector<std::vector<std::string>>
cells;
Table is used to generate a table with configurable style.
Definition: table.h:31
void push_back(std::vector< std::string > &row, T &&t, Args &&... args)
Definition: table.h:107
void add_rows(T &&t, Args &&... args)
Definition: table.h:126
void add_row(std::initializer_list< std::string > _row)
Definition: table.h:104
Table(std::string title)
Definition: table.h:34
_push_back(rank< 0 >, std::vector< std::string > &row, T &&t)
Definition: table.h:138
std::vector< std::string > header
Definition: table.h:165
void push_back(std::vector< std::string > &row, T &&t)
Definition: table.h:113
Table(std::string title, unsigned width, unsigned height)
Definition: table.h:36
void add_rows(T &&t)
Definition: table.h:132
Table(unsigned width, unsigned height)
Definition: table.h:35
Table()
Definition: table.h:33
std::vector< std::vector< std::string > > cells
Definition: table.h:166
~Table()
Definition: table.h:37
std::string str(Config config=Config(), Style style=Table::getStyle("square_double_head"))
str is used to generate the table string.
Definition: table.cpp:276
std::vector< std::string > footer
Definition: table.h:165
static void registerStyle(std::string name, Style style)
Definition: table.cpp:244
void set_header(std::vector< std::string > _header)
Definition: table.h:103
std::vector< unsigned > col_width
Definition: table.h:164
static Style getStyle(std::string name)
getStyle can load predefined style from the StyleManager.
Definition: table.cpp:247
void add_row(Args &&... args)
Definition: table.h:119
Definition: benchmark.cpp:17
Card defines a display range in the console.
Definition: table.h:16
void show(std::ostream &os, std::string str)
std::string title
Definition: table.h:22
Card()
Definition: table.h:17
Card(std::string title, unsigned width, unsigned height)
Definition: table.h:20
Card(std::string title)
Definition: table.h:18
unsigned height
Definition: table.h:23
unsigned width
Definition: table.h:23
Card(unsigned width, unsigned height)
Definition: table.h:19
A functor class Printer for printing a value of any type.
Definition: print.h:80
bool isQuoted
Definition: print.h:123
std::string str() const
Definition: print.h:270
bool isCompact
Definition: print.h:122
const char * line_break
Definition: print.h:125
Config is used to configure the table style how it is displayed.
Definition: table.h:80
bool show_row_split
Definition: table.h:85
bool show_col_split
Definition: table.h:84
Config()
Definition: table.h:87
bool show_header_split
Definition: table.h:83
bool show_tb_border
Definition: table.h:81
bool show_lr_border
Definition: table.h:82
bool show_footer_split
Definition: table.h:86
Style is used to define the border style of the table.
Definition: table.h:42
Style()
Definition: table.h:43
Style(std::initializer_list< std::string > args)
Definition: table.h:44
std::vector< std::string > m_args
Definition: table.h:45
rank is a helper class for Printer to define the priority of overloaded functions.
Definition: print.h:44
#define ZEROERR_IS_CONTAINER
Definition: typetraits.h:244
#define ZEROERR_IS_STRING
Definition: typetraits.h:245
#define ZEROERR_ENABLE_IF(x)
Definition: typetraits.h:239