From e0a8ff31480df672e42e2382e8ed7f33ea65afb4 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Mon, 3 Jun 2019 09:26:59 +0200 Subject: cmPropertyMap: Use std::string as value container class --- Source/CMakeLists.txt | 1 - Source/cmExportFileGenerator.cxx | 1 - Source/cmJsonObjects.cxx | 1 - Source/cmProperty.cxx | 26 -------------------------- Source/cmProperty.h | 18 ------------------ Source/cmPropertyMap.cxx | 14 ++++++++++---- Source/cmPropertyMap.h | 4 +--- Source/cmTestGenerator.cxx | 1 - bootstrap | 1 - 9 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 Source/cmProperty.cxx diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 695e075..67bc598 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -338,7 +338,6 @@ set(SRCS cmProcessOutput.h cmProcessTools.cxx cmProcessTools.h - cmProperty.cxx cmProperty.h cmPropertyDefinition.cxx cmPropertyDefinition.h diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 6621797..c366183 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -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" diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 657d681..8d065e1 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -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" diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx deleted file mode 100644 index 27f0ecd..0000000 --- a/Source/cmProperty.cxx +++ /dev/null @@ -1,26 +0,0 @@ -/* 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; -} diff --git a/Source/cmProperty.h b/Source/cmProperty.h index d11c5ef..80f131a 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -5,8 +5,6 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include - 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 diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 7177a63..0874977 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -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> cmPropertyMap::GetList() const std::vector> 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; } diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 4fcbf58..165eb92 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -5,8 +5,6 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmProperty.h" - #include #include #include @@ -35,7 +33,7 @@ public: std::vector> GetList() const; private: - std::map Map_; + std::map Map_; }; #endif diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 3840e50..174fb8a 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -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" diff --git a/bootstrap b/bootstrap index 38fa32b..569a6a4 100755 --- a/bootstrap +++ b/bootstrap @@ -388,7 +388,6 @@ CMAKE_CXX_SOURCES="\ cmPolicies \ cmProcessOutput \ cmProjectCommand \ - cmProperty \ cmPropertyDefinition \ cmPropertyDefinitionMap \ cmPropertyMap \ -- cgit v0.12