diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-12-21 19:39:04 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-01-06 23:52:30 (GMT) |
commit | fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e (patch) | |
tree | c4dbf6fc64a862facea8948d350df173393a2629 /Source/cmCMakePresetsGraphInternal.h | |
parent | 13e71b7c3ec9351f0c25656e72c1c0199ddf771c (diff) | |
download | CMake-fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e.zip CMake-fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e.tar.gz CMake-fd6ea2f67fc5fd1aee27ae92d6a16bc0fba1209e.tar.bz2 |
Refactor: Rename cmCMakePresetsFile to cmCMakePresetsGraph
And change all references to "file" to say "graph" instead.
Diffstat (limited to 'Source/cmCMakePresetsGraphInternal.h')
-rw-r--r-- | Source/cmCMakePresetsGraphInternal.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/Source/cmCMakePresetsGraphInternal.h b/Source/cmCMakePresetsGraphInternal.h new file mode 100644 index 0000000..b2e6791 --- /dev/null +++ b/Source/cmCMakePresetsGraphInternal.h @@ -0,0 +1,112 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include <memory> + +#include "cmCMakePresetsGraph.h" + +#define CHECK_OK(expr) \ + do { \ + auto _result = expr; \ + if (_result != ReadFileResult::READ_OK) \ + return _result; \ + } while (false) + +namespace cmCMakePresetsGraphInternal { +enum class ExpandMacroResult +{ + Ok, + Ignore, + Error, +}; + +using MacroExpander = std::function<ExpandMacroResult( + const std::string&, const std::string&, std::string&, int version)>; +} + +class cmCMakePresetsGraph::Condition +{ +public: + virtual ~Condition() = default; + + virtual bool Evaluate( + const std::vector<cmCMakePresetsGraphInternal::MacroExpander>& expanders, + int version, cm::optional<bool>& out) const = 0; + virtual bool IsNull() const { return false; } +}; + +namespace cmCMakePresetsGraphInternal { + +class NullCondition : public cmCMakePresetsGraph::Condition +{ + bool Evaluate(const std::vector<MacroExpander>& /*expanders*/, + int /*version*/, cm::optional<bool>& out) const override + { + out = true; + return true; + } + + bool IsNull() const override { return true; } +}; + +class ConstCondition : public cmCMakePresetsGraph::Condition +{ +public: + bool Evaluate(const std::vector<MacroExpander>& /*expanders*/, + int /*version*/, cm::optional<bool>& out) const override + { + out = this->Value; + return true; + } + + bool Value; +}; + +class EqualsCondition : public cmCMakePresetsGraph::Condition +{ +public: + bool Evaluate(const std::vector<MacroExpander>& expanders, int version, + cm::optional<bool>& out) const override; + + std::string Lhs; + std::string Rhs; +}; + +class InListCondition : public cmCMakePresetsGraph::Condition +{ +public: + bool Evaluate(const std::vector<MacroExpander>& expanders, int version, + cm::optional<bool>& out) const override; + + std::string String; + std::vector<std::string> List; +}; + +class MatchesCondition : public cmCMakePresetsGraph::Condition +{ +public: + bool Evaluate(const std::vector<MacroExpander>& expanders, int version, + cm::optional<bool>& out) const override; + + std::string String; + std::string Regex; +}; + +class AnyAllOfCondition : public cmCMakePresetsGraph::Condition +{ +public: + bool Evaluate(const std::vector<MacroExpander>& expanders, int version, + cm::optional<bool>& out) const override; + + std::vector<std::unique_ptr<Condition>> Conditions; + bool StopValue; +}; + +class NotCondition : public cmCMakePresetsGraph::Condition +{ +public: + bool Evaluate(const std::vector<MacroExpander>& expanders, int version, + cm::optional<bool>& out) const override; + + std::unique_ptr<Condition> SubCondition; +}; +} |