cmCTestUploadHandler: Port to cmXMLWriter

This commit is contained in:
Daniel Pfeifer 2015-05-23 23:31:20 +02:00 committed by Brad King
parent ed42c203ed
commit 6cf5cc717f
1 changed files with 25 additions and 21 deletions

View File

@ -13,7 +13,7 @@
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmVersion.h" #include "cmVersion.h"
#include "cmXMLSafe.h" #include "cmXMLWriter.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmCTestUploadHandler::cmCTestUploadHandler() cmCTestUploadHandler::cmCTestUploadHandler()
@ -47,32 +47,36 @@ int cmCTestUploadHandler::ProcessHandler()
std::string buildname = cmCTest::SafeBuildIdField( std::string buildname = cmCTest::SafeBuildIdField(
this->CTest->GetCTestConfiguration("BuildName")); this->CTest->GetCTestConfiguration("BuildName"));
cmCTest::SetOfStrings::const_iterator it; cmCTest::SetOfStrings::const_iterator it;
ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
<< "<?xml-stylesheet type=\"text/xsl\" " cmXMLWriter xml(ofs);
xml.StartDocument();
xml.ProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" "
"href=\"Dart/Source/Server/XSL/Build.xsl " "href=\"Dart/Source/Server/XSL/Build.xsl "
"<file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n" "<file:///Dart/Source/Server/XSL/Build.xsl> \"");
<< "<Site BuildName=\"" xml.StartElement("Site");
<< buildname xml.Attribute("BuildName", buildname);
<< "\" BuildStamp=\"" xml.Attribute("BuildStamp",
<< this->CTest->GetCurrentTag() << "-" this->CTest->GetCurrentTag() + "-" + this->CTest->GetTestModelString());
<< this->CTest->GetTestModelString() << "\" Name=\"" xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
<< this->CTest->GetCTestConfiguration("Site") << "\" Generator=\"ctest" xml.Attribute("Generator",
<< cmVersion::GetCMakeVersion() std::string("ctest") + cmVersion::GetCMakeVersion());
<< "\">\n"; this->CTest->AddSiteProperties(xml);
this->CTest->AddSiteProperties(ofs); xml.StartElement("Upload");
ofs << "<Upload>\n";
for ( it = this->Files.begin(); it != this->Files.end(); it ++ ) for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
{ {
cmCTestOptionalLog(this->CTest, OUTPUT, cmCTestOptionalLog(this->CTest, OUTPUT,
"\tUpload file: " << *it << std::endl, this->Quiet); "\tUpload file: " << *it << std::endl, this->Quiet);
ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n" xml.StartElement("File");
<< "<Content encoding=\"base64\">\n"; xml.Attribute("filename", *it);
ofs << this->CTest->Base64EncodeFile(*it); xml.StartElement("Content");
ofs << "\n</Content>\n" xml.Attribute("encoding", "base64");
<< "</File>\n"; xml.Content(this->CTest->Base64EncodeFile(*it));
xml.EndElement(); // Content
xml.EndElement(); // File
} }
ofs << "</Upload>\n" xml.EndElement(); // Upload
<< "</Site>\n"; xml.EndElement(); // Site
xml.EndDocument();
return 0; return 0;
} }