12#include <gemc/guts/gutsConventions.h>
97 if (yamlConf !=
nullptr) {
98 if (yamlConf->is_open()) { yamlConf->close(); }
120 void defineSwitch(
const std::string& name,
const std::string& description,
bool default_status =
false);
147 void defineOption(
const std::string& name,
const std::string& description,
const std::vector<GVariable>& gvars,
148 const std::string& help);
159 [[nodiscard]]
int getScalarInt(
const std::string& tag)
const;
181 [[nodiscard]] std::string
getScalarString(
const std::string& tag)
const;
189 [[nodiscard]]
bool getSwitch(
const std::string& tag)
const;
208 [[nodiscard]]
inline YAML::Node
getOptionNode(
const std::string& tag)
const {
210 std::cerr <<
"Option " << tag <<
" does not exist. Exiting." << std::endl;
213 const auto& option_value = getOptionIterator(tag)->value;
214 if (!option_value || option_value.size() == 0) {
return YAML::Node{}; }
215 return option_value.begin()->second;
232 [[nodiscard]] YAML::Node
getOptionMapInNode(
const std::string& option_name,
const std::string& map_key)
const;
269 [[nodiscard]]
int getDebugFor(
const std::string& tag)
const;
283 [[nodiscard]]
const std::map<std::string, GSwitch>&
getSwitches()
const {
return switches; }
305 auto already = std::find_if(
307 [&opt](
const GOption& o) { return o.name == opt.name; });
320 auto same = std::find_if(
322 [&v](
const GVariable& existing) { return existing.name == v.name; });
348 std::string option_verbosity_name_desc = name +
" verbosity level or debug switch";
365 template <
typename T>
366 T
get_variable_in_option(
const YAML::Node& node,
const std::string& variable_name,
const T& default_value);
378 [[nodiscard]] std::vector<std::string>
getYamlFiles()
const {
return yaml_files; }
390 std::map<std::string, GSwitch> switches;
391 std::ofstream* yamlConf{};
392 std::string executableName;
393 std::string executableCallingDir;
395 std::string installDir;
396 std::vector<std::string> yaml_files;
398 std::vector<std::string> findYamls(
int argc,
char* argv[]);
399 void setOptionsValuesFromYamlFile(
const std::string& yaml);
400 void setOptionValuesFromCommandLineArgument(
const std::string& optionName,
const std::string& possibleYamlNode);
401 std::vector<GOption>::iterator getOptionIterator(
const std::string& name);
402 [[nodiscard]] std::vector<GOption>::const_iterator getOptionIterator(
const std::string& name)
const;
403 void printOptionOrSwitchHelp(
const std::string& tag)
const;
404 void printSearch(
const std::string& tag)
const;
405 void printHelp()
const;
406 void printWebHelp()
const;
407 void saveOptions()
const;
408 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 setOptionValueFromString(const std::string &optionName, const std::string &possibleYamlNode)
Updates an option value from a YAML-formatted string.
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.
void defineSwitch(const std::string &name, const std::string &description, bool default_status=false)
Defines and adds a command-line switch.
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.