28 #include <QXmlStreamAttributes>
29 #include <QXmlStreamReader>
30 #include <QXmlStreamWriter>
33 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
42 throw std::runtime_error(QObject::tr(
"line %1: Unhandled element %2").arg(xmlReader.lineNumber()).arg(xmlReader.name().toString()).toStdString());
47 throw std::runtime_error(QObject::tr(
"line %1: Mandatory attribute '%2' missing in '%3'")
48 .arg(xmlReader.lineNumber())
50 .arg(xmlReader.name().toString()).toStdString());
56 container.
id = xmlReader.attributes().value(
"id").toString();
57 container.
inherits = xmlReader.attributes().value(
"inherits").toString();
58 container.
startPattern = xmlReader.attributes().value(
"startPattern").toString();
59 container.
endPattern = xmlReader.attributes().value(
"endPattern").toString();
60 container.
opLessAllowed = xmlReader.attributes().value(
"opLessAllowed").toString();
61 container.
itEndPattern = xmlReader.attributes().value(
"itEndPattern").toString();
63 QXmlStreamReader::TokenType type;
64 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
65 xmlReader.name().toString() !=
"container") {
66 if (type != QXmlStreamReader::StartElement)
68 const QString elementName = xmlReader.name().toString();
69 if (elementName ==
"type") {
71 container.
type.
string = xmlReader.attributes().value(
"string").toString();
72 }
else if (elementName ==
"size" || elementName ==
"access" || elementName ==
"other" || elementName ==
"rangeItemRecordType") {
73 const QString indexOperator = xmlReader.attributes().value(
"indexOperator").toString();
74 if (elementName ==
"access" && indexOperator ==
"array-like")
76 const QString templateParameter = xmlReader.attributes().value(
"templateParameter").toString();
77 if (elementName ==
"size" && !templateParameter.isEmpty())
80 type = xmlReader.readNext();
81 if (xmlReader.name().toString() == elementName)
83 if (type != QXmlStreamReader::StartElement)
86 function.
name = xmlReader.attributes().value(
"name").toString();
87 function.action = xmlReader.attributes().value(
"action").toString();
88 function.yields = xmlReader.attributes().value(
"yields").toString();
89 if (elementName ==
"size")
91 else if (elementName ==
"access")
93 else if (elementName ==
"rangeItemRecordType") {
95 rangeItemRecordType.
name = xmlReader.attributes().value(
"name").toString();
96 rangeItemRecordType.
templateParameter = xmlReader.attributes().value(
"templateParameter").toString();
111 define.
name = xmlReader.attributes().value(
"name").toString();
112 define.
value = xmlReader.attributes().value(
"value").toString();
118 return xmlReader.attributes().value(
"name").toString();
124 smartPointer.
name = xmlReader.attributes().value(
"class-name").toString();
125 QXmlStreamReader::TokenType type;
126 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
127 xmlReader.name().toString() !=
"smart-pointer") {
128 if (type != QXmlStreamReader::StartElement)
130 const QString elementName = xmlReader.name().toString();
131 if (elementName ==
"unique") {
132 smartPointer.
unique =
true;
143 QXmlStreamReader::TokenType type;
144 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
145 xmlReader.name().toString() !=
"type-checks") {
146 if (type != QXmlStreamReader::StartElement)
148 const QString elementName = xmlReader.name().toString();
149 if (elementName ==
"suppress" || elementName ==
"check") {
150 QPair<QString, QString> entry(elementName, xmlReader.readElementText());
151 typeChecks.append(entry);
160 QString argnr = xmlReader.attributes().value(
"nr").toString();
163 else if (argnr ==
"variadic")
166 arg.
nr = argnr.toUInt();
167 arg.
defaultValue = xmlReader.attributes().value(
"default").toString();
169 QXmlStreamReader::TokenType type;
170 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
171 xmlReader.name().toString() !=
"arg") {
172 if (type != QXmlStreamReader::StartElement)
174 const QString elementName = xmlReader.name().toString();
175 if (elementName ==
"not-bool")
177 else if (elementName ==
"not-null")
179 else if (elementName ==
"not-uninit")
181 else if (elementName ==
"strz")
183 else if (elementName ==
"formatstr")
185 else if (elementName ==
"valid")
186 arg.
valid = xmlReader.readElementText();
187 else if (elementName ==
"minsize") {
189 minsize.
type = xmlReader.attributes().value(
"type").toString();
190 minsize.
arg = xmlReader.attributes().value(
"arg").toString();
191 minsize.
arg2 = xmlReader.attributes().value(
"arg2").toString();
193 }
else if (elementName ==
"iterator") {
195 arg.
iterator.
type = xmlReader.attributes().value(
"type").toString();
207 function.name = xmlReader.attributes().value(
"name").toString();
208 QXmlStreamReader::TokenType type;
209 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
210 xmlReader.name().toString() !=
"function") {
211 if (type != QXmlStreamReader::StartElement)
213 const QString elementName = xmlReader.name().toString();
214 if (elementName ==
"noreturn")
216 else if (elementName ==
"pure")
217 function.gccPure =
true;
218 else if (elementName ==
"const")
219 function.gccConst =
true;
220 else if (elementName ==
"leak-ignore")
221 function.leakignore =
true;
222 else if (elementName ==
"use-retval")
223 function.useretval =
true;
224 else if (elementName ==
"returnValue") {
225 const QString container = xmlReader.attributes().value(
"container").toString();
226 function.returnValue.container = container.isNull() ? -1 : container.toInt();
227 function.returnValue.type = xmlReader.attributes().value(
"type").toString();
228 function.returnValue.value = xmlReader.readElementText();
229 }
else if (elementName ==
"formatstr") {
230 function.formatstr.scan = xmlReader.attributes().value(
"scan").toString();
231 function.formatstr.secure = xmlReader.attributes().value(
"secure").toString();
232 }
else if (elementName ==
"arg")
234 else if (elementName ==
"warn") {
235 function.warn.severity = xmlReader.attributes().value(
"severity").toString();
236 function.warn.cstd = xmlReader.attributes().value(
"cstd").toString();
237 function.warn.reason = xmlReader.attributes().value(
"reason").toString();
238 function.warn.alternatives = xmlReader.attributes().value(
"alternatives").toString();
239 function.warn.msg = xmlReader.readElementText();
240 }
else if (elementName ==
"not-overlapping-data") {
241 const QStringList attributeList {
"ptr1-arg",
"ptr2-arg",
"size-arg",
"strlen-arg"};
242 for (
const QString &attr : attributeList) {
243 if (xmlReader.attributes().hasAttribute(attr)) {
244 function.notOverlappingDataArgs[attr] = xmlReader.attributes().value(attr).toString();
247 }
else if (elementName ==
"container") {
248 const QStringList attributeList {
"action",
"yields"};
249 for (
const QString &attr : attributeList) {
250 if (xmlReader.attributes().hasAttribute(attr)) {
251 function.containerAttributes[attr] = xmlReader.attributes().value(attr).toString();
264 memoryresource.
type = xmlReader.name().toString();
265 QXmlStreamReader::TokenType type;
266 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
267 xmlReader.name().toString() != memoryresource.
type) {
268 if (type != QXmlStreamReader::StartElement)
270 const QString elementName = xmlReader.name().toString();
271 if (elementName ==
"alloc" || elementName ==
"realloc") {
273 alloc.
isRealloc = (elementName ==
"realloc");
274 alloc.
init = (xmlReader.attributes().value(
"init").toString() ==
"true");
275 if (xmlReader.attributes().hasAttribute(
"arg")) {
276 alloc.
arg = xmlReader.attributes().value(
"arg").toInt();
278 if (alloc.
isRealloc && xmlReader.attributes().hasAttribute(
"realloc-arg")) {
279 alloc.
reallocArg = xmlReader.attributes().value(
"realloc-arg").toInt();
281 if (memoryresource.
type ==
"memory") {
282 alloc.
bufferSize = xmlReader.attributes().value(
"buffer-size").toString();
284 alloc.
name = xmlReader.readElementText();
285 memoryresource.
alloc.append(alloc);
286 }
else if (elementName ==
"dealloc") {
288 if (xmlReader.attributes().hasAttribute(
"arg")) {
289 dealloc.
arg = xmlReader.attributes().value(
"arg").toInt();
291 dealloc.
name = xmlReader.readElementText();
292 memoryresource.
dealloc.append(dealloc);
293 }
else if (elementName ==
"use")
294 memoryresource.
use.append(xmlReader.readElementText());
298 return memoryresource;
304 podtype.
name = xmlReader.attributes().value(
"name").toString();
305 if (podtype.
name.isEmpty()) {
308 podtype.
stdtype = xmlReader.attributes().value(
"stdtype").toString();
309 podtype.
size = xmlReader.attributes().value(
"size").toString();
310 podtype.
sign = xmlReader.attributes().value(
"sign").toString();
317 platformType.
name = xmlReader.attributes().value(
"name").toString();
318 platformType.
value = xmlReader.attributes().value(
"value").toString();
320 QXmlStreamReader::TokenType type;
321 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
322 xmlReader.name().toString() !=
"platformtype") {
323 if (type != QXmlStreamReader::StartElement)
325 const QString elementName = xmlReader.name().toString();
326 if (QStringList({
"unsigned",
"long",
"pointer",
"const_ptr",
"ptr_ptr"}).
contains(elementName)) {
327 platformType.
types.append(elementName);
328 }
else if (elementName ==
"platform") {
329 platformType.
platforms.append(xmlReader.attributes().value(
"type").toString());
341 QXmlStreamReader::TokenType type;
342 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
343 xmlReader.name().toString() !=
"reflection") {
344 if (type != QXmlStreamReader::StartElement)
346 const QString elementName = xmlReader.name().toString();
347 if (elementName ==
"call") {
349 if (xmlReader.attributes().hasAttribute(
"arg")) {
350 call.
arg = xmlReader.attributes().value(
"arg").toInt();
354 call.
name = xmlReader.readElementText();
355 reflection.
calls.append(call);
368 QXmlStreamReader::TokenType type;
369 if (xmlReader.attributes().hasAttribute(
"ext")) {
370 markup.
ext = xmlReader.attributes().value(
"ext").toString();
374 if (xmlReader.attributes().hasAttribute(
"aftercode")) {
375 markup.
afterCode = (xmlReader.attributes().value(
"aftercode") == QString(
"true"));
379 if (xmlReader.attributes().hasAttribute(
"reporterrors")) {
380 markup.
reportErrors = (xmlReader.attributes().value(
"reporterrors") == QString(
"true"));
385 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
386 xmlReader.name().toString() !=
"markup") {
387 if (type != QXmlStreamReader::StartElement)
389 const QString elementName = xmlReader.name().toString();
390 if (elementName ==
"keywords") {
391 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
392 xmlReader.name().toString() !=
"keywords") {
393 if (type != QXmlStreamReader::StartElement)
395 if (xmlReader.name().toString() ==
"keyword") {
396 markup.
keywords.append(xmlReader.attributes().value(
"name").toString());
401 }
else if (elementName ==
"codeblocks") {
404 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
405 xmlReader.name().toString() !=
"codeblocks") {
406 if (type != QXmlStreamReader::StartElement)
408 if (xmlReader.name().toString() ==
"block") {
409 codeBlock.
blocks.append(xmlReader.attributes().value(
"name").toString());
410 }
else if (xmlReader.name().toString() ==
"structure") {
411 codeBlock.
offset = xmlReader.attributes().value(
"offset").toInt();
412 codeBlock.
start = xmlReader.attributes().value(
"start").toString();
413 codeBlock.
end = xmlReader.attributes().value(
"end").toString();
419 }
else if (elementName ==
"exported") {
422 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
423 xmlReader.name().toString() !=
"exported") {
424 if (type != QXmlStreamReader::StartElement)
426 if (xmlReader.name().toString() ==
"exporter") {
427 exporter.
prefix = xmlReader.attributes().value(
"prefix").toString();
428 }
else if (xmlReader.name().toString() ==
"prefix") {
429 exporter.
prefixList.append(xmlReader.readElementText());
430 }
else if (xmlReader.name().toString() ==
"suffix") {
431 exporter.
suffixList.append(xmlReader.readElementText());
437 }
else if (elementName ==
"imported") {
438 while ((type = xmlReader.readNext()) != QXmlStreamReader::EndElement ||
439 xmlReader.name().toString() !=
"imported") {
440 if (type != QXmlStreamReader::StartElement)
442 if (xmlReader.name().toString() ==
"importer") {
443 markup.
importer.append(xmlReader.readElementText());
459 entrypoint.
name = xmlReader.attributes().value(
"name").toString();
467 QXmlStreamReader xmlReader(&file);
468 while (!xmlReader.atEnd()) {
469 const QXmlStreamReader::TokenType t = xmlReader.readNext();
471 case QXmlStreamReader::Comment:
472 if (!comments.isEmpty())
474 comments += xmlReader.text().toString();
476 case QXmlStreamReader::StartElement:
478 const QString elementName(xmlReader.name().toString());
479 if (elementName ==
"def")
481 else if (elementName ==
"container")
483 else if (elementName ==
"define")
485 else if (elementName ==
"undefine")
487 else if (elementName ==
"function")
489 else if (elementName ==
"memory" || elementName ==
"resource")
491 else if (elementName ==
"podtype")
493 else if (elementName ==
"smart-pointer")
495 else if (elementName ==
"type-checks")
497 else if (elementName ==
"platformtype")
499 else if (elementName ==
"reflection")
501 else if (elementName ==
"markup")
503 else if (elementName ==
"entrypoint")
507 }
catch (std::runtime_error &e) {
516 if (xmlReader.hasError())
517 return xmlReader.errorString();
521 static void writeContainerFunctions(QXmlStreamWriter &xmlWriter,
const QString &name,
int extra,
const QList<CppcheckLibraryData::Container::Function> &functions)
523 if (functions.isEmpty() && extra < 0)
525 xmlWriter.writeStartElement(name);
527 if (name ==
"access")
528 xmlWriter.writeAttribute(
"indexOperator",
"array-like");
529 else if (name ==
"size")
530 xmlWriter.writeAttribute(
"templateParameter", QString::number(extra));
533 xmlWriter.writeStartElement(
"function");
534 xmlWriter.writeAttribute(
"name",
function.name);
535 if (!
function.action.isEmpty())
536 xmlWriter.writeAttribute(
"action",
function.action);
537 if (!
function.yields.isEmpty())
538 xmlWriter.writeAttribute(
"yields",
function.yields);
539 xmlWriter.writeEndElement();
541 xmlWriter.writeEndElement();
546 if (rangeItemRecords.isEmpty())
548 xmlWriter.writeStartElement(
"rangeItemRecordType");
550 xmlWriter.writeStartElement(
"member");
551 xmlWriter.writeAttribute(
"name", item.name);
552 xmlWriter.writeAttribute(
"templateParameter", item.templateParameter);
553 xmlWriter.writeEndElement();
555 xmlWriter.writeEndElement();
560 xmlWriter.writeStartElement(
"container");
561 xmlWriter.writeAttribute(
"id", container.
id);
563 xmlWriter.writeAttribute(
"startPattern", container.
startPattern);
565 xmlWriter.writeAttribute(
"endPattern", container.
endPattern);
567 xmlWriter.writeAttribute(
"inherits", container.
inherits);
569 xmlWriter.writeAttribute(
"opLessAllowed", container.
opLessAllowed);
571 xmlWriter.writeAttribute(
"itEndPattern", container.
itEndPattern);
574 xmlWriter.writeStartElement(
"type");
578 xmlWriter.writeAttribute(
"string", container.
type.
string);
579 xmlWriter.writeEndElement();
585 xmlWriter.writeEndElement();
590 QString comments =
function.comments;
591 while (comments.startsWith(
"\n"))
592 comments = comments.mid(1);
593 while (comments.endsWith(
"\n"))
595 for (
const QString &comment : comments.split(
'\n')) {
596 if (comment.length() >= 1)
597 xmlWriter.writeComment(comment);
600 xmlWriter.writeStartElement(
"function");
601 xmlWriter.writeAttribute(
"name",
function.name);
603 if (
function.useretval)
604 xmlWriter.writeEmptyElement(
"use-retval");
605 if (
function.gccConst)
606 xmlWriter.writeEmptyElement(
"const");
607 if (
function.gccPure)
608 xmlWriter.writeEmptyElement(
"pure");
609 if (!
function.returnValue.empty()) {
610 xmlWriter.writeStartElement(
"returnValue");
611 if (!
function.returnValue.type.isNull())
612 xmlWriter.writeAttribute(
"type",
function.returnValue.type);
613 if (
function.returnValue.container >= 0)
614 xmlWriter.writeAttribute(
"container", QString::number(
function.returnValue.container));
615 if (!
function.returnValue.value.isNull())
616 xmlWriter.writeCharacters(
function.returnValue.value);
617 xmlWriter.writeEndElement();
621 if (
function.leakignore)
622 xmlWriter.writeEmptyElement(
"leak-ignore");
626 xmlWriter.writeStartElement(
"formatstr");
627 if (!
function.formatstr.scan.isNull())
628 xmlWriter.writeAttribute(
"scan",
function.formatstr.scan);
629 if (!
function.formatstr.secure.isNull())
630 xmlWriter.writeAttribute(
"secure",
function.formatstr.secure);
631 xmlWriter.writeEndElement();
634 xmlWriter.writeStartElement(
"arg");
636 xmlWriter.writeAttribute(
"nr",
"any");
638 xmlWriter.writeAttribute(
"nr",
"variadic");
640 xmlWriter.writeAttribute(
"nr", QString::number(arg.nr));
641 if (!arg.defaultValue.isNull())
642 xmlWriter.writeAttribute(
"default", arg.defaultValue);
644 xmlWriter.writeEmptyElement(
"formatstr");
646 xmlWriter.writeEmptyElement(
"not-null");
648 xmlWriter.writeEmptyElement(
"not-uninit");
650 xmlWriter.writeEmptyElement(
"not-bool");
652 xmlWriter.writeEmptyElement(
"strz");
654 if (!arg.valid.isEmpty())
655 xmlWriter.writeTextElement(
"valid",arg.valid);
658 xmlWriter.writeStartElement(
"minsize");
659 xmlWriter.writeAttribute(
"type", minsize.
type);
660 xmlWriter.writeAttribute(
"arg", minsize.
arg);
661 if (!minsize.
arg2.isEmpty())
662 xmlWriter.writeAttribute(
"arg2", minsize.
arg2);
663 xmlWriter.writeEndElement();
666 if (arg.iterator.container >= 0 || !arg.iterator.type.isNull()) {
667 xmlWriter.writeStartElement(
"iterator");
668 if (arg.iterator.container >= 0)
669 xmlWriter.writeAttribute(
"container", QString::number(arg.iterator.container));
670 if (!arg.iterator.type.isNull())
671 xmlWriter.writeAttribute(
"type", arg.iterator.type);
672 xmlWriter.writeEndElement();
675 xmlWriter.writeEndElement();
678 if (!
function.warn.isEmpty()) {
679 xmlWriter.writeStartElement(
"warn");
681 if (!
function.warn.severity.isEmpty())
682 xmlWriter.writeAttribute(
"severity",
function.warn.severity);
684 if (!
function.warn.cstd.isEmpty())
685 xmlWriter.writeAttribute(
"cstd",
function.warn.cstd);
687 if (!
function.warn.alternatives.isEmpty())
688 xmlWriter.writeAttribute(
"alternatives",
function.warn.alternatives);
690 if (!
function.warn.reason.isEmpty())
691 xmlWriter.writeAttribute(
"reason",
function.warn.reason);
693 if (!
function.warn.msg.isEmpty())
694 xmlWriter.writeCharacters(
function.warn.msg);
696 xmlWriter.writeEndElement();
698 if (!
function.notOverlappingDataArgs.isEmpty()) {
699 xmlWriter.writeStartElement(
"not-overlapping-data");
700 foreach (
const QString& value,
function.notOverlappingDataArgs) {
701 xmlWriter.writeAttribute(
function.notOverlappingDataArgs.key(value), value);
703 xmlWriter.writeEndElement();
705 if (!
function.containerAttributes.isEmpty()) {
706 xmlWriter.writeStartElement(
"container");
707 foreach (
const QString& value,
function.containerAttributes) {
708 xmlWriter.writeAttribute(
function.containerAttributes.key(value), value);
710 xmlWriter.writeEndElement();
712 xmlWriter.writeEndElement();
717 xmlWriter.writeStartElement(mr.
type);
720 xmlWriter.writeStartElement(
"realloc");
722 xmlWriter.writeStartElement(
"alloc");
725 if (alloc.
arg != -1) {
726 xmlWriter.writeAttribute(
"arg", QString(
"%1").arg(alloc.
arg));
729 xmlWriter.writeAttribute(
"realloc-arg", QString(
"%1").arg(alloc.
reallocArg));
732 xmlWriter.writeAttribute(
"buffer-size", alloc.
bufferSize);
734 xmlWriter.writeCharacters(alloc.
name);
735 xmlWriter.writeEndElement();
739 xmlWriter.writeStartElement(
"dealloc");
740 if (dealloc.
arg != -1) {
741 xmlWriter.writeAttribute(
"arg", QString(
"%1").arg(dealloc.
arg));
743 xmlWriter.writeCharacters(dealloc.
name);
744 xmlWriter.writeEndElement();
747 for (
const QString &use : mr.
use) {
748 xmlWriter.writeTextElement(
"use", use);
750 xmlWriter.writeEndElement();
755 xmlWriter.writeStartElement(
"type-checks");
756 if (!typeChecks.isEmpty()) {
757 xmlWriter.writeStartElement(
"unusedvar");
759 for (
const QPair<QString, QString> &check : typeChecks) {
760 xmlWriter.writeStartElement(check.first);
761 xmlWriter.writeCharacters(check.second);
762 xmlWriter.writeEndElement();
764 if (!typeChecks.isEmpty()) {
765 xmlWriter.writeEndElement();
767 xmlWriter.writeEndElement();
772 xmlWriter.writeStartElement(
"platformtype");
773 xmlWriter.writeAttribute(
"name", pt.
name);
774 xmlWriter.writeAttribute(
"value", pt.
value);
775 for (
const QString &type : pt.
types) {
776 xmlWriter.writeStartElement(type);
777 xmlWriter.writeEndElement();
779 for (
const QString &platform : pt.
platforms) {
780 xmlWriter.writeStartElement(
"platform");
781 if (!platform.isEmpty()) {
782 xmlWriter.writeAttribute(
"type", platform);
784 xmlWriter.writeEndElement();
786 xmlWriter.writeEndElement();
791 xmlWriter.writeStartElement(
"reflection");
793 xmlWriter.writeStartElement(
"call");
794 xmlWriter.writeAttribute(
"arg", QString(
"%1").arg(call.
arg));
795 xmlWriter.writeCharacters(call.
name);
796 xmlWriter.writeEndElement();
798 xmlWriter.writeEndElement();
803 xmlWriter.writeStartElement(
"markup");
804 xmlWriter.writeAttribute(
"ext", mup.
ext);
805 xmlWriter.writeAttribute(
"aftercode", QVariant(mup.
afterCode).toString());
806 xmlWriter.writeAttribute(
"reporterrors", QVariant(mup.
reportErrors).toString());
808 xmlWriter.writeStartElement(
"keywords");
809 for (
const QString &keyword : mup.
keywords) {
810 xmlWriter.writeStartElement(
"keyword");
811 xmlWriter.writeAttribute(
"name", keyword);
812 xmlWriter.writeEndElement();
814 xmlWriter.writeEndElement();
817 xmlWriter.writeStartElement(
"imported");
818 for (
const QString &
import : mup.
importer) {
819 xmlWriter.writeStartElement(
"importer");
820 xmlWriter.writeCharacters(
import);
821 xmlWriter.writeEndElement();
823 xmlWriter.writeEndElement();
826 xmlWriter.writeStartElement(
"exported");
828 xmlWriter.writeStartElement(
"exporter");
829 xmlWriter.writeAttribute(
"prefix", exporter.
prefix);
830 for (
const QString &prefix : exporter.
prefixList) {
831 xmlWriter.writeStartElement(
"prefix");
832 xmlWriter.writeCharacters(prefix);
833 xmlWriter.writeEndElement();
835 for (
const QString &suffix : exporter.
suffixList) {
836 xmlWriter.writeStartElement(
"suffix");
837 xmlWriter.writeCharacters(suffix);
838 xmlWriter.writeEndElement();
840 xmlWriter.writeEndElement();
842 xmlWriter.writeEndElement();
846 xmlWriter.writeStartElement(
"codeblocks");
847 for (
const QString &block : codeblock.
blocks) {
848 xmlWriter.writeStartElement(
"block");
849 xmlWriter.writeAttribute(
"name", block);
850 xmlWriter.writeEndElement();
852 xmlWriter.writeStartElement(
"structure");
853 xmlWriter.writeAttribute(
"offset", QString(
"%1").arg(codeblock.
offset));
854 xmlWriter.writeAttribute(
"start", codeblock.
start);
855 xmlWriter.writeAttribute(
"end", codeblock.
end);
856 xmlWriter.writeEndElement();
857 xmlWriter.writeEndElement();
860 xmlWriter.writeEndElement();
865 QString outputString;
866 QXmlStreamWriter xmlWriter(&outputString);
867 xmlWriter.setAutoFormatting(
true);
868 xmlWriter.setAutoFormattingIndent(2);
869 xmlWriter.writeStartDocument(
"1.0");
870 xmlWriter.writeStartElement(
"def");
871 xmlWriter.writeAttribute(
"format",
"2");
874 xmlWriter.writeStartElement(
"define");
875 xmlWriter.writeAttribute(
"name", define.name);
876 xmlWriter.writeAttribute(
"value", define.value);
877 xmlWriter.writeEndElement();
881 xmlWriter.writeStartElement(
"undefine");
882 xmlWriter.writeAttribute(
"name", undef);
883 xmlWriter.writeEndElement();
899 xmlWriter.writeStartElement(
"podtype");
900 xmlWriter.writeAttribute(
"name", podtype.name);
901 if (!podtype.stdtype.isEmpty())
902 xmlWriter.writeAttribute(
"stdtype", podtype.stdtype);
903 if (!podtype.sign.isEmpty())
904 xmlWriter.writeAttribute(
"sign", podtype.sign);
905 if (!podtype.size.isEmpty())
906 xmlWriter.writeAttribute(
"size", podtype.size);
907 xmlWriter.writeEndElement();
915 xmlWriter.writeStartElement(
"smart-pointer");
916 xmlWriter.writeAttribute(
"class-name", smartPtr.name);
917 if (smartPtr.unique) {
918 xmlWriter.writeEmptyElement(
"unique");
920 xmlWriter.writeEndElement();
936 xmlWriter.writeStartElement(
"entrypoint");
937 xmlWriter.writeAttribute(
"name", ent.name);
938 xmlWriter.writeEndElement();
941 xmlWriter.writeEndElement();
QList< QPair< QString, QString > > TypeChecks
QList< PlatformType > platformTypes
QList< PodType > podtypes
QList< SmartPointer > smartPointers
QList< Container > containers
QString open(QIODevice &file)
QList< Function > functions
QList< TypeChecks > typeChecks
QList< Entrypoint > entrypoints
QList< MemoryResource > memoryresource
QList< Reflection > reflections
static CppcheckLibraryData::MemoryResource loadMemoryResource(QXmlStreamReader &xmlReader)
static void writeContainer(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::Container &container)
static CppcheckLibraryData::Define loadDefine(const QXmlStreamReader &xmlReader)
static CppcheckLibraryData::Container loadContainer(QXmlStreamReader &xmlReader)
static CppcheckLibraryData::PodType loadPodType(const QXmlStreamReader &xmlReader)
static CppcheckLibraryData::Function::Arg loadFunctionArg(QXmlStreamReader &xmlReader)
static std::string mandatoryAttibuteMissing(const QXmlStreamReader &xmlReader, const QString &attributeName)
static std::string unhandledElement(const QXmlStreamReader &xmlReader)
static CppcheckLibraryData::TypeChecks loadTypeChecks(QXmlStreamReader &xmlReader)
static void writeContainerFunctions(QXmlStreamWriter &xmlWriter, const QString &name, int extra, const QList< CppcheckLibraryData::Container::Function > &functions)
static CppcheckLibraryData::Markup loadMarkup(QXmlStreamReader &xmlReader)
static void writeMarkup(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::Markup &mup)
static CppcheckLibraryData::SmartPointer loadSmartPointer(QXmlStreamReader &xmlReader)
static CppcheckLibraryData::PlatformType loadPlatformType(QXmlStreamReader &xmlReader)
static void writePlatformType(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::PlatformType &pt)
static void writeMemoryResource(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::MemoryResource &mr)
static void writeContainerRangeItemRecords(QXmlStreamWriter &xmlWriter, const QList< CppcheckLibraryData::Container::RangeItemRecordType > &rangeItemRecords)
static void writeReflection(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::Reflection &refl)
static void writeTypeChecks(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::TypeChecks &typeChecks)
static QString loadUndefine(const QXmlStreamReader &xmlReader)
static CppcheckLibraryData::Function loadFunction(QXmlStreamReader &xmlReader, const QString &comments)
static CppcheckLibraryData::Entrypoint loadEntrypoint(const QXmlStreamReader &xmlReader)
static void writeFunction(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData::Function &function)
static CppcheckLibraryData::Reflection loadReflection(QXmlStreamReader &xmlReader)
QString templateParameter
QList< Function > accessFunctions
struct CppcheckLibraryData::Container::@0 type
QList< Function > otherFunctions
QList< RangeItemRecordType > rangeItemRecordTypeList
QList< Function > sizeFunctions
int size_templateParameter
QString templateParameter
static const unsigned int ANY
QList< MinSize > minsizes
static const unsigned int VARIADIC
struct CppcheckLibraryData::Function::Arg::Iterator iterator
QList< CodeBlocks > codeBlocks
QList< Exporter > exporter
static const char * bool_to_string(bool b)
bool contains(const Range &r, const T &x)