xml: use version from configuration if provided (#5215)
This commit is contained in:
parent
db49687ae5
commit
72245b1b15
|
@ -379,8 +379,17 @@ void ErrorMessage::deserialize(const std::string &data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ErrorMessage::getXMLHeader(const std::string& productName)
|
std::string ErrorMessage::getXMLHeader(std::string productName)
|
||||||
{
|
{
|
||||||
|
std::string version = CppCheck::version();
|
||||||
|
if (!productName.empty() && std::isdigit(productName.back())) {
|
||||||
|
const std::string::size_type pos = productName.find_last_not_of(".0123456789");
|
||||||
|
if (pos > 1 && pos != std::string::npos && productName[pos] == ' ') {
|
||||||
|
version = productName.substr(pos+1);
|
||||||
|
productName.erase(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tinyxml2::XMLPrinter printer;
|
tinyxml2::XMLPrinter printer;
|
||||||
|
|
||||||
// standard xml header
|
// standard xml header
|
||||||
|
@ -393,7 +402,7 @@ std::string ErrorMessage::getXMLHeader(const std::string& productName)
|
||||||
printer.OpenElement("cppcheck", false);
|
printer.OpenElement("cppcheck", false);
|
||||||
if (!productName.empty())
|
if (!productName.empty())
|
||||||
printer.PushAttribute("product-name", productName.c_str());
|
printer.PushAttribute("product-name", productName.c_str());
|
||||||
printer.PushAttribute("version", CppCheck::version());
|
printer.PushAttribute("version", version.c_str());
|
||||||
printer.CloseElement(false);
|
printer.CloseElement(false);
|
||||||
printer.OpenElement("errors", false);
|
printer.OpenElement("errors", false);
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ public:
|
||||||
*/
|
*/
|
||||||
std::string toXML() const;
|
std::string toXML() const;
|
||||||
|
|
||||||
static std::string getXMLHeader(const std::string& productName);
|
static std::string getXMLHeader(std::string productName);
|
||||||
static std::string getXMLFooter();
|
static std::string getXMLFooter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue