Skip to content

Commit e2b859b

Browse files
committed
Library Editor: Load/save <warn> elements
1 parent 8db7299 commit e2b859b

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

gui/cppchecklibrarydata.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,16 @@ static CppcheckLibraryData::Function loadFunction(QXmlStreamReader &xmlReader, c
145145
function.formatstr.secure = xmlReader.attributes().value("secure").toString();
146146
} else if (elementName == "arg")
147147
function.args.append(loadFunctionArg(xmlReader));
148+
else if (elementName == "warn") {
149+
function.warn.severity = xmlReader.attributes().value("severity").toString();
150+
function.warn.reason = xmlReader.attributes().value("reason").toString();
151+
function.warn.alternatives = xmlReader.attributes().value("alternatives").toString();
152+
function.warn.msg = xmlReader.readElementText();
153+
}
148154
}
149155
return function;
150156
}
151157

152-
153158
static CppcheckLibraryData::MemoryResource loadMemoryResource(QXmlStreamReader &xmlReader)
154159
{
155160
CppcheckLibraryData::MemoryResource memoryresource;
@@ -329,6 +334,25 @@ static void writeFunction(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData
329334

330335
xmlWriter.writeEndElement();
331336
}
337+
338+
if (!function.warn.isEmpty()) {
339+
xmlWriter.writeStartElement("warn");
340+
341+
if (!function.warn.severity.isEmpty())
342+
xmlWriter.writeAttribute("severity", function.warn.severity);
343+
344+
if (!function.warn.reason.isEmpty())
345+
xmlWriter.writeAttribute("reason", function.warn.reason);
346+
347+
if (!function.warn.alternatives.isEmpty())
348+
xmlWriter.writeAttribute("alternatives", function.warn.alternatives);
349+
350+
if (!function.warn.msg.isEmpty())
351+
xmlWriter.writeCharacters(function.warn.msg);
352+
353+
xmlWriter.writeEndElement();
354+
}
355+
332356
xmlWriter.writeEndElement();
333357
}
334358

gui/cppchecklibrarydata.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ class CppcheckLibraryData {
9797
QList<struct MinSize> minsizes;
9898
};
9999
QList<struct Arg> args;
100+
101+
struct {
102+
QString severity;
103+
QString reason;
104+
QString alternatives;
105+
QString msg;
106+
107+
bool isEmpty() const {
108+
return severity.isEmpty() &&
109+
reason.isEmpty() &&
110+
alternatives.isEmpty() &&
111+
msg.isEmpty();
112+
}
113+
} warn;
100114
};
101115

102116
struct MemoryResource {

0 commit comments

Comments
 (0)