summaryrefslogtreecommitdiff
path: root/Source/cmDefinitions.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmDefinitions.h')
-rw-r--r--Source/cmDefinitions.h46
1 files changed, 24 insertions, 22 deletions
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 6c252bee5..0e38fb1af 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -5,11 +5,15 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <functional>
#include <string>
#include <unordered_map>
#include <vector>
+#include <cm/string_view>
+
#include "cmLinkedTree.h"
+#include "cmString.hxx"
/** \class cmDefinitions
* \brief Store a scope of variable definitions for CMake language.
@@ -20,9 +24,11 @@
*/
class cmDefinitions
{
- typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
+ using StackIter = cmLinkedTree<cmDefinitions>::iterator;
public:
+ // -- Static member functions
+
static const std::string* Get(const std::string& key, StackIter begin,
StackIter end);
@@ -30,41 +36,37 @@ public:
static bool HasKey(const std::string& key, StackIter begin, StackIter end);
- /** Set (or unset if null) a value associated with a key. */
- void Set(const std::string& key, const char* value);
-
- std::vector<std::string> UnusedKeys() const;
-
static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
static cmDefinitions MakeClosure(StackIter begin, StackIter end);
+ // -- Member functions
+
+ /** Set a value associated with a key. */
+ void Set(const std::string& key, cm::string_view value);
+
+ /** Unset a definition. */
+ void Unset(const std::string& key);
+
+ /** List of unused keys. */
+ std::vector<std::string> UnusedKeys() const;
+
private:
- // String with existence boolean.
- struct Def : public std::string
+ /** String with existence boolean. */
+ struct Def
{
- private:
- typedef std::string std_string;
-
public:
Def() = default;
- Def(const char* v)
- : std_string(v ? v : "")
- , Exists(v ? true : false)
- {
- }
- Def(const std_string& v)
- : std_string(v)
- , Exists(true)
+ Def(cm::string_view value)
+ : Value(value)
{
}
- bool Exists = false;
+ cm::String Value;
bool Used = false;
};
static Def NoDef;
- typedef std::unordered_map<std::string, Def> MapType;
- MapType Map;
+ std::unordered_map<cm::String, Def> Map;
static Def const& GetInternal(const std::string& key, StackIter begin,
StackIter end, bool raise);