getXMLFooter() and getXMLHeader() functions added and taken into use

This commit is contained in:
Reijo Tomperi 2009-06-15 21:36:39 +03:00
parent 433ff048a4
commit 0c059af3cb
3 changed files with 17 additions and 3 deletions

View File

@ -42,8 +42,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
_settings = cppCheck.settings(); _settings = cppCheck.settings();
if (_settings._xml) if (_settings._xml)
{ {
reportErr("<?xml version=\"1.0\"?>"); reportErr(ErrorLogger::ErrorMessage::getXMLHeader());
reportErr("<results>");
} }
unsigned int returnValue = 0; unsigned int returnValue = 0;
@ -67,7 +66,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
if (_settings._xml) if (_settings._xml)
{ {
reportErr("</results>"); reportErr(ErrorLogger::ErrorMessage::getXMLFooter());
} }
if (returnValue) if (returnValue)

View File

@ -113,6 +113,17 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
return true; return true;
} }
std::string ErrorLogger::ErrorMessage::getXMLHeader()
{
return "<?xml version=\"1.0\"?>\n"
"<results>";
}
std::string ErrorLogger::ErrorMessage::getXMLFooter()
{
return "</results>";
}
std::string ErrorLogger::ErrorMessage::toXML() const std::string ErrorLogger::ErrorMessage::toXML() const
{ {
std::ostringstream xml; std::ostringstream xml;

View File

@ -59,6 +59,10 @@ public:
ErrorMessage(const std::list<FileLocation> &callStack, const std::string &severity, const std::string &msg, const std::string &id); ErrorMessage(const std::list<FileLocation> &callStack, const std::string &severity, const std::string &msg, const std::string &id);
ErrorMessage(); ErrorMessage();
std::string toXML() const; std::string toXML() const;
static std::string getXMLHeader();
static std::string getXMLFooter();
std::string toText() const; std::string toText() const;
std::string serialize() const; std::string serialize() const;
bool deserialize(const std::string &data); bool deserialize(const std::string &data);