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/src/opt_bool.cpp | |
| parent | f2d40c5b81cba14c86d836bc21978c4f3f691538 (diff) | |
| download | vcpkg-bd1a10e5b97b073731cbb97e26611edf317c16d5.tar.gz vcpkg-bd1a10e5b97b073731cbb97e26611edf317c16d5.zip | |
Enhance the opt_bool type
Diffstat (limited to 'toolsrc/src/opt_bool.cpp')
| -rw-r--r-- | toolsrc/src/opt_bool.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/toolsrc/src/opt_bool.cpp b/toolsrc/src/opt_bool.cpp new file mode 100644 index 000000000..324936fb4 --- /dev/null +++ b/toolsrc/src/opt_bool.cpp @@ -0,0 +1,29 @@ +#include "pch.h" +#include "opt_bool.h" +#include "vcpkg_Checks.h" + +namespace vcpkg::opt_bool +{ + static const std::string UNSPECIFIED_NAME = "unspecified"; + static const std::string ENABLED_NAME = "enabled"; + static const std::string DISABLED_NAME = "disabled"; + type parse(const std::string& s) + { + if (s == UNSPECIFIED_NAME) + { + return opt_bool_t::UNSPECIFIED; + } + + if (s == ENABLED_NAME) + { + return opt_bool_t::ENABLED; + } + + if (s == DISABLED_NAME) + { + return opt_bool_t::DISABLED; + } + + Checks::exit_with_message("Could not convert string [%s] to opt_bool", s); + } +} |
