![]() |
CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
|
The class ReadParameters. More...
#include <ReadParameters.h>
Public Member Functions | |
Constructors/destructors | |
ReadParameters ()=default | |
Default empty constructor. | |
ReadParameters (const std::string parameter_file) | |
Constructor. More... | |
~ReadParameters ()=default | |
Default destructor. | |
Member functions used to get private/protected parameters | |
template<class T > | |
T | find (const std::string key) const |
Template method to get parameter value. More... | |
template<class T > | |
T | find (const std::string key, const T default_value) const |
Template method to get parameter value with default value. More... | |
template<class T > | |
std::vector< T > | find_vector (const std::string key) const |
Template method to get a vector parameter. More... | |
template<class T > | |
std::vector< T > | find_vector (const std::string key, const std::vector< T > default_value) const |
Template method to get a vector parameter with default value. More... | |
Private Member Functions | |
std::string | m_trim (const std::string inStr) |
Remove white spaces treading and leading each std::string (private function) More... | |
std::vector< std::string > | m_trim_vect (const std::string inStr) |
Stores values contained in between curly brackets in a vector of std::string (private function) More... | |
Private Attributes | |
std::unordered_map< std::string, std::string > | m_parameters |
map with all the parameter name/value couples | |
std::unordered_map< std::string, std::vector< std::string > > | m_vectors |
map with all the vector type parameter name/value couples | |
The class ReadParameters.
"Headers/ReadParameters.h"
Definition at line 54 of file ReadParameters.h.
cbl::glob::ReadParameters::ReadParameters | ( | const std::string | parameter_file | ) |
Constructor.
parameter_file | std::string with path and name of the parameter file to read |
Definition at line 46 of file ReadParameters.cpp.
T cbl::glob::ReadParameters::find | ( | const std::string | key | ) | const |
Template method to get parameter value.
template method to get the parameter value in the requested T type
key | std::string, parameter name |
Definition at line 172 of file ReadParameters.h.
T cbl::glob::ReadParameters::find | ( | const std::string | key, |
const T | default_value | ||
) | const |
Template method to get parameter value with default value.
template method to get the parameter value in the requested T type with default
key | std::string, parameter name |
default_value | typeT parameter default value to be returned if parameter not found |
Definition at line 187 of file ReadParameters.h.
std::vector< T > cbl::glob::ReadParameters::find_vector | ( | const std::string | key | ) | const |
Template method to get a vector parameter.
template method to get the parameter value in the requested T type
key | std::string, vector parameter name |
Definition at line 205 of file ReadParameters.h.
std::vector< T > cbl::glob::ReadParameters::find_vector | ( | const std::string | key, |
const std::vector< T > | default_value | ||
) | const |
Template method to get a vector parameter with default value.
template method to get the parameter value in the requested T type with default
key | std::string, parameter name |
default_value | std::vector<typeT> parameter default value to be returned if parameter not found |
Definition at line 224 of file ReadParameters.h.
|
private |
Remove white spaces treading and leading each std::string (private function)
inStr | std::string read in the parameter file (after '=') |
Definition at line 85 of file ReadParameters.cpp.
|
private |
Stores values contained in between curly brackets in a vector of std::string (private function)
inStr | std::string read in the parameter file (after '=', in between curly brackets '{', '}'); values inside brackets must be separated by comas ',' |
Definition at line 93 of file ReadParameters.cpp.