Просмотр исходного кода

cmPropertyMap: Use std::string as value container class

Sebastian Holtermann 6 лет назад
Родитель
Сommit
e0a8ff3148

+ 0 - 1
Source/CMakeLists.txt

@@ -338,7 +338,6 @@ set(SRCS
   cmProcessOutput.h
   cmProcessTools.cxx
   cmProcessTools.h
-  cmProperty.cxx
   cmProperty.h
   cmPropertyDefinition.cxx
   cmPropertyDefinition.h

+ 0 - 1
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"

+ 0 - 1
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"

+ 0 - 26
Source/cmProperty.cxx

@@ -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;
-}

+ 0 - 18
Source/cmProperty.h

@@ -5,8 +5,6 @@
 
 #include "cmConfigure.h" // IWYU pragma: keep
 
-#include <string>
-
 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

+ 10 - 4
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<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
   std::vector<std::pair<std::string, std::string>> 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;
 }

+ 1 - 3
Source/cmPropertyMap.h

@@ -5,8 +5,6 @@
 
 #include "cmConfigure.h" // IWYU pragma: keep
 
-#include "cmProperty.h"
-
 #include <map>
 #include <string>
 #include <utility>
@@ -35,7 +33,7 @@ public:
   std::vector<std::pair<std::string, std::string>> GetList() const;
 
 private:
-  std::map<std::string, cmProperty> Map_;
+  std::map<std::string, std::string> Map_;
 };
 
 #endif

+ 0 - 1
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"

+ 0 - 1
bootstrap

@@ -388,7 +388,6 @@ CMAKE_CXX_SOURCES="\
   cmPolicies \
   cmProcessOutput \
   cmProjectCommand \
-  cmProperty \
   cmPropertyDefinition \
   cmPropertyDefinitionMap \
   cmPropertyMap \