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::ColumnInfo Class Reference

Provides information about the columns of a Table. More...

#include <ColumnInfo.h>

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

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 ColumnDescriptiongetDescription (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 ColumnDescriptiongetDescription (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_tfind (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_typem_info_list
 

Detailed Description

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.

Member Typedef Documentation

◆ info_type

Definition at line 55 of file ColumnInfo.h.

Constructor & Destructor Documentation

◆ ColumnInfo()

Euclid::Table::ColumnInfo::ColumnInfo ( std::vector< info_type info_list)
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.

Parameters
info_listA vector containing the descriptions of the columns
Exceptions
Elements::Exceptionif the info_list is empty
Elements::Exceptionif the info_list contains duplicate name entries

Definition at line 33 of file ColumnInfo.cpp.

References m_info_list.

◆ ~ColumnInfo()

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

Default destructor.

Member Function Documentation

◆ find()

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.

Parameters
nameThe name to search for
Returns
The index of the column or nullptr if there is no such column

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

Here is the call graph for this function:

◆ getDescription() [1/2]

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.

Parameters
nameThe name to search for
Returns
The description of the column
Exceptions
Elements::Exceptionif the index is out of bounds

Definition at line 68 of file ColumnInfo.cpp.

References std::find_if(), and m_info_list.

Here is the call graph for this function:

◆ getDescription() [2/2]

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.

Parameters
indexThe index to search for
Returns
The description of the column
Exceptions
Elements::Exceptionif 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().

Here is the call graph for this function:

◆ operator!=()

bool Euclid::Table::ColumnInfo::operator!= ( const ColumnInfo other) const

Returns false if this ColumnInfo represents the same columns with the given one.

Parameters
otherthe ColumnInfo to compare with
Returns
false if the two ColumnInfos represent the same columns, true otherwise

Definition at line 53 of file ColumnInfo.cpp.

◆ operator==()

bool Euclid::Table::ColumnInfo::operator== ( const ColumnInfo other) const

Returns true if this ColumnInfo represents the same columns with the given one.

Parameters
otherthe ColumnInfo to compare with
Returns
true if the two ColumnInfos represent the same columns, false otherwise

Definition at line 46 of file ColumnInfo.cpp.

References std::equal(), and m_info_list.

Here is the call graph for this function:

◆ size()

std::size_t Euclid::Table::ColumnInfo::size ( ) const

Returns the number of columns represented by this ColumnInfo.

Returns
the number of columns

Definition at line 57 of file ColumnInfo.cpp.

References m_info_list.

Referenced by getDescription(), Euclid::Configuration::getErrColumnFromOptions(), and Euclid::Configuration::getFluxColumnFromOptions().

Member Data Documentation

◆ m_info_list

std::vector<info_type> Euclid::Table::ColumnInfo::m_info_list
private

Definition at line 141 of file ColumnInfo.h.

Referenced by ColumnInfo(), find(), getDescription(), getDescription(), operator==(), and size().


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