Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
Euclid::Table::Row Class Reference

Represents one row of a Table. More...

#include <Row.h>

Collaboration diagram for Euclid::Table::Row:
Collaboration graph
[legend]

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< ColumnInfogetColumnInfo () 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_typeoperator[] (const size_t index) const
 Returns the value of the column with the given index (zero based)
 
const cell_typeoperator[] (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_typem_values
 
std::shared_ptr< ColumnInfom_column_info
 

Detailed Description

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.

Definition at line 57 of file Row.h.

Member Typedef Documentation

◆ cell_type

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> >

The possible cell types.

Definition at line 61 of file Row.h.

◆ const_iterator

Definition at line 66 of file Row.h.

Constructor & Destructor Documentation

◆ Row()

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).

Parameters
valuesThe values of the row cells
column_infoThe information of the columns
Exceptions
Elements::Exceptionif column_info is null
Elements::Exceptionif the values vector have different size than the number of columns
Elements::Exceptionif the values have different types than the columns
Elements::Exceptionif any of the cell values is the empty string
Elements::Exceptionif 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().

Here is the call graph for this function:

◆ ~Row()

virtual Euclid::Table::Row::~Row ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ begin()

Row::const_iterator Euclid::Table::Row::begin ( ) const

Returns a const iterator to the first cell of the row.

Returns
An iterator to the first cell

Definition at line 129 of file Row.cpp.

References std::vector< T >::cbegin(), and m_values.

Here is the call graph for this function:

◆ end()

Row::const_iterator Euclid::Table::Row::end ( ) const

Returns a const iterator to the past-the-end cell of the row.

Returns
An iterator to the cell past the end of the row

Definition at line 133 of file Row.cpp.

References std::vector< T >::cend(), and m_values.

Here is the call graph for this function:

◆ getColumnInfo()

std::shared_ptr< ColumnInfo > Euclid::Table::Row::getColumnInfo ( ) const

Returns a ColumnInfo object describing the columns of the Row.

Returns
the information about the columns

Definition at line 106 of file Row.cpp.

References m_column_info.

◆ operator[]() [1/2]

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)

Parameters
indexThe index of the column (zero based)
Returns
The value of the column
Exceptions
Elements::Exceptionif the index is out of range

Definition at line 114 of file Row.cpp.

References m_values, and std::vector< T >::size().

Here is the call graph for this function:

◆ operator[]() [2/2]

const Row::cell_type & Euclid::Table::Row::operator[] ( const std::string column) const

Returns the value of the row for the given column.

Parameters
columnThe name of the column
Returns
The value of the row for the column
Exceptions
Elements::Exceptionif there is no column with such name

Definition at line 121 of file Row.cpp.

References m_column_info, and m_values.

◆ size()

size_t Euclid::Table::Row::size ( ) const

Returns the number of cells in the row.

Returns
the number of cells

Definition at line 110 of file Row.cpp.

References m_values, and std::vector< T >::size().

Here is the call graph for this function:

Member Data Documentation

◆ m_column_info

std::shared_ptr<ColumnInfo> Euclid::Table::Row::m_column_info
private

Definition at line 151 of file Row.h.

Referenced by getColumnInfo(), operator[](), and Row().

◆ m_values

std::vector<cell_type> Euclid::Table::Row::m_values
private

Definition at line 150 of file Row.h.

Referenced by begin(), end(), operator[](), operator[](), Row(), and size().


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