goptions
|
The GOptions class manages command-line options and switches. More...
#include <goptions.h>
Public Member Functions | |
GOptions () | |
Default constructor. More... | |
GOptions (int argc, char *argv[], const GOptions &user_defined_options) | |
void | defineSwitch (const std::string &name, const std::string &description) |
Defines and adds a command-line switch to the map of switches. More... | |
void | defineOption (const GVariable &gvar, const std::string &help) |
Defines and adds a scalar option to the map of options. More... | |
void | defineOption (const std::string &name, const std::string &description, const std::vector< GVariable > &gvars, const std::string &help) |
Defines and adds a structured option to the map of options. More... | |
int | getScalarInt (const std::string &tag) const |
Retrieves the value of a scalar integer option. More... | |
float | getScalarFloat (const std::string &tag) const |
Retrieves the value of a scalar float option. More... | |
double | getScalarDouble (const std::string &tag) const |
Retrieves the value of a scalar double option. More... | |
std::string | getScalarString (const std::string &tag) const |
Retrieves the value of a scalar string option. More... | |
bool | getSwitch (const std::string &tag) const |
Retrieves the status of a switch. More... | |
const YAML::Node | getOptionNode (const std::string &tag) const |
Retrieves the YAML::Node of the specified option. More... | |
YAML::Node | getOptionMapInNode (string option_name, string map_key) |
Retrieves a map option within a YAML::Node. More... | |
int | getVerbosityFor (const std::string &tag) const |
Retrieves the verbosity level for a given tag. More... | |
const std::vector< GOption > & | getOptions () const |
Returns the list of all defined options. More... | |
const std::map< std::string, GSwitch > & | getSwitches () const |
Returns the map of all defined switches. More... | |
void | addGOptions (const GOptions &goptions_to_add) |
Adds a set of GOptions to the current options. More... | |
template<typename T > | |
T | get_variable_in_option (const YAML::Node &node, const string &variable_name, const T &default_value) |
Retrieves a variable from a YAML::Node. More... | |
std::vector< std::string > | getYamlFiles () const |
Retrieves the list of YAML files. More... | |
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 22 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.
GOptions::GOptions | ( | int | argc, |
char * | argv[], | ||
const GOptions & | user_defined_options | ||
) |
Library based constructor: each library can define its own options,
argc | number of arguments, passed from "main" |
argv | argument arrays of *chars, passed from main |
user_defined_options | vector of user options, usually returned by a defineOptions() function |
Definition at line 21 of file goptions.cc.
|
inline |
goptions_to_add | The GOptions object to be added. |
Definition at line 158 of file goptions.h.
void GOptions::defineOption | ( | const GVariable & | gvar, |
const std::string & | help | ||
) |
gvar | The GVariable object representing the scalar option. |
help | The help message for the option. |
Definition at line 182 of file goptions.cc.
void GOptions::defineOption | ( | const std::string & | name, |
const std::string & | description, | ||
const std::vector< GVariable > & | gvars, | ||
const std::string & | help | ||
) |
name | The name of the option. |
description | The description of the option. |
gvars | A vector of GVariable objects representing the structured option. |
help | The help message for the option. |
Definition at line 193 of file goptions.cc.
void GOptions::defineSwitch | ( | const std::string & | name, |
const std::string & | description | ||
) |
name | The name of the switch. |
description | The description of the switch. |
Definition at line 172 of file goptions.cc.
template bool GOptions::get_variable_in_option< bool > | ( | const YAML::Node & | node, |
const string & | variable_name, | ||
const T & | default_value | ||
) |
node | The YAML::Node containing the variable. |
variable_name | The name of the variable. |
default_value | The default value to return if the variable is not found. |
Definition at line 408 of file goptions.cc.
YAML::Node GOptions::getOptionMapInNode | ( | string | option_name, |
string | map_key | ||
) |
option_name | The name of the option. |
map_key | The key of the map within the option. |
Definition at line 388 of file goptions.cc.
|
inline |
tag | The name of the option. |
Definition at line 113 of file goptions.h.
|
inline |
Definition at line 144 of file goptions.h.
double GOptions::getScalarDouble | ( | const std::string & | tag | ) | const |
tag | The name of the option. |
Definition at line 227 of file goptions.cc.
float GOptions::getScalarFloat | ( | const std::string & | tag | ) | const |
tag | The name of the option. |
Definition at line 215 of file goptions.cc.
int GOptions::getScalarInt | ( | const std::string & | tag | ) | const |
tag | The name of the option. |
Definition at line 203 of file goptions.cc.
string GOptions::getScalarString | ( | const std::string & | tag | ) | const |
tag | The name of the option. |
Definition at line 239 of file goptions.cc.
bool GOptions::getSwitch | ( | const std::string & | tag | ) | const |
tag | The name of the switch. |
Definition at line 374 of file goptions.cc.
|
inline |
Definition at line 151 of file goptions.h.
int GOptions::getVerbosityFor | ( | const std::string & | tag | ) | const |
tag | The name of the verbosity option. |
Definition at line 426 of file goptions.cc.
|
inline |
Definition at line 183 of file goptions.h.