14 #include "yaml-cpp/yaml.h"
35 GVariable(std::string n, std::string val, std::string d)
54 GVariable(std::string n,
const char* val, std::string d)
92 GOption(
GVariable dv, std::string h) : name(dv.name), description(dv.description), help(h) {
93 defaultValue = YAML::Load(name +
": " + dv.
value);
104 GOption(std::string n, std::string desc, std::vector<GVariable> dv, std::string h)
105 : name(n), description(desc), help(h) {
107 for (
const auto& v : dv) {
108 YAML::Node this_node = YAML::Load(v.name +
": " + v.value);
109 nodes.push_back(this_node);
110 gvar_descs.push_back(v.description);
113 mandatory_keys.push_back(v.name);
116 defaultValue[n] = nodes;
117 if (!isCumulative) { value = defaultValue; }
132 bool isCumulative =
false;
133 const std::string name;
134 const std::string description;
135 const std::string help;
138 YAML::Node defaultValue;
139 std::vector<std::string> gvar_descs;
140 std::vector<std::string> mandatory_keys;
146 void saveOption(std::ofstream* yamlConf)
const;
152 void printHelp(
bool detailed)
const;
158 std::string detailedHelp()
const;
164 void set_scalar_value(
const std::string& v);
170 void set_value(
const YAML::Node& v);
177 bool does_the_option_set_all_necessary_values(
const YAML::Node& v);
Represents a configurable option with a name, value(s), description, and help text.
GOption(GVariable dv, std::string h)
Constructor for a scalar option with a default value.
GOption(std::string n, std::string desc, std::vector< GVariable > dv, std::string h)
Constructor for a sequence option.
void set_sub_option_value(const std::string &subkey, const std::string &subvalue)
Sets the value of a sub–option using dot–notation.
The GOptions class manages command-line options and switches.
Encapsulates a variable with a name, value, and description.
GVariable(std::string n, const char *val, std::string d)
Constructor for initializing a variable with a const char* value.
GVariable(std::string n, std::string val, std::string d)
Constructor for initializing a variable with a string value.
std::string name
The name of the variable.
std::string value
The value of the variable, stored as a string.
std::string description
A brief description of the variable.
GVariable(std::string n, bool val, std::string d)
Constructor for initializing a variable with a boolean value.
GVariable(std::string n, double val, std::string d)
Constructor for initializing a variable with a double value.
GVariable(std::string n, int val, std::string d)
Constructor for initializing a variable with an integer value.