summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2015-05-23 22:33:24 (GMT)
committerBrad King <brad.king@kitware.com>2015-05-26 15:09:21 (GMT)
commited42c203ed4b258091bd6eeaa1fe567c6f9b120a (patch)
tree1af5663f5d42da0b2304180761f801ebe97e29e1
parent18825bafd99c6a9c8ec1fb4e7b22a8059c680572 (diff)
downloadCMake-ed42c203ed4b258091bd6eeaa1fe567c6f9b120a.zip
CMake-ed42c203ed4b258091bd6eeaa1fe567c6f9b120a.tar.gz
CMake-ed42c203ed4b258091bd6eeaa1fe567c6f9b120a.tar.bz2
cmCTestUpdateHandler: Port to cmXMLWriter
-rw-r--r--Source/CTest/cmCTestCVS.cxx12
-rw-r--r--Source/CTest/cmCTestCVS.h4
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx18
-rw-r--r--Source/CTest/cmCTestGlobalVC.h6
-rw-r--r--Source/CTest/cmCTestSVN.cxx6
-rw-r--r--Source/CTest/cmCTestSVN.h2
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx63
-rw-r--r--Source/CTest/cmCTestVC.cxx38
-rw-r--r--Source/CTest/cmCTestVC.h7
9 files changed, 78 insertions, 78 deletions
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index ab363d0..0fb3fec 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -13,7 +13,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
@@ -266,13 +266,13 @@ void cmCTestCVS::LoadRevisions(std::string const& file,
}
//----------------------------------------------------------------------------
-void cmCTestCVS::WriteXMLDirectory(std::ostream& xml,
+void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
std::string const& path,
Directory const& dir)
{
const char* slash = path.empty()? "":"/";
- xml << "\t<Directory>\n"
- << "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
+ xml.StartElement("Directory");
+ xml.Element("Name", path);
// Lookup the branch checked out in the working tree.
std::string branchFlag = this->ComputeBranchFlag(path);
@@ -298,11 +298,11 @@ void cmCTestCVS::WriteXMLDirectory(std::ostream& xml,
File f(fi->second, &revisions[0], &revisions[1]);
this->WriteXMLEntry(xml, path, fi->first, full, f);
}
- xml << "\t</Directory>\n";
+ xml.EndElement(); // Directory
}
//----------------------------------------------------------------------------
-bool cmCTestCVS::WriteXMLUpdates(std::ostream& xml)
+bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per updated file):\n"
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index 64e1747..f2c0a73 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -29,7 +29,7 @@ public:
private:
// Implement cmCTestVC internal API.
virtual bool UpdateImpl();
- virtual bool WriteXMLUpdates(std::ostream& xml);
+ virtual bool WriteXMLUpdates(cmXMLWriter& xml);
// Update status for files in each directory.
class Directory: public std::map<std::string, PathStatus> {};
@@ -38,7 +38,7 @@ private:
std::string ComputeBranchFlag(std::string const& dir);
void LoadRevisions(std::string const& file, const char* branchFlag,
std::vector<Revision>& revisions);
- void WriteXMLDirectory(std::ostream& xml, std::string const& path,
+ void WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
Directory const& dir);
// Parsing helper classes.
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 5f570b5..c091ec4 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -13,7 +13,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/RegularExpression.hxx>
@@ -91,36 +91,36 @@ void cmCTestGlobalVC::DoModification(PathStatus status,
}
//----------------------------------------------------------------------------
-void cmCTestGlobalVC::WriteXMLDirectory(std::ostream& xml,
+void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
std::string const& path,
Directory const& dir)
{
const char* slash = path.empty()? "":"/";
- xml << "\t<Directory>\n"
- << "\t\t<Name>" << cmXMLSafe(path) << "</Name>\n";
+ xml.StartElement("Directory");
+ xml.Element("Name", path);
for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi)
{
std::string full = path + slash + fi->first;
this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
}
- xml << "\t</Directory>\n";
+ xml.EndElement(); // Directory
}
//----------------------------------------------------------------------------
-void cmCTestGlobalVC::WriteXMLGlobal(std::ostream& xml)
+void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
{
if(!this->NewRevision.empty())
{
- xml << "\t<Revision>" << this->NewRevision << "</Revision>\n";
+ xml.Element("Revision", this->NewRevision);
}
if(!this->OldRevision.empty() && this->OldRevision != this->NewRevision)
{
- xml << "\t<PriorRevision>" << this->OldRevision << "</PriorRevision>\n";
+ xml.Element("PriorRevision", this->OldRevision);
}
}
//----------------------------------------------------------------------------
-bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml)
+bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n"
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index 29e0a61..d0e9410 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -30,7 +30,7 @@ public:
protected:
// Implement cmCTestVC internal API.
- virtual bool WriteXMLUpdates(std::ostream& xml);
+ virtual bool WriteXMLUpdates(cmXMLWriter& xml);
/** Represent a vcs-reported action for one path in a revision. */
struct Change
@@ -62,8 +62,8 @@ protected:
virtual void LoadModifications() = 0;
virtual void LoadRevisions() = 0;
- virtual void WriteXMLGlobal(std::ostream& xml);
- void WriteXMLDirectory(std::ostream& xml, std::string const& path,
+ virtual void WriteXMLGlobal(cmXMLWriter& xml);
+ void WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
Directory const& dir);
};
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 86dc2f2..f7bd1f9 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -14,7 +14,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/RegularExpression.hxx>
@@ -535,11 +535,11 @@ void cmCTestSVN::LoadModifications()
}
//----------------------------------------------------------------------------
-void cmCTestSVN::WriteXMLGlobal(std::ostream& xml)
+void cmCTestSVN::WriteXMLGlobal(cmXMLWriter& xml)
{
this->cmCTestGlobalVC::WriteXMLGlobal(xml);
- xml << "\t<SVNPath>" << this->RootInfo->Base << "</SVNPath>\n";
+ xml.Element("SVNPath", this->RootInfo->Base);
}
//----------------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h
index 17bf7cb..f9febc5 100644
--- a/Source/CTest/cmCTestSVN.h
+++ b/Source/CTest/cmCTestSVN.h
@@ -84,7 +84,7 @@ private:
void DoRevisionSVN(Revision const& revision,
std::vector<Change> const& changes);
- void WriteXMLGlobal(std::ostream& xml);
+ void WriteXMLGlobal(cmXMLWriter& xml);
// Parsing helper classes.
class InfoParser;
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 10927e7..8494d28 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -20,7 +20,7 @@
#include "cmVersion.h"
#include "cmGeneratedFileStream.h"
#include "cmXMLParser.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include "cmCLocaleEnvironmentScope.h"
#include "cmCTestVC.h"
@@ -224,24 +224,24 @@ int cmCTestUpdateHandler::ProcessHandler()
bool updated = vc->Update();
std::string buildname = cmCTest::SafeBuildIdField(
this->CTest->GetCTestConfiguration("BuildName"));
- os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<Update mode=\"Client\" Generator=\"ctest-"
- << cmVersion::GetCMakeVersion() << "\">\n"
- << "\t<Site>" << this->CTest->GetCTestConfiguration("Site") << "</Site>\n"
- << "\t<BuildName>" << buildname
- << "</BuildName>\n"
- << "\t<BuildStamp>" << this->CTest->GetCurrentTag() << "-"
- << this->CTest->GetTestModelString() << "</BuildStamp>" << std::endl;
- os << "\t<StartDateTime>" << start_time << "</StartDateTime>\n"
- << "\t<StartTime>" << start_time_time << "</StartTime>\n"
- << "\t<UpdateCommand>"
- << cmXMLSafe(vc->GetUpdateCommandLine()).Quotes(false)
- << "</UpdateCommand>\n"
- << "\t<UpdateType>" << cmXMLSafe(
- cmCTestUpdateHandlerUpdateToString(this->UpdateType))
- << "</UpdateType>\n";
-
- vc->WriteXML(os);
+
+ cmXMLWriter xml(os);
+ xml.StartDocument();
+ xml.StartElement("Update");
+ xml.Attribute("mode", "Client");
+ xml.Attribute("Generator",
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
+ xml.Element("Site", this->CTest->GetCTestConfiguration("Site"));
+ xml.Element("BuildName", buildname);
+ xml.Element("BuildStamp", this->CTest->GetCurrentTag() + "-" +
+ this->CTest->GetTestModelString());
+ xml.Element("StartDateTime", start_time);
+ xml.Element("StartTime", start_time_time);
+ xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
+ xml.Element("UpdateType",
+ cmCTestUpdateHandlerUpdateToString(this->UpdateType));
+
+ vc->WriteXML(xml);
int localModifications = 0;
int numUpdated = vc->GetPathCount(cmCTestVC::PathUpdated);
@@ -265,29 +265,30 @@ int cmCTestUpdateHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
std::string end_time = this->CTest->CurrentTime();
- os << "\t<EndDateTime>" << end_time << "</EndDateTime>\n"
- << "\t<EndTime>" << static_cast<unsigned int>(cmSystemTools::GetTime())
- << "</EndTime>\n"
- << "<ElapsedMinutes>" <<
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0
- << "</ElapsedMinutes>\n"
- << "\t<UpdateReturnStatus>";
+ xml.Element("EndDateTime", end_time);
+ xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("ElapsedMinutes",
+ static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0);
+
+ xml.StartElement("UpdateReturnStatus");
if(localModifications)
{
- os << "Update error: There are modified or conflicting files in the "
- "repository";
+ xml.Content("Update error: "
+ "There are modified or conflicting files in the repository");
cmCTestLog(this->CTest, ERROR_MESSAGE,
" There are modified or conflicting files in the repository"
<< std::endl);
}
if(!updated)
{
- os << "Update command failed:\n" << vc->GetUpdateCommandLine();
+ xml.Content("Update command failed:\n");
+ xml.Content(vc->GetUpdateCommandLine());
cmCTestLog(this->CTest, ERROR_MESSAGE, " Update command failed: "
<< vc->GetUpdateCommandLine() << "\n");
}
- os << "</UpdateReturnStatus>" << std::endl;
- os << "</Update>" << std::endl;
+ xml.EndElement(); // UpdateReturnStatus
+ xml.EndElement(); // Update
+ xml.EndDocument();
return numUpdated;
}
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 6e93e95..8eff4d6 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -13,7 +13,7 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
+#include "cmXMLWriter.h"
#include <cmsys/Process.h>
@@ -202,7 +202,7 @@ bool cmCTestVC::UpdateImpl()
}
//----------------------------------------------------------------------------
-bool cmCTestVC::WriteXML(std::ostream& xml)
+bool cmCTestVC::WriteXML(cmXMLWriter& xml)
{
this->Log << "--- Begin Revisions ---\n";
bool result = this->WriteXMLUpdates(xml);
@@ -211,7 +211,7 @@ bool cmCTestVC::WriteXML(std::ostream& xml)
}
//----------------------------------------------------------------------------
-bool cmCTestVC::WriteXMLUpdates(std::ostream&)
+bool cmCTestVC::WriteXMLUpdates(cmXMLWriter&)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"* CTest cannot extract updates for this VCS tool.\n");
@@ -219,7 +219,7 @@ bool cmCTestVC::WriteXMLUpdates(std::ostream&)
}
//----------------------------------------------------------------------------
-void cmCTestVC::WriteXMLEntry(std::ostream& xml,
+void cmCTestVC::WriteXMLEntry(cmXMLWriter& xml,
std::string const& path,
std::string const& name,
std::string const& full,
@@ -228,21 +228,19 @@ void cmCTestVC::WriteXMLEntry(std::ostream& xml,
static const char* desc[3] = { "Updated", "Modified", "Conflicting"};
Revision const& rev = f.Rev? *f.Rev : this->Unknown;
std::string prior = f.PriorRev? f.PriorRev->Rev : std::string("Unknown");
- xml << "\t\t<" << desc[f.Status] << ">\n"
- << "\t\t\t<File>" << cmXMLSafe(name) << "</File>\n"
- << "\t\t\t<Directory>" << cmXMLSafe(path) << "</Directory>\n"
- << "\t\t\t<FullName>" << cmXMLSafe(full) << "</FullName>\n"
- << "\t\t\t<CheckinDate>" << cmXMLSafe(rev.Date) << "</CheckinDate>\n"
- << "\t\t\t<Author>" << cmXMLSafe(rev.Author) << "</Author>\n"
- << "\t\t\t<Email>" << cmXMLSafe(rev.EMail) << "</Email>\n"
- << "\t\t\t<Committer>" << cmXMLSafe(rev.Committer) << "</Committer>\n"
- << "\t\t\t<CommitterEmail>" << cmXMLSafe(rev.CommitterEMail)
- << "</CommitterEmail>\n"
- << "\t\t\t<CommitDate>" << cmXMLSafe(rev.CommitDate)
- << "</CommitDate>\n"
- << "\t\t\t<Log>" << cmXMLSafe(rev.Log) << "</Log>\n"
- << "\t\t\t<Revision>" << cmXMLSafe(rev.Rev) << "</Revision>\n"
- << "\t\t\t<PriorRevision>" << cmXMLSafe(prior) << "</PriorRevision>\n"
- << "\t\t</" << desc[f.Status] << ">\n";
+ xml.StartElement(desc[f.Status]);
+ xml.Element("File", name);
+ xml.Element("Directory", path);
+ xml.Element("FullName", full);
+ xml.Element("CheckinDate", rev.Date);
+ xml.Element("Author", rev.Author);
+ xml.Element("Email", rev.EMail);
+ xml.Element("Committer", rev.Committer);
+ xml.Element("CommitterEmail", rev.CommitterEMail);
+ xml.Element("CommitDate", rev.CommitDate);
+ xml.Element("Log", rev.Log);
+ xml.Element("Revision", rev.Rev);
+ xml.Element("PriorRevision", prior);
+ xml.EndElement();
++this->PathCount[f.Status];
}
diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h
index 9dd0651..bc89302 100644
--- a/Source/CTest/cmCTestVC.h
+++ b/Source/CTest/cmCTestVC.h
@@ -15,6 +15,7 @@
#include "cmProcessTools.h"
class cmCTest;
+class cmXMLWriter;
/** \class cmCTestVC
* \brief Base class for version control system handlers
@@ -51,7 +52,7 @@ public:
{ return this->UpdateCommandLine; }
/** Write Update.xml entries for the updates found. */
- bool WriteXML(std::ostream& xml);
+ bool WriteXML(cmXMLWriter& xml);
/** Enumerate non-trivial working tree states during update. */
enum PathStatus { PathUpdated, PathModified, PathConflicting };
@@ -65,7 +66,7 @@ protected:
virtual void NoteOldRevision();
virtual bool UpdateImpl();
virtual void NoteNewRevision();
- virtual bool WriteXMLUpdates(std::ostream& xml);
+ virtual bool WriteXMLUpdates(cmXMLWriter& xml);
#if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510
public: // Sun CC 5.1 needs help to allow cmCTestSVN::Revision to see this
@@ -110,7 +111,7 @@ protected:
OutputParser* out, OutputParser* err = 0);
/** Write xml element for one file. */
- void WriteXMLEntry(std::ostream& xml, std::string const& path,
+ void WriteXMLEntry(cmXMLWriter& xml, std::string const& path,
std::string const& name, std::string const& full,
File const& f);