summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmExportFileGenerator.cxx9
-rw-r--r--Source/cmPropertyMap.cxx40
-rw-r--r--Source/cmPropertyMap.h11
-rw-r--r--Source/cmState.cxx4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx24
5 files changed, 40 insertions, 48 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index a12e0c48dd..6621797ab2 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -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_")) {
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index 09b30ba7e0..7177a638b3 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -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;
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index e2348a3ef0..4fcbf5816e 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -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
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index fa7df0b2cd..091c2e0b9a 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -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();
}
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 936841446d..634c990325 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -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 {