|
goptions
|
The GOptions class manages command-line options and switches. More...
#include <goptions.h>

Public Member Functions | |
| GOptions () | |
| Default constructor. | |
| GOptions (std::string name) | |
| Constructor for verbosity and debug options. | |
| GOptions (int argc, char *argv[], const GOptions &user_defined_options=GOptions()) | |
| Library–based constructor. | |
| ~GOptions () | |
| void | defineSwitch (const std::string &name, const std::string &description) |
| Defines and adds a command–line switch. | |
| void | defineOption (const GVariable &gvar, const std::string &help) |
| Defines and adds a scalar option. | |
| void | defineOption (const std::string &name, const std::string &description, const std::vector< GVariable > &gvars, const std::string &help) |
| Defines and adds a structured (map/sequence) option. | |
| int | getScalarInt (const std::string &tag) const |
| Retrieves the value of a scalar integer option. | |
| double | getScalarDouble (const std::string &tag) const |
| Retrieves the value of a scalar double option. | |
| std::string | getScalarString (const std::string &tag) const |
| Retrieves the value of a scalar string option. | |
| bool | getSwitch (const std::string &tag) const |
| Retrieves the status of a switch. | |
| YAML::Node | getOptionNode (const std::string &tag) const |
| Retrieves the YAML node for the specified option. | |
| YAML::Node | getOptionMapInNode (const std::string &option_name, const std::string &map_key) const |
| Retrieves a map option’s value from within a YAML node. | |
| int | getVerbosityFor (const std::string &tag) const |
| Retrieves the verbosity level for the specified tag. | |
| int | getDebugFor (const std::string &tag) const |
| Retrieves the debug level for the specified tag. | |
| const std::vector< GOption > & | getOptions () const |
| Returns the list of defined options. | |
| const std::map< std::string, GSwitch > & | getSwitches () const |
| Returns the map of defined switches. | |
| void | addGOptions (const GOptions &src) |
| Adds options from another GOptions object. | |
| void | addOptionTitle (const std::string &name) |
| template<typename T > | |
| T | get_variable_in_option (const YAML::Node &node, const std::string &variable_name, const T &default_value) |
| Retrieves a variable from a YAML node within an option. | |
| std::vector< std::string > | getYamlFiles () const |
| Retrieves the list of YAML file paths. | |
| bool | doesOptionExist (const std::string &tag) const |
| Checks if the specified option exists. | |
Data Fields | |
| std::string | option_verbosity_name {UNINITIALIZEDSTRINGQUANTITY} |
| std::vector< GVariable > | option_verbosity_names |
This class provides methods to define, access, and manage configuration options and switches for command-line applications. Options can be scalar or sequence-based and are stored in YAML format.
Definition at line 24 of file goptions.h.
|
inline |
Creates an empty GOptions object, typically used for defining user–defined options.
Definition at line 31 of file goptions.h.
|
inlineexplicit |
| name | verbosity and debug option name |
Definition at line 39 of file goptions.h.
Constructs a GOptions object.
Constructs a GOptions object by initializing built–in options and switches, loading user-defined options, parsing YAML files, and processing command line arguments.
| argc | Number of command–line arguments. |
| argv | Array of command–line argument strings. |
| user_defined_options | A GOptions object containing user–defined options. |
This constructor performs the following tasks:
| argc | Number of command-line arguments. |
| argv | Array of command-line argument strings. |
| user_defined_options | A GOptions object containing user-defined options. |
Definition at line 29 of file goptions.cc.
|
inline |
Definition at line 54 of file goptions.h.
|
inline |
| src | The GOptions object to add. |
Definition at line 170 of file goptions.h.
|
inline |
Definition at line 201 of file goptions.h.
| void GOptions::defineOption | ( | const GVariable & | gvar, |
| const std::string & | help ) |
| gvar | A GVariable representing the option. |
| help | Help text for the option. |
| gvar | The GVariable representing the option. |
| help | Help text for the option. |
Definition at line 188 of file goptions.cc.
| void GOptions::defineOption | ( | const std::string & | name, |
| const std::string & | description, | ||
| const std::vector< GVariable > & | g_vars, | ||
| const std::string & | help ) |
Defines and adds a structured option.
| name | The name of the option. |
| description | A summary description of the option. |
| gvars | A vector of GVariable objects representing the option elements. |
| help | Help text for the option. |
| name | The name of the option. |
| description | Summary description of the option. |
| g_vars | Vector of GVariable objects representing the option elements. |
| help | Help text for the option. |
Definition at line 206 of file goptions.cc.
| void GOptions::defineSwitch | ( | const std::string & | name, |
| const std::string & | description ) |
Defines and adds a command-line switch.
| name | The name of the switch. |
| description | The description of the switch. |
Definition at line 172 of file goptions.cc.
| bool GOptions::doesOptionExist | ( | const std::string & | tag | ) | const |
| tag | The name of the option. |
Definition at line 311 of file goptions.cc.
| template bool GOptions::get_variable_in_option< bool > | ( | const YAML::Node & | node, |
| const std::string & | variable_name, | ||
| const T & | default_value ) |
Template function to retrieve a variable from a YAML node.
| T | The type of the variable. |
| node | The YAML node. |
| variable_name | The name of the variable. |
| default_value | The default value if the variable is not found. |
Definition at line 454 of file goptions.cc.
| int GOptions::getDebugFor | ( | const std::string & | tag | ) | const |
Accepts values as either booleans ("true"/"false") or integers.
| tag | The name of the debug option. |
Definition at line 494 of file goptions.cc.
| YAML::Node GOptions::getOptionMapInNode | ( | const std::string & | option_name, |
| const std::string & | map_key ) const |
| option_name | The name of the option. |
| map_key | The key within the option. |
| option_name | The name of the option. |
| map_key | The key to look up within the option. |
Definition at line 430 of file goptions.cc.
|
inline |
| tag | The name of the option. |
Definition at line 121 of file goptions.h.
|
inline |
Definition at line 158 of file goptions.h.
| double GOptions::getScalarDouble | ( | const std::string & | tag | ) | const |
| tag | The name of the option. |
Definition at line 239 of file goptions.cc.
| int GOptions::getScalarInt | ( | const std::string & | tag | ) | const |
| tag | The name of the option. |
Definition at line 223 of file goptions.cc.
| std::string GOptions::getScalarString | ( | const std::string & | tag | ) | const |
| tag | The name of the option. |
Definition at line 255 of file goptions.cc.
| bool GOptions::getSwitch | ( | const std::string & | tag | ) | const |
Retrieves the status of the specified switch.
| tag | The name of the switch. |
Definition at line 412 of file goptions.cc.
|
inline |
Definition at line 164 of file goptions.h.
| int GOptions::getVerbosityFor | ( | const std::string & | tag | ) | const |
| tag | The name of the verbosity option. |
Definition at line 473 of file goptions.cc.
|
inline |
Definition at line 221 of file goptions.h.
| std::string GOptions::option_verbosity_name {UNINITIALIZEDSTRINGQUANTITY} |
Definition at line 198 of file goptions.h.
| std::vector<GVariable> GOptions::option_verbosity_names |
Definition at line 199 of file goptions.h.