Contains configurable elements as attributes, populated from the command line, a configuration file or default values.
More...
#include <Config.hpp>
|
const std::vector< KeyValues > & | arguments () const |
|
void | registerSection (const std::string &name) |
|
void | registerArgument (const std::string &longName, const std::string &shortName, const std::string &details, const std::vector< std::string > ¶ms={}) |
|
void | registerArgument (const std::string &longName, const std::string &shortName, const std::string &details, const std::string ¶m) |
|
|
std::vector< KeyValues > | _rawArguments |
| Store the internal parsed (keys, [values]) extracted from a file or the command-line.
|
|
std::vector< ArgumentInfo > | _infos |
| Store informations about each argument, for displaying the help message.
|
|
bool | _showHelp = false |
| Should the help be displayed.
|
|
Contains configurable elements as attributes, populated from the command line, a configuration file or default values.
Inherited by ObjToSceneConfig, and RenderingConfig.
◆ Config()
Config::Config |
( |
const std::vector< std::string > & |
argv | ) |
|
|
explicit |
Initialize a new config object, parsing the input arguments and filling the attributes with their values.
- Parameters
-
argv | the raw input arguments |
◆ arguments()
const std::vector< KeyValues > & Config::arguments |
( |
| ) |
const |
|
protected |
List of raw arguments.
- Returns
- the arguments list
◆ parseFromArgs()
void Config::parseFromArgs |
( |
const std::vector< std::string > & |
argv, |
|
|
std::vector< KeyValues > & |
arguments |
|
) |
| |
|
staticprivate |
Helper to extract (key, [values]) from the given command-line arguments.
- Parameters
-
argv | the raw input arguments |
arguments | a vector will be populated with (key, [values]) tuples. |
◆ parseFromFile()
void Config::parseFromFile |
( |
const std::string & |
filePath, |
|
|
std::vector< KeyValues > & |
arguments |
|
) |
| |
|
staticprivate |
Helper to extract (key, [values]) from a configuration file on disk.
- Parameters
-
filePath | the path to the configuration file. |
arguments | a vector will be populated with (key, [values]) tuples. |
◆ registerArgument() [1/2]
void Config::registerArgument |
( |
const std::string & |
longName, |
|
|
const std::string & |
shortName, |
|
|
const std::string & |
details, |
|
|
const std::string & |
param |
|
) |
| |
|
protected |
Register help infos for an argument. The command will be listed as follow in the help message: "--shortName,--longName <param> Details."
- Parameters
-
longName | the command full name |
shortName | the command abbreviated name |
details | the command description |
param | name or type of the expected parameter |
◆ registerArgument() [2/2]
void Config::registerArgument |
( |
const std::string & |
longName, |
|
|
const std::string & |
shortName, |
|
|
const std::string & |
details, |
|
|
const std::vector< std::string > & |
params = {} |
|
) |
| |
|
protected |
Register help infos for an argument. The command will be listed as follow in the help message: "--shortName,--longName <param0> <param1> Details."
- Parameters
-
longName | the command full name |
shortName | the command abbreviated name |
details | the command description |
params | name or type of each expected parameter |
◆ registerSection()
void Config::registerSection |
( |
const std::string & |
name | ) |
|
|
protected |
Create a section in the help messages, to group arguments.
- Parameters
-
◆ showHelp()
bool Config::showHelp |
( |
| ) |
|
Display help using the logger if the '–help' argument has been passed.
- Returns
- true if the help is shown, can be used for early exit
- Note
- Arguments with no name but a description will be used as headers.
The documentation for this class was generated from the following files:
- src/engine/system/Config.hpp
- src/engine/system/Config.cpp