32 #include <QXmlStreamAttributes>
33 #include <QXmlStreamReader>
34 #include <QXmlStreamWriter>
36 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
64 mProductName(std::move(productName)),
96 const QString name = QString::fromStdString(nameAndVersion.first);
97 const QString version = nameAndVersion.first.empty() ?
CppCheck::version() : QString::fromStdString(nameAndVersion.second);
138 if (
error.inconclusive)
144 if (!
error.file0.isEmpty())
146 if (!
error.sinceDate.isEmpty())
148 if (!
error.tags.isEmpty())
151 for (
int i =
error.errorPath.count() - 1; i >= 0; i--) {
154 QString file = QDir::toNativeSeparators(
error.errorPath[i].file);
157 if (
error.errorPath[i].column > 0)
159 if (
error.errorPath.count() > 1)
170 QList<ErrorItem> errors;
171 bool insideResults =
false;
173 qDebug() <<
"You must Open() the file before reading it!";
178 case QXmlStreamReader::StartElement:
180 insideResults =
true;
189 case QXmlStreamReader::EndElement:
191 insideResults =
false;
195 case QXmlStreamReader::NoToken:
196 case QXmlStreamReader::Invalid:
197 case QXmlStreamReader::StartDocument:
198 case QXmlStreamReader::EndDocument:
199 case QXmlStreamReader::Characters:
200 case QXmlStreamReader::Comment:
201 case QXmlStreamReader::DTD:
202 case QXmlStreamReader::EntityReference:
203 case QXmlStreamReader::ProcessingInstruction:
225 QXmlStreamAttributes attribs = reader->attributes();
228 const QString summary = attribs.value(QString(),
MsgAttribute).toString();
230 const QString message = attribs.value(QString(),
VerboseAttribute).toString();
246 bool errorRead =
false;
249 case QXmlStreamReader::StartElement:
253 QXmlStreamAttributes attribs =
mXmlReader->attributes();
255 if (!file0.isEmpty())
268 case QXmlStreamReader::EndElement:
274 case QXmlStreamReader::NoToken:
275 case QXmlStreamReader::Invalid:
276 case QXmlStreamReader::StartDocument:
277 case QXmlStreamReader::EndDocument:
278 case QXmlStreamReader::Characters:
279 case QXmlStreamReader::Comment:
280 case QXmlStreamReader::DTD:
281 case QXmlStreamReader::EntityReference:
282 case QXmlStreamReader::ProcessingInstruction:
static const char * version()
Returns current version number as a string.
A class containing error data for one error.
QList< QErrorPathItem > errorPath
static QString toString(Severity severity)
static Severity fromString(const QString &severity)
A class containing data for one error path item.
QFile * getFile()
Get the file object where the report is written to.
virtual bool open()
Open the existing report (file).
virtual bool create()
Create the report (file).
static std::pair< std::string, std::string > getNameAndVersion(const std::string &productName)
const QString mProductName
Product name read from cppcheck.cfg.
ErrorItem readError(const QXmlStreamReader *reader)
Read and parse error item from XML stream.
void writeFooter() override
Write report footer.
QXmlStreamReader * mXmlReader
XML stream reader for reading the report in XML format.
void writeError(const ErrorItem &error) override
Write error to report.
XmlReportV2(const QString &filename, QString productName)
QXmlStreamWriter * mXmlWriter
XML stream writer for writing the report in XML format.
QList< ErrorItem > read() override
Read contents of the report file.
bool create() override
Create the report (file).
bool open() override
Open existing report file.
void writeHeader() override
Write report header.
Base class for XML report classes.
static QString quoteMessage(const QString &message)
Quote the message.
static QString unquoteMessage(const QString &message)
Unquote the message.
std::string toString(Color c)
@ error
Programming error.
static const QString SeverityAttribute
static const QString FilenameAttribute
static const QString InfoAttribute
static const QString LocationElementName
static const QString ResultElementName
static const QString MsgAttribute
static const QString ProductNameAttribute
static const QString CWEAttribute
static const QString ErrorsElementName
static const QString SinceDateAttribute
static const QString VerboseAttribute
static const QString VersionAttribute
static const QString LineAttribute
static const QString IdAttribute
static const QString TagsAttribute
static const QString HashAttribute
static const QString ColumnAttribute
static const QString IncludedFromFilenameAttribute
static const QString CppcheckElementName
static const QString InconclusiveAttribute
static const QString ErrorElementName