Commit e0a8ff31 authored by Sebastian Holtermann's avatar Sebastian Holtermann

cmPropertyMap: Use std::string as value container class

parent 8d934d86
......@@ -338,7 +338,6 @@ set(SRCS
cmProcessOutput.h
cmProcessTools.cxx
cmProcessTools.h
cmProperty.cxx
cmProperty.h
cmPropertyDefinition.cxx
cmPropertyDefinition.h
......
......@@ -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"
......
......@@ -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"
......
/* 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;
}
......@@ -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
......@@ -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;
}
......@@ -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
......@@ -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"
......
......@@ -388,7 +388,6 @@ CMAKE_CXX_SOURCES="\
cmPolicies \
cmProcessOutput \
cmProjectCommand \
cmProperty \
cmPropertyDefinition \
cmPropertyDefinitionMap \
cmPropertyMap \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment