From 026f65d284deaea9f2dba41ed956fabf84e17b6d Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Sun, 2 Jun 2019 12:43:16 +0200 Subject: cmPropertyMap: Add GetList method --- Source/cmJsonObjects.cxx | 4 ++-- Source/cmPropertyMap.cxx | 10 ++++++++++ Source/cmPropertyMap.h | 4 ++++ Source/cmTestGenerator.cxx | 10 ++++------ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 636a8e1..657d681 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -363,12 +363,12 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo, // Build up the list of properties that may have been specified Json::Value properties = Json::arrayValue; - for (auto& prop : testInfo->GetProperties()) { + for (auto& prop : testInfo->GetProperties().GetList()) { Json::Value entry = Json::objectValue; entry[kKEY_KEY] = prop.first; // Remove config variables from the value too. - auto cge_value = ge.Parse(prop.second.GetValue()); + auto cge_value = ge.Parse(prop.second); const std::string& processed_value = cge_value->Evaluate(lg, config); entry[kVALUE_KEY] = processed_value; properties.append(entry); diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index a97e1f0..09b30ba 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -60,3 +60,13 @@ std::vector cmPropertyMap::GetKeys() const } return keyList; } + +std::vector> cmPropertyMap::GetList() const +{ + std::vector> kvList; + kvList.reserve(this->size()); + for (auto const& item : *this) { + kvList.emplace_back(item.first, item.second.GetValue()); + } + return kvList; +} diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 5c93627..e2348a3 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -9,6 +9,7 @@ #include #include +#include #include class cmPropertyMap : public std::map @@ -27,6 +28,9 @@ public: // -- Lists //! Get a sorted list of property keys std::vector GetKeys() const; + + //! Get a sorted by key list of property key,value pairs + std::vector> GetList() const; }; #endif diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 571cd09..3840e50 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -117,13 +117,12 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, os << ")\n"; // Output properties for the test. - cmPropertyMap& pm = this->Test->GetProperties(); os << indent << "set_tests_properties(" << this->Test->GetName() << " PROPERTIES "; - for (auto const& i : pm) { + for (auto const& i : this->Test->GetProperties().GetList()) { os << " " << i.first << " " << cmOutputConverter::EscapeForCMake( - ge.Parse(i.second.GetValue())->Evaluate(this->LG, config)); + ge.Parse(i.second)->Evaluate(this->LG, config)); } this->GenerateInternalProperties(os); os << ")" << std::endl; @@ -173,12 +172,11 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent) fout << ")" << std::endl; // Output properties for the test. - cmPropertyMap& pm = this->Test->GetProperties(); fout << indent << "set_tests_properties(" << this->Test->GetName() << " PROPERTIES "; - for (auto const& i : pm) { + for (auto const& i : this->Test->GetProperties().GetList()) { fout << " " << i.first << " " - << cmOutputConverter::EscapeForCMake(i.second.GetValue()); + << cmOutputConverter::EscapeForCMake(i.second); } this->GenerateInternalProperties(fout); fout << ")" << std::endl; -- cgit v0.12