aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/OptBool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'toolsrc/src/OptBool.cpp')
-rw-r--r--toolsrc/src/OptBool.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/toolsrc/src/OptBool.cpp b/toolsrc/src/OptBool.cpp
new file mode 100644
index 000000000..1c063c92e
--- /dev/null
+++ b/toolsrc/src/OptBool.cpp
@@ -0,0 +1,29 @@
+#include "pch.h"
+#include "OptBool.h"
+#include "vcpkg_Checks.h"
+
+namespace vcpkg::OptBool
+{
+ 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 OptBoolT::UNSPECIFIED;
+ }
+
+ if (s == ENABLED_NAME)
+ {
+ return OptBoolT::ENABLED;
+ }
+
+ if (s == DISABLED_NAME)
+ {
+ return OptBoolT::DISABLED;
+ }
+
+ Checks::exit_with_message(VCPKG_LINE_INFO, "Could not convert string [%s] to OptBool", s);
+ }
+}