44 Style(std::initializer_list<zeroerr::String> args) :
m_args(args) {}
47 operator bool()
const {
return !
m_args.empty(); }
104 void add_row(std::initializer_list<zeroerr::String> _row) {
cells.push_back(_row); }
106 template <
typename T,
typename... Args>
107 void push_back(std::vector<zeroerr::String>& row, T&& t, Args&&... args) {
109 push_back(row, std::forward<Args>(args)...);
112 template <
typename T>
113 void push_back(std::vector<zeroerr::String>& row, T&& t) {
118 template <
typename... Args>
120 std::vector<zeroerr::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<zeroerr::String>(t));
154 for (
auto& ele : t) {
160 row.push_back(print.str());
166 std::vector<std::vector<zeroerr::String>>
cells;
Table is used to generate a table with configurable style.
Definition table.h:31
std::vector< zeroerr::String > footer
Definition table.h:165
static Style getStyle(zeroerr::String name)
getStyle can load predefined style from the StyleManager.
Definition table.cpp:247
std::vector< std::vector< zeroerr::String > > cells
Definition table.h:166
void add_rows(T &&t, Args &&... args)
Definition table.h:126
void push_back(std::vector< zeroerr::String > &row, T &&t)
Definition table.h:113
void add_row(std::initializer_list< zeroerr::String > _row)
Definition table.h:104
void set_header(std::vector< zeroerr::String > _header)
Definition table.h:103
std::vector< zeroerr::String > header
Definition table.h:165
void add_rows(T &&t)
Definition table.h:132
Table(unsigned width, unsigned height)
Definition table.h:35
Table(zeroerr::String title, unsigned width, unsigned height)
Definition table.h:36
Table()
Definition table.h:33
~Table()
Definition table.h:37
void push_back(std::vector< zeroerr::String > &row, T &&t, Args &&... args)
Definition table.h:107
Table(zeroerr::String title)
Definition table.h:34
static void registerStyle(zeroerr::String name, Style style)
Definition table.cpp:244
std::vector< unsigned > col_width
Definition table.h:164
_push_back(rank< 0 >, std::vector< zeroerr::String > &row, T &&t)
Definition table.h:138
zeroerr::String str(Config config=Config(), Style style=Table::getStyle("square_double_head"))
str is used to generate the table string.
Definition table.cpp:276
void add_row(Args &&... args)
Definition table.h:119
Definition assert_text.cpp:5
Card defines a display range in the console.
Definition table.h:16
zeroerr::String title
Definition table.h:22
Card()
Definition table.h:17
unsigned height
Definition table.h:23
Card(zeroerr::String title, unsigned width, unsigned height)
Definition table.h:20
Card(zeroerr::String title)
Definition table.h:18
unsigned width
Definition table.h:23
Card(unsigned width, unsigned height)
Definition table.h:19
void show(std::ostream &os, zeroerr::String str)
A functor class Printer for printing a value of any type.
Definition print.h:74
bool isQuoted
Definition print.h:118
bool isCompact
Definition print.h:117
const char * line_break
Definition print.h:120
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< zeroerr::String > args)
Definition table.h:44
std::vector< zeroerr::String > m_args
Definition table.h:45
rank is a helper class for Printer to define the priority of overloaded functions.
Definition typetraits.h:43
#define ZEROERR_IS_CONTAINER
Definition typetraits.h:340
#define ZEROERR_IS_STRING
Definition typetraits.h:341
#define ZEROERR_ENABLE_IF(x)
Definition typetraits.h:334