|
goptions
|
Stores one configuration option (scalar or structured), including schema defaults and current value. More...
#include <goption.h>
Public Member Functions | |
| 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. | |
Friends | |
| class | GOptions |
| Grants GOptions : access to private members for parsing and serialization. | |
GOption : encapsulates:
Structured options are defined by a vector of GVariable : entries. If any schema entry uses goptions::NODFLT : as its default, that schema key becomes mandatory and the option becomes cumulative (expects a YAML sequence of maps).
GOptions : is a friend and drives parsing and saving.
|
inline |
Builds YAML nodes of the form:
The constructed node is stored in both:
defaultValue (schema/default snapshot),value (current resolved value), initially equal to the default.| dv | Scalar option descriptor (name, default value, description). |
| h | Multi-line help text shown in detailed help. |
|
inline |
The schema is defined by dv, where each GVariable : entry corresponds to one key. The default value node is constructed as a sequence of single-entry maps:
If any schema entry has value goptions::NODFLT : :
mandatory_keys isCumulative = true)For non-cumulative structured options, the current value is initialized to the default schema. For cumulative options, the current value is intentionally left unset until user values are provided, because mandatory keys require explicit user input.
| n | Option name. |
| desc | One-line description shown in summary help. |
| dv | Schema entries (keys, defaults, descriptions). |
| h | Multi-line help text shown in detailed help. |
| void GOption::set_sub_option_value | ( | const std::string & | subkey, |
| const std::string & | subvalue ) |
For a command-line payload like:
GOptions : locates the GOption : for "verbosity" and calls this method to update the "general" entry.
Update rules:
subkey is updated.subkey is updated.subkey does not exist in the stored structured value, the program exits with EC__NOOPTIONFOUND .| subkey | The sub-option key to update. |
| subvalue | The new value expressed as a string; it is parsed as YAML. |
Definition at line 270 of file goption.cc.