#include <formatter.h>
|
| FmtTable (const std::vector< std::string > &titles, const size_t nrows, const std::vector< std::string > &fmts, const size_t indent=0, const Alignments &aligns={}, const Frames &frames={}, const Delimiters &delimiters={}) |
| Construct a new Fmt Table object.
|
|
| ~FmtTable () |
|
template<typename T > |
FmtTable & | operator<< (const std::vector< T > &src) |
| import data from std::vector
|
|
template<typename T > |
void | set_value (const size_t &i, const size_t &j, const T &value) |
| Set the value object.
|
|
std::vector< std::string > | relax_col_width (const std::vector< std::string > &col, const std::string &title="", const Align valign=Align::RIGHT, const Align talign=Align::CENTER) |
| adjust the width of each column
|
|
std::string | concat_title (const std::vector< std::string > &titles) const |
| concatenate titles into a string
|
|
std::string | concat_row (const std::vector< std::string > &row, const char &pos) const |
| concatenate a row into a string
|
|
std::string | str () |
| to get the table as a string
|
|
void | str (const std::string &s) |
|
void | iter_set (const size_t val) |
|
|
template<typename T > |
void | set_value (const size_t &i, const size_t &j, const char &dir, const std::vector< T > &src) |
| Set the value object from std::vector.
|
|
◆ core
◆ Align
Enumerator |
---|
LEFT | |
RIGHT | |
CENTER | |
◆ FmtTable()
FmtTable::FmtTable |
( |
const std::vector< std::string > & |
titles, |
|
|
const size_t |
nrows, |
|
|
const std::vector< std::string > & |
fmts, |
|
|
const size_t |
indent = 0 , |
|
|
const Alignments & |
aligns = {} , |
|
|
const Frames & |
frames = {} , |
|
|
const Delimiters & |
delimiters = {} |
|
) |
| |
|
inline |
Construct a new Fmt Table object.
- Parameters
-
titles | titles, its size should be the same as the number of columns |
nrows | number of rows |
fmts | format strings for each column, its size should be the same as the number of columns |
indent | indent for each column, default is 0 |
aligns | Alignments instance, for alignment of values and titles, e.g. {Align::LEFT, Align::RIGHT} for left alignment of values and right alignment of titles |
frames | Frames instance, can be constructed with initializer_list<char> like {'-', '-', '-', ' ', ' '}, for up, middle, down, left and right frames |
delimiters | Delimiters instance, can be constructed with initializer_list<char> like {'-', ' '}, for horizontal and vertical delimiters |
◆ ~FmtTable()
◆ concat_row()
std::string FmtTable::concat_row |
( |
const std::vector< std::string > & |
row, |
|
|
const char & |
pos |
|
) |
| const |
|
inline |
concatenate a row into a string
- Parameters
-
row | row to concatenate |
pos | position, can be 't' for top, 'b' for bottom, 'n' for normal |
- Returns
- std::string
◆ concat_title()
std::string FmtTable::concat_title |
( |
const std::vector< std::string > & |
titles | ) |
const |
|
inline |
concatenate titles into a string
- Parameters
-
titles | titles to concatenate |
- Returns
- std::string
◆ iter_set()
void FmtTable::iter_set |
( |
const size_t |
val | ) |
|
|
inline |
◆ operator<<()
FmtTable & FmtTable::operator<< |
( |
const std::vector< T > & |
src | ) |
|
|
inline |
import data from std::vector
- Template Parameters
-
- Parameters
-
- Returns
- FmtTable& itself
◆ relax_col_width()
std::vector< std::string > FmtTable::relax_col_width |
( |
const std::vector< std::string > & |
col, |
|
|
const std::string & |
title = "" , |
|
|
const Align |
valign = Align::RIGHT , |
|
|
const Align |
talign = Align::CENTER |
|
) |
| |
|
inline |
adjust the width of each column
- Parameters
-
- Returns
- std::vector<std::string> newly relaxed column
◆ set_value() [1/2]
void FmtTable::set_value |
( |
const size_t & |
i, |
|
|
const size_t & |
j, |
|
|
const char & |
dir, |
|
|
const std::vector< T > & |
src |
|
) |
| |
|
inlineprivate |
Set the value object from std::vector.
- Template Parameters
-
- Parameters
-
i | row index |
j | column index |
dir | direction, if 'v' then vertical, if 'h' then horizontal |
src | source data |
◆ set_value() [2/2]
void FmtTable::set_value |
( |
const size_t & |
i, |
|
|
const size_t & |
j, |
|
|
const T & |
value |
|
) |
| |
|
inline |
Set the value object.
- Template Parameters
-
- Parameters
-
i | row index |
j | col index |
value | value to set |
◆ str() [1/2]
std::string FmtTable::str |
( |
| ) |
|
|
inline |
to get the table as a string
- Returns
- std::string
◆ str() [2/2]
void FmtTable::str |
( |
const std::string & |
s | ) |
|
|
inline |
◆ aligns_
◆ data_
NDArray<std::string> FmtTable::data_ |
|
private |
◆ delimiters_
◆ fmts_
std::vector<std::string> FmtTable::fmts_ |
|
private |
◆ frames_
◆ indent_
size_t FmtTable::indent_ = 0 |
|
private |
◆ j_
◆ titles_
std::vector<std::string> FmtTable::titles_ |
|
private |
The documentation for this class was generated from the following file:
- /home/runner/work/abacus-develop/abacus-develop/source/source_base/formatter.h