LevelS C++ support library  3.83
Public Member Functions | List of all members
paramfile Class Reference

#include <paramfile.h>

Public Member Functions

 paramfile (const std::string &filename, bool verbose_=true)
 
 paramfile (const params_type &par, bool verbose_=true)
 
void setVerbosity (bool verbose_)
 
bool getVerbosity () const
 
bool param_present (const std::string &key) const
 
template<typename T >
find (const std::string &key) const
 
template<typename T >
find (const std::string &key, const T &deflt)
 
const params_type & getParams () const
 
template<typename T >
void setParam (const std::string &key, const T &value)
 

Detailed Description

Class for storing and querying key/value pairs. The name is historical; the parameters can actually be obtained from othersources as well (e.g. the command line).

Definition at line 44 of file paramfile.h.

Constructor & Destructor Documentation

◆ paramfile() [1/2]

paramfile::paramfile ( const std::string &  filename,
bool  verbose_ = true 
)

Constructs a paramfile object from the contents of filename. If verbose_==true, diagnostic output is generated when calling methods on this object, otherwise not.

◆ paramfile() [2/2]

paramfile::paramfile ( const params_type &  par,
bool  verbose_ = true 
)

Constructs a paramfile object from the contents of par. If verbose_==true, diagnostic output is generated when calling methods on this object, otherwise not.

Definition at line 52 of file paramfile.cc.

Member Function Documentation

◆ setVerbosity()

void paramfile::setVerbosity ( bool  verbose_)
inline

Allows adjusting the verbosity.

Definition at line 71 of file paramfile.h.

◆ getVerbosity()

bool paramfile::getVerbosity ( ) const
inline

Returns the verbosity setting of the object.

Definition at line 75 of file paramfile.h.

◆ param_present()

bool paramfile::param_present ( const std::string &  key) const

Returns true, if a paremeter called key is stored in the object, else false.

Definition at line 66 of file paramfile.cc.

◆ find() [1/2]

template<typename T >
T paramfile::find ( const std::string &  key) const

Returns the value stored for the parameter name key, after converting it to the requested type. If key is not present, an exception is thrown.

◆ find() [2/2]

template<typename T >
T paramfile::find ( const std::string &  key,
const T &  deflt 
)

Returns the value stored for the parameter name key, after converting it to the requested type. If key is not present, deflt is returned instead, and is also entered into the parameter set.

◆ getParams()

const params_type& paramfile::getParams ( ) const
inline

Returns the entire set of currently stored parameters.

Definition at line 93 of file paramfile.h.

◆ setParam()

template<typename T >
void paramfile::setParam ( const std::string &  key,
const T &  value 
)
inline

Sets the parameter with the name key to value.

Definition at line 97 of file paramfile.h.


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

Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library