UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Utils::Table::Table Class Reference

The main class for creating and managing a table. More...

#include <Table.hxx>

Public Types

using vecRow = std::vector<Row>
 
using vecCell = std::vector<Cell>
 
using vecstr = std::vector<string>
 
using vecvecstr = std::vector<vecstr>
 
using integer = int
 

Public Member Functions

 Table ()=default
 Default constructor for an empty table.
 
 Table (Style const &style, vecvecstr const &rows=vecvecstr())
 Constructs a table with a given style and initial rows.
 
void setup (Style const &style, vecvecstr const &rows=vecvecstr())
 
void align_column (integer n, Alignment align)
 
void add_row (vecstr const &row)
 
integer cell_spacing () const
 
integer cell_padding () const
 
vecCell column (integer n) const
 
integer column_width (integer n) const
 
integer num_columns () const
 
Style const & style () const
 
void style (Style const &style)
 
string_view title () const
 
void title (string_view title)
 
Row const & headings () const
 
void headings (vecstr const &headings)
 
Rowrow (integer n)
 
Row const & row (integer n) const
 
Rowoperator[] (integer n)
 
Row const & operator[] (integer n) const
 
Celloperator() (integer i, integer j)
 
Cell const & operator() (integer i, integer j) const
 
vecRow const & rows () const
 
void rows (vecvecstr const &rows)
 
std::string render_separator (char left, char mid, char right, char sep) const
 
std::string render () const
 

Detailed Description

The main class for creating and managing a table.

The Table class represents a 2D table structure that supports rows, cells, and table styles. It provides methods for rendering, alignment, and other table-related operations.

Member Typedef Documentation

◆ integer

◆ vecCell

using Utils::Table::Table::vecCell = std::vector<Cell>

◆ vecRow

using Utils::Table::Table::vecRow = std::vector<Row>

◆ vecstr

using Utils::Table::Table::vecstr = std::vector<string>

◆ vecvecstr

using Utils::Table::Table::vecvecstr = std::vector<vecstr>

Constructor & Destructor Documentation

◆ Table() [1/2]

Utils::Table::Table::Table ( )
default

Default constructor for an empty table.

◆ Table() [2/2]

Utils::Table::Table::Table ( Style const & style,
vecvecstr const & rows = vecvecstr() )
inlineexplicit

Constructs a table with a given style and initial rows.

Parameters
styleThe style object to customize the table's borders and alignment.
rowsA 2D vector of strings representing the table's content.

Member Function Documentation

◆ add_row()

void Utils::Table::Table::add_row ( vecstr const & row)

◆ align_column()

void Utils::Table::Table::align_column ( integer n,
Alignment align )

◆ cell_padding()

integer Utils::Table::Table::cell_padding ( ) const

◆ cell_spacing()

integer Utils::Table::Table::cell_spacing ( ) const

◆ column()

vecCell Utils::Table::Table::column ( integer n) const

◆ column_width()

integer Utils::Table::Table::column_width ( integer n) const

◆ headings() [1/2]

Row const & Utils::Table::Table::headings ( ) const
inline

◆ headings() [2/2]

void Utils::Table::Table::headings ( vecstr const & headings)

◆ num_columns()

integer Utils::Table::Table::num_columns ( ) const

◆ operator()() [1/2]

Cell & Utils::Table::Table::operator() ( integer i,
integer j )
inline

◆ operator()() [2/2]

Cell const & Utils::Table::Table::operator() ( integer i,
integer j ) const
inline

◆ operator[]() [1/2]

Row & Utils::Table::Table::operator[] ( integer n)
inline

◆ operator[]() [2/2]

Row const & Utils::Table::Table::operator[] ( integer n) const
inline

◆ render()

std::string Utils::Table::Table::render ( ) const

◆ render_separator()

std::string Utils::Table::Table::render_separator ( char left,
char mid,
char right,
char sep ) const

◆ row() [1/2]

Row & Utils::Table::Table::row ( integer n)

◆ row() [2/2]

Row const & Utils::Table::Table::row ( integer n) const

◆ rows() [1/2]

vecRow const & Utils::Table::Table::rows ( ) const
inline

◆ rows() [2/2]

void Utils::Table::Table::rows ( vecvecstr const & rows)

◆ setup()

void Utils::Table::Table::setup ( Style const & style,
vecvecstr const & rows = vecvecstr() )
inline

◆ style() [1/2]

Style const & Utils::Table::Table::style ( ) const
inline

◆ style() [2/2]

void Utils::Table::Table::style ( Style const & style)
inline

◆ title() [1/2]

string_view Utils::Table::Table::title ( ) const
inline

◆ title() [2/2]

void Utils::Table::Table::title ( string_view title)
inline

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