20#include "yaml-cpp/yaml.h"
47 GVariable(std::string n, std::string val, std::string d)
67 GVariable(std::string n,
const char* val, std::string d)
92 GVariable(std::string n, std::nullopt_t, std::string d)
138 GOption(
GVariable dv, std::string h) : name(dv.name), description(dv.description), help(h) {
140 value = defaultValue;
168 GOption(std::string n, std::string desc, std::vector<GVariable> dv, std::string h)
169 : name(n), description(desc), help(h) {
171 for (
const auto& v : dv) {
172 YAML::Node this_node;
173 this_node[v.name] = v.defaultValue;
174 nodes.push_back(this_node);
175 gvar_descs.push_back(v.description);
176 gvar_required.push_back(v.required);
179 mandatory_keys.push_back(v.name);
182 defaultValue[n] = nodes;
183 if (!isCumulative) { value = defaultValue; }
209 bool isCumulative =
false;
210 const std::string name;
211 const std::string description;
212 const std::string help;
215 YAML::Node defaultValue;
216 std::vector<std::string> gvar_descs;
217 std::vector<bool> gvar_required;
218 std::vector<std::string> mandatory_keys;
232 void saveOption(std::ofstream* yamlConf)
const;
246 void printHelp(
bool detailed)
const;
259 std::string detailedHelp()
const;
272 void set_scalar_value(
const std::string& v);
290 void set_value(
const YAML::Node& v);
302 bool does_the_option_set_all_necessary_values(
const YAML::Node& v);
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).
friend class GOptions
Grants GOptions : access to private members for parsing and serialization.
void set_sub_option_value(const std::string &subkey, const std::string &subvalue)
Updates a structured sub-option using dot-notation semantics.
Conventions, constants, and error codes for the GOptions : / GOption : subsystem.
Describes a schema entry: key name, default value, and user-facing description.
GVariable(std::string n, goptions::RequiredValue, std::string d)
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).
YAML::Node defaultValue
Typed default; null for optional-null and required fields.
bool required
Whether a structured field must be supplied by the user.
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, std::nullopt_t, std::string d)
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.