Table¶
-
class
Table
¶ Class to store several rows of data values. Each Row will contain value objects that are mapped to the Columns defined in this Table.
Public Functions
-
Table &
operator=
(const Table &other)¶ Assign operators
-
void
clear
()¶ Clear all columns and rows
-
bool
isEmpty
() const¶ Return true if the number of rows is 0
-
size_t
getIndex
(size_t colId)¶ Return the index of the column with this ID
-
size_t
getIndex
(const std::string &colName)¶ Return the index of the column with this NAME.
-
const Table::Column &
getColumn
(size_t colId)¶ Return the column with this column ID.
-
const Table::Column &
getColumn
(const std::string &colName)¶ Return the column with this NAME
-
const Column &
getColumnByIndex
(size_t index)¶ Return the column in the given INDEX
-
size_t
getColumnsSize
() const¶ Return number of columns in the table
-
size_t
addColumn
(const Column &col)¶ Add a column when the table does not contain any row. If there are rows, the other function should be used where a default value should be provided.
- Parameters
col
: Column to be added
-
size_t
addColumn
(const Column &col, const Object &defaultValue)¶ Add a new column when the table already contains some rows.
-
size_t
insertColumn
(const Column &col, size_t pos)¶ Insert a new column at a given position
-
void
moveColumn
(size_t colId, size_t pos)¶ Change the position of a column
-
Table::const_col_iterator
cbegin_cols
() const¶ Return column iterator at the beginning
-
Table::const_col_iterator
cend_cols
() const¶ Return column iterator at the end
-
const Table::Row &
operator[]
(size_t pos) const¶ Return the row at this position
-
bool
addRow
(const Row &row)¶ Add a new row to the set
-
size_t
deleteRows
(const std::string &queryStr)¶ Delete all rows that match a query string
- Return
The number of deleted rows.
-
size_t
updateRows
(const std::string &operation, const std::string &queryStr)¶ Update many rows at once. Apply the operation string to all rows that match the query string.
- Return
The number of updated rows.
-
void
sort
(const StringVector &columnName)¶ Sort the table by a given column name.
-
void
read
(const std::string &tableName, const std::string &path)¶ Shortcut function to read a table from file without the need to explicitly instantiating a TableFile object. After calling this function, the current table will be populated.
- Parameters
tableName
: Name of the table that will be readpath
: Path to the table file, the type of reader will be inferred from the filename extension
-
void
read
(const std::string &path)¶ Shortcut function to read a table from file without the need to explicitly instantiating a TableFile object. After calling this function, the current table will be populated.
- Parameters
path
: Path to the table file, the type of reader will be inferred from the filename extension
-
class
Column
¶ Class defining the properties of a given column in a Row or Table. Each column should have an integer ID and a string NAME (both of which should be unique among a given set of Columns). Additionally, a Column should have a Type and could have a description of its meaning.
-
class
Impl
¶ Public Functions
-
void
updateIndexes
(ColumnVector::iterator firstToUpdate, int updateFactor)¶ Update the indexes of some columns when new columns are added or existing one are deleted.
- Parameters
firstToUpdate
: This is the position (iterator) of the first element to updateupdateFactor
: This will be 1 if a new column is inserted and -1 if a column was deleted.
-
void
-
class
Row
¶ Class to hold key-value pairs. Keys will be either string or integer representing a given column. Values are instances of class Object that can hold values of different types. The Type of a given object in the Row should be of the same type of the Column’s Type.
Public Functions
-
Row
()¶ Empty constructor
-
const Object &
operator[]
(size_t colId) const¶ Return the index of the column specified by colId.
-
const Object &
operator[]
(const std::string &colName) const¶ Return the index of the column specified by colName.
-
class
Impl
¶
-
-
Table &