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.
This commit is contained in:
Brad King 2012-02-03 14:32:17 -05:00
parent 9e01aefd24
commit a03447b3df
1 changed files with 20 additions and 34 deletions

View File

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