librcsb-core-wrapper
1.000
|
Private class that represents a table of tuples. More...
#include <TTable.h>
Public Member Functions | |
TTable () | |
TTable (const TTable &inTable) | |
virtual | ~TTable () |
TTable & | operator= (const TTable &inTable) |
void | Clear () |
unsigned int | GetNumTuples () const |
unsigned int | AddTuple (const std::vector< std::string > &tuple=std::vector< std::string >()) |
void | InsertTuple (const unsigned int tupleIndex, const std::vector< std::string > &tuple=std::vector< std::string >()) |
void | InsertTuple (const unsigned int tupleIndex, std::vector< std::string >::const_iterator tupleBeg, std::vector< std::string >::const_iterator tupleEnd) |
void | FillTuple (const unsigned int tupleIndex, const std::vector< std::string > &tuple, const unsigned int fromColIndex=0) |
void | GetTuple (std::vector< std::string > &tuple, const unsigned int tupleIndex, const unsigned int fromColIndex, unsigned int toColIndex) |
const std::vector< std::string > & | GetTuple (const unsigned int tupleIndex) |
void | ClearTuple (const unsigned int tupleIndex) |
void | DeleteTuple (const unsigned int tupleIndex) |
unsigned int | GetNumColumns () const |
unsigned int | AddColumn (const std::vector< std::string > &col=std::vector< std::string >()) |
unsigned int | InsertColumn (const unsigned int atColIndex, const std::vector< std::string > &col=std::vector< std::string >()) |
void | InsertColumn (const unsigned int atColIndex, std::vector< std::string >::const_iterator colBeg, std::vector< std::string >::const_iterator colEnd) |
void | FillColumn (const unsigned int colIndex, const std::vector< std::string > &col, const unsigned int fromTupleIndex=0) |
void | FillColumn (const unsigned int colIndex, std::vector< std::string >::const_iterator colBeg, std::vector< std::string >::const_iterator colEnd, const unsigned int fromTupleIndex=0) |
void | GetColumn (std::vector< std::string > &col, const unsigned int colIndex, const unsigned int fromTupleIndex, unsigned int toTupleIndex) |
void | ClearColumn (const unsigned int colIndex) |
void | DeleteColumn (const unsigned int colIndex) |
std::string & | operator() (const unsigned int tupleIndex, const unsigned int colIndex) |
const std::string & | operator() (const unsigned int tupleIndex, const unsigned int colIndex) const |
int | Write (Serializer *ser, unsigned int &size) |
int | Read (UInt32 index, Serializer *ser) |
Private class that represents a table of tuples.
This class represents a two-dimensional table of cells. Each cell is represented by a text string. Tuples are horizontal table entities identified by tuple indices, which are unsigned integers ranging from zero to the number of tuples minus one. Tuples are vertical table entities identified by tuple indices. The class provides methods for table construction and destruction, assignment operator, tuple and column based methods for addition, insertion, retrieval, update, deletion, cell based methods for update and retrieval and table printing.
TTable::TTable | ( | ) |
Constructs a tuple table.
Parameters: None
Exceptions: None
TTable::TTable | ( | const TTable & | inTable | ) |
Constructs a tuple table by copying from another table (copy constructor).
[in] | inTable | - reference to a table that will be copied to the newly constructed table |
Exceptions: None
|
virtual |
Destructs a table.
Parameters: None
Exceptions: None
unsigned int TTable::AddColumn | ( | const std::vector< std::string > & | col = std::vector< std::string >() | ) |
Adds a new column to the bottom end of the table. For an empty table, the number of inserted cells is equal to the number of table tuples. For a non-empty table, the number of inserted cells is equal to the number of non-empty tuples (this is in order to prevent creation of non-rectangular tables). The newly added column is, optionally, filled with values, starting at the first tuple.
[in] | column | - optional parameter that contains the values which are to be used to fill in the newly added column. Filling starts at the first tuple and continues until size of column. |
EmptyContainerException | - if table has no tuples. |
out_of_range | - if table is not empty and size of column is greater than the number of non-empty tuples. |
out_of_range | - if table is empty and size of column is greater than the number of tuples. |
unsigned int TTable::AddTuple | ( | const std::vector< std::string > & | tuple = std::vector< std::string >() | ) |
void TTable::Clear | ( | ) |
Deletes all the content from the table.
Parameters: None
Exceptions: None
void TTable::ClearColumn | ( | const unsigned int | colIndex | ) |
Sets all cells in the column to empty string.
[in] | colIndex | - index of the column that is to be cleared. |
out_of_range | - if colIndex is less than 0 or greater than or equal to the number of table columns. |
void TTable::ClearTuple | ( | const unsigned int | tupleIndex | ) |
Sets all cells in the tuple to empty string.
[in] | colName | - the name of the tuple |
EmptyValueException | - if colName is empty |
NotFoundException | - if tuple with name colName does not exist |
void TTable::DeleteColumn | ( | const unsigned int | colIndex | ) |
Deletes a column with the specified column index.
[in] | colIndex | - index of the column that is to be deleted. |
out_of_range | - if colIndex is less than 0 or greater than or equal to the number of table columns. |
void TTable::DeleteTuple | ( | const unsigned int | tupleIndex | ) |
Deletes a tuple from the table.
[in] | colName | - the name of the tuple |
EmptyValueException | - if colName is empty |
NotFoundException | - if tuple with name colName does not exist |
void TTable::FillColumn | ( | const unsigned int | colIndex, |
const std::vector< std::string > & | col, | ||
const unsigned int | fromTupleIndex = 0 |
||
) |
Fills, with values, a column at the specified column index, starting at the the first tuple.
[in] | colIndex | - index of the column that is to be filled. |
[in] | column | - values which are to be used to fill in the column. Filling starts at the first tuple and continues until size of column. |
out_of_range | - if colIndex is greater than or equal to the number of table columns. |
out_of_range | - if size of column is greater than the number of non-empty tuples. |
void TTable::FillColumn | ( | const unsigned int | colIndex, |
std::vector< std::string >::const_iterator | colBeg, | ||
std::vector< std::string >::const_iterator | colEnd, | ||
const unsigned int | fromTupleIndex = 0 |
||
) |
void TTable::FillTuple | ( | const unsigned int | tupleIndex, |
const std::vector< std::string > & | tuple, | ||
const unsigned int | fromColIndex = 0 |
||
) |
Inserts a new tuple at the specified tuple index and shifts, to the right by one, the specified existing tuple and all tuples after it.
[in] | tupleIndex | - the index of the tuple at which the new tuple is to be inserted |
[in] | tuple | - contains the values which are to be used to fill in the newly inserted tuple. Filling starts at column index 0 and continues until size of tuple. |
out_of_range | - if tupleIndex is greater than than the number of tuples |
out_of_range | - if size of tuple is greater than the number of columns |
out_of_range | - if tuple, which comes, in order, before the tuple with name atColName, is empty. |
void TTable::GetColumn | ( | std::vector< std::string > & | col, |
const unsigned int | colIndex, | ||
const unsigned int | fromTupleIndex, | ||
unsigned int | toTupleIndex | ||
) |
Retrieves the values in the specified column.
[out] | column | - retrieved column values |
[in] | colIndex | - index of the column which values are to be retrieved. |
[in] | fromColName | - optional parameter which specifies the column location of the first cell to be retrieved. If not specified the first tuple cell is used. |
[in] | toColName | - optional parameter which specifies the column location of the last cell to be retrieved. If not specified the last non-empty-tuple cell is used. |
out_of_range | - if colIndex is less than 0 or greater than or equal to the number of table columns. |
NotFoundException | - If fromColName is specified and tuple with name fromColName does not exist |
NotFoundException | - If toColName is specified and tuple with name toColName does not exist |
out_of_range | - If fromColName is specified and tuple with name fromColName exists but is empty |
out_of_range | - If toColName is specified and tuple with name toColName exists but is empty |
out_of_range | - if fromColName is different than toColName and it comes after it in the tuple order. |
|
inline |
Retrieves the number of columns in the table.
Parameters: None
Referenced by ITTable::GetNumColumns(), and ITTable::GetNumRows().
|
inline |
Retrieves the number of tuples in the table.
Parameters: None
Exceptions: None
Referenced by ITTable::GetNumColumns(), and ITTable::GetNumRows().
void TTable::GetTuple | ( | std::vector< std::string > & | tuple, |
const unsigned int | tupleIndex, | ||
const unsigned int | fromColIndex, | ||
unsigned int | toColIndex | ||
) |
const std::vector<std::string>& TTable::GetTuple | ( | const unsigned int | tupleIndex | ) |
unsigned int TTable::InsertColumn | ( | const unsigned int | atColIndex, |
const std::vector< std::string > & | col = std::vector< std::string >() |
||
) |
Inserts a new column at the specified column index and shifts, down by one, the old column with the specified column index and all other columns below it. For an empty table, the number of inserted cells is equal to the number of table tuples. For a non-empty table, the number of inserted cells is equal to the number of non-empty tuples (this is in order to prevent creation of non-rectangular tables). The newly inserted column is optionally filled with values, starting at the first tuple.
[in] | atColIndex | - index of the column at which the new column is to be inserted. Note: If atColIndex is equal to the number of columns, the operation of this method is equivalent to AddRow(). |
[in] | column | - optional parameter that contains the values which are to be used to fill in the newly inserted column. Filling starts at the first tuple and continues until size of column. |
EmptyContainerException | - if table has no tuples. |
out_of_range | - if atColIndex is greater than the number of table columns. |
out_of_range | - if table is not empty and size of column is greater than the number of non-empty tuples. |
out_of_range | - if table is empty and size of column is greater than the number of tuples. |
void TTable::InsertColumn | ( | const unsigned int | atColIndex, |
std::vector< std::string >::const_iterator | colBeg, | ||
std::vector< std::string >::const_iterator | colEnd | ||
) |
void TTable::InsertTuple | ( | const unsigned int | tupleIndex, |
const std::vector< std::string > & | tuple = std::vector< std::string >() |
||
) |
Inserts a new tuple at the specified tuple index and shifts, to the right by one, the specified existing tuple and all tuples after it.
[in] | tupleIndex | - the index of the tuple at which the new tuple is to be inserted |
[in] | tuple | - optional parameter that contains the values which are to be used to fill in the newly inserted tuple. If tuple is specified, filling starts at column index 0 and continues until size of tuple. If tuple is not specified, the newly inserted tuple is filled with empty values, where filling starts at column index 0 and ends at column index "number of columns - 1". |
out_of_range | - if tupleIndex is greater than than the number of tuples |
out_of_range | - if size of tuple is greater than the number of columns |
out_of_range | - if tuple, which comes, in order, before the tuple with name atColName, is empty. |
void TTable::InsertTuple | ( | const unsigned int | tupleIndex, |
std::vector< std::string >::const_iterator | tupleBeg, | ||
std::vector< std::string >::const_iterator | tupleEnd | ||
) |
std::string& TTable::operator() | ( | const unsigned int | tupleIndex, |
const unsigned int | colIndex | ||
) |
Updates a cell in the table.
[in] | colIndex | - column index of the cell that is to be updated. |
[in] | colName | - the name of the tuple |
out_of_range | - if colIndex is less than 0 or greater than or equal to the number of table columns. |
EmptyValueException | - if colName is empty |
NotFoundException | - if tuple with name colName does not exist |
const std::string& TTable::operator() | ( | const unsigned int | tupleIndex, |
const unsigned int | colIndex | ||
) | const |
Retrieves a reference to the cell in the table.
[in] | colIndex | - column index of the cell that is to be updated. |
[in] | colName | - the name of the tuple |
out_of_range | - if colIndex is less than 0 or greater than or equal to the number of table columns. |
EmptyValueException | - if colName is empty |
NotFoundException | - if tuple with name colName does not exist |
Copies a tuple table to another table (assignment operator).
[in] | inTable | - reference to the source table |
Exceptions: None
int TTable::Read | ( | UInt32 | index, |
Serializer * | ser | ||
) |
int TTable::Write | ( | Serializer * | ser, |
unsigned int & | size | ||
) |