aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configuration.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/configuration.h b/src/configuration.h
index c9223eb..5038a4d 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -37,7 +37,20 @@ public:
#endif
if constexpr(std::is_same_v<T, std::string>) {
- std::string r = vm[path].as<std::string>();
+ std::string r;
+ try {
+ r = vm[path].as<std::string>();
+ } catch (boost::bad_any_cast &) {
+ // try int
+ try {
+ r = std::to_string(vm[path].as<int>());
+ } catch (boost::bad_any_cast &) {
+
+ // try bool, and crash if not that either
+ r = vm[path].as<bool>() ? "true" : "false";
+ }
+
+ }
// check if it's a path
if(r.front() == '~') {
@@ -49,6 +62,10 @@ public:
return std::optional<T>(vm[path].as<T>());
}
+ const std::vector<boost::shared_ptr<boost::program_options::option_description>> & options() {
+ return desc.options();
+ }
+
private:
boost::program_options::options_description desc;
boost::program_options::variables_map vm;