diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-03-05 15:35:32 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-03-05 15:35:32 +0100 |
commit | 40de7d18bb5e91c049947344b8c632c40989ad10 (patch) | |
tree | 33c0a3a6500ea0c2d7b62f192f685bb93d7b99e0 /src | |
parent | Fixed pkgbuild again (diff) | |
download | smolbote-40de7d18bb5e91c049947344b8c632c40989ad10.tar.xz |
Added poi-config
- view default configuration
Diffstat (limited to 'src')
-rw-r--r-- | src/configuration.h | 19 |
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; |