Generate a grid-like or list-like output from a given input.
More...
#include <Utils.h>
|
| CTable () |
|
virtual | ~CTable () |
|
bool | AddColumn (const CString &sName) |
| Adds a new column to the table.
|
|
bool | SetStyle (EStyle eNewStyle) |
| Selects the output style of the table.
|
|
size_type | AddRow () |
| Adds a new row to the table.
|
|
bool | SetCell (const CString &sColumn, const CString &sValue, size_type uRowIdx=~0) |
| Sets a given cell in the table to a value.
|
|
bool | GetLine (unsigned int uIdx, CString &sLine) const |
| Get a line of the table's output.
|
|
CString::size_type | GetColumnWidth (unsigned int uIdx) const |
| Return the width of the given column.
|
|
void | Clear () |
| Completely clear the table.
|
|
Generate a grid-like or list-like output from a given input.
unsigned int idx = 0;
while (table.
GetLine(idx++, tmp)) {
}
String class that is used inside ZNC.
Definition ZNCString.h:68
bool AddColumn(const CString &sName)
Adds a new column to the table.
bool SetCell(const CString &sColumn, const CString &sValue, size_type uRowIdx=~0)
Sets a given cell in the table to a value.
bool GetLine(unsigned int uIdx, CString &sLine) const
Get a line of the table's output.
size_type AddRow()
Adds a new row to the table.
CTable()
Definition Utils.h:175
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:
bool SetStyle(EStyle eNewStyle)
Selects the output style of the table.
@ ListStyle
Definition Utils.h:174
This will yield the following (Note that the header is omitted; asterisks denote bold text):
*hello*: world
◆ EStyle
Enumerator |
---|
GridStyle | |
ListStyle | |
◆ CTable()
◆ ~CTable()
virtual CTable::~CTable |
( |
| ) |
|
|
inlinevirtual |
◆ AddColumn()
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!
- Parameters
-
sName | The name of the column. |
- Returns
- false if a column by that name already existed or the current style does not allow this many columns.
◆ AddRow()
size_type CTable::AddRow |
( |
| ) |
|
Adds a new row to the table.
After calling this you can fill the row with content.
- Returns
- The index of this row
◆ Clear()
Completely clear the table.
◆ GetColumnWidth()
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!
- Parameters
-
uIdx | The index of the column you are interested in. |
- Returns
- The width of the column.
◆ GetLine()
bool CTable::GetLine |
( |
unsigned int | uIdx, |
|
|
CString & | sLine ) const |
Get a line of the table's output.
- Parameters
-
uIdx | The index of the line you want. |
sLine | This string will receive the output. |
- Returns
- True unless uIdx is past the end of the table.
◆ SetCell()
bool CTable::SetCell |
( |
const CString & | sColumn, |
|
|
const CString & | sValue, |
|
|
size_type | uRowIdx = ~0 ) |
Sets a given cell in the table to a value.
- Parameters
-
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. |
- Returns
- True if setting the cell was successful.
◆ SetStyle()
bool CTable::SetStyle |
( |
EStyle | eNewStyle | ) |
|
Selects the output style of the table.
Select between different styles for printing. Default is GridStyle.
- Parameters
-
eNewStyle | Table style type. |
- Returns
- false if the style cannot be applied (usually too many columns).
◆ elements
T std::vector< T >::elements |
|
inherited |
◆ eStyle
◆ m_msuWidths
std::map<CString, CString::size_type> CTable::m_msuWidths |
|
protected |
◆ m_vsHeaders
std::vector<CString> CTable::m_vsHeaders |
|
protected |
The documentation for this class was generated from the following file: