mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
An ascii table formatter.
Manages a table of string content, including word-wrapping within cells. Contents are output to an ostream line by line with a table structure.
have ability to add whole row, with a variadic template to handle different types
allow non-wrapping (i.e. unlimited width) columns
headers and footers
add centering (h and v) and right and bottom justification
have a latex() setup function
add sort capability, with vector of column choices to sort first by column N, then M, etc.
Definition at line 60 of file textTable.hpp.
#include <ioutils/textTable.hpp>
Public Member Functions | |
void | addCell (size_t row, size_t col, const std::string &cell) |
Add one cell to the table, overwriting if it already exists. More... | |
void | addCell (size_t row, size_t col, const char *cell) |
template<typename typeT > | |
void | addCell (size_t row, size_t col, const typeT &cell, int precision=0) |
Add one cell to the table, overwriting if it already exists. More... | |
template<typename iosT > | |
void | outPut (iosT &ios) |
Output the table to a stream. More... | |
Public Attributes | |
std::vector< int > | m_colWidths |
The widths of each column, not including the separator. More... | |
std::vector< std::vector< std::vector< std::string > > > | m_rows |
The table cells. More... | |
std::string | m_lineStart |
Text to print at the beginning of the line. More... | |
std::string | m_lineEnd |
Text to print at the end of the line. More... | |
std::string | m_colSep |
Text to print between each column. More... | |
std::string | m_rowSep |
Text to print between each row. More... | |
void mx::ioutils::textTable::addCell | ( | size_t | row, |
size_t | col, | ||
const char * | cell | ||
) |
[in] | row | the row of the cell. |
[in] | col | the column of the cell. |
[in] | cell | the new contents of the cell, will be wrapped. |
Definition at line 56 of file textTable.cpp.
References addCell().
void mx::ioutils::textTable::addCell | ( | size_t | row, |
size_t | col, | ||
const std::string & | cell | ||
) |
Add one cell to the table, overwriting if it already exists.
[in] | row | the row of the cell. |
[in] | col | the column of the cell. |
[in] | cell | the new contents of the cell, will be wrapped. |
Definition at line 36 of file textTable.cpp.
References m_colWidths, m_rows, and mx::ioutils::stringWrap().
Referenced by addCell(), and mx::app::application::optionHelp().
std::string mx::ioutils::textTable::m_colSep |
Text to print between each column.
Definition at line 73 of file textTable.hpp.
Referenced by mx::app::application::help(), and outPut().
std::vector<int> mx::ioutils::textTable::m_colWidths |
The widths of each column, not including the separator.
Definition at line 62 of file textTable.hpp.
Referenced by addCell(), mx::app::application::help(), and outPut().
std::string mx::ioutils::textTable::m_lineEnd |
Text to print at the end of the line.
Definition at line 71 of file textTable.hpp.
Referenced by outPut().
std::string mx::ioutils::textTable::m_lineStart |
Text to print at the beginning of the line.
Definition at line 69 of file textTable.hpp.
Referenced by mx::app::application::help(), and outPut().
std::vector<std::vector<std::vector<std::string> > > mx::ioutils::textTable::m_rows |
The table cells.
Organized as rows.cells.lines, where a cell could be multiple lines.
Definition at line 67 of file textTable.hpp.
Referenced by addCell(), mx::app::application::help(), and outPut().
std::string mx::ioutils::textTable::m_rowSep |
Text to print between each row.
Definition at line 75 of file textTable.hpp.
Referenced by mx::app::application::help(), and outPut().