ROSE 0.11.145.192
|
Class for printing nicely formattated tables.
A table is a two-dimensional grid containing cells. A FormattedTable object holds information about how to format cells, functions to populate the cells, and functions to print the table.
Definition at line 15 of file FormattedTable.h.
#include <Rose/FormattedTable.h>
Classes | |
class | CellProperties |
Properties for a particular cell. More... | |
Public Types | |
enum class | Format { PLAIN , HTML , CSV , SHELL } |
Format when generating output. More... | |
enum class | Alignment { LEFT , RIGHT , CENTER } |
How text is aligned in a table cell. More... | |
Public Member Functions | |
FormattedTable () | |
Construct an empty table. | |
FormattedTable (size_t nRows, size_t nColumns) | |
Construct a table with a certain number of cells. | |
const std::string & | get (size_t rowIdx, size_t colIdx) const |
Get the data for a table cell. | |
void | print (std::ostream &) const |
Print a table. | |
Format | format () const |
Property: Output format. | |
void | format (Format) |
Property: Output format. | |
const std::string & | indentation () const |
Property: Indentation. | |
void | indentation (const std::string &) |
Property: Indentation. | |
void | resize (size_t nRows, size_t nColumns) |
Resize the table data. | |
void | resize (size_t nRows) |
Resize the table data. | |
size_t | nRows () const |
Number of rows or columns of data. | |
size_t | nColumns () const |
Number of rows or columns of data. | |
void | insert (size_t rowIdx, size_t columnIdx, const std::string &repr) |
Insert data into a table. | |
void | insert (size_t rowIdx, size_t columnIdx, const std::string &repr, const CellProperties &) |
Insert data into a table. | |
template<typename T > | |
void | insert (size_t rowIdx, size_t columnIdx, const T &value) |
Insert data into a table. | |
template<typename T > | |
void | insert (size_t rowIdx, size_t columnIdx, const T &value, const CellProperties &prop) |
Insert data into a table. | |
const CellProperties & | cellProperties (size_t rowIdx, size_t columnIdx) const |
Properties for a data cell. | |
void | cellProperties (size_t rowIdx, size_t columnIdx, const CellProperties &) |
Properties for a data cell. | |
size_t | nColumnHeaderRows () const |
Property: Number of column header rows. | |
void | nColumnHeaderRows (size_t) |
Property: Number of column header rows. | |
const std::string & | columnHeader (size_t rowIdx, size_t columnIdx) const |
Property: Name for column headers. | |
void | columnHeader (size_t rowIdx, size_t columnIdx, const std::string &title) |
Property: Name for column headers. | |
const CellProperties & | columnHeaderProperties (size_t rowIdx, size_t columnIdx) const |
Properties for column headers. | |
void | columnHeaderProperties (size_t rowIdx, size_t columnIdx, const CellProperties &) |
Properties for column headers. | |
|
strong |
Format when generating output.
Definition at line 22 of file FormattedTable.h.
|
strong |
How text is aligned in a table cell.
Enumerator | |
---|---|
LEFT | Text is aligned to the left edge of the cell. |
RIGHT | Text is aligned to the right edge of the cell. |
CENTER | Text is centered in the cell. |
Definition at line 35 of file FormattedTable.h.
Format Rose::FormattedTable::format | ( | ) | const |
Property: Output format.
How the table is formatted in general.
void Rose::FormattedTable::format | ( | Format | ) |
Property: Output format.
How the table is formatted in general.
const std::string & Rose::FormattedTable::indentation | ( | ) | const |
Property: Indentation.
This property holds a string that is printed at the beginning of every line of output. This used for the plain-text format; it's ignored for HTML output.
void Rose::FormattedTable::indentation | ( | const std::string & | ) |
Property: Indentation.
This property holds a string that is printed at the beginning of every line of output. This used for the plain-text format; it's ignored for HTML output.
void Rose::FormattedTable::resize | ( | size_t | nRows, |
size_t | nColumns | ||
) |
Resize the table data.
Making a table smaller will remove data cells but not row and column properties. Making a table larger will insert cells with empty data, and if necessary create default row and column properties.
void Rose::FormattedTable::resize | ( | size_t | nRows | ) |
Resize the table data.
Making a table smaller will remove data cells but not row and column properties. Making a table larger will insert cells with empty data, and if necessary create default row and column properties.
size_t Rose::FormattedTable::nRows | ( | ) | const |
Number of rows or columns of data.
See also, resize.
size_t Rose::FormattedTable::nColumns | ( | ) | const |
Number of rows or columns of data.
See also, resize.
void Rose::FormattedTable::insert | ( | size_t | rowIdx, |
size_t | columnIdx, | ||
const std::string & | repr | ||
) |
void Rose::FormattedTable::insert | ( | size_t | rowIdx, |
size_t | columnIdx, | ||
const std::string & | repr, | ||
const CellProperties & | |||
) |
Insert data into a table.
If the row and/or column number is outside the current size of the table, then the table is automatically resized, but it's more efficient to resize the table before adding data.
|
inline |
Insert data into a table.
If the row and/or column number is outside the current size of the table, then the table is automatically resized, but it's more efficient to resize the table before adding data.
Definition at line 160 of file FormattedTable.h.
References insert().
|
inline |
Insert data into a table.
If the row and/or column number is outside the current size of the table, then the table is automatically resized, but it's more efficient to resize the table before adding data.
Definition at line 163 of file FormattedTable.h.
References insert().
const CellProperties & Rose::FormattedTable::cellProperties | ( | size_t | rowIdx, |
size_t | columnIdx | ||
) | const |
Properties for a data cell.
When inserting properties, the table is automatically extended.
void Rose::FormattedTable::cellProperties | ( | size_t | rowIdx, |
size_t | columnIdx, | ||
const CellProperties & | |||
) |
Properties for a data cell.
When inserting properties, the table is automatically extended.
size_t Rose::FormattedTable::nColumnHeaderRows | ( | ) | const |
Property: Number of column header rows.
Column headers appear above the data and the number of column header rows is independent of the number of data rows that's returned by nRows. When the number of column header rows is decreased, the affected column header names are deleted; when the number of rows is increased, the new titles are set to empty strings.
void Rose::FormattedTable::nColumnHeaderRows | ( | size_t | ) |
Property: Number of column header rows.
Column headers appear above the data and the number of column header rows is independent of the number of data rows that's returned by nRows. When the number of column header rows is decreased, the affected column header names are deleted; when the number of rows is increased, the new titles are set to empty strings.
const std::string & Rose::FormattedTable::columnHeader | ( | size_t | rowIdx, |
size_t | columnIdx | ||
) | const |
Property: Name for column headers.
Column headers occupy one or more rows, but the rows do not count as data. Column information is extended as necessary when new column headers are added. When querying a column header that doesn't exist, an empty string is returned.
void Rose::FormattedTable::columnHeader | ( | size_t | rowIdx, |
size_t | columnIdx, | ||
const std::string & | title | ||
) |
Property: Name for column headers.
Column headers occupy one or more rows, but the rows do not count as data. Column information is extended as necessary when new column headers are added. When querying a column header that doesn't exist, an empty string is returned.
const CellProperties & Rose::FormattedTable::columnHeaderProperties | ( | size_t | rowIdx, |
size_t | columnIdx | ||
) | const |
Properties for column headers.
These are the properties for formatting column header cells. Column header row indices are indpendent of the data cell indices.
void Rose::FormattedTable::columnHeaderProperties | ( | size_t | rowIdx, |
size_t | columnIdx, | ||
const CellProperties & | |||
) |
Properties for column headers.
These are the properties for formatting column header cells. Column header row indices are indpendent of the data cell indices.