Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Represents one row of a Table. More...
#include <Row.h>
Public Types | |
using | cell_type = boost::variant< bool, int32_t, int64_t, float, double, std::string, std::vector< bool >, std::vector< int32_t >, std::vector< int64_t >, std::vector< float >, std::vector< double >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > |
The possible cell types. | |
using | const_iterator = std::vector< cell_type >::const_iterator |
Public Member Functions | |
Row (std::vector< cell_type > values, std::shared_ptr< ColumnInfo > column_info) | |
Constructs a Row with the given cell values and column info descriptor. | |
virtual | ~Row ()=default |
Default destructor. | |
std::shared_ptr< ColumnInfo > | getColumnInfo () const |
Returns a ColumnInfo object describing the columns of the Row. | |
size_t | size () const |
Returns the number of cells in the row. | |
const cell_type & | operator[] (const size_t index) const |
Returns the value of the column with the given index (zero based) | |
const cell_type & | operator[] (const std::string &column) const |
Returns the value of the row for the given column. | |
const_iterator | begin () const |
Returns a const iterator to the first cell of the row. | |
const_iterator | end () const |
Returns a const iterator to the past-the-end cell of the row. | |
Private Attributes | |
std::vector< cell_type > | m_values |
std::shared_ptr< ColumnInfo > | m_column_info |
Represents one row of a Table.
The Row is an immutable class which represents a single row of a Table. It contains one cell for each column, which has a value of one of the types defined in the cell_type boost::variant specialization. The information about the columns can be retrieved via a ColumnInfo object provided by the getColumnInfo() method. The values of the cells, in the case they are of std::string type, they cannot be the empty string, neither a string containing whitespace characters, because these values break the representation of the columns in the ASCII file.
using Euclid::Table::Row::cell_type = boost::variant<bool, int32_t, int64_t, float, double, std::string, std::vector<bool>, std::vector<int32_t>, std::vector<int64_t>, std::vector<float>, std::vector<double>, NdArray::NdArray<int32_t>, NdArray::NdArray<int64_t>, NdArray::NdArray<float>, NdArray::NdArray<double> > |
using Euclid::Table::Row::const_iterator = std::vector<cell_type>::const_iterator |
Euclid::Table::Row::Row | ( | std::vector< cell_type > | values, |
std::shared_ptr< ColumnInfo > | column_info | ||
) |
Constructs a Row with the given cell values and column info descriptor.
The number and type of the cells must match the ones of the columns, otherwise a Elements::Exception is thrown. The column_info cannot be the nullptr and the values of the cells cannot be the empty string or contain any whitespace characters (if they are of type std::string).
values | The values of the row cells |
column_info | The information of the columns |
Elements::Exception | if column_info is null |
Elements::Exception | if the values vector have different size than the number of columns |
Elements::Exception | if the values have different types than the columns |
Elements::Exception | if any of the cell values is the empty string |
Elements::Exception | if any of the cell values contains whitespace characters |
Definition at line 72 of file Row.cpp.
References std::string::empty(), m_column_info, m_values, and std::vector< T >::size().
|
virtualdefault |
Default destructor.
Row::const_iterator Euclid::Table::Row::begin | ( | ) | const |
Returns a const iterator to the first cell of the row.
Definition at line 129 of file Row.cpp.
References std::vector< T >::cbegin(), and m_values.
Row::const_iterator Euclid::Table::Row::end | ( | ) | const |
Returns a const iterator to the past-the-end cell of the row.
Definition at line 133 of file Row.cpp.
References std::vector< T >::cend(), and m_values.
std::shared_ptr< ColumnInfo > Euclid::Table::Row::getColumnInfo | ( | ) | const |
Returns a ColumnInfo object describing the columns of the Row.
Definition at line 106 of file Row.cpp.
References m_column_info.
const Row::cell_type & Euclid::Table::Row::operator[] | ( | const size_t | index | ) | const |
Returns the value of the column with the given index (zero based)
index | The index of the column (zero based) |
Elements::Exception | if the index is out of range |
Definition at line 114 of file Row.cpp.
References m_values, and std::vector< T >::size().
const Row::cell_type & Euclid::Table::Row::operator[] | ( | const std::string & | column | ) | const |
Returns the value of the row for the given column.
column | The name of the column |
Elements::Exception | if there is no column with such name |
Definition at line 121 of file Row.cpp.
References m_column_info, and m_values.
size_t Euclid::Table::Row::size | ( | ) | const |
Returns the number of cells in the row.
Definition at line 110 of file Row.cpp.
References m_values, and std::vector< T >::size().
|
private |
Definition at line 151 of file Row.h.
Referenced by getColumnInfo(), operator[](), and Row().
|
private |
Definition at line 150 of file Row.h.
Referenced by begin(), end(), operator[](), operator[](), Row(), and size().