aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include/opt_bool.h
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include/opt_bool.h')
-rw-r--r--toolsrc/include/opt_bool.h28
1 files changed, 25 insertions, 3 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