Alexandria  2.16
Please provide a description of the project.
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:
[legend]

Public Types

typedef 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< bool >, NdArray::NdArray< int32_t >, NdArray::NdArray< int64_t >, NdArray::NdArray< float >, NdArray::NdArray< double > > cell_type
 The possible cell types. More...
 
typedef std::vector< cell_type >::const_iterator 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. More...
 
virtual ~Row ()=default
 Default destructor. More...
 
std::shared_ptr< ColumnInfogetColumnInfo () const
 Returns a ColumnInfo object describing the columns of the Row. More...
 
size_t size () const
 Returns the number of cells in the row. More...
 
const cell_typeoperator[] (const size_t index) const
 Returns the value of the column with the given index (zero based) More...
 
const cell_typeoperator[] (const std::string &column) const
 Returns the value of the row for the given column. More...
 
const_iterator begin () const
 Returns a const iterator to the first cell of the row. More...
 
const_iterator end () const
 Returns a const iterator to the past-the-end cell of the row. More...
 

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 64 of file Row.h.

Member Typedef Documentation

◆ cell_type

typedef 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<bool>, NdArray::NdArray<int32_t>, NdArray::NdArray<int64_t>, NdArray::NdArray<float>, NdArray::NdArray<double> > Euclid::Table::Row::cell_type

The possible cell types.

Definition at line 84 of file Row.h.

◆ const_iterator

Definition at line 86 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 69 of file Row.cpp.

◆ ~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 126 of file Row.cpp.

References m_values.

◆ 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 130 of file Row.cpp.

References m_values.

◆ 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 103 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 111 of file Row.cpp.

References m_values.

◆ 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 118 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 107 of file Row.cpp.

References m_values.

Member Data Documentation

◆ m_column_info

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

Definition at line 171 of file Row.h.

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

◆ m_values

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

Definition at line 170 of file Row.h.

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


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