19#include "yaml-cpp/yaml.h"
45 GVariable(std::string n, std::string val, std::string d)
64 GVariable(std::string n,
const char* val, std::string d)
123 GOption(
GVariable dv, std::string h) : name(dv.name), description(dv.description), help(h) {
124 defaultValue = YAML::Load(name +
": " + dv.
value);
125 value = defaultValue;
153 GOption(std::string n, std::string desc, std::vector<GVariable> dv, std::string h)
154 : name(n), description(desc), help(h) {
156 for (
const auto& v : dv) {
157 YAML::Node this_node = YAML::Load(v.name +
": " + v.value);
158 nodes.push_back(this_node);
159 gvar_descs.push_back(v.description);
162 mandatory_keys.push_back(v.name);
165 defaultValue[n] = nodes;
166 if (!isCumulative) { value = defaultValue; }
191 bool isCumulative =
false;
192 const std::string name;
193 const std::string description;
194 const std::string help;
197 YAML::Node defaultValue;
198 std::vector<std::string> gvar_descs;
199 std::vector<std::string> mandatory_keys;
213 void saveOption(std::ofstream* yamlConf)
const;
227 void printHelp(
bool detailed)
const;
240 std::string detailedHelp()
const;
253 void set_scalar_value(
const std::string& v);
271 void set_value(
const YAML::Node& v);
283 bool does_the_option_set_all_necessary_values(
const YAML::Node& v);
Stores one configuration option (scalar or structured), including schema defaults and current value.
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 structured option schema (map/sequence).
void set_sub_option_value(const std::string &subkey, const std::string &subvalue)
Updates a structured sub-option using dot-notation semantics.
Parses, stores, and exposes command-line options and YAML configuration values.
Conventions, constants, and error codes for the GOptions : / GOption : subsystem.
const std::string NODFLT
Marker literal indicating "no default value" for a structured option key.
Describes a schema entry: key name, default value, and user-facing description.
GVariable(std::string n, const char *val, std::string d)
Constructor for initializing a variable with a C-string default.
GVariable(std::string n, std::string val, std::string d)
Constructor for initializing a variable with a string default.
std::string name
Variable name (option name for scalar options, schema key name for structured options).
std::string value
Default value as a string (or goptions::NODFLT : to mark as mandatory).
std::string description
Human-readable description used in help output.
GVariable(std::string n, bool val, std::string d)
Constructor for initializing a variable with a boolean default.
GVariable(std::string n, double val, std::string d)
Constructor for initializing a variable with a double default.
GVariable(std::string n, int val, std::string d)
Constructor for initializing a variable with an integer default.