ZNC
trunk
|
Generate a grid-like or list-like output from a given input. More...
#include <Utils.h>
Public Types | |
enum | EStyle { GridStyle , ListStyle } |
Public Member Functions | |
CTable () | |
virtual | ~CTable () |
bool | AddColumn (const CString &sName) |
Adds a new column to the table. More... | |
bool | SetStyle (EStyle eNewStyle) |
Selects the output style of the table. More... | |
size_type | AddRow () |
Adds a new row to the table. More... | |
bool | SetCell (const CString &sColumn, const CString &sValue, size_type uRowIdx=~0) |
Sets a given cell in the table to a value. More... | |
bool | GetLine (unsigned int uIdx, CString &sLine) const |
Get a line of the table's output. More... | |
CString::size_type | GetColumnWidth (unsigned int uIdx) const |
Return the width of the given column. More... | |
void | Clear () |
Completely clear the table. More... | |
Protected Attributes | |
std::vector< CString > | m_vsHeaders |
std::map< CString, CString::size_type > | m_msuWidths |
EStyle | eStyle = GridStyle |
T | elements |
STL member. More... | |
Generate a grid-like or list-like output from a given input.
The above code would generate the following output:
+-------+-------+ | a | b | +-------+-------+ | hello | world | +-------+-------+
If the table has at most two columns, one can switch to ListStyle output like so: @code CTable table; table.AddColumn("a"); table.AddColumn("b"); table.SetStyle(CTable::ListStyle); // ... @endcode This will yield the following (Note that the header is omitted; asterisks denote bold text): @verbatim
hello: world
enum CTable::EStyle |
|
inline |
|
inlinevirtual |
bool CTable::AddColumn | ( | const CString & | sName | ) |
Adds a new column to the table.
Please note that you should add all columns before starting to fill the table!
sName | The name of the column. |
size_type CTable::AddRow | ( | ) |
Adds a new row to the table.
After calling this you can fill the row with content.
void CTable::Clear | ( | ) |
Completely clear the table.
CString::size_type CTable::GetColumnWidth | ( | unsigned int | uIdx | ) | const |
Return the width of the given column.
Please note that adding and filling new rows might change the result of this function!
uIdx | The index of the column you are interested in. |
bool CTable::GetLine | ( | unsigned int | uIdx, |
CString & | sLine | ||
) | const |
Get a line of the table's output.
uIdx | The index of the line you want. |
sLine | This string will receive the output. |
Sets a given cell in the table to a value.
sColumn | The name of the column you want to fill. |
sValue | The value to write into that column. |
uRowIdx | The index of the row to use as returned by AddRow(). If this is not given, the last row will be used. |
bool CTable::SetStyle | ( | EStyle | eNewStyle | ) |
Selects the output style of the table.
Select between different styles for printing. Default is GridStyle.
eNewStyle | Table style type. |
|
inherited |
STL member.
|
protected |
|
protected |