Parcourir la source

cmGlobalXCodeGenerator: Convert CreateString signature to string_view

Brad King il y a 4 mois
Parent
commit
ced6b31c48

+ 1 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -850,7 +850,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
   return ptr;
 }
 
-cmXCodeObject* cmGlobalXCodeGenerator::CreateString(std::string const& s)
+cmXCodeObject* cmGlobalXCodeGenerator::CreateString(cm::string_view s)
 {
   cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING);
   obj->SetString(s);

+ 1 - 1
Source/cmGlobalXCodeGenerator.h

@@ -192,7 +192,7 @@ private:
   cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype,
                               cm::string_view key = {});
   cmXCodeObject* CreateObject(cmXCodeObject::Type type);
-  cmXCodeObject* CreateString(std::string const& s);
+  cmXCodeObject* CreateString(cm::string_view s);
   cmXCodeObject* CreateObjectReference(cmXCodeObject*);
   cmXCodeObject* CreateFlatClone(cmXCodeObject*);
   cmXCodeObject* CreateXCodeTarget(cmGeneratorTarget* gtgt,

+ 3 - 2
Source/cmXCodeObject.cxx

@@ -4,6 +4,7 @@
 
 #include <ostream>
 
+#include <cm/string_view>
 #include <cmext/string_view>
 
 char const* cmXCodeObject::PBXTypeNames[] = {
@@ -225,7 +226,7 @@ void cmXCodeObject::PrintString(std::ostream& os) const
   cmXCodeObject::PrintString(os, this->String);
 }
 
-void cmXCodeObject::SetString(std::string const& s)
+void cmXCodeObject::SetString(cm::string_view s)
 {
-  this->String = s;
+  this->String = std::string(s);
 }

+ 2 - 1
Source/cmXCodeObject.h

@@ -12,6 +12,7 @@
 #include <utility>
 #include <vector>
 
+#include <cm/string_view>
 #include <cmext/algorithm>
 
 class cmGeneratorTarget;
@@ -64,7 +65,7 @@ public:
 
   bool IsEmpty() const;
 
-  void SetString(std::string const& s);
+  void SetString(cm::string_view s);
   std::string const& GetString() const { return this->String; }
 
   void AddAttribute(std::string const& name, cmXCodeObject* value)