librcsb-core-wrapper  1.000
Public Member Functions | List of all members
TTable Class Reference

Private class that represents a table of tuples. More...

#include <TTable.h>

Collaboration diagram for TTable:
Collaboration graph

Public Member Functions

 TTable ()
 
 TTable (const TTable &inTable)
 
virtual ~TTable ()
 
TTableoperator= (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)
 

Detailed Description

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.

Constructor & Destructor Documentation

TTable::TTable ( )

Constructs a tuple table.

Parameters: None

Returns
Not applicable
Precondition
None
Postcondition
Constructed table has 0 columns and 0 tuples.

Exceptions: None

TTable::TTable ( const TTable inTable)

Constructs a tuple table by copying from another table (copy constructor).

Parameters
[in]inTable- reference to a table that will be copied to the newly constructed table
Returns
Not applicable
Precondition
None
Postcondition
Constructed table has the same content as the table referenced by inTable.

Exceptions: None

virtual TTable::~TTable ( )
virtual

Destructs a table.

Parameters: None

Returns
Not applicable
Precondition
None
Postcondition
None

Exceptions: None

Member Function Documentation

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.

Parameters
[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.
Returns
The new number of columns after the column addition.
Precondition
Table must have at least one tuple, which can be empty.
If table is not empty and column is specified, the size of column must be less than or equal to the number of non-empty tuples. This is in order to prevent creation of non-rectangular tables.
If table is empty and column is specified, the size of column must be less than or equal to the number of tuples.
Postcondition
The number of columns is increased by one.
Exceptions
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

Returns
None
Precondition
None
Postcondition
Table has 0 columns and 0 tuples.

Exceptions: None

void TTable::ClearColumn ( const unsigned int  colIndex)

Sets all cells in the column to empty string.

Parameters
[in]colIndex- index of the column that is to be cleared.
Returns
None
Precondition
colIndex must be greater than 0 and less than the number of table columns.
Postcondition
None
Exceptions
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.

Parameters
[in]colName- the name of the tuple
Returns
None
Precondition
colName must be non-empty
Tuple with name colName must be present
Postcondition
Tuple length is unchanged.
Exceptions
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.

Parameters
[in]colIndex- index of the column that is to be deleted.
Returns
None
Precondition
colIndex must be greater than 0 and less than the number of table columns.
Postcondition
Number of table columns is reduced by 1.
Row indices of the columns which are below the deleted column are invalidated by being reduced by 1.
Exceptions
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.

Parameters
[in]colName- the name of the tuple
Returns
None
Precondition
colName must be non-empty
Tuple with name colName must be present
Postcondition
The number of table tuples is reduced by one.
Exceptions
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.

Parameters
[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.
Returns
None
Precondition
colIndex must be greater than 0 and less than the number of table columns.
The size of column must be less than or equal to the number of non-empty tuples. This is in order to prevent creation of non-rectangular tables.
Postcondition
None
Exceptions
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.

Parameters
[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.
Returns
None
Precondition
tupleIndex must be greater than 0 and less than the number of tuples
The size of tuple must be less than or equal to the number of columns.
The tuple which comes, in order, before the tuple with name atColName, must be non-empty. This is to prevent creation of non-rectangular tables.
Postcondition
If table is empty (0 columns) and tuple is specified, the number of columns is set to the size of tuple. Otherwise, the number of columns is unchanged.
Exceptions
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.

Parameters
[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.
Returns
None
Precondition
colIndex must be greater than 0 and less than the number of table columns.
If fromColName is specified, the tuple with name fromColName must be present and must be non-empty
If toColName is specified, the tuple 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 tuple order.
Postcondition
None
Exceptions
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.
unsigned int TTable::GetNumColumns ( ) const
inline

Retrieves the number of columns in the table.

Parameters: None

Returns
The number of columns in the table.
Precondition
None
Postcondition
None

Referenced by ITTable::GetNumColumns(), and ITTable::GetNumRows().

unsigned int TTable::GetNumTuples ( ) const
inline

Retrieves the number of tuples in the table.

Parameters: None

Returns
The number of tuples in the table.
Precondition
None
Postcondition
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.

Parameters
[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.
Returns
The new number of columns after the column insertion.
Precondition
Table must have at least one tuple, which can be empty.
atColIndex must be less than or equal to the number of table columns.
If table is not empty and column is specified, the size of column must be less than or equal to the number of non-empty tuples. This is in order to prevent creation of non-rectangular tables.
If table is empty and column is specified, the size of column must be less than or equal to the number of tuples.
Postcondition
The number of columns is increased by one.
Row indices of the columns which are below the inserted column are invalidated by being increased by 1.
Exceptions
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.

Parameters
[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".
Returns
None
Precondition
tupleIndex must be greater than 0 and less than or equal to the number of tuples
If tuple is specified, the size of tuple must be less than or equal to the number of columns.
The tuple which comes, in order, before the tuple with name atColName, must be non-empty. This is to prevent creation of non-rectangular tables.
Postcondition
If table is empty (0 columns) and tuple is specified, the number of columns is set to the size of tuple. Otherwise, the number of columns is unchanged.
Exceptions
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.

Parameters
[in]colIndex- column index of the cell that is to be updated.
[in]colName- the name of the tuple
Returns
None
Precondition
colIndex must be greater than 0 and less than the number of table columns.
colName must be non-empty
Tuple with name colName must be present
Postcondition
None
Exceptions
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.

Parameters
[in]colIndex- column index of the cell that is to be updated.
[in]colName- the name of the tuple
Returns
Constant reference to a cell in the table.
Precondition
colIndex must be greater than 0 and less than the number of table columns.
colName must be non-empty
Tuple with name colName must be present
Postcondition
None
Exceptions
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
TTable& TTable::operator= ( const TTable inTable)

Copies a tuple table to another table (assignment operator).

Parameters
[in]inTable- reference to the source table
Returns
Reference to the destination table
Precondition
None
Postcondition
Constructed table has the same content as the table referenced by inTable.

Exceptions: None

int TTable::Read ( UInt32  index,
Serializer ser 
)
int TTable::Write ( Serializer ser,
unsigned int &  size 
)

The documentation for this class was generated from the following file: