#include <STable.h>
Inherited by ISTable.
Inheritance diagram for STable:
Public Member Functions | |
STable (const StringCompare::eCompareType colCaseSense=StringCompare::eCASE_SENSITIVE) | |
STable (const string &name, const StringCompare::eCompareType colCaseSense=StringCompare::eCASE_SENSITIVE) | |
STable (const STable &inTable) | |
virtual | ~STable () |
virtual STable & | operator= (const STable &inTable) |
virtual void | Clear () |
const string | GetName () const |
void | Rename (const string &name) |
unsigned int | GetNumColumns () const |
void | GetColumnNames (vector< string > &colNames) const |
bool | IsColumnPresent (const string &colName) |
void | AddColumn (const string &colName, const vector< string > &col=vector< string >(0)) |
void | InsertColumn (const string &colName, const string &atColName, const vector< string > &col=vector< string >(0)) |
virtual void | FillColumn (const string &colName, const vector< string > &col) |
virtual void | AppendToColumn (const string &colName, const string &cell) |
virtual void | AppendToColumn (const string &colName, const vector< string > &col) |
virtual void | GetColumn (vector< string > &col, const string &colName) |
virtual void | GetColumn (vector< string > &col, const string &colName, const unsigned int fromRowIndex, unsigned int toRowIndex) |
virtual void | GetColumn (vector< string > &col, const string &colName, const vector< unsigned int > &rowIndices) |
unsigned int | ColumnLength (const string &colName) const |
void | RenameColumn (const string &oldColName, const string &newColName) |
virtual void | ClearColumn (const string &colName) |
virtual void | DeleteColumn (const string &colName) |
unsigned int | GetColumnIndex (const string &colName) const |
void | GetColumnsIndices (vector< unsigned int > &colIndices, const vector< string > &colNames=vector< string >(0)) |
virtual unsigned int | GetNumRows () const |
virtual unsigned int | AddRow (const vector< string > &row=vector< string >(0)) |
virtual unsigned int | InsertRow (const unsigned int atRowIndex, const vector< string > &row=vector< string >(0)) |
virtual void | FillRow (const unsigned int rowIndex, const vector< string > &row) |
virtual void | GetRow (vector< string > &row, const unsigned int rowIndex, const string &fromColName=String::Empty, const string &toColName=String::Empty) |
virtual void | ClearRow (const unsigned int rowIndex) |
virtual void | DeleteRow (const unsigned int rowIndex) |
virtual void | UpdateCell (const unsigned int rowIndex, const string &colName, const string &cell) |
virtual const string & | operator() (const unsigned int rowIndex, const string &colName) const |
Protected Member Functions | |
void | InsertColumn (const string &colName, const unsigned int colIndex, const vector< string > &col=vector< string >(0)) |
void | FillColumn (const vector< string > &col, const unsigned int colIndex) |
void | CreateColumn (const unsigned int colIndex, const vector< string > &col=vector< string >(0)) |
void | AppendToColumn (const string &cell, const unsigned int colIndex) |
void | AppendToColumn (const vector< string > &col, const unsigned int colIndex) |
void | ClearColumn (const unsigned int colIndex) |
void | DeleteColumn (const unsigned int colIndex) |
void | VerifyColumnsIndices (const vector< unsigned int > &colIndices) |
void | _GetColumnsIndices (vector< unsigned int > &colIndices, const vector< string > &colNames) |
void | FillRow (const vector< string > &row, const unsigned int rowIndex, const unsigned int fromColIndex, const unsigned int toColIndex) |
void | GetSubRow (vector< string > &subRow, const unsigned int rowIndex, const unsigned int fromColIndex, unsigned int toColIndex) |
void | UpdateCell (const string &cell, const unsigned int colIndex, const unsigned int rowIndex) |
void | GetCell (string &cell, const unsigned int colIndex, const unsigned int rowIndex) |
Protected Attributes | |
string | _name |
StringCompare::eCompareType | _colCaseSense |
vector< string > | _colNames |
unsigned int | _numRows |
unsigned int | _numNonEmptyCols |
vector< vector< string > * > | _data |
STable::STable | ( | const StringCompare::eCompareType | colCaseSense = StringCompare::eCASE_SENSITIVE |
) |
Constructs a table.
[in] | colCaseSense | - optional parameter that indicates case sensitivity of column names. Possible values are case sensitive and case in-sensitive. If not specified, a table with case sensitive column names is constructed. |
Constructed table is nameless (its name is an empty string)
STable::STable | ( | const string & | name, | |
const StringCompare::eCompareType | colCaseSense = StringCompare::eCASE_SENSITIVE | |||
) |
Constructs a table.
[in] | name | - the name of the table to be constructed |
[in] | colCaseSense | - optional parameter that indicates case sensitivity of column names. Possible values are case sensitive and case in-sensitive. If not specified, a table with case sensitive column names is constructed. |
STable::STable | ( | const STable & | inTable | ) |
Constructs a table by copying from another table (copy constructor).
[in] | inTable | - reference to a table that will be copied to the newly constructed table |
STable::~STable | ( | ) | [virtual] |
Destructs a table.
Parameters: Not applicable
Copies a table to another table (assignment operator).
[in] | inTable | - reference to the source table |
void STable::Clear | ( | ) | [virtual] |
Deletes all the content from the table.
Table name is not affected by this method.
Reimplemented in ISTable.
const string STable::GetName | ( | ) | const [inline] |
Retrieves table name.
Parameters: None
void STable::Rename | ( | const string & | name | ) |
Changes the table name.
[in] | name | - the new name of the table |
unsigned int STable::GetNumColumns | ( | ) | const [inline] |
Retrieves the number of columns in the table.
Parameters: None
void STable::GetColumnNames | ( | vector< string > & | colNames | ) | const |
Retrieves column names.
[out] | colNames | - retrieved column names |
bool STable::IsColumnPresent | ( | const string & | colName | ) |
Checks for column existence.
[in] | colName | - the name of the column |
false - if column does not exist
EmptyValueException | - if colName is empty |
void STable::AddColumn | ( | const string & | colName, | |
const vector< string > & | col = vector< string >(0) | |||
) |
Adds a column to the end of the table.
[in] | colName | - the name of the column to be added |
[in] | col | - optional parameter that contains the values which are to be used to fill in the newly added column. If col is specified, filling starts at row index 0 and continues until size of col. If col is not specified, the newly added column is filled with empty values, where filling starts at row index 0 and ends at row index "number of rows - 1". |
Column with name colName must not be present
If col is specified, the size of col must be less than or equal to the number of rows.
EmptyValueException | - if colName is empty | |
AlreadyExistsException | - if column with name colName already exists | |
out_of_range | - if size of col is greater than the number of rows |
void STable::InsertColumn | ( | const string & | colName, | |
const string & | atColName, | |||
const vector< string > & | col = vector< string >(0) | |||
) |
Inserts a new column at the specified existing column and shifts, to the right by one, the specified existing column and all columns after it.
[in] | colName | - the name of the column to be inserted |
[in] | atColName | - the name of the column at which the new column is to be inserted |
[in] | col | - optional parameter that contains the values which are to be used to fill in the newly inserted column. If col is specified, filling starts at row index 0 and continues until size of col. If col is not specified, the newly inserted column is filled with empty values, where filling starts at row index 0 and ends at row index "number of rows - 1". |
Column with name colName must not be present
atColName must be non-empty
Column with name atColName must be present
If col is specified, the size of col must be less than or equal to the number of rows.
The column which comes, in order, before the column with name atColName, must be non-empty. This is to prevent creation of non-rectangular tables.
EmptyValueException | - if colName is empty | |
EmptyValueException | - if atColName is empty | |
AlreadyExistsException | - if column with name colName already exists | |
NotFoundException | - if column with name atColName does not exist | |
out_of_range | - if size of col is greater than the number of rows | |
out_of_range | - if column, which comes, in order, before the column with name atColName, is empty. |
void STable::FillColumn | ( | const string & | colName, | |
const vector< string > & | col | |||
) | [virtual] |
Fills a column with values.
[in] | colName | - the name of the column to be filled |
[in] | col | - contains the values which are to be used for filling. Filling starts at row index 0 and continues until size of col. |
Column with name colName must be present
The size of col must be less than or equal to the number of rows.
The column which comes, in order, before the column with name colName, must be non-empty. This is to prevent creation of non-rectangular tables.
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist | |
out_of_range | - if size of col is greater than the number of rows | |
out_of_range | - if column, which comes, in order, before the column with name colName, is empty. |
Reimplemented in ISTable.
void STable::AppendToColumn | ( | const string & | colName, | |
const string & | cell | |||
) | [virtual] |
Appends one cell to the specified column.
[in] | colName | - the name of the column to which the cell is to be appended |
[in] | cell | - contains the value that is to be appended |
Column with name colName must be present
The column, which comes, in order, before the column with name colName, must be non-empty. This is to prevent creation of non-rectangular tables.
Cells in other columns of the, newly appended row, are set to empty values.
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist | |
out_of_range | - if column, which comes, in order, before the column with name colName, is empty. |
Reimplemented in ISTable.
void STable::AppendToColumn | ( | const string & | colName, | |
const vector< string > & | col | |||
) | [virtual] |
Appends cells to the specified column.
[in] | colName | - the name of the column to which the cells are to be appended |
[in] | col | - contains the values which are to be appended. |
Column with name colName must be present
The column, which comes, in order, before the column with name colName, must be non-empty. This is to prevent creation of non-rectangular tables.
Cells in other columns of the, newly appended rows, are set to empty values.
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist | |
out_of_range | - if column, which comes, in order, before the column with name colName, is empty. |
Reimplemented in ISTable.
void STable::GetColumn | ( | vector< string > & | col, | |
const string & | colName | |||
) | [virtual] |
Retrieves the values in the specified column.
[out] | col | - retrieved column values |
[in] | colName | - the name of the column which content is to be retrieved. |
Column with name colName must be present
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist |
Reimplemented in ISTable.
void STable::GetColumn | ( | vector< string > & | col, | |
const string & | colName, | |||
const unsigned int | fromRowIndex, | |||
unsigned int | toRowIndex | |||
) | [virtual] |
Retrieves values in the specified column range.
[out] | col | - retrieved values |
[in] | colName | - the name of the column which content is to be retrieved. |
[in] | fromRowIndex | - the row index of the first cell in the column to be retrieved. |
[in] | toRowIndex | - the row index of the last cell in the column to be retrieved. |
Column with name colName must be present
fromRowIndex must be less than or equal to the column length
toRowIndex must be less than or equal to the column length
fromRowIndex must be less than or equal to the toRowIndex
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist | |
out_of_range | - if fromRowIndex is greater than the column length | |
out_of_range | - if toRowIndex is greater than the column length | |
out_of_range | - if fromRowIndex is greater than toRowIndex |
Reimplemented in ISTable.
void STable::GetColumn | ( | vector< string > & | col, | |
const string & | colName, | |||
const vector< unsigned int > & | rowIndices | |||
) | [virtual] |
Retrieves values in the specified column cells.
[out] | col | - retrieved values |
[in] | colName | - the name of the column which content is to be retrieved |
[in] | rowIndices | - indices of column cells to be retrieved |
Column with name colName must be present
Row indices in rowIndices must be less than or equal to the column length
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist | |
out_of_range | - if at least one row index in rowIndices is greater than the column length |
Reimplemented in ISTable.
unsigned int STable::ColumnLength | ( | const string & | colName | ) | const |
Retrieves the number of cells in the column.
[in] | colName | - the name of the column |
Column with name colName must be present
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist |
void STable::RenameColumn | ( | const string & | oldColName, | |
const string & | newColName | |||
) |
Changes the column name.
[in] | oldColName | - the name of the column which is to be renamed |
[in] | newColName | - the new column name |
Column with name oldColName must be present
newColName must be non-empty
Column with name newColName must not be present
EmptyValueException | - if oldColName is empty | |
NotFoundException | - if column with name oldColName does not exist | |
EmptyValueException | - if newColName is empty | |
AlreadyExistsException | - if column with name newColName already exists |
void STable::ClearColumn | ( | const string & | colName | ) | [virtual] |
Sets all cells in the column to empty string.
[in] | colName | - the name of the column |
Column with name colName must be present
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist |
Reimplemented in ISTable.
void STable::DeleteColumn | ( | const string & | colName | ) | [virtual] |
Deletes a column from the table.
[in] | colName | - the name of the column |
Column with name colName must be present
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist |
Reimplemented in ISTable.
unsigned int STable::GetColumnIndex | ( | const string & | colName | ) | const |
void STable::GetColumnsIndices | ( | vector< unsigned int > & | colIndices, | |
const vector< string > & | colNames = vector< string >(0) | |||
) |
unsigned int STable::GetNumRows | ( | ) | const [inline, virtual] |
Retrieves the number of rows in the table.
Parameters: None
Reimplemented in ISTable.
unsigned int STable::AddRow | ( | const vector< string > & | row = vector< string >(0) |
) | [virtual] |
Adds a new row to the bottom end of the table. For an empty table, the number of inserted cells is equal to the number of table columns. For a non-empty table, the number of inserted cells is equal to the number of non-empty columns (this is in order to prevent creation of non-rectangular tables). The newly added row is, optionally, filled with values, starting at the first column.
[in] | row | - optional parameter that contains the values which are to be used to fill in the newly added row. Filling starts at the first column and continues until size of row. |
If table is not empty and row is specified, the size of row must be less than or equal to the number of non-empty columns. This is in order to prevent creation of non-rectangular tables.
If table is empty and row is specified, the size of row must be less than or equal to the number of columns.
EmptyContainerException | - if table has no columns. | |
out_of_range | - if table is not empty and size of row is greater than the number of non-empty columns. | |
out_of_range | - if table is empty and size of row is greater than the number of columns. |
unsigned int STable::InsertRow | ( | const unsigned int | atRowIndex, | |
const vector< string > & | row = vector< string >(0) | |||
) | [virtual] |
Inserts a new row at the specified row index and shifts, down by one, the old row with the specified row index and all other rows below it. For an empty table, the number of inserted cells is equal to the number of table columns. For a non-empty table, the number of inserted cells is equal to the number of non-empty columns (this is in order to prevent creation of non-rectangular tables). The newly inserted row is optionally filled with values, starting at the first column.
[in] | atRowIndex | - index of the row at which the new row is to be inserted. Note: If atRowIndex is equal to the number of rows, the operation of this method is equivalent to AddRow(). |
[in] | row | - optional parameter that contains the values which are to be used to fill in the newly inserted row. Filling starts at the first column and continues until size of row. |
atRowIndex must be less than or equal to the number of table rows.
If table is not empty and row is specified, the size of row must be less than or equal to the number of non-empty columns. This is in order to prevent creation of non-rectangular tables.
If table is empty and row is specified, the size of row must be less than or equal to the number of columns.
Row indices of the rows which are below the inserted row are invalidated by being increased by 1.
EmptyContainerException | - if table has no columns. | |
out_of_range | - if atRowIndex is greater than the number of table rows. | |
out_of_range | - if table is not empty and size of row is greater than the number of non-empty columns. | |
out_of_range | - if table is empty and size of row is greater than the number of columns. |
Reimplemented in ISTable.
void STable::FillRow | ( | const unsigned int | rowIndex, | |
const vector< string > & | row | |||
) | [virtual] |
Fills, with values, a row at the specified row index, starting at the the first column.
[in] | rowIndex | - index of the row that is to be filled. |
[in] | row | - values which are to be used to fill in the row. Filling starts at the first column and continues until size of row. |
The size of row must be less than or equal to the number of non-empty columns. This is in order to prevent creation of non-rectangular tables.
out_of_range | - if rowIndex is greater than or equal to the number of table rows. | |
out_of_range | - if size of row is greater than the number of non-empty columns. |
Reimplemented in ISTable.
void STable::GetRow | ( | vector< string > & | row, | |
const unsigned int | rowIndex, | |||
const string & | fromColName = String::Empty , |
|||
const string & | toColName = String::Empty | |||
) | [virtual] |
Retrieves the values in the specified row.
[out] | row | - retrieved row values |
[in] | rowIndex | - index of the row which values are to be retrieved. |
[in] | fromColName | - optional parameter which specifies the row location of the first cell to be retrieved. If not specified the first column cell is used. |
[in] | toColName | - optional parameter which specifies the row location of the last cell to be retrieved. If not specified the last non-empty-column cell is used. |
If fromColName is specified, the column with name fromColName must be present and must be non-empty
If toColName is specified, the column with name toColName must be present and must be non-empty
If fromColName is different than toColName, it must come prior to it in the column order.
out_of_range | - if rowIndex is less than 0 or greater than or equal to the number of table rows. | |
NotFoundException | - If fromColName is specified and column with name fromColName does not exist | |
NotFoundException | - If toColName is specified and column with name toColName does not exist | |
out_of_range | - If fromColName is specified and column with name fromColName exists but is empty | |
out_of_range | - If toColName is specified and column with name toColName exists but is empty | |
out_of_range | - if fromColName is different than toColName and it comes after it in the column order. |
Reimplemented in ISTable.
void STable::ClearRow | ( | const unsigned int | rowIndex | ) | [virtual] |
Sets all cells in the row to empty string.
[in] | rowIndex | - index of the row that is to be cleared. |
out_of_range | - if rowIndex is less than 0 or greater than or equal to the number of table rows. |
Reimplemented in ISTable.
void STable::DeleteRow | ( | const unsigned int | rowIndex | ) | [virtual] |
Deletes a row with the specified row index.
[in] | rowIndex | - index of the row that is to be deleted. |
Row indices of the rows which are below the deleted row are invalidated by being reduced by 1.
out_of_range | - if rowIndex is less than 0 or greater than or equal to the number of table rows. |
Reimplemented in ISTable.
void STable::UpdateCell | ( | const unsigned int | rowIndex, | |
const string & | colName, | |||
const string & | cell | |||
) | [virtual] |
Updates a cell in the table.
[in] | rowIndex | - row index of the cell that is to be updated. |
[in] | colName | - the name of the column |
colName must be non-empty
Column with name colName must be present
out_of_range | - if rowIndex is less than 0 or greater than or equal to the number of table rows. | |
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist |
Reimplemented in ISTable.
const string & STable::operator() | ( | const unsigned int | rowIndex, | |
const string & | colName | |||
) | const [virtual] |
Retrieves a reference to the cell in the table.
[in] | rowIndex | - row index of the cell that is to be updated. |
[in] | colName | - the name of the column |
colName must be non-empty
Column with name colName must be present
out_of_range | - if rowIndex is less than 0 or greater than or equal to the number of table rows. | |
EmptyValueException | - if colName is empty | |
NotFoundException | - if column with name colName does not exist |
Reimplemented in ISTable.
void STable::InsertColumn | ( | const string & | colName, | |
const unsigned int | colIndex, | |||
const vector< string > & | col = vector< string >(0) | |||
) | [protected] |
void STable::FillColumn | ( | const vector< string > & | col, | |
const unsigned int | colIndex | |||
) | [protected] |
Reimplemented in ISTable.
void STable::CreateColumn | ( | const unsigned int | colIndex, | |
const vector< string > & | col = vector< string >(0) | |||
) | [protected] |
void STable::AppendToColumn | ( | const string & | cell, | |
const unsigned int | colIndex | |||
) | [protected] |
void STable::AppendToColumn | ( | const vector< string > & | col, | |
const unsigned int | colIndex | |||
) | [protected] |
Reimplemented in ISTable.
void STable::ClearColumn | ( | const unsigned int | colIndex | ) | [protected] |
void STable::DeleteColumn | ( | const unsigned int | colIndex | ) | [protected] |
void STable::VerifyColumnsIndices | ( | const vector< unsigned int > & | colIndices | ) | [protected] |
void STable::_GetColumnsIndices | ( | vector< unsigned int > & | colIndices, | |
const vector< string > & | colNames | |||
) | [protected] |
void STable::FillRow | ( | const vector< string > & | row, | |
const unsigned int | rowIndex, | |||
const unsigned int | fromColIndex, | |||
const unsigned int | toColIndex | |||
) | [protected] |
void STable::GetSubRow | ( | vector< string > & | subRow, | |
const unsigned int | rowIndex, | |||
const unsigned int | fromColIndex, | |||
unsigned int | toColIndex | |||
) | [protected] |
void STable::UpdateCell | ( | const string & | cell, | |
const unsigned int | colIndex, | |||
const unsigned int | rowIndex | |||
) | [protected] |
Reimplemented in ISTable.
void STable::GetCell | ( | string & | cell, | |
const unsigned int | colIndex, | |||
const unsigned int | rowIndex | |||
) | [protected] |
Reimplemented in ISTable.
string STable::_name [protected] |
StringCompare::eCompareType STable::_colCaseSense [protected] |
vector<string> STable::_colNames [protected] |
unsigned int STable::_numRows [protected] |
unsigned int STable::_numNonEmptyCols [protected] |
vector<vector<string>*> STable::_data [protected] |