Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Provides information about the columns of a Table. More...
#include <ColumnInfo.h>
Public Types | |
using | info_type = ColumnDescription |
Public Member Functions | |
ColumnInfo (std::vector< info_type > info_list) | |
Constructs a ColumnInfo representing the given column names and types. | |
virtual | ~ColumnInfo ()=default |
Default destructor. | |
bool | operator== (const ColumnInfo &other) const |
Returns true if this ColumnInfo represents the same columns with the given one. | |
bool | operator!= (const ColumnInfo &other) const |
Returns false if this ColumnInfo represents the same columns with the given one. | |
std::size_t | size () const |
Returns the number of columns represented by this ColumnInfo. | |
const ColumnDescription & | getDescription (std::size_t index) const |
Returns the description of the column with the given index or throws an exception if the index is bigger than the size of the ColumnInfo. | |
const ColumnDescription & | getDescription (const std::string &name) const |
Returns the description of the column with the given name or throws an exception if column does not exist. | |
std::unique_ptr< std::size_t > | find (const std::string &name) const |
Returns the index of a column, given the name of it, or nullptr if there is no column with this name. | |
Private Attributes | |
std::vector< info_type > | m_info_list |
Provides information about the columns of a Table.
The ColumnInfo is an immutable class which provides information about the columns of a Table. This class can be used for retrieving the ColumnDescription of a column using its index (zero based) and for searching a column with a specific name. The names of the columns must by unique.
Definition at line 52 of file ColumnInfo.h.
Definition at line 55 of file ColumnInfo.h.
|
explicit |
Constructs a ColumnInfo representing the given column names and types.
The order of the columns is assumed to be the same with their order in the passed vector. Because the ColumnInfo is immutable the info_list cannot be empty.
Note that the info_list is passed by value to allow the caller to optimize for performance, meaning that the constructor will take advantage of move semantics if the passed object is an rvalue.
info_list | A vector containing the descriptions of the columns |
Elements::Exception | if the info_list is empty |
Elements::Exception | if the info_list contains duplicate name entries |
Definition at line 33 of file ColumnInfo.cpp.
References m_info_list.
|
virtualdefault |
Default destructor.
std::unique_ptr< size_t > Euclid::Table::ColumnInfo::find | ( | const std::string & | name | ) | const |
Returns the index of a column, given the name of it, or nullptr if there is no column with this name.
name | The name to search for |
Definition at line 77 of file ColumnInfo.cpp.
References std::distance(), std::find_if(), m_info_list, and Euclid::Table::ColumnDescription::name.
Referenced by Euclid::Configuration::getErrColumnFromOptions(), and Euclid::Configuration::getFluxColumnFromOptions().
const ColumnDescription & Euclid::Table::ColumnInfo::getDescription | ( | const std::string & | name | ) | const |
Returns the description of the column with the given name or throws an exception if column does not exist.
name | The name to search for |
Elements::Exception | if the index is out of bounds |
Definition at line 68 of file ColumnInfo.cpp.
References std::find_if(), and m_info_list.
const ColumnDescription & Euclid::Table::ColumnInfo::getDescription | ( | std::size_t | index | ) | const |
Returns the description of the column with the given index or throws an exception if the index is bigger than the size of the ColumnInfo.
index | The index to search for |
Elements::Exception | if the index is out of bounds |
Definition at line 61 of file ColumnInfo.cpp.
References m_info_list, and size().
Referenced by Euclid::Configuration::getErrColumnFromOptions(), and Euclid::Configuration::getFluxColumnFromOptions().
bool Euclid::Table::ColumnInfo::operator!= | ( | const ColumnInfo & | other | ) | const |
Returns false if this ColumnInfo represents the same columns with the given one.
other | the ColumnInfo to compare with |
Definition at line 53 of file ColumnInfo.cpp.
bool Euclid::Table::ColumnInfo::operator== | ( | const ColumnInfo & | other | ) | const |
Returns true if this ColumnInfo represents the same columns with the given one.
other | the ColumnInfo to compare with |
Definition at line 46 of file ColumnInfo.cpp.
References std::equal(), and m_info_list.
std::size_t Euclid::Table::ColumnInfo::size | ( | ) | const |
Returns the number of columns represented by this ColumnInfo.
Definition at line 57 of file ColumnInfo.cpp.
References m_info_list.
Referenced by getDescription(), Euclid::Configuration::getErrColumnFromOptions(), and Euclid::Configuration::getFluxColumnFromOptions().
|
private |
Definition at line 141 of file ColumnInfo.h.
Referenced by ColumnInfo(), find(), getDescription(), getDescription(), operator==(), and size().