From 40de7d18bb5e91c049947344b8c632c40989ad10 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 5 Mar 2018 15:35:32 +0100 Subject: Added poi-config - view default configuration --- src/configuration.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src') 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) { - std::string r = vm[path].as(); + std::string r; + try { + r = vm[path].as(); + } catch (boost::bad_any_cast &) { + // try int + try { + r = std::to_string(vm[path].as()); + } catch (boost::bad_any_cast &) { + + // try bool, and crash if not that either + r = vm[path].as() ? "true" : "false"; + } + + } // check if it's a path if(r.front() == '~') { @@ -49,6 +62,10 @@ public: return std::optional(vm[path].as()); } + const std::vector> & options() { + return desc.options(); + } + private: boost::program_options::options_description desc; boost::program_options::variables_map vm; -- cgit v1.2.1