diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-01-31 13:31:45 -0800 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-02-01 11:42:41 -0800 |
| commit | bd1a10e5b97b073731cbb97e26611edf317c16d5 (patch) | |
| tree | 0c55b8322c3d6598ebbe67985ee3c2f5a2421c86 /toolsrc/include | |
| parent | f2d40c5b81cba14c86d836bc21978c4f3f691538 (diff) | |
| download | vcpkg-bd1a10e5b97b073731cbb97e26611edf317c16d5.tar.gz vcpkg-bd1a10e5b97b073731cbb97e26611edf317c16d5.zip | |
Enhance the opt_bool type
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/opt_bool.h | 28 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_cmd_arguments.h | 6 |
2 files changed, 28 insertions, 6 deletions
diff --git a/toolsrc/include/opt_bool.h b/toolsrc/include/opt_bool.h index 42133fb7a..06642a399 100644 --- a/toolsrc/include/opt_bool.h +++ b/toolsrc/include/opt_bool.h @@ -1,11 +1,33 @@ #pragma once -namespace vcpkg +#include <string> +#include <map> + +namespace vcpkg::opt_bool { - enum class opt_bool + enum class type { - UNSPECIFIED, + UNSPECIFIED = 0, ENABLED, DISABLED }; + + type parse(const std::string& s); + + template <class T> + type from_map(const std::map<T, std::string>& map, const T& key) + { + auto it = map.find(key); + if (it == map.cend()) + { + return type::UNSPECIFIED; + } + + return parse(*it); + } } + +namespace vcpkg +{ + using opt_bool_t = opt_bool::type; +}
\ No newline at end of file diff --git a/toolsrc/include/vcpkg_cmd_arguments.h b/toolsrc/include/vcpkg_cmd_arguments.h index 79e12841d..91f7de8ac 100644 --- a/toolsrc/include/vcpkg_cmd_arguments.h +++ b/toolsrc/include/vcpkg_cmd_arguments.h @@ -14,9 +14,9 @@ namespace vcpkg std::unique_ptr<std::string> vcpkg_root_dir; std::unique_ptr<std::string> target_triplet; - opt_bool debug = opt_bool::UNSPECIFIED; - opt_bool sendmetrics = opt_bool::UNSPECIFIED; - opt_bool printmetrics = opt_bool::UNSPECIFIED; + opt_bool_t debug = opt_bool_t::UNSPECIFIED; + opt_bool_t sendmetrics = opt_bool_t::UNSPECIFIED; + opt_bool_t printmetrics = opt_bool_t::UNSPECIFIED; std::string command; std::vector<std::string> command_arguments; |
