mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
cmDefinitions: Remove const char* based Set method
- Removes `cmDefinitions::Set` method overload that takes a `const char*` value argument. - Updates calls to `cmDefinitions::Set` to use the `cm::string_view` based version instead.
This commit is contained in:
@@ -32,16 +32,6 @@ 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)
|
||||
{
|
||||
if (value) {
|
||||
this->Set(key, cm::string_view(value));
|
||||
} else {
|
||||
this->Unset(key);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set a value associated with a key. */
|
||||
void Set(const std::string& key, cm::string_view value);
|
||||
|
||||
|
@@ -308,8 +308,8 @@ cmStateSnapshot cmState::Reset()
|
||||
pos->Parent = this->VarTree.Root();
|
||||
pos->Root = this->VarTree.Root();
|
||||
|
||||
pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
|
||||
pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
|
||||
pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir);
|
||||
pos->Vars->Set("CMAKE_BINARY_DIR", binDir);
|
||||
}
|
||||
|
||||
this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "",
|
||||
|
@@ -222,14 +222,14 @@ bool cmStateSnapshot::IsInitialized(std::string const& name) const
|
||||
}
|
||||
|
||||
void cmStateSnapshot::SetDefinition(std::string const& name,
|
||||
std::string const& value)
|
||||
cm::string_view value)
|
||||
{
|
||||
this->Position->Vars->Set(name, value.c_str());
|
||||
this->Position->Vars->Set(name, value);
|
||||
}
|
||||
|
||||
void cmStateSnapshot::RemoveDefinition(std::string const& name)
|
||||
{
|
||||
this->Position->Vars->Set(name, nullptr);
|
||||
this->Position->Vars->Unset(name);
|
||||
}
|
||||
|
||||
std::vector<std::string> cmStateSnapshot::UnusedKeys() const
|
||||
@@ -264,7 +264,11 @@ bool cmStateSnapshot::RaiseScope(std::string const& var, const char* varDef)
|
||||
cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root);
|
||||
|
||||
// Now update the definition in the parent scope.
|
||||
this->Position->Parent->Set(var, varDef);
|
||||
if (varDef) {
|
||||
this->Position->Parent->Set(var, varDef);
|
||||
} else {
|
||||
this->Position->Parent->Unset(var);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cm_string_view.hxx"
|
||||
|
||||
#include "cmLinkedTree.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
@@ -24,7 +26,7 @@ public:
|
||||
|
||||
std::string const* GetDefinition(std::string const& name) const;
|
||||
bool IsInitialized(std::string const& name) const;
|
||||
void SetDefinition(std::string const& name, std::string const& value);
|
||||
void SetDefinition(std::string const& name, cm::string_view value);
|
||||
void RemoveDefinition(std::string const& name);
|
||||
std::vector<std::string> UnusedKeys() const;
|
||||
std::vector<std::string> ClosureKeys() const;
|
||||
|
Reference in New Issue
Block a user