Class to read parameters given from the command line and from a parameter file.
More...
#include <configuration_helper.hh>
|
| static ConfigTree | probe (int argc, char *argv[], const std::string parameter_file="parameter.json") |
| | Read the configuration without producing any diagnostics or terminating.
|
| |
Class to read parameters given from the command line and from a parameter file.
◆ ConfigurationHelper() [1/4]
| DiFfRG::ConfigurationHelper::ConfigurationHelper |
( |
int | argc, |
|
|
char * | argv[], |
|
|
const std::string | parameter_file = "parameter.json" ) |
Construct a new Configuration Helper object To get an overview of the available arguments, just pass –help as an argument.
- Parameters
-
| argc | Forwarded argc from main() function |
| argv | Forwarded argv from main() function |
| parameter_file | The name of the parameter file to be read. If this default name does not exist on disk, but the same name with a ".toml" extension does, the latter is read instead. A file given explicitly with the -p flag is never substituted. |
◆ ConfigurationHelper() [2/4]
Copy a Configuration Helper.
◆ ConfigurationHelper() [3/4]
| DiFfRG::ConfigurationHelper::ConfigurationHelper |
( |
const ConfigTree & | config | ) |
|
Construct a new Configuration Helper object from a ConfigTree object.
◆ ConfigurationHelper() [4/4]
| DiFfRG::ConfigurationHelper::ConfigurationHelper |
( |
| ) |
|
|
privatedefault |
◆ append()
| void DiFfRG::ConfigurationHelper::append |
( |
std::string | arg | ) |
|
Add a CLI-like argument to the list of arguments.
◆ generate_parameter_file()
| void DiFfRG::ConfigurationHelper::generate_parameter_file |
( |
| ) |
|
|
private |
◆ get_config() [1/2]
| ConfigTree & DiFfRG::ConfigurationHelper::get_config |
( |
| ) |
|
Obtain the configuration tree containing all the parameters.
◆ get_config() [2/2]
| const ConfigTree & DiFfRG::ConfigurationHelper::get_config |
( |
| ) |
const |
Obtain the configuration tree containing all the parameters.
◆ get_json() [1/2]
| ConfigTree & DiFfRG::ConfigurationHelper::get_json |
( |
| ) |
|
Obtain the configuration tree containing all the parameters.
Kept as the historical spelling of get_config().
◆ get_json() [2/2]
| const ConfigTree & DiFfRG::ConfigurationHelper::get_json |
( |
| ) |
const |
Obtain the configuration tree containing all the parameters.
Kept as the historical spelling of get_config().
◆ get_log_file()
| std::string DiFfRG::ConfigurationHelper::get_log_file |
( |
| ) |
const |
◆ get_output_folder()
| std::string DiFfRG::ConfigurationHelper::get_output_folder |
( |
| ) |
const |
◆ get_output_name()
| std::string DiFfRG::ConfigurationHelper::get_output_name |
( |
| ) |
const |
◆ get_parameter_file()
| std::string DiFfRG::ConfigurationHelper::get_parameter_file |
( |
| ) |
const |
◆ get_top_folder()
| std::string DiFfRG::ConfigurationHelper::get_top_folder |
( |
| ) |
const |
◆ parse()
| void DiFfRG::ConfigurationHelper::parse |
( |
| ) |
|
|
private |
◆ parse_cli()
| void DiFfRG::ConfigurationHelper::parse_cli |
( |
| ) |
|
|
private |
◆ print_usage_message()
| void DiFfRG::ConfigurationHelper::print_usage_message |
( |
| ) |
|
|
private |
◆ probe()
| static ConfigTree DiFfRG::ConfigurationHelper::probe |
( |
int | argc, |
|
|
char * | argv[], |
|
|
const std::string | parameter_file = "parameter.json" ) |
|
static |
Read the configuration without producing any diagnostics or terminating.
Behaves like the (argc, argv, parameter_file) constructor - same -p handling, same TOML fallback, same -sd/-si/-sb/-ss overrides - but never prints a usage message, never warns about unknown arguments and never calls exit(). Errors yield an empty tree instead.
This exists so that DiFfRG::Init can look at a few parameters (notably /discretization/threads) before the libraries are brought up, while leaving the authoritative, diagnostics-producing parse to the application itself.
◆ args
| std::list<std::string> DiFfRG::ConfigurationHelper::args |
|
private |
◆ cli_parameters
| std::list<std::pair<std::string, std::string> > DiFfRG::ConfigurationHelper::cli_parameters |
|
private |
◆ config
◆ parameter_file
| std::string DiFfRG::ConfigurationHelper::parameter_file |
|
private |
◆ parameter_file_explicit
| bool DiFfRG::ConfigurationHelper::parameter_file_explicit = false |
|
private |
Whether parameter_file was named explicitly with -p, which disables the fallback to a TOML file of the same name.
◆ parsed
| bool DiFfRG::ConfigurationHelper::parsed = false |
|
private |
◆ quiet
| bool DiFfRG::ConfigurationHelper::quiet = false |
|
private |
In quiet mode nothing is printed and nothing exits the process; failures are thrown instead. Set by probe(). See probe() for why.
The documentation for this class was generated from the following file: