1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 14:08:35 +08:00

cmPropertyMap: Rename GetPropertyList method to GetKeys

This commit is contained in:
Sebastian Holtermann
2019-06-02 12:35:33 +02:00
parent f4bbeb785c
commit 9e64e617eb
5 changed files with 18 additions and 28 deletions

View File

@@ -620,7 +620,7 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const
std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const
{ {
return this->Properties.GetPropertyList(); return this->Properties.GetKeys();
} }
const char* cmCacheManager::CacheEntry::GetProperty( const char* cmCacheManager::CacheEntry::GetProperty(

View File

@@ -5032,13 +5032,7 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
{ {
cmPropertyMap const& propsObject = this->Target->GetProperties(); return this->Target->GetProperties().GetKeys();
std::vector<std::string> props;
props.reserve(propsObject.size());
for (auto const& it : propsObject) {
props.push_back(it.first);
}
return props;
} }
void cmGeneratorTarget::ReportPropertyOrigin( void cmGeneratorTarget::ReportPropertyOrigin(

View File

@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */ file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPropertyMap.h" #include "cmPropertyMap.h"
#include <algorithm>
#include <assert.h> #include <assert.h>
#include <utility> #include <utility>
@@ -18,16 +17,6 @@ cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
return prop; return prop;
} }
std::vector<std::string> cmPropertyMap::GetPropertyList() const
{
std::vector<std::string> keyList;
for (auto const& i : *this) {
keyList.push_back(i.first);
}
std::sort(keyList.begin(), keyList.end());
return keyList;
}
void cmPropertyMap::SetProperty(const std::string& name, const char* value) void cmPropertyMap::SetProperty(const std::string& name, const char* value)
{ {
if (!value) { if (!value) {
@@ -61,3 +50,13 @@ const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
} }
return it->second.GetValue(); return it->second.GetValue();
} }
std::vector<std::string> cmPropertyMap::GetKeys() const
{
std::vector<std::string> keyList;
keyList.reserve(this->size());
for (auto const& item : *this) {
keyList.push_back(item.first);
}
return keyList;
}

View File

@@ -14,16 +14,19 @@
class cmPropertyMap : public std::map<std::string, cmProperty> class cmPropertyMap : public std::map<std::string, cmProperty>
{ {
public: public:
// -- Properties
cmProperty* GetOrCreateProperty(const std::string& name); cmProperty* GetOrCreateProperty(const std::string& name);
std::vector<std::string> GetPropertyList() const;
void SetProperty(const std::string& name, const char* value); void SetProperty(const std::string& name, const char* value);
void AppendProperty(const std::string& name, const char* value, void AppendProperty(const std::string& name, const char* value,
bool asString = false); bool asString = false);
const char* GetPropertyValue(const std::string& name) const; const char* GetPropertyValue(const std::string& name) const;
// -- Lists
//! Get a sorted list of property keys
std::vector<std::string> GetKeys() const;
}; };
#endif #endif

View File

@@ -6,7 +6,6 @@
#include <algorithm> #include <algorithm>
#include <assert.h> #include <assert.h>
#include <iterator> #include <iterator>
#include <utility>
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmProperty.h" #include "cmProperty.h"
@@ -667,12 +666,7 @@ bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const
std::vector<std::string> cmStateDirectory::GetPropertyKeys() const std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
{ {
std::vector<std::string> keys; return this->DirectoryState->Properties.GetKeys();
keys.reserve(this->DirectoryState->Properties.size());
for (auto const& it : this->DirectoryState->Properties) {
keys.push_back(it.first);
}
return keys;
} }
void cmStateDirectory::AddNormalTargetName(std::string const& name) void cmStateDirectory::AddNormalTargetName(std::string const& name)