Class StringTable
#include <StringTable.h >
Contain a simple table of values that readily converts to/from a string.
The string contains CSV values in rows, separated by |.
const string& text |
the string representation of the table Default value: "" |
const string& rowSeparator |
the text that separates rows; default is | Default value: "|" |
const string& columnSeparator |
the text that separates columns; default is , Default value: "," |
Construct a StringTable. If text is provided, the table is populated from that
string (see fromString()).
Determine if this instance of StringTable is valid. A table is invalid when it
has no rows and no columns.
Determine if this instance of StringTable is empty. A table is empty when it
has no rows and no columns.
Reset this instance to empty.
int row |
the row (1+) of the table where the value resides |
int column |
position of column (1+) in the specified row of table |
Pull a string value out of the table at the row and column specified. Fetching a
value outside the defined table returns null string.
Return value: the value at the position specified
int column |
position of column (1+) in first/only row of table |
If there's only one row in the table (it's a vector of data), this is
shorthand for pulling a column string value. Fetching a value outside the defined
table returns null string.
Return value: the value at the position specified
const string& id |
row id (id is first value of line) |
int column |
position of column (1+) in first/only row of table |
If the first value on a row is the id, locate by row by that id and column.
Fetching a value outside the defined table returns null string.
Return value: the value at the position specified
int id |
row id (id is first value of line) |
int column |
position of column (1+) in first/only row of table |
If the first value on a row is the id, locate by row by that id and column.
Fetching a value outside the defined table returns null string.
Return value: the value at the position specified
const string& rowId |
If the first value on a row is the id, locate by row by that id and column.
Fetching a value outside the defined table returns null string.
@param id - row id (id is first value of line)
Return value: the row number for that id or 0 if id not found
Get the list of valid ids from the records
Return value: list of row ids
const string& rowId |
Determine if a row id exists
@param id - row id (id is first value of line)
Return value: the row number for that id or 0 if id not found
long rowId |
Determine if a row id exists
@param id - row id (id is first value of line)
Return value: the row number for that id or 0 if id not found
Get the known size of the table in rows.
Get the known size of the table in columns.
int row |
the row (1+) of the table where the value resides |
int column |
position of column (1+) in the specified row of table |
const string& value |
the value to put at the location |
Set a value at a row and column position in the table.
Note that if the position is outside the current table, then the table is
expanded. By doing this, the table is auto-sizing.
Return value: the instance of this StringTable with the new value set
int column |
position of column (1+) in the specified row of table |
const string& value |
the value to put at the location |
Set a value at a column position in the table in the first/only row.
Note that if the position is outside the current table, then the table is
expanded. By doing this, the table is auto-sizing.
@param row - the row (1+) of the table where the value resides
Return value: the instance of this StringTable with the new value set
bool yes |
true to treat id 0 as first row, false to not do so Default value: true |
If setById()/getById() is given rowId=0, it will return no value by default since
most applications have no row ids allowed as 0. So, if your application would like
to treat rowId=0 as the first row of the table, set that here.
const string& id |
row id (id is first value of line) |
int column |
position of column (1+) in first/only row of table |
const string& value |
the value to put at the location |
bool createRowIfNew |
if true, a row is appended with the rowId if rowId not found Default value: false |
If the first value on a row is the id, locate by row by that id and column
and then set the provided value.
Fetching a value outside the defined table returns null string.
Return value: the value at the position specified
int id |
row id (id is first value of line) |
int column |
position of column (1+) in first/only row of table |
const string& value |
the value to put at the location |
bool createRowIfNew |
if true, a row is appended with the rowId if rowId not found Default value: false |
If the first value on a row is the id, locate by row by that id and column
and then set the provided value.
Fetching a value outside the defined table returns null string.
Return value: the value at the position specified
int newRowCount |
the new height (1+) of the table |
Set the height of the table in rows.
Return value: true if table resized
int newColumnCount |
the new width (1+) of the table |
Set the width of the table in columns.
Return value: true if table resized
Transpose the table (swap columns and row)
Return value: transposed table; return false if table is invalid
const StringTable& columns |
Add a column or columns to the table. Basically, the new table is added to the
right of the current table, making it wider. If the new table has more rows, then
the existing table will become taller.
Return value: the updated table
const StringTable& rows |
Add a row or rows to the table. Basically, the new table is added under the
current table, making it taller. If the new table has more columns, then
the existing table will become wider.
Return value: the updated table
const string& rowSeparator |
the text that separates rows; default is | Default value: "|" |
const string& columnSeparator |
the text that separates columns; default is , Default value: "," |
Convert the StringTable to a string. Columns are separated by commas; rows
are separated by |. If any values contain either of these symbols, they are
escaped.
Return value: a string representing the table
const string& text |
the string representation of the table |
const string& rowSeparator |
the text that separates rows; default is | Default value: "|" |
const string& columnSeparator |
the text that separates columns; default is , Default value: "," |
Convert a string into a StringTable table.
Return value: true if table successfully converted from the string
int rowCount |
|
int columnCount |
|
vector < table |
|
static bool idZeroIsFirstRow |