Configuration loader from JSON files.
More...
#include <config.hpp>
|
|
| Config (const std::string &config_filename) |
| | Configuration JSON filename.
|
| |
| template<typename T > |
| std::optional< T > | param (const std::string &module_name, const std::string ¶m_name) const |
| | Get a parameter.
|
| |
| template<typename T > |
| T | param (const std::string &module_name, const std::string ¶m_name, const T &default_value) const |
| | Get a parameter with default value.
|
| |
| template<typename T > |
| T | param_cast (const std::string &module_name, const std::string ¶m_name) const |
| | Get a parameter.
|
| |
| template<typename T > |
| std::optional< T > | param_nested (const std::vector< std::string > &nested_module_names, const std::string ¶m_name) const |
| | Get a parameter from a nested module.
|
| |
| template<typename T > |
| T | param_nested (const std::vector< std::string > &nested_module_names, const std::string ¶m_name, const T &default_value) const |
| | Get a parameter from a nested module with default value.
|
| |
| template<typename T > |
| T | param_cast_nested (const std::vector< std::string > &nested_module_names, const std::string ¶m_name) const |
| | Get a parameter.
|
| |
| template<typename T > |
| bool | override_param (const std::string &module_name, const std::string ¶m_name, const T &value) |
| | Override a parameter value.
|
| |
| void | save (const std::string &path) const |
| | Save config parameters as a JSON file.
|
| |
Configuration loader from JSON files.
◆ override_param()
template<typename T >
| bool glim::Config::override_param |
( |
const std::string & |
module_name, |
|
|
const std::string & |
param_name, |
|
|
const T & |
value |
|
) |
| |
Override a parameter value.
- Note
- This parameter override is volatile and does not make any changes on the JSON file
- Parameters
-
| module_name | Module name |
| param_name | Parameter name |
| value | Value to override the parameter |
- Returns
- True if the parameter exists, otherwise false
◆ param() [1/2]
template<typename T >
| std::optional< T > glim::Config::param |
( |
const std::string & |
module_name, |
|
|
const std::string & |
param_name |
|
) |
| const |
Get a parameter.
- Parameters
-
| module_name | Module name |
| param_name | Parameter name |
- Returns
- Parameter value if the param is found, otherwise nullopt
◆ param() [2/2]
template<typename T >
| T glim::Config::param |
( |
const std::string & |
module_name, |
|
|
const std::string & |
param_name, |
|
|
const T & |
default_value |
|
) |
| const |
Get a parameter with default value.
- Parameters
-
| module_name | Module name |
| param_name | Parameter name |
| default_value | Default value |
- Returns
- Parameter value if the param is found, otherwise the default value
◆ param_cast()
template<typename T >
| T glim::Config::param_cast |
( |
const std::string & |
module_name, |
|
|
const std::string & |
param_name |
|
) |
| const |
Get a parameter.
- Note
- If the parameter is not found, this method aborts the program
- Parameters
-
| module_name | Module name |
| param_name | Parameter name |
- Returns
- Returns the parameter value
◆ param_cast_nested()
template<typename T >
| T glim::Config::param_cast_nested |
( |
const std::vector< std::string > & |
nested_module_names, |
|
|
const std::string & |
param_name |
|
) |
| const |
Get a parameter.
- Note
- If the parameter is not found, this method aborts the program
- Parameters
-
| nested_module_names | Nested module names |
| param_name | Parameter name |
- Returns
- Returns the parameter value
◆ param_nested() [1/2]
template<typename T >
| std::optional< T > glim::Config::param_nested |
( |
const std::vector< std::string > & |
nested_module_names, |
|
|
const std::string & |
param_name |
|
) |
| const |
Get a parameter from a nested module.
- Parameters
-
| nested_module_names | Nested module names |
| param_name | Parameter name |
- Returns
- Parameter value if the param is found, otherwise nullopt
◆ param_nested() [2/2]
template<typename T >
| T glim::Config::param_nested |
( |
const std::vector< std::string > & |
nested_module_names, |
|
|
const std::string & |
param_name, |
|
|
const T & |
default_value |
|
) |
| const |
Get a parameter from a nested module with default value.
- Parameters
-
| nested_module_names | Nested module names |
| param_name | Parameter name |
| default_value | Default value |
- Returns
- Parameter value if the param is found, otherwise the default value
◆ save()
| void glim::Config::save |
( |
const std::string & |
path | ) |
const |
Save config parameters as a JSON file.
- Parameters
-
The documentation for this class was generated from the following files: