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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "librarydata.h" #include "cppchecklibrarydata.h"
#include <QDomDocument> #include <QDomDocument>
#include <QDomNode> #include <QDomNode>
#include <QDomNodeList> #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.name = defineElement.attribute("name");
define.value = defineElement.attribute("value"); define.value = defineElement.attribute("value");
return define; 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") if (functionArgElement.attribute("nr") == "any")
arg.nr = LibraryData::Function::Arg::ANY; arg.nr = CppcheckLibraryData::Function::Arg::ANY;
else else
arg.nr = functionArgElement.attribute("nr").toUInt(); arg.nr = functionArgElement.attribute("nr").toUInt();
for (QDomElement childElement = functionArgElement.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) { 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") else if (childElement.tagName() == "valid")
arg.valid = childElement.text(); arg.valid = childElement.text();
else if (childElement.tagName() == "minsize") { else if (childElement.tagName() == "minsize") {
LibraryData::Function::Arg::MinSize minsize; CppcheckLibraryData::Function::Arg::MinSize minsize;
minsize.type = childElement.attribute("type"); minsize.type = childElement.attribute("type");
minsize.arg = childElement.attribute("arg"); minsize.arg = childElement.attribute("arg");
minsize.arg2 = childElement.attribute("arg2"); minsize.arg2 = childElement.attribute("arg2");
@ -68,9 +68,9 @@ static LibraryData::Function::Arg loadFunctionArg(const QDomElement &functionArg
return arg; 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.comments = comments;
function.name = functionElement.attribute("name"); function.name = functionElement.attribute("name");
for (QDomElement childElement = functionElement.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) { 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.scan = childElement.attribute("scan");
function.formatstr.secure = childElement.attribute("secure"); function.formatstr.secure = childElement.attribute("secure");
} else if (childElement.tagName() == "arg") { } else if (childElement.tagName() == "arg") {
const LibraryData::Function::Arg fa = loadFunctionArg(childElement); const CppcheckLibraryData::Function::Arg fa = loadFunctionArg(childElement);
function.args.append(fa); function.args.append(fa);
} else { } else {
int x = 123; 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(); memoryresource.type = element.tagName();
for (QDomElement childElement = element.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) { for (QDomElement childElement = element.firstChildElement(); !childElement.isNull(); childElement = childElement.nextSiblingElement()) {
if (childElement.tagName() == "alloc") { if (childElement.tagName() == "alloc") {
LibraryData::MemoryResource::Alloc alloc; CppcheckLibraryData::MemoryResource::Alloc alloc;
alloc.init = (childElement.attribute("init", "false") == "true"); alloc.init = (childElement.attribute("init", "false") == "true");
alloc.name = childElement.text(); alloc.name = childElement.text();
memoryresource.alloc.append(alloc); memoryresource.alloc.append(alloc);
@ -118,9 +118,9 @@ static LibraryData::MemoryResource loadMemoryResource(const QDomElement &element
return memoryresource; 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.name = element.attribute("name");
podtype.size = element.attribute("size"); podtype.size = element.attribute("size");
podtype.sign = element.attribute("sign"); 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; QDomDocument doc;
if (!doc.setContent(&file)) 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"); QDomElement functionElement = doc.createElement("function");
functionElement.setAttribute("name", function.name); functionElement.setAttribute("name", function.name);
@ -188,10 +188,10 @@ static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Functio
} }
// Argument info.. // Argument info..
foreach(const LibraryData::Function::Arg &arg, function.args) { foreach(const CppcheckLibraryData::Function::Arg &arg, function.args) {
QDomElement argElement = doc.createElement("arg"); QDomElement argElement = doc.createElement("arg");
functionElement.appendChild(argElement); functionElement.appendChild(argElement);
if (arg.nr == LibraryData::Function::Arg::ANY) if (arg.nr == CppcheckLibraryData::Function::Arg::ANY)
argElement.setAttribute("nr", "any"); argElement.setAttribute("nr", "any");
else else
argElement.setAttribute("nr", arg.nr); argElement.setAttribute("nr", arg.nr);
@ -213,7 +213,7 @@ static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Functio
} }
if (!arg.minsizes.isEmpty()) { 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"); QDomElement e = doc.createElement("minsize");
e.setAttribute("type", minsize.type); e.setAttribute("type", minsize.type);
e.setAttribute("arg", minsize.arg); e.setAttribute("arg", minsize.arg);
@ -227,10 +227,10 @@ static QDomElement FunctionElement(QDomDocument &doc, const LibraryData::Functio
return functionElement; 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); 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"); QDomElement e = doc.createElement("alloc");
if (alloc.init) if (alloc.init)
e.setAttribute("init", "true"); 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; QDomDocument doc;
QDomElement root = doc.createElement("def"); QDomElement root = doc.createElement("def");

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
#include "libraryeditargdialog.h" #include "libraryeditargdialog.h"
#include "ui_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), QDialog(parent),
ui(new Ui::LibraryEditArgDialog), ui(new Ui::LibraryEditArgDialog),
arg(a) arg(a)
@ -22,9 +22,9 @@ LibraryEditArgDialog::~LibraryEditArgDialog()
delete ui; 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.notbool = ui->notbool->isChecked();
ret.notnull = ui->notnull->isChecked(); ret.notnull = ui->notnull->isChecked();
ret.notuninit = ui->notuninit->isChecked(); ret.notuninit = ui->notuninit->isChecked();

View File

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