2009-06-22 10:57:17 +02:00
|
|
|
/*
|
|
|
|
* Cppcheck - A tool for static C/C++ code analysis
|
2019-06-29 07:49:14 +02:00
|
|
|
* Copyright (C) 2007-2019 Cppcheck team.
|
2009-06-22 10:57:17 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-09-27 17:08:31 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-22 10:57:17 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QXmlStreamReader>
|
2010-07-07 23:59:02 +02:00
|
|
|
#include <QXmlStreamWriter>
|
2009-06-22 10:57:17 +02:00
|
|
|
#include <QFile>
|
2011-02-28 16:18:14 +01:00
|
|
|
#include <QDir>
|
2009-06-22 10:57:17 +02:00
|
|
|
#include "projectfile.h"
|
2017-09-22 15:41:27 +02:00
|
|
|
#include "common.h"
|
2009-06-22 10:57:17 +02:00
|
|
|
|
2019-04-19 15:09:55 +02:00
|
|
|
#include "path.h"
|
|
|
|
|
2019-04-11 21:06:37 +02:00
|
|
|
static const char ProjectElementName[] = "project";
|
|
|
|
static const char ProjectVersionAttrib[] = "version";
|
|
|
|
static const char ProjectFileVersion[] = "1";
|
|
|
|
static const char BuildDirElementName[] = "builddir";
|
|
|
|
static const char ImportProjectElementName[] = "importproject";
|
|
|
|
static const char AnalyzeAllVsConfigsElementName[] = "analyze-all-vs-configs";
|
|
|
|
static const char IncludeDirElementName[] = "includedir";
|
|
|
|
static const char DirElementName[] = "dir";
|
|
|
|
static const char DirNameAttrib[] = "name";
|
|
|
|
static const char DefinesElementName[] = "defines";
|
|
|
|
static const char DefineName[] = "define";
|
|
|
|
static const char DefineNameAttrib[] = "name";
|
|
|
|
static const char UndefinesElementName[] = "undefines";
|
|
|
|
static const char UndefineName[] = "undefine";
|
|
|
|
static const char PathsElementName[] = "paths";
|
|
|
|
static const char PathName[] = "dir";
|
|
|
|
static const char PathNameAttrib[] = "name";
|
|
|
|
static const char RootPathName[] = "root";
|
|
|
|
static const char RootPathNameAttrib[] = "name";
|
|
|
|
static const char IgnoreElementName[] = "ignore";
|
|
|
|
static const char IgnorePathName[] = "path";
|
|
|
|
static const char IgnorePathNameAttrib[] = "name";
|
|
|
|
static const char ExcludeElementName[] = "exclude";
|
|
|
|
static const char ExcludePathName[] = "path";
|
|
|
|
static const char ExcludePathNameAttrib[] = "name";
|
|
|
|
static const char LibrariesElementName[] = "libraries";
|
|
|
|
static const char LibraryElementName[] = "library";
|
|
|
|
static const char PlatformElementName[] = "platform";
|
|
|
|
static const char SuppressionsElementName[] = "suppressions";
|
|
|
|
static const char SuppressionElementName[] = "suppression";
|
|
|
|
static const char AddonElementName[] = "addon";
|
|
|
|
static const char AddonsElementName[] = "addons";
|
|
|
|
static const char ToolElementName[] = "tool";
|
|
|
|
static const char ToolsElementName[] = "tools";
|
|
|
|
static const char TagsElementName[] = "tags";
|
|
|
|
static const char TagElementName[] = "tag";
|
|
|
|
static const char CheckHeadersElementName[] = "check-headers";
|
|
|
|
static const char CheckUnusedTemplatesElementName[] = "check-unused-templates";
|
|
|
|
static const char MaxCtuDepthElementName[] = "max-ctu-depth";
|
2019-07-11 21:05:52 +02:00
|
|
|
static const char CheckUnknownFunctionReturn[] = "check-unknown-function-return-values";
|
|
|
|
static const char CheckAllFunctionParameterValues[] = "check-all-function-parameter-values";
|
|
|
|
static const char Name[] = "name";
|
2009-06-22 10:57:17 +02:00
|
|
|
|
|
|
|
ProjectFile::ProjectFile(QObject *parent) :
|
2010-04-15 20:08:51 +02:00
|
|
|
QObject(parent)
|
2009-06-22 10:57:17 +02:00
|
|
|
{
|
2017-08-10 00:18:04 +02:00
|
|
|
clear();
|
2009-06-22 10:57:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ProjectFile::ProjectFile(const QString &filename, QObject *parent) :
|
2010-04-15 20:08:51 +02:00
|
|
|
QObject(parent),
|
|
|
|
mFilename(filename)
|
2009-06-22 10:57:17 +02:00
|
|
|
{
|
2017-08-10 00:18:04 +02:00
|
|
|
clear();
|
2017-07-31 12:02:51 +02:00
|
|
|
read();
|
2009-06-22 10:57:17 +02:00
|
|
|
}
|
|
|
|
|
2017-08-10 00:18:04 +02:00
|
|
|
void ProjectFile::clear()
|
|
|
|
{
|
|
|
|
mRootPath.clear();
|
|
|
|
mBuildDir.clear();
|
|
|
|
mImportProject.clear();
|
|
|
|
mAnalyzeAllVsConfigs = true;
|
|
|
|
mIncludeDirs.clear();
|
|
|
|
mDefines.clear();
|
2018-10-09 15:05:05 +02:00
|
|
|
mUndefines.clear();
|
2017-08-10 00:18:04 +02:00
|
|
|
mPaths.clear();
|
|
|
|
mExcludedPaths.clear();
|
|
|
|
mLibraries.clear();
|
2018-03-13 13:07:10 +01:00
|
|
|
mPlatform.clear();
|
2017-08-10 00:18:04 +02:00
|
|
|
mSuppressions.clear();
|
|
|
|
mAddons.clear();
|
2017-09-22 15:41:27 +02:00
|
|
|
mClangAnalyzer = mClangTidy = false;
|
2019-04-10 16:49:24 +02:00
|
|
|
mAnalyzeAllVsConfigs = false;
|
|
|
|
mCheckHeaders = true;
|
|
|
|
mCheckUnusedTemplates = false;
|
|
|
|
mMaxCtuDepth = 10;
|
2019-07-11 21:05:52 +02:00
|
|
|
mCheckAllFunctionParameterValues = false;
|
|
|
|
mCheckUnknownFunctionReturn.clear();
|
2017-08-10 00:18:04 +02:00
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
bool ProjectFile::read(const QString &filename)
|
2009-06-22 10:57:17 +02:00
|
|
|
{
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!filename.isEmpty())
|
2009-06-22 10:57:17 +02:00
|
|
|
mFilename = filename;
|
|
|
|
|
|
|
|
QFile file(mFilename);
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
2009-06-22 10:57:17 +02:00
|
|
|
return false;
|
|
|
|
|
2017-08-10 00:18:04 +02:00
|
|
|
clear();
|
|
|
|
|
2009-06-22 10:57:17 +02:00
|
|
|
QXmlStreamReader xmlReader(&file);
|
|
|
|
bool insideProject = false;
|
2010-07-08 18:49:04 +02:00
|
|
|
bool projectTagFound = false;
|
2011-10-13 20:53:06 +02:00
|
|
|
while (!xmlReader.atEnd()) {
|
|
|
|
switch (xmlReader.readNext()) {
|
2009-06-22 10:57:17 +02:00
|
|
|
case QXmlStreamReader::StartElement:
|
2011-10-13 20:53:06 +02:00
|
|
|
if (xmlReader.name() == ProjectElementName) {
|
2009-06-22 10:57:17 +02:00
|
|
|
insideProject = true;
|
2010-07-08 18:49:04 +02:00
|
|
|
projectTagFound = true;
|
|
|
|
}
|
2010-08-20 22:58:00 +02:00
|
|
|
// Read root path from inside project element
|
|
|
|
if (insideProject && xmlReader.name() == RootPathName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readRootPath(xmlReader);
|
2010-08-20 22:58:00 +02:00
|
|
|
|
2016-11-19 20:38:50 +01:00
|
|
|
// Read root path from inside project element
|
|
|
|
if (insideProject && xmlReader.name() == BuildDirElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readBuildDir(xmlReader);
|
2016-11-19 20:38:50 +01:00
|
|
|
|
2010-08-14 17:42:37 +02:00
|
|
|
// Find paths to check from inside project element
|
|
|
|
if (insideProject && xmlReader.name() == PathsElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readCheckPaths(xmlReader);
|
2009-06-23 08:15:00 +02:00
|
|
|
|
2016-08-18 21:58:50 +02:00
|
|
|
if (insideProject && xmlReader.name() == ImportProjectElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readImportProject(xmlReader);
|
2016-08-18 21:58:50 +02:00
|
|
|
|
2017-08-10 00:18:04 +02:00
|
|
|
if (insideProject && xmlReader.name() == AnalyzeAllVsConfigsElementName)
|
2019-04-10 16:49:24 +02:00
|
|
|
mAnalyzeAllVsConfigs = readBool(xmlReader);
|
|
|
|
|
|
|
|
if (insideProject && xmlReader.name() == CheckHeadersElementName)
|
|
|
|
mCheckHeaders = readBool(xmlReader);
|
|
|
|
|
|
|
|
if (insideProject && xmlReader.name() == CheckUnusedTemplatesElementName)
|
|
|
|
mCheckUnusedTemplates = readBool(xmlReader);
|
2017-08-10 00:18:04 +02:00
|
|
|
|
2010-07-03 23:15:19 +02:00
|
|
|
// Find include directory from inside project element
|
2013-02-10 07:43:09 +01:00
|
|
|
if (insideProject && xmlReader.name() == IncludeDirElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readIncludeDirs(xmlReader);
|
2010-05-20 07:22:19 +02:00
|
|
|
|
2010-07-03 23:15:19 +02:00
|
|
|
// Find preprocessor define from inside project element
|
2010-05-20 07:22:19 +02:00
|
|
|
if (insideProject && xmlReader.name() == DefinesElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readDefines(xmlReader);
|
2010-05-20 07:22:19 +02:00
|
|
|
|
2018-10-09 15:05:05 +02:00
|
|
|
// Find preprocessor define from inside project element
|
|
|
|
if (insideProject && xmlReader.name() == UndefinesElementName)
|
|
|
|
readStringList(mUndefines, xmlReader, UndefineName);
|
|
|
|
|
2011-08-23 18:54:53 +02:00
|
|
|
// Find exclude list from inside project element
|
|
|
|
if (insideProject && xmlReader.name() == ExcludeElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readExcludes(xmlReader);
|
2011-08-23 18:54:53 +02:00
|
|
|
|
2011-02-27 17:32:53 +01:00
|
|
|
// Find ignore list from inside project element
|
2011-08-23 18:54:53 +02:00
|
|
|
// These are read for compatibility
|
2011-02-27 17:32:53 +01:00
|
|
|
if (insideProject && xmlReader.name() == IgnoreElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readExcludes(xmlReader);
|
2011-02-27 17:32:53 +01:00
|
|
|
|
2013-12-30 22:32:50 +01:00
|
|
|
// Find libraries list from inside project element
|
2013-12-29 18:06:31 +01:00
|
|
|
if (insideProject && xmlReader.name() == LibrariesElementName)
|
2017-07-28 05:08:59 +02:00
|
|
|
readStringList(mLibraries, xmlReader,LibraryElementName);
|
2013-12-30 22:32:50 +01:00
|
|
|
|
2018-03-13 13:07:10 +01:00
|
|
|
if (insideProject && xmlReader.name() == PlatformElementName)
|
|
|
|
readPlatform(xmlReader);
|
|
|
|
|
2013-12-30 22:32:50 +01:00
|
|
|
// Find suppressions list from inside project element
|
|
|
|
if (insideProject && xmlReader.name() == SuppressionsElementName)
|
2018-04-09 06:43:48 +02:00
|
|
|
readSuppressions(xmlReader);
|
2013-12-29 18:06:31 +01:00
|
|
|
|
2019-07-11 21:05:52 +02:00
|
|
|
// Unknown function return values
|
|
|
|
if (insideProject && xmlReader.name() == CheckUnknownFunctionReturn)
|
|
|
|
readStringList(mCheckUnknownFunctionReturn, xmlReader, Name);
|
|
|
|
|
|
|
|
// check all function parameter values
|
|
|
|
if (insideProject && xmlReader.name() == CheckAllFunctionParameterValues)
|
|
|
|
mCheckAllFunctionParameterValues = true;
|
|
|
|
|
2017-08-03 12:30:28 +02:00
|
|
|
// Addons
|
|
|
|
if (insideProject && xmlReader.name() == AddonsElementName)
|
|
|
|
readStringList(mAddons, xmlReader, AddonElementName);
|
|
|
|
|
2017-09-22 15:41:27 +02:00
|
|
|
// Tools
|
|
|
|
if (insideProject && xmlReader.name() == ToolsElementName) {
|
|
|
|
QStringList tools;
|
|
|
|
readStringList(tools, xmlReader, ToolElementName);
|
|
|
|
mClangAnalyzer = tools.contains(CLANG_ANALYZER);
|
|
|
|
mClangTidy = tools.contains(CLANG_TIDY);
|
|
|
|
}
|
|
|
|
|
2017-08-18 17:25:08 +02:00
|
|
|
if (insideProject && xmlReader.name() == TagsElementName)
|
|
|
|
readStringList(mTags, xmlReader, TagElementName);
|
|
|
|
|
2019-04-10 16:49:24 +02:00
|
|
|
if (insideProject && xmlReader.name() == MaxCtuDepthElementName)
|
|
|
|
mMaxCtuDepth = readInt(xmlReader, mMaxCtuDepth);
|
|
|
|
|
2009-06-22 10:57:17 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
2010-04-02 07:30:58 +02:00
|
|
|
if (xmlReader.name() == ProjectElementName)
|
2009-06-22 10:57:17 +02:00
|
|
|
insideProject = false;
|
|
|
|
break;
|
2009-06-23 08:15:00 +02:00
|
|
|
|
2015-12-17 15:40:54 +01:00
|
|
|
// Not handled
|
2009-06-23 08:15:00 +02:00
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
2009-06-22 10:57:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
2017-07-28 05:08:59 +02:00
|
|
|
return projectTagFound;
|
2009-06-22 10:57:17 +02:00
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readRootPath(QXmlStreamReader &reader)
|
2010-08-20 22:58:00 +02:00
|
|
|
{
|
|
|
|
QXmlStreamAttributes attribs = reader.attributes();
|
2017-08-03 12:39:31 +02:00
|
|
|
QString name = attribs.value(QString(), RootPathNameAttrib).toString();
|
2010-08-20 22:58:00 +02:00
|
|
|
if (!name.isEmpty())
|
|
|
|
mRootPath = name;
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readBuildDir(QXmlStreamReader &reader)
|
2016-11-19 20:38:50 +01:00
|
|
|
{
|
|
|
|
mBuildDir.clear();
|
|
|
|
do {
|
|
|
|
const QXmlStreamReader::TokenType type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
mBuildDir = reader.text().toString();
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
return;
|
|
|
|
// Not handled
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readImportProject(QXmlStreamReader &reader)
|
2016-08-18 21:58:50 +02:00
|
|
|
{
|
|
|
|
mImportProject.clear();
|
|
|
|
do {
|
|
|
|
const QXmlStreamReader::TokenType type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
mImportProject = reader.text().toString();
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
return;
|
|
|
|
// Not handled
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2019-04-10 16:49:24 +02:00
|
|
|
bool ProjectFile::readBool(QXmlStreamReader &reader)
|
2017-08-10 00:18:04 +02:00
|
|
|
{
|
2019-04-10 16:49:24 +02:00
|
|
|
bool ret = false;
|
2017-08-10 00:18:04 +02:00
|
|
|
do {
|
|
|
|
const QXmlStreamReader::TokenType type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::Characters:
|
2019-04-10 16:49:24 +02:00
|
|
|
ret = (reader.text().toString() == "true");
|
2017-08-10 00:18:04 +02:00
|
|
|
case QXmlStreamReader::EndElement:
|
2019-04-10 16:49:24 +02:00
|
|
|
return ret;
|
|
|
|
// Not handled
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int ProjectFile::readInt(QXmlStreamReader &reader, int defaultValue)
|
|
|
|
{
|
|
|
|
int ret = defaultValue;
|
|
|
|
do {
|
|
|
|
const QXmlStreamReader::TokenType type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
ret = reader.text().toString().toInt();
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
return ret;
|
2017-08-10 00:18:04 +02:00
|
|
|
// Not handled
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
|
2009-07-04 00:38:47 +02:00
|
|
|
{
|
|
|
|
QXmlStreamReader::TokenType type;
|
|
|
|
bool allRead = false;
|
2011-10-13 20:53:06 +02:00
|
|
|
do {
|
2009-07-04 00:38:47 +02:00
|
|
|
type = reader.readNext();
|
2011-10-13 20:53:06 +02:00
|
|
|
switch (type) {
|
2009-07-04 00:38:47 +02:00
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
|
|
|
|
// Read dir-elements
|
2011-10-13 20:53:06 +02:00
|
|
|
if (reader.name().toString() == DirElementName) {
|
2009-07-04 00:38:47 +02:00
|
|
|
QXmlStreamAttributes attribs = reader.attributes();
|
2017-08-03 12:39:31 +02:00
|
|
|
QString name = attribs.value(QString(), DirNameAttrib).toString();
|
2010-04-02 07:30:58 +02:00
|
|
|
if (!name.isEmpty())
|
2009-07-04 00:38:47 +02:00
|
|
|
mIncludeDirs << name;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
2013-02-10 07:43:09 +01:00
|
|
|
if (reader.name().toString() == IncludeDirElementName)
|
2009-07-04 00:38:47 +02:00
|
|
|
allRead = true;
|
|
|
|
break;
|
|
|
|
|
2015-12-17 15:40:54 +01:00
|
|
|
// Not handled
|
2009-07-04 00:38:47 +02:00
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-13 20:53:06 +02:00
|
|
|
} while (!allRead);
|
2009-07-04 00:38:47 +02:00
|
|
|
}
|
2010-05-20 07:22:19 +02:00
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readDefines(QXmlStreamReader &reader)
|
2010-05-20 07:22:19 +02:00
|
|
|
{
|
|
|
|
QXmlStreamReader::TokenType type;
|
|
|
|
bool allRead = false;
|
2011-10-13 20:53:06 +02:00
|
|
|
do {
|
2010-05-20 07:22:19 +02:00
|
|
|
type = reader.readNext();
|
2011-10-13 20:53:06 +02:00
|
|
|
switch (type) {
|
2010-05-20 07:22:19 +02:00
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
// Read define-elements
|
2011-10-13 20:53:06 +02:00
|
|
|
if (reader.name().toString() == DefineName) {
|
2010-05-20 07:22:19 +02:00
|
|
|
QXmlStreamAttributes attribs = reader.attributes();
|
2017-08-03 12:39:31 +02:00
|
|
|
QString name = attribs.value(QString(), DefineNameAttrib).toString();
|
2010-05-20 07:22:19 +02:00
|
|
|
if (!name.isEmpty())
|
|
|
|
mDefines << name;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
if (reader.name().toString() == DefinesElementName)
|
|
|
|
allRead = true;
|
|
|
|
break;
|
|
|
|
|
2015-12-17 15:40:54 +01:00
|
|
|
// Not handled
|
2010-05-20 07:22:19 +02:00
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-13 20:53:06 +02:00
|
|
|
} while (!allRead);
|
2010-05-20 07:22:19 +02:00
|
|
|
}
|
2010-07-07 23:59:02 +02:00
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
|
2010-08-14 17:42:37 +02:00
|
|
|
{
|
|
|
|
QXmlStreamReader::TokenType type;
|
|
|
|
bool allRead = false;
|
2011-10-13 20:53:06 +02:00
|
|
|
do {
|
2010-08-14 17:42:37 +02:00
|
|
|
type = reader.readNext();
|
2011-10-13 20:53:06 +02:00
|
|
|
switch (type) {
|
2010-08-14 17:42:37 +02:00
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
|
|
|
|
// Read dir-elements
|
2011-10-13 20:53:06 +02:00
|
|
|
if (reader.name().toString() == PathName) {
|
2010-08-14 17:42:37 +02:00
|
|
|
QXmlStreamAttributes attribs = reader.attributes();
|
2017-08-03 12:39:31 +02:00
|
|
|
QString name = attribs.value(QString(), PathNameAttrib).toString();
|
2010-08-14 17:42:37 +02:00
|
|
|
if (!name.isEmpty())
|
|
|
|
mPaths << name;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
if (reader.name().toString() == PathsElementName)
|
|
|
|
allRead = true;
|
|
|
|
break;
|
|
|
|
|
2015-12-17 15:40:54 +01:00
|
|
|
// Not handled
|
2010-08-14 17:42:37 +02:00
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-13 20:53:06 +02:00
|
|
|
} while (!allRead);
|
2010-08-14 17:42:37 +02:00
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readExcludes(QXmlStreamReader &reader)
|
2011-02-27 17:32:53 +01:00
|
|
|
{
|
|
|
|
QXmlStreamReader::TokenType type;
|
|
|
|
bool allRead = false;
|
2011-10-13 20:53:06 +02:00
|
|
|
do {
|
2011-02-27 17:32:53 +01:00
|
|
|
type = reader.readNext();
|
2011-10-13 20:53:06 +02:00
|
|
|
switch (type) {
|
2011-02-27 17:32:53 +01:00
|
|
|
case QXmlStreamReader::StartElement:
|
2011-08-23 18:54:53 +02:00
|
|
|
// Read exclude-elements
|
2011-10-13 20:53:06 +02:00
|
|
|
if (reader.name().toString() == ExcludePathName) {
|
2011-08-23 18:54:53 +02:00
|
|
|
QXmlStreamAttributes attribs = reader.attributes();
|
2017-08-03 12:39:31 +02:00
|
|
|
QString name = attribs.value(QString(), ExcludePathNameAttrib).toString();
|
2011-08-23 18:54:53 +02:00
|
|
|
if (!name.isEmpty())
|
|
|
|
mExcludedPaths << name;
|
|
|
|
}
|
|
|
|
// Read ignore-elements - deprecated but support reading them
|
2011-10-13 20:53:06 +02:00
|
|
|
else if (reader.name().toString() == IgnorePathName) {
|
2011-02-27 17:32:53 +01:00
|
|
|
QXmlStreamAttributes attribs = reader.attributes();
|
2017-08-03 12:39:31 +02:00
|
|
|
QString name = attribs.value(QString(), IgnorePathNameAttrib).toString();
|
2011-02-27 17:32:53 +01:00
|
|
|
if (!name.isEmpty())
|
2011-08-23 18:54:53 +02:00
|
|
|
mExcludedPaths << name;
|
2011-02-27 17:32:53 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
if (reader.name().toString() == IgnoreElementName)
|
|
|
|
allRead = true;
|
2011-08-23 18:54:53 +02:00
|
|
|
if (reader.name().toString() == ExcludeElementName)
|
|
|
|
allRead = true;
|
2011-02-27 17:32:53 +01:00
|
|
|
break;
|
|
|
|
|
2015-12-17 15:40:54 +01:00
|
|
|
// Not handled
|
2011-02-27 17:32:53 +01:00
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
2011-10-13 20:53:06 +02:00
|
|
|
} while (!allRead);
|
2011-02-27 17:32:53 +01:00
|
|
|
}
|
|
|
|
|
2018-03-13 13:07:10 +01:00
|
|
|
void ProjectFile::readPlatform(QXmlStreamReader &reader)
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
const QXmlStreamReader::TokenType type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
mPlatform = reader.text().toString();
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
return;
|
|
|
|
// Not handled
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2013-12-29 18:06:31 +01:00
|
|
|
|
2018-04-09 06:43:48 +02:00
|
|
|
void ProjectFile::readSuppressions(QXmlStreamReader &reader)
|
|
|
|
{
|
|
|
|
QXmlStreamReader::TokenType type;
|
|
|
|
do {
|
|
|
|
type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
// Read library-elements
|
|
|
|
if (reader.name().toString() == SuppressionElementName) {
|
|
|
|
Suppressions::Suppression suppression;
|
|
|
|
if (reader.attributes().hasAttribute(QString(),"fileName"))
|
|
|
|
suppression.fileName = reader.attributes().value(QString(),"fileName").toString().toStdString();
|
|
|
|
if (reader.attributes().hasAttribute(QString(),"lineNumber"))
|
|
|
|
suppression.lineNumber = reader.attributes().value(QString(),"lineNumber").toInt();
|
|
|
|
if (reader.attributes().hasAttribute(QString(),"symbolName"))
|
|
|
|
suppression.symbolName = reader.attributes().value(QString(),"symbolName").toString().toStdString();
|
|
|
|
type = reader.readNext();
|
|
|
|
if (type == QXmlStreamReader::Characters) {
|
|
|
|
suppression.errorId = reader.text().toString().toStdString();
|
|
|
|
}
|
|
|
|
mSuppressions << suppression;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
|
|
|
if (reader.name().toString() != SuppressionElementName)
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Not handled
|
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
|
2013-12-29 18:06:31 +01:00
|
|
|
{
|
|
|
|
QXmlStreamReader::TokenType type;
|
|
|
|
bool allRead = false;
|
|
|
|
do {
|
|
|
|
type = reader.readNext();
|
|
|
|
switch (type) {
|
|
|
|
case QXmlStreamReader::StartElement:
|
|
|
|
// Read library-elements
|
2013-12-30 22:32:50 +01:00
|
|
|
if (reader.name().toString() == elementname) {
|
2013-12-29 18:06:31 +01:00
|
|
|
type = reader.readNext();
|
|
|
|
if (type == QXmlStreamReader::Characters) {
|
2013-12-30 22:32:50 +01:00
|
|
|
QString text = reader.text().toString();
|
|
|
|
stringlist << text;
|
2013-12-29 18:06:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case QXmlStreamReader::EndElement:
|
2013-12-30 22:32:50 +01:00
|
|
|
if (reader.name().toString() != elementname)
|
2013-12-29 18:06:31 +01:00
|
|
|
allRead = true;
|
|
|
|
break;
|
|
|
|
|
2015-12-17 15:40:54 +01:00
|
|
|
// Not handled
|
2013-12-29 18:06:31 +01:00
|
|
|
case QXmlStreamReader::NoToken:
|
|
|
|
case QXmlStreamReader::Invalid:
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
case QXmlStreamReader::Characters:
|
|
|
|
case QXmlStreamReader::Comment:
|
|
|
|
case QXmlStreamReader::DTD:
|
|
|
|
case QXmlStreamReader::EntityReference:
|
|
|
|
case QXmlStreamReader::ProcessingInstruction:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (!allRead);
|
|
|
|
}
|
|
|
|
|
2019-04-19 15:09:55 +02:00
|
|
|
QList<Suppressions::Suppression> ProjectFile::getCheckSuppressions() const
|
|
|
|
{
|
|
|
|
QList<Suppressions::Suppression> ret;
|
|
|
|
const std::string projectFilePath = Path::getPathFromFilename(mFilename.toStdString());
|
|
|
|
foreach (Suppressions::Suppression suppression, getSuppressions()) {
|
|
|
|
if (!suppression.fileName.empty() && suppression.fileName[0]!='*' && !Path::isAbsolute(suppression.fileName))
|
|
|
|
suppression.fileName = Path::simplifyPath(projectFilePath) + suppression.fileName;
|
|
|
|
|
|
|
|
ret.append(suppression);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::setIncludes(const QStringList &includes)
|
2010-07-07 23:59:02 +02:00
|
|
|
{
|
|
|
|
mIncludeDirs = includes;
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::setDefines(const QStringList &defines)
|
2010-07-07 23:59:02 +02:00
|
|
|
{
|
|
|
|
mDefines = defines;
|
|
|
|
}
|
|
|
|
|
2018-10-09 15:05:05 +02:00
|
|
|
void ProjectFile::setUndefines(const QStringList &undefines)
|
|
|
|
{
|
|
|
|
mUndefines = undefines;
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::setCheckPaths(const QStringList &paths)
|
2010-08-14 17:42:37 +02:00
|
|
|
{
|
|
|
|
mPaths = paths;
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::setExcludedPaths(const QStringList &paths)
|
2011-02-27 17:32:53 +01:00
|
|
|
{
|
2011-08-23 18:54:53 +02:00
|
|
|
mExcludedPaths = paths;
|
2011-02-27 17:32:53 +01:00
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::setLibraries(const QStringList &libraries)
|
2013-12-29 18:06:31 +01:00
|
|
|
{
|
|
|
|
mLibraries = libraries;
|
|
|
|
}
|
|
|
|
|
2018-03-13 13:07:10 +01:00
|
|
|
void ProjectFile::setPlatform(const QString &platform)
|
|
|
|
{
|
|
|
|
mPlatform = platform;
|
|
|
|
}
|
|
|
|
|
2018-04-09 06:43:48 +02:00
|
|
|
void ProjectFile::setSuppressions(const QList<Suppressions::Suppression> &suppressions)
|
2013-12-30 22:32:50 +01:00
|
|
|
{
|
|
|
|
mSuppressions = suppressions;
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:30:28 +02:00
|
|
|
void ProjectFile::setAddons(const QStringList &addons)
|
|
|
|
{
|
|
|
|
mAddons = addons;
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
bool ProjectFile::write(const QString &filename)
|
2010-07-07 23:59:02 +02:00
|
|
|
{
|
2010-07-08 15:16:25 +02:00
|
|
|
if (!filename.isEmpty())
|
|
|
|
mFilename = filename;
|
|
|
|
|
2010-07-07 23:59:02 +02:00
|
|
|
QFile file(mFilename);
|
|
|
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
QXmlStreamWriter xmlWriter(&file);
|
|
|
|
xmlWriter.setAutoFormatting(true);
|
|
|
|
xmlWriter.writeStartDocument("1.0");
|
|
|
|
xmlWriter.writeStartElement(ProjectElementName);
|
|
|
|
xmlWriter.writeAttribute(ProjectVersionAttrib, ProjectFileVersion);
|
|
|
|
|
2011-10-13 20:53:06 +02:00
|
|
|
if (!mRootPath.isEmpty()) {
|
2010-08-20 22:58:00 +02:00
|
|
|
xmlWriter.writeStartElement(RootPathName);
|
|
|
|
xmlWriter.writeAttribute(RootPathNameAttrib, mRootPath);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2016-11-19 20:38:50 +01:00
|
|
|
if (!mBuildDir.isEmpty()) {
|
|
|
|
xmlWriter.writeStartElement(BuildDirElementName);
|
|
|
|
xmlWriter.writeCharacters(mBuildDir);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2018-03-13 13:07:10 +01:00
|
|
|
if (!mPlatform.isEmpty()) {
|
|
|
|
xmlWriter.writeStartElement(PlatformElementName);
|
|
|
|
xmlWriter.writeCharacters(mPlatform);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2016-08-18 21:58:50 +02:00
|
|
|
if (!mImportProject.isEmpty()) {
|
|
|
|
xmlWriter.writeStartElement(ImportProjectElementName);
|
|
|
|
xmlWriter.writeCharacters(mImportProject);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2017-08-10 00:18:04 +02:00
|
|
|
xmlWriter.writeStartElement(AnalyzeAllVsConfigsElementName);
|
|
|
|
xmlWriter.writeCharacters(mAnalyzeAllVsConfigs ? "true" : "false");
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
|
2019-04-10 16:49:24 +02:00
|
|
|
xmlWriter.writeStartElement(CheckHeadersElementName);
|
|
|
|
xmlWriter.writeCharacters(mCheckHeaders ? "true" : "false");
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
|
|
|
|
xmlWriter.writeStartElement(CheckUnusedTemplatesElementName);
|
|
|
|
xmlWriter.writeCharacters(mCheckUnusedTemplates ? "true" : "false");
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
|
|
|
|
xmlWriter.writeStartElement(MaxCtuDepthElementName);
|
|
|
|
xmlWriter.writeCharacters(QString::number(mMaxCtuDepth));
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
|
2011-10-13 20:53:06 +02:00
|
|
|
if (!mIncludeDirs.isEmpty()) {
|
2013-02-10 07:43:09 +01:00
|
|
|
xmlWriter.writeStartElement(IncludeDirElementName);
|
2015-12-17 15:40:54 +01:00
|
|
|
foreach (QString incdir, mIncludeDirs) {
|
2010-07-07 23:59:02 +02:00
|
|
|
xmlWriter.writeStartElement(DirElementName);
|
|
|
|
xmlWriter.writeAttribute(DirNameAttrib, incdir);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2011-10-13 20:53:06 +02:00
|
|
|
if (!mDefines.isEmpty()) {
|
2010-07-07 23:59:02 +02:00
|
|
|
xmlWriter.writeStartElement(DefinesElementName);
|
2015-12-17 15:40:54 +01:00
|
|
|
foreach (QString define, mDefines) {
|
2010-07-07 23:59:02 +02:00
|
|
|
xmlWriter.writeStartElement(DefineName);
|
|
|
|
xmlWriter.writeAttribute(DefineNameAttrib, define);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
2010-08-14 17:42:37 +02:00
|
|
|
|
2018-10-09 15:05:05 +02:00
|
|
|
writeStringList(xmlWriter,
|
|
|
|
mUndefines,
|
|
|
|
UndefinesElementName,
|
|
|
|
UndefineName);
|
|
|
|
|
2011-10-13 20:53:06 +02:00
|
|
|
if (!mPaths.isEmpty()) {
|
2010-08-14 17:42:37 +02:00
|
|
|
xmlWriter.writeStartElement(PathsElementName);
|
2015-12-17 15:40:54 +01:00
|
|
|
foreach (QString path, mPaths) {
|
2010-08-14 17:42:37 +02:00
|
|
|
xmlWriter.writeStartElement(PathName);
|
|
|
|
xmlWriter.writeAttribute(PathNameAttrib, path);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2011-10-13 20:53:06 +02:00
|
|
|
if (!mExcludedPaths.isEmpty()) {
|
2011-08-23 18:54:53 +02:00
|
|
|
xmlWriter.writeStartElement(ExcludeElementName);
|
2015-12-17 15:40:54 +01:00
|
|
|
foreach (QString path, mExcludedPaths) {
|
2011-08-23 18:54:53 +02:00
|
|
|
xmlWriter.writeStartElement(ExcludePathName);
|
|
|
|
xmlWriter.writeAttribute(ExcludePathNameAttrib, path);
|
2011-02-28 15:08:14 +01:00
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
writeStringList(xmlWriter,
|
2013-12-30 22:32:50 +01:00
|
|
|
mLibraries,
|
|
|
|
LibrariesElementName,
|
|
|
|
LibraryElementName);
|
|
|
|
|
2018-04-09 06:43:48 +02:00
|
|
|
if (!mSuppressions.isEmpty()) {
|
|
|
|
xmlWriter.writeStartElement(SuppressionsElementName);
|
|
|
|
foreach (const Suppressions::Suppression &suppression, mSuppressions) {
|
|
|
|
xmlWriter.writeStartElement(SuppressionElementName);
|
|
|
|
if (!suppression.fileName.empty())
|
|
|
|
xmlWriter.writeAttribute("fileName", QString::fromStdString(suppression.fileName));
|
|
|
|
if (suppression.lineNumber > 0)
|
|
|
|
xmlWriter.writeAttribute("lineNumber", QString::number(suppression.lineNumber));
|
|
|
|
if (!suppression.symbolName.empty())
|
|
|
|
xmlWriter.writeAttribute("symbolName", QString::fromStdString(suppression.symbolName));
|
|
|
|
if (!suppression.errorId.empty())
|
|
|
|
xmlWriter.writeCharacters(QString::fromStdString(suppression.errorId));
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
2013-12-29 18:06:31 +01:00
|
|
|
|
2019-07-11 21:05:52 +02:00
|
|
|
writeStringList(xmlWriter,
|
|
|
|
mCheckUnknownFunctionReturn,
|
|
|
|
CheckUnknownFunctionReturn,
|
|
|
|
Name);
|
|
|
|
|
|
|
|
if (mCheckAllFunctionParameterValues) {
|
|
|
|
xmlWriter.writeStartElement(CheckAllFunctionParameterValues);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
|
2017-08-03 12:30:28 +02:00
|
|
|
writeStringList(xmlWriter,
|
|
|
|
mAddons,
|
|
|
|
AddonsElementName,
|
|
|
|
AddonElementName);
|
|
|
|
|
2017-09-22 15:41:27 +02:00
|
|
|
QStringList tools;
|
|
|
|
if (mClangAnalyzer)
|
|
|
|
tools << CLANG_ANALYZER;
|
|
|
|
if (mClangTidy)
|
|
|
|
tools << CLANG_TIDY;
|
|
|
|
writeStringList(xmlWriter,
|
|
|
|
tools,
|
|
|
|
ToolsElementName,
|
|
|
|
ToolElementName);
|
|
|
|
|
2017-08-18 17:25:08 +02:00
|
|
|
writeStringList(xmlWriter, mTags, TagsElementName, TagElementName);
|
|
|
|
|
2010-07-07 23:59:02 +02:00
|
|
|
xmlWriter.writeEndDocument();
|
|
|
|
file.close();
|
|
|
|
return true;
|
|
|
|
}
|
2013-12-30 22:32:50 +01:00
|
|
|
|
2017-07-28 05:08:59 +02:00
|
|
|
void ProjectFile::writeStringList(QXmlStreamWriter &xmlWriter, const QStringList &stringlist, const char startelementname[], const char stringelementname[])
|
2013-12-30 22:32:50 +01:00
|
|
|
{
|
|
|
|
if (stringlist.isEmpty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
xmlWriter.writeStartElement(startelementname);
|
2015-12-17 15:40:54 +01:00
|
|
|
foreach (QString str, stringlist) {
|
2013-12-30 22:32:50 +01:00
|
|
|
xmlWriter.writeStartElement(stringelementname);
|
|
|
|
xmlWriter.writeCharacters(str);
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
|
|
|
xmlWriter.writeEndElement();
|
|
|
|
}
|
2016-10-02 18:03:21 +02:00
|
|
|
|
|
|
|
QStringList ProjectFile::fromNativeSeparators(const QStringList &paths)
|
|
|
|
{
|
|
|
|
QStringList ret;
|
|
|
|
foreach (const QString &path, paths)
|
|
|
|
ret << QDir::fromNativeSeparators(path);
|
|
|
|
return ret;
|
|
|
|
}
|
2017-09-22 15:41:27 +02:00
|
|
|
|
2017-09-22 18:57:53 +02:00
|
|
|
QStringList ProjectFile::getAddonsAndTools() const
|
|
|
|
{
|
|
|
|
QStringList ret(mAddons);
|
|
|
|
if (mClangAnalyzer)
|
|
|
|
ret << CLANG_ANALYZER;
|
|
|
|
if (mClangTidy)
|
|
|
|
ret << CLANG_TIDY;
|
|
|
|
return ret;
|
|
|
|
}
|