aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/include
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/include')
-rw-r--r--toolsrc/include/opt_bool.h28
-rw-r--r--toolsrc/include/vcpkg_cmd_arguments.h6
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;