aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/OptBool.h
diff options
context:
space:
mode:
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