97 if (yamlConf !=
nullptr) {
98 if (yamlConf->is_open()) { yamlConf->close(); }
118 void defineSwitch(
const std::string& name,
const std::string& description);
145 void defineOption(
const std::string& name,
const std::string& description,
const std::vector<GVariable>&
gvars,
146 const std::string& help);
208 std::cerr <<
"Option " <<
tag <<
" does not exist. Exiting." << std::endl;
211 return getOptionIterator(
tag)->value.begin()->second;
288 for (
const auto&
opt :
src.getOptions()) {
291 [&
opt](
const GOption&
o) { return o.name == opt.name; });
298 for (
const auto&
sw :
src.getSwitches()) {
303 for (
const auto&
v :
src.option_verbosity_names) {
304 auto same = std::find_if(
349 template <
typename T>
374 std::map<std::string, GSwitch> switches;
375 std::ofstream* yamlConf{};
376 std::string executableName;
377 std::string executableCallingDir;
379 std::string installDir;
380 std::vector<std::string> yaml_files;
382 std::vector<std::string> findYamls(
int argc,
char*
argv[]);
383 void setOptionsValuesFromYamlFile(
const std::string&
yaml);
385 std::vector<GOption>::iterator getOptionIterator(
const std::string& name);
386 [[
nodiscard]] std::vector<GOption>::const_iterator getOptionIterator(
const std::string& name)
const;
387 void printOptionOrSwitchHelp(
const std::string&
tag)
const;
388 void printHelp()
const;
389 void printWebHelp()
const;
390 void saveOptions()
const;
391 void print_version();
Stores one configuration option (scalar or structured), including schema defaults and current value.
Parses, stores, and exposes command-line options and YAML configuration values.
std::string option_verbosity_name
Name used when constructing the verbosity/debug schema helper.
bool getSwitch(const std::string &tag) const
Retrieves the status of a switch.
const std::vector< GOption > & getOptions() const
Returns the list of defined options.
YAML::Node getOptionNode(const std::string &tag) const
Retrieves the YAML node for the specified option.
void addOptionTitle(const std::string &name)
GOptions(std::string name)
Constructor for creating verbosity/debug schema helpers.
void defineSwitch(const std::string &name, const std::string &description)
Defines and adds a command-line switch.
std::string getScalarString(const std::string &tag) const
Retrieves the value of a scalar string option.
GOptions()
Default constructor.
void defineOption(const GVariable &gvar, const std::string &help)
Defines and adds a scalar option.
YAML::Node getOptionMapInNode(const std::string &option_name, const std::string &map_key) const
Retrieves a map entry value from a structured option stored as a sequence of maps.
T get_variable_in_option(const YAML::Node &node, const std::string &variable_name, const T &default_value)
Retrieves a typed variable from a YAML node within an option.
double getScalarDouble(const std::string &tag) const
Retrieves the value of a scalar double option.
bool doesOptionExist(const std::string &tag) const
Checks if an option exists.
int getScalarInt(const std::string &tag) const
Retrieves the value of a scalar integer option.
std::vector< std::string > getYamlFiles() const
Returns the list of YAML file paths detected on the command line.
void addGOptions(const GOptions &src)
Merges options and switches from another GOptions : into this one.
const std::map< std::string, GSwitch > & getSwitches() const
Returns the map of defined switches.
int getDebugFor(const std::string &tag) const
Retrieves the debug level for the specified tag.
int getVerbosityFor(const std::string &tag) const
Retrieves the verbosity level for the specified tag.
std::vector< GVariable > option_verbosity_names
Schema entries used to define the verbosity and debug structured options.
Definitions of GVariable : and GOption : used by GOptions : .
#define EC__NOOPTIONFOUND
Option/switch/key not found, or invalid command-line token.
GOptions & operator+=(GOptions &original, const GOptions &optionsToAdd)
Overloaded operator to add options and switches from one GOptions : to another.
Definition of GSwitch : the boolean command-line switch type used by GOptions : .
#define UNINITIALIZEDSTRINGQUANTITY
Describes a schema entry: key name, default value, and user-facing description.