aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/OptBool.h
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-04-03 14:43:44 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-04-04 16:44:41 -0700
commit1c1423014f5aab77339ebcb261e1d33e3106ec5d (patch)
tree61d1e76d550cecefbc4a31b4803137d9cbcf0c43 /toolsrc/include/OptBool.h
parent830a4d97d470dad6ca4a27ef1eecce17057fa432 (diff)
downloadvcpkg-1c1423014f5aab77339ebcb261e1d33e3106ec5d.tar.gz
vcpkg-1c1423014f5aab77339ebcb261e1d33e3106ec5d.zip
opt_bool->OptBool
Diffstat (limited to 'toolsrc/include/OptBool.h')
-rw-r--r--toolsrc/include/OptBool.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/toolsrc/include/OptBool.h b/toolsrc/include/OptBool.h
new file mode 100644
index 000000000..4098e6f03
--- /dev/null
+++ b/toolsrc/include/OptBool.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <string>
+#include <map>
+
+namespace vcpkg::OptBool
+{
+ enum class Type
+ {
+ 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 OptBoolT = OptBool::Type;
+} \ No newline at end of file