Merge topic 'clean-up-cmDefinitions'
a3358fac
cmDefinitions: Inline SetInternal method.23370344
cmDefinitions: Remove unused Set return value.b9f4dd39
cmDefinitions: Remove unused method.
This commit is contained in:
commit
036e449c66
|
@ -20,13 +20,6 @@ cmDefinitions::cmDefinitions(cmDefinitions* parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDefinitions::Reset(cmDefinitions* parent)
|
|
||||||
{
|
|
||||||
this->Up = parent;
|
|
||||||
this->Map.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmDefinitions::Def const&
|
cmDefinitions::Def const&
|
||||||
cmDefinitions::GetInternal(const std::string& key)
|
cmDefinitions::GetInternal(const std::string& key)
|
||||||
|
@ -45,23 +38,6 @@ cmDefinitions::GetInternal(const std::string& key)
|
||||||
return this->NoDef;
|
return this->NoDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
cmDefinitions::Def const&
|
|
||||||
cmDefinitions::SetInternal(const std::string& key, Def const& def)
|
|
||||||
{
|
|
||||||
if(this->Up || def.Exists)
|
|
||||||
{
|
|
||||||
// In lower scopes we store keys, defined or not.
|
|
||||||
return (this->Map[key] = def);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// In the top-most scope we need not store undefined keys.
|
|
||||||
this->Map.erase(key);
|
|
||||||
return this->NoDef;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmDefinitions::Get(const std::string& key)
|
const char* cmDefinitions::Get(const std::string& key)
|
||||||
{
|
{
|
||||||
|
@ -70,10 +46,19 @@ const char* cmDefinitions::Get(const std::string& key)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmDefinitions::Set(const std::string& key, const char* value)
|
void cmDefinitions::Set(const std::string& key, const char* value)
|
||||||
{
|
{
|
||||||
Def const& def = this->SetInternal(key, Def(value));
|
Def def(value);
|
||||||
return def.Exists? def.c_str() : 0;
|
if(this->Up || def.Exists)
|
||||||
|
{
|
||||||
|
// In lower scopes we store keys, defined or not.
|
||||||
|
this->Map[key] = def;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// In the top-most scope we need not store undefined keys.
|
||||||
|
this->Map.erase(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -30,9 +30,6 @@ public:
|
||||||
/** Construct with the given parent scope. */
|
/** Construct with the given parent scope. */
|
||||||
cmDefinitions(cmDefinitions* parent = 0);
|
cmDefinitions(cmDefinitions* parent = 0);
|
||||||
|
|
||||||
/** Reset object as if newly constructed. */
|
|
||||||
void Reset(cmDefinitions* parent = 0);
|
|
||||||
|
|
||||||
/** Returns the parent scope, if any. */
|
/** Returns the parent scope, if any. */
|
||||||
cmDefinitions* GetParent() const { return this->Up; }
|
cmDefinitions* GetParent() const { return this->Up; }
|
||||||
|
|
||||||
|
@ -41,7 +38,7 @@ public:
|
||||||
const char* Get(const std::string& key);
|
const char* Get(const std::string& key);
|
||||||
|
|
||||||
/** Set (or unset if null) a value associated with a key. */
|
/** Set (or unset if null) a value associated with a key. */
|
||||||
const char* Set(const std::string& key, const char* value);
|
void Set(const std::string& key, const char* value);
|
||||||
|
|
||||||
/** Get the set of all local keys. */
|
/** Get the set of all local keys. */
|
||||||
std::set<std::string> LocalKeys() const;
|
std::set<std::string> LocalKeys() const;
|
||||||
|
@ -81,7 +78,6 @@ private:
|
||||||
|
|
||||||
// Internal query and update methods.
|
// Internal query and update methods.
|
||||||
Def const& GetInternal(const std::string& key);
|
Def const& GetInternal(const std::string& key);
|
||||||
Def const& SetInternal(const std::string& key, Def const& def);
|
|
||||||
|
|
||||||
// Implementation of Closure() method.
|
// Implementation of Closure() method.
|
||||||
struct ClosureTag {};
|
struct ClosureTag {};
|
||||||
|
|
Loading…
Reference in New Issue