GUI: Renamed LibraryData to CppcheckLibraryData to try to avoid a name clash

This commit is contained in:
Daniel Marjamäki 2015-08-30 13:41:57 +02:00
parent 779207933c
commit 3bae4ae429
7 changed files with 52 additions and 52 deletions

View File

@ -16,32 +16,32 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "librarydata.h"
#include "cppchecklibrarydata.h"
#include <QDomDocument>
#include <QDomNode>
#include <QDomNodeList>
const unsigned int LibraryData::Function::Arg::ANY = ~0U;
const unsigned int CppcheckLibraryData::Function::Arg::ANY = ~0U;
LibraryData::LibraryData()
CppcheckLibraryData::CppcheckLibraryData()
{
}
static LibraryData::Define loadDefine(const QDomElement &defineElement)
static CppcheckLibraryData::Define loadDefine(const QDomElement &defineElement)
{
LibraryData::Define define;
CppcheckLibraryData::Define define;
define.name = defineElement.attribute("name");
define.value = defineElement.attribute("value");
return define;
}
static LibraryData::Function::Arg loadFunctionArg(const QDomElement &functionArgElement)
static CppcheckLibraryData::Function::Arg loadFunctionArg(const QDomElement &functionArgElement)
{
LibraryData::Function::Arg arg;
CppcheckLibraryData::Function::Arg arg;
if (functionArgElement.attribute("nr") == "any")
arg.nr = LibraryData::Function::Arg::ANY;
arg.nr = CppcheckLibraryData::Function::Arg::ANY;
else
arg.nr = functionArgElement.attribute("nr").toUInt();
for (QDomElement childElement = functionArgElement.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) {
@ -58,7 +58,7 @@ static LibraryData::Function::Arg loadFunctionArg(const QDomElement &functionArg
else if (childElement.tagName() == "valid")
arg.valid = childElement.text();
else if (childElement.tagName() == "minsize") {
LibraryData::Function::Arg::MinSize minsize;
CppcheckLibraryData::Function::Arg::MinSize minsize;
minsize.type = childElement.attribute("type");
minsize.arg = childElement.attribute("arg");
minsize.arg2 = childElement.attribute("arg2");
@ -68,9 +68,9 @@ static LibraryData::Function::Arg loadFunctionArg(const QDomElement &functionArg
return arg;
}
static LibraryData::Function loadFunction(const QDomElement &functionElement, const QStringList &comments)
static CppcheckLibraryData::Function loadFunction(const QDomElement &functionElement, const QStringList &comments)
{
LibraryData::Function function;
CppcheckLibraryData::Function function;
function.comments = comments;
function.name = functionElement.attribute("name");
for (QDomElement childElement = functionElement.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) {
@ -88,7 +88,7 @@ static LibraryData::Function loadFunction(const QDomElement &functionElement, co
function.formatstr.scan = childElement.attribute("scan");
function.formatstr.secure = childElement.attribute("secure");
} else if (childElement.tagName() == "arg") {
const LibraryData::Function::Arg fa = loadFunctionArg(childElement);
const CppcheckLibraryData::Function::Arg fa = loadFunctionArg(childElement);
function.args.append(fa);
} else {
int x = 123;
@ -100,13 +100,13 @@ static LibraryData::Function loadFunction(const QDomElement &functionElement, co
}
static LibraryData::MemoryResource loadMemoryResource(const QDomElement &element)
static CppcheckLibraryData::MemoryResource loadMemoryResource(const QDomElement &element)
{
LibraryData::MemoryResource memoryresource;
CppcheckLibraryData::MemoryResource memoryresource;
memoryresource.type = element.tagName();
for (QDomElement childElement = element.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) {
if (childElement.tagName() == "alloc") {
LibraryData::MemoryResource::Alloc alloc;
CppcheckLibraryData::MemoryResource::Alloc alloc;
alloc.init = (childElement.attribute("init", "false") == "true");
alloc.name = childElement.text();
memoryresource.alloc.append(alloc);
@ -118,9 +118,9 @@ static LibraryData::MemoryResource loadMemoryResource(const QDomElement &element
return memoryresource;
}
static LibraryData::PodType loadPodType(const QDomElement &element)
static CppcheckLibraryData::PodType loadPodType(const QDomElement &element)
{
LibraryData::PodType podtype;
CppcheckLibraryData::PodType podtype;
podtype.name = element.attribute("name");
podtype.size = element.attribute("size");
podtype.sign = element.attribute("sign");
@ -128,7 +128,7 @@ static LibraryData::PodType loadPodType(const QDomElement &element)
}
bool LibraryData::open(QIODevice &file)
bool CppcheckLibraryData::open(QIODevice &file)
{
QDomDocument doc;
if (!doc.setContent(&file))
@ -162,7 +162,7 @@ bool LibraryData::open(QIODevice &file)
static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Function &function)
static QDomElement FunctionElement(QDomDocument &doc, const CppcheckLibraryData::Function &function)
{
QDomElement functionElement = doc.createElement("function");
functionElement.setAttribute("name", function.name);
@ -188,10 +188,10 @@ static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Functio
}
// Argument info..
foreach(const LibraryData::Function::Arg &arg, function.args) {
foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) {
QDomElement argElement = doc.createElement("arg");
functionElement.appendChild(argElement);
if (arg.nr == LibraryData::Function::Arg::ANY)
if (arg.nr == CppcheckLibraryData::Function::Arg::ANY)
argElement.setAttribute("nr", "any");
else
argElement.setAttribute("nr", arg.nr);
@ -213,7 +213,7 @@ static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Functio
}
if (!arg.minsizes.isEmpty()) {
foreach(const LibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
foreach(const CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
QDomElement e = doc.createElement("minsize");
e.setAttribute("type", minsize.type);
e.setAttribute("arg", minsize.arg);
@ -227,10 +227,10 @@ static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Functio
return functionElement;
}
static QDomElement MemoryResourceElement(QDomDocument &doc, const LibraryData::MemoryResource &mr)
static QDomElement MemoryResourceElement(QDomDocument &doc, const CppcheckLibraryData::MemoryResource &mr)
{
QDomElement element = doc.createElement(mr.type);
foreach(const LibraryData::MemoryResource::Alloc &alloc, mr.alloc) {
foreach(const CppcheckLibraryData::MemoryResource::Alloc &alloc, mr.alloc) {
QDomElement e = doc.createElement("alloc");
if (alloc.init)
e.setAttribute("init", "true");
@ -251,7 +251,7 @@ static QDomElement MemoryResourceElement(QDomDocument &doc, const LibraryData::M
}
QString LibraryData::toString() const
QString CppcheckLibraryData::toString() const
{
QDomDocument doc;
QDomElement root = doc.createElement("def");

View File

@ -16,17 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBRARYDATA_H
#define LIBRARYDATA_H
#ifndef CPPCHECKLIBRARYDATA_H
#define CPPCHECKLIBRARYDATA_H
#include <QList>
#include <QString>
#include <QStringList>
#include <QIODevice>
class LibraryData {
class CppcheckLibraryData {
public:
LibraryData();
CppcheckLibraryData();
struct Define {
QString name;

View File

@ -110,7 +110,7 @@ HEADERS += aboutdialog.h \
xmlreportv1.h \
xmlreportv2.h \
librarydialog.h \
librarydata.h \
cppchecklibrarydata.h \
libraryaddfunctiondialog.h \
libraryeditargdialog.h
@ -148,7 +148,7 @@ SOURCES += aboutdialog.cpp \
xmlreportv1.cpp \
xmlreportv2.cpp \
librarydialog.cpp \
librarydata.cpp \
cppchecklibrarydata.cpp \
libraryaddfunctiondialog.cpp \
libraryeditargdialog.cpp

View File

@ -65,7 +65,7 @@ void LibraryDialog::openCfg()
mFileName = selectedFile;
ui->buttonSave->setEnabled(false);
ui->functions->clear();
foreach(const struct LibraryData::Function &function, data.functions) {
foreach(const struct CppcheckLibraryData::Function &function, data.functions) {
ui->functions->addItem(function.name);
}
ignoreChanges = false;
@ -90,12 +90,12 @@ void LibraryDialog::addFunction()
LibraryAddFunctionDialog *d = new LibraryAddFunctionDialog;
if (d->exec() == QDialog::Accepted && !d->functionName().isEmpty()) {
LibraryData::Function f;
CppcheckLibraryData::Function f;
f.name = d->functionName();
int args = d->numberOfArguments();
for (int i = 1; i <= args; i++) {
LibraryData::Function::Arg arg;
CppcheckLibraryData::Function::Arg arg;
arg.nr = i;
f.args.append(arg);
}
@ -117,7 +117,7 @@ void LibraryDialog::selectFunction(int row)
}
ignoreChanges = true;
const LibraryData::Function &function = data.functions[row];
const CppcheckLibraryData::Function &function = data.functions[row];
ui->functionreturn->setChecked(!function.noreturn);
ui->useretval->setChecked(function.useretval);
ui->leakignore->setChecked(function.leakignore);
@ -130,7 +130,7 @@ void LibraryDialog::changeFunction()
if (ignoreChanges)
return;
foreach(const QListWidgetItem *item, ui->functions->selectedItems()) {
LibraryData::Function &function = data.functions[ui->functions->row(item)];
CppcheckLibraryData::Function &function = data.functions[ui->functions->row(item)];
function.noreturn = !ui->functionreturn->isChecked();
function.useretval = ui->useretval->isChecked();
function.leakignore = ui->leakignore->isChecked();
@ -145,8 +145,8 @@ void LibraryDialog::editArg()
if (ui->arguments->selectedItems().count() != 1)
return;
LibraryData::Function &function = data.functions[ui->functions->row(ui->functions->selectedItems().first())];
LibraryData::Function::Arg &arg = function.args[ui->arguments->row(ui->arguments->selectedItems().first())];
CppcheckLibraryData::Function &function = data.functions[ui->functions->row(ui->functions->selectedItems().first())];
CppcheckLibraryData::Function::Arg &arg = function.args[ui->arguments->row(ui->arguments->selectedItems().first())];
LibraryEditArgDialog *d = new LibraryEditArgDialog(0, arg);
if (d->exec() == QDialog::Accepted) {
@ -158,12 +158,12 @@ void LibraryDialog::editArg()
ui->buttonSave->setEnabled(true);
}
void LibraryDialog::updateArguments(const LibraryData::Function &function)
void LibraryDialog::updateArguments(const CppcheckLibraryData::Function &function)
{
ui->arguments->clear();
foreach(const LibraryData::Function::Arg &arg, function.args) {
foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) {
QString s("arg");
if (arg.nr != LibraryData::Function::Arg::ANY)
if (arg.nr != CppcheckLibraryData::Function::Arg::ANY)
s += QString::number(arg.nr);
s += "\n not bool: " + QString(arg.notbool ? "true" : "false");
@ -172,7 +172,7 @@ void LibraryDialog::updateArguments(const LibraryData::Function &function)
s += "\n format string: " + QString(arg.formatstr ? "true" : "false");
s += "\n strz: " + QString(arg.strz ? "true" : "false");
s += "\n valid: " + QString(arg.valid.isEmpty() ? "any" : arg.valid);
foreach(const LibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
foreach(const CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.minsizes) {
s += "\n minsize: " + minsize.type + " " + minsize.arg + " " + minsize.arg2;
}

View File

@ -22,7 +22,7 @@
#include <QDialog>
#include <QFile>
#include "librarydata.h"
#include "cppchecklibrarydata.h"
class QListWidgetItem;
@ -47,11 +47,11 @@ private slots:
private:
Ui::LibraryDialog *ui;
LibraryData data;
CppcheckLibraryData data;
QString mFileName;
bool ignoreChanges;
void updateArguments(const LibraryData::Function &function);
void updateArguments(const CppcheckLibraryData::Function &function);
};
#endif // LIBRARYDIALOG_H

View File

@ -1,7 +1,7 @@
#include "libraryeditargdialog.h"
#include "ui_libraryeditargdialog.h"
LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const LibraryData::Function::Arg &a) :
LibraryEditArgDialog::LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &a) :
QDialog(parent),
ui(new Ui::LibraryEditArgDialog),
arg(a)
@ -22,9 +22,9 @@ LibraryEditArgDialog::~LibraryEditArgDialog()
delete ui;
}
LibraryData::Function::Arg LibraryEditArgDialog::getArg() const
CppcheckLibraryData::Function::Arg LibraryEditArgDialog::getArg() const
{
LibraryData::Function::Arg ret;
CppcheckLibraryData::Function::Arg ret;
ret.notbool = ui->notbool->isChecked();
ret.notnull = ui->notnull->isChecked();
ret.notuninit = ui->notuninit->isChecked();

View File

@ -2,7 +2,7 @@
#define LIBRARYEDITARGDIALOG_H
#include <QDialog>
#include "librarydata.h"
#include "cppchecklibrarydata.h"
namespace Ui {
class LibraryEditArgDialog;
@ -12,15 +12,15 @@ class LibraryEditArgDialog : public QDialog {
Q_OBJECT
public:
LibraryEditArgDialog(QWidget *parent, const LibraryData::Function::Arg &a);
LibraryEditArgDialog(QWidget *parent, const CppcheckLibraryData::Function::Arg &a);
~LibraryEditArgDialog();
LibraryData::Function::Arg getArg() const;
CppcheckLibraryData::Function::Arg getArg() const;
private:
Ui::LibraryEditArgDialog *ui;
LibraryData::Function::Arg arg;
CppcheckLibraryData::Function::Arg arg;
};
#endif // LIBRARYEDITARGDIALOG_H