1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
9 #include <unordered_map>
12 #include <cm/string_view>
14 #include "cmLinkedTree.h"
15 #include "cmString.hxx"
18 /** \class cmDefinitions
19 * \brief Store a scope of variable definitions for CMake language.
21 * This stores the state of variable definitions (set or unset) for
22 * one scope. Sets are always local. Gets search parent scopes
23 * transitively and save results locally.
27 using StackIter = cmLinkedTree<cmDefinitions>::iterator;
30 // -- Static member functions
32 static cmValue Get(const std::string& key, StackIter begin, StackIter end);
34 static void Raise(const std::string& key, StackIter begin, StackIter end);
36 static bool HasKey(const std::string& key, StackIter begin, StackIter end);
38 static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
40 static cmDefinitions MakeClosure(StackIter begin, StackIter end);
42 // -- Member functions
44 /** Set a value associated with a key. */
45 void Set(const std::string& key, cm::string_view value);
47 /** Unset a definition. */
48 void Unset(const std::string& key);
51 /** String with existence boolean. */
56 Def(cm::string_view value)
64 std::unordered_map<cm::String, Def> Map;
66 static Def const& GetInternal(const std::string& key, StackIter begin,
67 StackIter end, bool raise);