Commit 8d934d86 authored by Sebastian Holtermann's avatar Sebastian Holtermann

cmPropertyMap: Make std::map container private

parent 026f65d2
......@@ -1205,12 +1205,9 @@ bool cmExportFileGenerator::PopulateExportProperties(
std::string& errorMessage)
{
auto& targetProperties = gte->Target->GetProperties();
const auto& exportProperties = targetProperties.find("EXPORT_PROPERTIES");
if (exportProperties != targetProperties.end()) {
std::vector<std::string> propsToExport;
cmSystemTools::ExpandListArgument(exportProperties->second.GetValue(),
propsToExport);
for (auto& prop : propsToExport) {
if (const char* exportProperties =
targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) {
for (auto& prop : cmSystemTools::ExpandedListArgument(exportProperties)) {
/* Black list reserved properties */
if (cmSystemTools::StringStartsWith(prop, "IMPORTED_") ||
cmSystemTools::StringStartsWith(prop, "INTERFACE_")) {
......
......@@ -2,30 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPropertyMap.h"
#include <assert.h>
#include <utility>
cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
void cmPropertyMap::Clear()
{
cmPropertyMap::iterator it = this->find(name);
cmProperty* prop;
if (it == this->end()) {
prop = &(*this)[name];
} else {
prop = &(it->second);
}
return prop;
Map_.clear();
}
void cmPropertyMap::SetProperty(const std::string& name, const char* value)
{
if (!value) {
this->erase(name);
Map_.erase(name);
return;
}
cmProperty* prop = this->GetOrCreateProperty(name);
prop->Set(value);
Map_[name].Set(value);
}
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
......@@ -36,26 +27,25 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
return;
}
cmProperty* prop = this->GetOrCreateProperty(name);
prop->Append(value, asString);
Map_[name].Append(value, asString);
}
const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
{
assert(!name.empty());
cmPropertyMap::const_iterator it = this->find(name);
if (it == this->end()) {
return nullptr;
{
auto it = Map_.find(name);
if (it != Map_.end()) {
return it->second.GetValue();
}
}
return it->second.GetValue();
return nullptr;
}
std::vector<std::string> cmPropertyMap::GetKeys() const
{
std::vector<std::string> keyList;
keyList.reserve(this->size());
for (auto const& item : *this) {
keyList.reserve(Map_.size());
for (auto const& item : Map_) {
keyList.push_back(item.first);
}
return keyList;
......@@ -64,8 +54,8 @@ std::vector<std::string> cmPropertyMap::GetKeys() const
std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
{
std::vector<std::pair<std::string, std::string>> kvList;
kvList.reserve(this->size());
for (auto const& item : *this) {
kvList.reserve(Map_.size());
for (auto const& item : Map_) {
kvList.emplace_back(item.first, item.second.GetValue());
}
return kvList;
......
......@@ -12,12 +12,14 @@
#include <utility>
#include <vector>
class cmPropertyMap : public std::map<std::string, cmProperty>
class cmPropertyMap
{
public:
// -- Properties
cmProperty* GetOrCreateProperty(const std::string& name);
// -- General
//! Clear property list
void Clear();
// -- Properties
void SetProperty(const std::string& name, const char* value);
void AppendProperty(const std::string& name, const char* value,
......@@ -31,6 +33,9 @@ public:
//! Get a sorted by key list of property key,value pairs
std::vector<std::pair<std::string, std::string>> GetList() const;
private:
std::map<std::string, cmProperty> Map_;
};
#endif
......@@ -267,7 +267,7 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
cmStateSnapshot cmState::Reset()
{
this->GlobalProperties.clear();
this->GlobalProperties.Clear();
this->PropertyDefinitions.clear();
this->GlobVerificationManager->Reset();
......@@ -289,7 +289,7 @@ cmStateSnapshot cmState::Reset()
it->LinkDirectoriesBacktraces.clear();
it->DirectoryEnd = pos;
it->NormalTargetNames.clear();
it->Properties.clear();
it->Properties.Clear();
it->Children.clear();
}
......
......@@ -774,11 +774,11 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0)
cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
}
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
for (auto const& i : props) {
for (auto const& i : props.GetList()) {
if (i.first.find("VS_DOTNET_REFERENCE_") == 0) {
std::string name = i.first.substr(20);
if (!name.empty()) {
std::string path = i.second.GetValue();
std::string path = i.second;
if (!cmsys::SystemTools::FileIsFullPath(path)) {
path = this->Makefile->GetCurrentSourceDirectory() + "/" + path;
}
......@@ -870,10 +870,10 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags(
typedef std::map<std::string, std::string> CustomTags;
CustomTags tags;
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
for (const auto& i : props) {
for (const auto& i : props.GetList()) {
if (i.first.find(refPropFullPrefix) == 0) {
std::string refTag = i.first.substr(refPropFullPrefix.length());
std::string refVal = i.second.GetValue();
std::string refVal = i.second;
if (!refTag.empty() && !refVal.empty()) {
tags[refTag] = refVal;
}
......@@ -967,12 +967,12 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
}
}
const cmPropertyMap& props = oi->GetProperties();
for (const auto& p : props) {
for (const std::string& p : props.GetKeys()) {
static const std::string propNamePrefix = "VS_CSHARP_";
if (p.first.find(propNamePrefix) == 0) {
std::string tagName = p.first.substr(propNamePrefix.length());
if (p.find(propNamePrefix) == 0) {
std::string tagName = p.substr(propNamePrefix.length());
if (!tagName.empty()) {
std::string value = props.GetPropertyValue(p.first);
std::string value = props.GetPropertyValue(p);
if (!value.empty()) {
e2.Element(tagName.c_str(), value);
}
......@@ -4681,12 +4681,12 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties(
{
if (this->ProjectType == csproj) {
const cmPropertyMap& props = sf->GetProperties();
for (auto const& p : props) {
for (const std::string& p : props.GetKeys()) {
static const std::string propNamePrefix = "VS_CSHARP_";
if (p.first.find(propNamePrefix) == 0) {
std::string tagName = p.first.substr(propNamePrefix.length());
if (p.find(propNamePrefix) == 0) {
std::string tagName = p.substr(propNamePrefix.length());
if (!tagName.empty()) {
const std::string val = props.GetPropertyValue(p.first);
const std::string val = props.GetPropertyValue(p);
if (!val.empty()) {
tags[tagName] = val;
} else {
......
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