xml2: Added cppcheck-version

This commit is contained in:
Daniel Marjamäki 2010-12-22 10:29:23 +01:00
parent f392dbef95
commit 3a612d7cd8
2 changed files with 16 additions and 7 deletions

View File

@ -18,6 +18,7 @@
#include "errorlogger.h" #include "errorlogger.h"
#include "path.h" #include "path.h"
#include "cppcheck.h"
#include <sstream> #include <sstream>
#include <vector> #include <vector>
@ -129,14 +130,22 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
return true; return true;
} }
std::string ErrorLogger::ErrorMessage::getXMLHeader(int version) std::string ErrorLogger::ErrorMessage::getXMLHeader(int xml_version)
{ {
std::ostringstream strver; std::ostringstream ostr;
if (version > 1) ostr << "<?xml version=\"1.0\"?>\n";
strver << " version=\"" << version << "\"";
return "<?xml version=\"1.0\"?>\n" if (xml_version <= 1)
"<results" + strver.str() + ">"; {
ostr << "<results>";
}
else
{
ostr << "<results version=\"" << xml_version << "\">\n";
ostr << " <cppcheck-version>" << CppCheck::version() << "</cppcheck-version>";
}
return ostr.str();
} }
std::string ErrorLogger::ErrorMessage::getXMLFooter() std::string ErrorLogger::ErrorMessage::getXMLFooter()

View File

@ -132,7 +132,7 @@ public:
*/ */
std::string toXML(bool verbose, int ver) const; std::string toXML(bool verbose, int ver) const;
static std::string getXMLHeader(int ver); static std::string getXMLHeader(int xml_version);
static std::string getXMLFooter(); static std::string getXMLFooter();
/** /**