浏览代码

VS: Simplify ;-separated attribute value parsing

An implementation ;-separated list parsing was added by commit a1f976ce
(VS: Add support for three new project properties, 2011-11-23) and again
by commit 9e01aefd (VS: Add support for WinRT project properties,
2012-02-03).  Refactor both instances to use ExpandListArgument.
Brad King 13 年之前
父节点
当前提交
a03447b3df
共有 1 个文件被更改,包括 20 次插入34 次删除
  1. 20 34
      Source/cmVisualStudio10TargetGenerator.cxx

+ 20 - 34
Source/cmVisualStudio10TargetGenerator.cxx

@@ -269,63 +269,49 @@ void cmVisualStudio10TargetGenerator::Generate()
 
 
 void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
 void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
 {
 {
-  const char* vsDotNetReferences
-    = this->Target->GetProperty("VS_DOTNET_REFERENCES");
-  if(vsDotNetReferences)
+  std::vector<std::string> references;
+  if(const char* vsDotNetReferences =
+     this->Target->GetProperty("VS_DOTNET_REFERENCES"))
+    {
+    cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
+    }
+  if(!references.empty())
     {
     {
-    std::string references(vsDotNetReferences);
-    std::string::size_type position = 0;
-
     this->WriteString("<ItemGroup>\n", 1);
     this->WriteString("<ItemGroup>\n", 1);
-    while(references.length() > 0)
+    for(std::vector<std::string>::iterator ri = references.begin();
+        ri != references.end(); ++ri)
       {
       {
-      if((position = references.find(";")) == std::string::npos)
-        {
-        position = references.length() + 1;
-        }
-
       this->WriteString("<Reference Include=\"", 2);
       this->WriteString("<Reference Include=\"", 2);
-      (*this->BuildFileStream) <<
-        cmVS10EscapeXML(references.substr(0, position)) << "\">\n";
+      (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
       this->WriteString("<CopyLocalSatelliteAssemblies>true"
       this->WriteString("<CopyLocalSatelliteAssemblies>true"
                         "</CopyLocalSatelliteAssemblies>\n", 3);
                         "</CopyLocalSatelliteAssemblies>\n", 3);
       this->WriteString("<ReferenceOutputAssembly>true"
       this->WriteString("<ReferenceOutputAssembly>true"
                         "</ReferenceOutputAssembly>\n", 3);
                         "</ReferenceOutputAssembly>\n", 3);
       this->WriteString("</Reference>\n", 2);
       this->WriteString("</Reference>\n", 2);
-
-      references.erase(0, position + 1);
       }
       }
-
     this->WriteString("</ItemGroup>\n", 1);
     this->WriteString("</ItemGroup>\n", 1);
     }
     }
 }
 }
 
 
 void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
 void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
 {
 {
-  const char* vsWinRTReferences
-    = this->Target->GetProperty("VS_WINRT_REFERENCES");
-  if(vsWinRTReferences)
+  std::vector<std::string> references;
+  if(const char* vsWinRTReferences =
+     this->Target->GetProperty("VS_WINRT_REFERENCES"))
+    {
+    cmSystemTools::ExpandListArgument(vsWinRTReferences, references);
+    }
+  if(!references.empty())
     {
     {
-    std::string references(vsWinRTReferences);
-    std::string::size_type position = 0;
-
     this->WriteString("<ItemGroup>\n", 1);
     this->WriteString("<ItemGroup>\n", 1);
-    while(references.length() > 0)
+    for(std::vector<std::string>::iterator ri = references.begin();
+        ri != references.end(); ++ri)
       {
       {
-      if((position = references.find(";")) == std::string::npos)
-        {
-        position = references.length() + 1;
-        }
-
       this->WriteString("<Reference Include=\"", 2);
       this->WriteString("<Reference Include=\"", 2);
-      (*this->BuildFileStream) <<
-        cmVS10EscapeXML(references.substr(0, position)) << "\">\n";
+      (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
       this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
       this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
       this->WriteString("</Reference>\n", 2);
       this->WriteString("</Reference>\n", 2);
-
-      references.erase(0, position + 1);
       }
       }
-
     this->WriteString("</ItemGroup>\n", 1);
     this->WriteString("</ItemGroup>\n", 1);
     }
     }
 }
 }