diff --git a/data/forms/options.form b/data/forms/options.form
index 7b56912ea..8cf565137 100644
--- a/data/forms/options.form
+++ b/data/forms/options.form
@@ -3,60 +3,47 @@
diff --git a/framework/configfile.cpp b/framework/configfile.cpp
index 5b91daedd..521aab88c 100644
--- a/framework/configfile.cpp
+++ b/framework/configfile.cpp
@@ -365,6 +365,27 @@ class ConfigFileImpl
for (auto &optPair : this->optionSections)
std::cout << optPair.second << "\n";
}
+
+ std::map> getOptions()
+ {
+ std::map> options;
+ for (auto &optPair : this->optionSections)
+ {
+ std::vector vec;
+ for (auto &opt : optPair.second.options())
+ {
+ std::string short_name = opt->long_name();
+ size_t dot = short_name.find_last_of('.');
+ if (dot != std::string::npos)
+ {
+ short_name = short_name.substr(dot + 1);
+ }
+ vec.emplace_back(ConfigOption(optPair.first, short_name, opt->description()));
+ }
+ options[optPair.first] = vec;
+ }
+ return options;
+ }
};
ConfigFile::ConfigFile() { this->pimpl.reset(new ConfigFileImpl()); }
@@ -432,66 +453,59 @@ bool ConfigFile::loaded() const { return this->pimpl->loaded(); }
void ConfigFile::showHelp() { this->pimpl->showHelp(); }
-ConfigOptionString::ConfigOptionString(const UString section, const UString name,
- const UString description, const UString defaultValue)
- : section(section), name(name), description(description), defaultValue(defaultValue)
+std::map> ConfigFile::getOptions()
{
- config().addOptionString(section, name, "", description, defaultValue);
+ return this->pimpl->getOptions();
}
-UString ConfigOptionString::get() const
+ConfigOption::ConfigOption(const UString section, const UString name, const UString description)
+ : section(section), name(name), description(description)
+{
+}
+
+UString ConfigOption::getKey() const
{
if (section.empty())
- return config().getString(name);
+ return name;
else
- return config().getString(section + "." + name);
+ return section + "." + name;
}
+ConfigOptionString::ConfigOptionString(const UString section, const UString name,
+ const UString description, const UString defaultValue)
+ : ConfigOption(section, name, description), defaultValue(defaultValue)
+{
+ config().addOptionString(section, name, "", description, defaultValue);
+}
+
+UString ConfigOptionString::get() const { return config().getString(getKey()); }
+
ConfigOptionInt::ConfigOptionInt(const UString section, const UString name,
const UString description, const int defaultValue)
- : section(section), name(name), description(description), defaultValue(defaultValue)
+ : ConfigOption(section, name, description), defaultValue(defaultValue)
{
config().addOptionInt(section, name, "", description, defaultValue);
}
-int ConfigOptionInt::get() const
-{
-
- if (section.empty())
- return config().getInt(name);
- else
- return config().getInt(section + "." + name);
-}
+int ConfigOptionInt::get() const { return config().getInt(getKey()); }
ConfigOptionBool::ConfigOptionBool(const UString section, const UString name,
const UString description, const bool defaultValue)
- : section(section), name(name), description(description), defaultValue(defaultValue)
+ : ConfigOption(section, name, description), defaultValue(defaultValue)
{
config().addOptionBool(section, name, "", description, defaultValue);
}
-bool ConfigOptionBool::get() const
-{
- if (section.empty())
- return config().getBool(name);
- else
-
- return config().getBool(section + "." + name);
-}
+bool ConfigOptionBool::get() const { return config().getBool(getKey()); }
ConfigOptionFloat::ConfigOptionFloat(const UString section, const UString name,
const UString description, const float defaultValue)
+ : ConfigOption(section, name, description), defaultValue(defaultValue)
{
config().addOptionFloat(section, name, "", description, defaultValue);
}
-bool ConfigOptionFloat::get() const
-{
- if (section.empty())
- return config().getFloat(name);
- else
- return config().getFloat(section + "." + name);
-}
+bool ConfigOptionFloat::get() const { return config().getFloat(getKey()); }
void validate(boost::any &v, const std::vector &values, UString *, int)
{
diff --git a/framework/configfile.h b/framework/configfile.h
index 37c5a7d47..b7bf003e7 100644
--- a/framework/configfile.h
+++ b/framework/configfile.h
@@ -3,11 +3,14 @@
#include "library/sp.h"
#include "library/strings.h"
#include
+#include