![]() |
User Guide
|
Class to construct and pretty-print tabular data. More...
Class to construct and pretty-print tabular data.
This class is used to construct and print tables (like nmodl::symtab::SymbolTable and performance tables).
Definition at line 36 of file table_data.hpp.
#include <table_data.hpp>
Public Types | |
using | TableRowType = std::vector< std::string > |
Public Member Functions | |
void | print (int indent=0) const |
void | print (std::ostream &stream, int indent=0) const |
Print table data in below shown format: title as first row (centrally aligned), second row is header for individual column (centrally aligned) and then all data rows (with associated alignments). More... | |
Public Attributes | |
std::string | title |
title of the table More... | |
TableRowType | headers |
top header/keys More... | |
std::vector< TableRowType > | rows |
data More... | |
std::vector< stringutils::text_alignment > | alignments |
alignment for every column of data rows More... | |
using nmodl::utils::TableData::TableRowType = std::vector<std::string> |
Definition at line 37 of file table_data.hpp.
void nmodl::utils::TableData::print | ( | int | indent = 0 | ) | const |
Definition at line 127 of file table_data.cpp.
void nmodl::utils::TableData::print | ( | std::ostream & | stream, |
int | indent = 0 |
||
) | const |
Print table data in below shown format: title as first row (centrally aligned), second row is header for individual column (centrally aligned) and then all data rows (with associated alignments).
not necessary to print empty table
based on indentation level, spaces to prefix
alignment is optional, so fill remaining with right alignment
calculate space required for each column
if title is larger than headers then every column width needs to be scaled
check length of columns in each row to find max length required
title row
header row
data rows
bottom separator line
Definition at line 32 of file table_data.cpp.
std::vector<stringutils::text_alignment> nmodl::utils::TableData::alignments |
alignment for every column of data rows
Definition at line 49 of file table_data.hpp.
TableRowType nmodl::utils::TableData::headers |
top header/keys
Definition at line 43 of file table_data.hpp.
std::vector<TableRowType> nmodl::utils::TableData::rows |
data
Definition at line 46 of file table_data.hpp.
std::string nmodl::utils::TableData::title |
title of the table
Definition at line 40 of file table_data.hpp.