diff options
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/OptBool.h | 48 | ||||
| -rw-r--r-- | toolsrc/include/PostBuildLint_BuildInfo.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/VcpkgCmdArguments.h | 8 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_optional.h | 25 |
4 files changed, 30 insertions, 54 deletions
diff --git a/toolsrc/include/OptBool.h b/toolsrc/include/OptBool.h deleted file mode 100644 index 90655cb7e..000000000 --- a/toolsrc/include/OptBool.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include <map> -#include <string> - -namespace vcpkg -{ - struct OptBool final - { - enum class BackingEnum - { - UNSPECIFIED = 0, - ENABLED, - DISABLED - }; - - static OptBool parse(const std::string& s); - - template<class T> - static OptBool from_map(const std::map<T, std::string>& map, const T& key); - - constexpr OptBool() : backing_enum(BackingEnum::UNSPECIFIED) {} - constexpr explicit OptBool(BackingEnum backing_enum) : backing_enum(backing_enum) {} - constexpr operator BackingEnum() const { return backing_enum; } - - private: - BackingEnum backing_enum; - }; - - namespace OptBoolC - { - static constexpr OptBool UNSPECIFIED(OptBool::BackingEnum::UNSPECIFIED); - static constexpr OptBool ENABLED(OptBool::BackingEnum::ENABLED); - static constexpr OptBool DISABLED(OptBool::BackingEnum::DISABLED); - } - - template<class T> - OptBool OptBool::from_map(const std::map<T, std::string>& map, const T& key) - { - auto it = map.find(key); - if (it == map.cend()) - { - return OptBoolC::UNSPECIFIED; - } - - return parse(*it); - } -} diff --git a/toolsrc/include/PostBuildLint_BuildInfo.h b/toolsrc/include/PostBuildLint_BuildInfo.h index 4a4560b8e..29fa09e6c 100644 --- a/toolsrc/include/PostBuildLint_BuildInfo.h +++ b/toolsrc/include/PostBuildLint_BuildInfo.h @@ -1,6 +1,5 @@ #pragma once -#include "OptBool.h" #include "PostBuildLint_BuildPolicies.h" #include "PostBuildLint_LinkageType.h" #include "filesystem_fs.h" @@ -15,7 +14,7 @@ namespace vcpkg::PostBuildLint LinkageType crt_linkage; LinkageType library_linkage; - std::map<BuildPolicies, OptBool> policies; + std::map<BuildPolicies, bool> policies; }; BuildInfo read_build_info(const Files::Filesystem& fs, const fs::path& filepath); diff --git a/toolsrc/include/VcpkgCmdArguments.h b/toolsrc/include/VcpkgCmdArguments.h index 7cab0f192..316987100 100644 --- a/toolsrc/include/VcpkgCmdArguments.h +++ b/toolsrc/include/VcpkgCmdArguments.h @@ -1,6 +1,6 @@ #pragma once -#include "OptBool.h" +#include "vcpkg_optional.h" #include <memory> #include <unordered_set> #include <vector> @@ -14,9 +14,9 @@ namespace vcpkg std::unique_ptr<std::string> vcpkg_root_dir; std::unique_ptr<std::string> triplet; - OptBool debug = OptBoolC::UNSPECIFIED; - OptBool sendmetrics = OptBoolC::UNSPECIFIED; - OptBool printmetrics = OptBoolC::UNSPECIFIED; + Optional<bool> debug = nullopt; + Optional<bool> sendmetrics = nullopt; + Optional<bool> printmetrics = nullopt; std::string command; std::vector<std::string> command_arguments; diff --git a/toolsrc/include/vcpkg_optional.h b/toolsrc/include/vcpkg_optional.h index b5a3268f0..03fa50678 100644 --- a/toolsrc/include/vcpkg_optional.h +++ b/toolsrc/include/vcpkg_optional.h @@ -64,4 +64,29 @@ namespace vcpkg bool m_is_present; T m_t; }; + + template<class T> + bool operator==(const Optional<T>& o, const T& t) + { + if (auto p = o.get()) return *p == t; + return false; + } + template<class T> + bool operator==(const T& t, const Optional<T>& o) + { + if (auto p = o.get()) return t == *p; + return false; + } + template<class T> + bool operator!=(const Optional<T>& o, const T& t) + { + if (auto p = o.get()) return *p != t; + return true; + } + template<class T> + bool operator!=(const T& t, const Optional<T>& o) + { + if (auto p = o.get()) return t != *p; + return true; + } } |
