cmPropertyMap: Use std::string as value container class

This commit is contained in:
Sebastian Holtermann 2019-06-03 09:26:59 +02:00
parent 8d934d861b
commit e0a8ff3148
9 changed files with 11 additions and 56 deletions

View File

@ -338,7 +338,6 @@ set(SRCS
cmProcessOutput.h
cmProcessTools.cxx
cmProcessTools.h
cmProperty.cxx
cmProperty.h
cmPropertyDefinition.cxx
cmPropertyDefinition.h

View File

@ -12,7 +12,6 @@
#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"

View File

@ -14,7 +14,6 @@
#include "cmLinkLineComputer.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmSourceFile.h"
#include "cmState.h"

View File

@ -1,26 +0,0 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmProperty.h"
void cmProperty::Set(const char* value)
{
this->Value = value;
this->ValueHasBeenSet = true;
}
void cmProperty::Append(const char* value, bool asString)
{
if (!this->Value.empty() && *value && !asString) {
this->Value += ";";
}
this->Value += value;
this->ValueHasBeenSet = true;
}
const char* cmProperty::GetValue() const
{
if (this->ValueHasBeenSet) {
return this->Value.c_str();
}
return nullptr;
}

View File

@ -5,8 +5,6 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
class cmProperty
{
public:
@ -22,22 +20,6 @@ public:
CACHED_VARIABLE,
INSTALL
};
// set this property
void Set(const char* value);
// append to this property
void Append(const char* value, bool asString = false);
// get the value
const char* GetValue() const;
// construct with the value not set
cmProperty() { this->ValueHasBeenSet = false; }
protected:
std::string Value;
bool ValueHasBeenSet;
};
#endif

View File

@ -16,7 +16,7 @@ void cmPropertyMap::SetProperty(const std::string& name, const char* value)
return;
}
Map_[name].Set(value);
Map_[name] = value;
}
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
@ -27,7 +27,13 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
return;
}
Map_[name].Append(value, asString);
{
std::string& pVal = Map_[name];
if (!pVal.empty() && !asString) {
pVal += ';';
}
pVal += value;
}
}
const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
@ -35,7 +41,7 @@ const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
{
auto it = Map_.find(name);
if (it != Map_.end()) {
return it->second.GetValue();
return it->second.c_str();
}
}
return nullptr;
@ -56,7 +62,7 @@ std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
std::vector<std::pair<std::string, std::string>> kvList;
kvList.reserve(Map_.size());
for (auto const& item : Map_) {
kvList.emplace_back(item.first, item.second.GetValue());
kvList.emplace_back(item.first, item.second);
}
return kvList;
}

View File

@ -5,8 +5,6 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmProperty.h"
#include <map>
#include <string>
#include <utility>
@ -35,7 +33,7 @@ public:
std::vector<std::pair<std::string, std::string>> GetList() const;
private:
std::map<std::string, cmProperty> Map_;
std::map<std::string, std::string> Map_;
};
#endif

View File

@ -10,7 +10,6 @@
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmOutputConverter.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
#include "cmRange.h"
#include "cmStateTypes.h"

View File

@ -388,7 +388,6 @@ CMAKE_CXX_SOURCES="\
cmPolicies \
cmProcessOutput \
cmProjectCommand \
cmProperty \
cmPropertyDefinition \
cmPropertyDefinitionMap \
cmPropertyMap \