FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppcheck/gui/cppchecklibrarydata.cpp at master · 2php/cppcheck · GitHub
2php
/
cppcheck
Public
forked from
cppcheck-opensource/cppcheck
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppcheck
/
gui
/
cppchecklibrarydata.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
487 lines (444 loc) · 20.4 KB
Breadcrumbs
cppcheck
/
gui
/
cppchecklibrarydata.cpp
Copy path
File metadata and controls
487 lines (444 loc) · 20.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
/*
* Cppcheck - A tool for static C/C++ code analysis
* Copyright (C) 2007-2017 Cppcheck team.
*
* 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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#
include
"
cppchecklibrarydata.h
"
#
include
<
QXmlStreamReader
>
#
include
<
QXmlStreamWriter
>
const
unsigned
int
CppcheckLibraryData::Function::Arg::
ANY
= ~
0U
;
const
unsigned
int
CppcheckLibraryData::Function::Arg::
VARIADIC
= ~
1U
;
CppcheckLibraryData::CppcheckLibraryData
()
{
}
static
std::string
unhandledElement
(
const
QXmlStreamReader &xmlReader)
{
throw
std::runtime_error
(
QObject::tr
(
"
line %1: Unhandled element %2
"
).
arg
(xmlReader.
lineNumber
()).
arg
(xmlReader.
name
().
toString
()).
toStdString
());
}
static
CppcheckLibraryData::Container
loadContainer
(QXmlStreamReader &xmlReader)
{
CppcheckLibraryData::Container container;
container.
id
= xmlReader.
attributes
().
value
(
"
id
"
).
toString
();
container.
inherits
= xmlReader.
attributes
().
value
(
"
inherits
"
).
toString
();
container.
startPattern
= xmlReader.
attributes
().
value
(
"
startPattern
"
).
toString
();
container.
endPattern
= xmlReader.
attributes
().
value
(
"
endPattern
"
).
toString
();
container.
opLessAllowed
= xmlReader.
attributes
().
value
(
"
opLessAllowed
"
).
toString
();
container.
itEndPattern
= xmlReader.
attributes
().
value
(
"
itEndPattern
"
).
toString
();
QXmlStreamReader::TokenType type;
while
((type = xmlReader.
readNext
()) != QXmlStreamReader::EndElement ||
xmlReader.
name
().
toString
() !=
"
container
"
) {
if
(type != QXmlStreamReader::StartElement)
continue
;
const
QString elementName = xmlReader.
name
().
toString
();
if
(elementName ==
"
type
"
) {
container.
type
.
templateParameter
= xmlReader.
attributes
().
value
(
"
templateParameter
"
).
toString
();
container.
type
.
string
= xmlReader.
attributes
().
value
(
"
string
"
).
toString
();
}
else
if
(elementName ==
"
size
"
|| elementName ==
"
access
"
|| elementName ==
"
other
"
) {
const
QString indexOperator = xmlReader.
attributes
().
value
(
"
indexOperator
"
).
toString
();
if
(elementName ==
"
access
"
&& indexOperator ==
"
array-like
"
)
container.
access_arrayLike
=
true
;
const
QString templateParameter = xmlReader.
attributes
().
value
(
"
templateParameter
"
).
toString
();
if
(elementName ==
"
size
"
&& !templateParameter.
isEmpty
())
container.
size_templateParameter
= templateParameter.
toInt
();
for
(;;) {
type = xmlReader.
readNext
();
if
(xmlReader.
name
().
toString
() == elementName)
break
;
if
(type != QXmlStreamReader::StartElement)
continue
;
struct
CppcheckLibraryData
::Container::Function function;
function.
name
= xmlReader.
attributes
().
value
(
"
name
"
).
toString
();
function.
action
= xmlReader.
attributes
().
value
(
"
action
"
).
toString
();
function.
yields
= xmlReader.
attributes
().
value
(
"
yields
"
).
toString
();
if
(elementName ==
"
size
"
)
container.
sizeFunctions
.
append
(function);
else
if
(elementName ==
"
access
"
)
container.
accessFunctions
.
append
(function);
else
container.
otherFunctions
.
append
(function);
}
}
else
{
unhandledElement
(xmlReader);
}
}
return
container;
}
static
CppcheckLibraryData::Define
loadDefine
(
const
QXmlStreamReader &xmlReader)
{
CppcheckLibraryData::Define define;
define.
name
= xmlReader.
attributes
().
value
(
"
name
"
).
toString
();
define.
value
= xmlReader.
attributes
().
value
(
"
value
"
).
toString
();
return
define;
}
static
CppcheckLibraryData::Function::Arg
loadFunctionArg
(QXmlStreamReader &xmlReader)
{
CppcheckLibraryData::Function::Arg arg;
QString argnr = xmlReader.
attributes
().
value
(
"
nr
"
).
toString
();
if
(argnr ==
"
any
"
)
arg.
nr
= CppcheckLibraryData::Function::Arg::
ANY
;
else
if
(argnr ==
"
variadic
"
)
arg.
nr
= CppcheckLibraryData::Function::Arg::
VARIADIC
;
else
arg.
nr
= argnr.
toUInt
();
arg.
defaultValue
= xmlReader.
attributes
().
value
(
"
default
"
).
toString
();
QXmlStreamReader::TokenType type;
while
((type = xmlReader.
readNext
()) != QXmlStreamReader::EndElement ||
xmlReader.
name
().
toString
() !=
"
arg
"
) {
if
(type != QXmlStreamReader::StartElement)
continue
;
const
QString elementName = xmlReader.
name
().
toString
();
if
(elementName ==
"
not-bool
"
)
arg.
notbool
=
true
;
else
if
(elementName ==
"
not-null
"
)
arg.
notnull
=
true
;
else
if
(elementName ==
"
not-uninit
"
)
arg.
notuninit
=
true
;
else
if
(elementName ==
"
strz
"
)
arg.
strz
=
true
;
else
if
(elementName ==
"
formatstr
"
)
arg.
formatstr
=
true
;
else
if
(elementName ==
"
valid
"
)
arg.
valid
= xmlReader.
readElementText
();
else
if
(elementName ==
"
minsize
"
) {
CppcheckLibraryData::Function::Arg::MinSize minsize;
minsize.
type
= xmlReader.
attributes
().
value
(
"
type
"
).
toString
();
minsize.
arg
= xmlReader.
attributes
().
value
(
"
arg
"
).
toString
();
minsize.
arg2
= xmlReader.
attributes
().
value
(
"
arg2
"
).
toString
();
arg.
minsizes
.
append
(minsize);
}
else
if
(elementName ==
"
iterator
"
) {
arg.
iterator
.
container
= xmlReader.
attributes
().
value
(
"
container
"
).
toInt
();
arg.
iterator
.
type
= xmlReader.
attributes
().
value
(
"
type
"
).
toString
();
}
else
{
unhandledElement
(xmlReader);
}
}
return
arg;
}
static
CppcheckLibraryData::Function
loadFunction
(QXmlStreamReader &xmlReader,
const
QString &comments)
{
CppcheckLibraryData::Function function;
function.
comments
= comments;
function.
name
= xmlReader.
attributes
().
value
(
"
name
"
).
toString
();
QXmlStreamReader::TokenType type;
while
((type = xmlReader.
readNext
()) != QXmlStreamReader::EndElement ||
xmlReader.
name
().
toString
() !=
"
function
"
) {
if
(type != QXmlStreamReader::StartElement)
continue
;
const
QString elementName = xmlReader.
name
().
toString
();
if
(elementName ==
"
noreturn
"
)
function.
noreturn
= (xmlReader.
readElementText
() ==
"
true
"
) ? CppcheckLibraryData::Function::True : CppcheckLibraryData::Function::False;
else
if
(elementName ==
"
pure
"
)
function.
gccPure
=
true
;
else
if
(elementName ==
"
const
"
)
function.
gccConst
=
true
;
else
if
(elementName ==
"
leak-ignore
"
)
function.
leakignore
=
true
;
else
if
(elementName ==
"
use-retval
"
)
function.
useretval
=
true
;
else
if
(elementName ==
"
returnValue
"
) {
const
QString container = xmlReader.
attributes
().
value
(
"
container
"
).
toString
();
function.
returnValue
.
container
= container.
isNull
() ? -
1
: container.
toInt
();
function.
returnValue
.
type
= xmlReader.
attributes
().
value
(
"
type
"
).
toString
();
function.
returnValue
.
value
= xmlReader.
readElementText
();
}
else
if
(elementName ==
"
formatstr
"
) {
function.
formatstr
.
scan
= xmlReader.
attributes
().
value
(
"
scan
"
).
toString
();
function.
formatstr
.
secure
= xmlReader.
attributes
().
value
(
"
secure
"
).
toString
();
}
else
if
(elementName ==
"
arg
"
)
function.
args
.
append
(
loadFunctionArg
(xmlReader));
else
if
(elementName ==
"
warn
"
) {
function.
warn
.
severity
= xmlReader.
attributes
().
value
(
"
severity
"
).
toString
();
function.
warn
.
cstd
= xmlReader.
attributes
().
value
(
"
cstd
"
).
toString
();
function.
warn
.
reason
= xmlReader.
attributes
().
value
(
"
reason
"
).
toString
();
function.
warn
.
alternatives
= xmlReader.
attributes
().
value
(
"
alternatives
"
).
toString
();
function.
warn
.
msg
= xmlReader.
readElementText
();
}
else
{
unhandledElement
(xmlReader);
}
}
return
function;
}
static
CppcheckLibraryData::MemoryResource
loadMemoryResource
(QXmlStreamReader &xmlReader)
{
CppcheckLibraryData::MemoryResource memoryresource;
memoryresource.
type
= xmlReader.
name
().
toString
();
QXmlStreamReader::TokenType type;
while
((type = xmlReader.
readNext
()) != QXmlStreamReader::EndElement ||
xmlReader.
name
().
toString
() != memoryresource.
type
) {
if
(type != QXmlStreamReader::StartElement)
continue
;
const
QString elementName = xmlReader.
name
().
toString
();
if
(elementName ==
"
alloc
"
) {
CppcheckLibraryData::MemoryResource::Alloc alloc;
alloc.
init
= (xmlReader.
attributes
().
value
(
"
init
"
).
toString
() ==
"
true
"
);
alloc.
name
= xmlReader.
readElementText
();
memoryresource.
alloc
.
append
(alloc);
}
else
if
(elementName ==
"
dealloc
"
)
memoryresource.
dealloc
.
append
(xmlReader.
readElementText
());
else
if
(elementName ==
"
use
"
)
memoryresource.
use
.
append
(xmlReader.
readElementText
());
else
unhandledElement
(xmlReader);
}
return
memoryresource;
}
static
CppcheckLibraryData::PodType
loadPodType
(
const
QXmlStreamReader &xmlReader)
{
CppcheckLibraryData::PodType podtype;
podtype.
name
= xmlReader.
attributes
().
value
(
"
name
"
).
toString
();
podtype.
size
= xmlReader.
attributes
().
value
(
"
size
"
).
toString
();
podtype.
sign
= xmlReader.
attributes
().
value
(
"
sign
"
).
toString
();
return
podtype;
}
QString
CppcheckLibraryData::open
(QIODevice &file)
{
clear
();
QString comments;
QXmlStreamReader
xmlReader
(&file);
while
(!xmlReader.
atEnd
()) {
const
QXmlStreamReader::TokenType t = xmlReader.
readNext
();
switch
(t) {
case
QXmlStreamReader::Comment:
if
(!comments.
isEmpty
())
comments +=
"
\n
"
;
comments += xmlReader.
text
().
toString
();
break
;
case
QXmlStreamReader::StartElement:
try
{
const
QString
elementName
(xmlReader.
name
().
toString
());
if
(elementName ==
"
def
"
)
;
else
if
(elementName ==
"
container
"
)
containers.
append
(
loadContainer
(xmlReader));
else
if
(elementName ==
"
define
"
)
defines.
append
(
loadDefine
(xmlReader));
else
if
(elementName ==
"
function
"
)
functions.
append
(
loadFunction
(xmlReader, comments));
else
if
(elementName ==
"
memory
"
|| elementName ==
"
resource
"
)
memoryresource.
append
(
loadMemoryResource
(xmlReader));
else
if
(elementName ==
"
podtype
"
)
podtypes.
append
(
loadPodType
(xmlReader));
else
unhandledElement
(xmlReader);
}
catch
(std::runtime_error &e) {
return
e.
what
();
}
comments.
clear
();
break
;
default
:
break
;
}
}
return
QString
();
}
static
void
writeContainerFunctions
(QXmlStreamWriter &xmlWriter,
const
QString &name,
int
extra,
const
QList<
struct
CppcheckLibraryData
::Container::Function> &functions)
{
if
(functions.
isEmpty
() && extra <
0
)
return
;
xmlWriter.
writeStartElement
(name);
if
(extra >=
0
) {
if
(name ==
"
access
"
)
xmlWriter.
writeAttribute
(
"
indexOperator
"
,
"
array-like
"
);
else
if
(name ==
"
size
"
)
xmlWriter.
writeAttribute
(
"
templateParameter
"
,
QString::number
(extra));
}
foreach
(
const
CppcheckLibraryData::Container::Function &function, functions) {
xmlWriter.
writeStartElement
(
"
function
"
);
xmlWriter.
writeAttribute
(
"
name
"
, function.
name
);
if
(!function.
action
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
action
"
, function.
action
);
if
(!function.
yields
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
yields
"
, function.
yields
);
xmlWriter.
writeEndElement
();
}
xmlWriter.
writeEndElement
();
}
static
void
writeContainer
(QXmlStreamWriter &xmlWriter,
const
CppcheckLibraryData::Container &container)
{
xmlWriter.
writeStartElement
(
"
container
"
);
xmlWriter.
writeAttribute
(
"
id
"
, container.
id
);
if
(!container.
startPattern
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
startPattern
"
, container.
startPattern
);
if
(!container.
endPattern
.
isNull
())
xmlWriter.
writeAttribute
(
"
endPattern
"
, container.
endPattern
);
if
(!container.
inherits
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
inherits
"
, container.
inherits
);
if
(!container.
opLessAllowed
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
opLessAllowed
"
, container.
opLessAllowed
);
if
(!container.
itEndPattern
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
itEndPattern
"
, container.
itEndPattern
);
if
(!container.
type
.
templateParameter
.
isEmpty
() || !container.
type
.
string
.
isEmpty
()) {
xmlWriter.
writeStartElement
(
"
type
"
);
if
(!container.
type
.
templateParameter
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
templateParameter
"
, container.
type
.
templateParameter
);
if
(!container.
type
.
string
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
string
"
, container.
type
.
string
);
xmlWriter.
writeEndElement
();
}
writeContainerFunctions
(xmlWriter,
"
size
"
, container.
size_templateParameter
, container.
sizeFunctions
);
writeContainerFunctions
(xmlWriter,
"
access
"
, container.
access_arrayLike
?
1
:-
1
, container.
accessFunctions
);
writeContainerFunctions
(xmlWriter,
"
other
"
, -
1
, container.
otherFunctions
);
xmlWriter.
writeEndElement
();
}
static
void
writeFunction
(QXmlStreamWriter &xmlWriter,
const
CppcheckLibraryData::Function &function)
{
QString comments = function.
comments
;
while
(comments.
startsWith
(
"
\n
"
))
comments = comments.
mid
(
1
);
while
(comments.
endsWith
(
"
\n
"
))
comments.
chop
(
1
);
foreach
(
const
QString &comment, comments.
split
(
'
\n
'
)) {
if
(comment.
length
() >=
1
)
xmlWriter.
writeComment
(comment);
}
xmlWriter.
writeStartElement
(
"
function
"
);
xmlWriter.
writeAttribute
(
"
name
"
, function.
name
);
if
(function.
useretval
)
xmlWriter.
writeEmptyElement
(
"
use-retval
"
);
if
(function.
gccConst
)
xmlWriter.
writeEmptyElement
(
"
const
"
);
if
(function.
gccPure
)
xmlWriter.
writeEmptyElement
(
"
pure
"
);
if
(!function.
returnValue
.
empty
()) {
xmlWriter.
writeStartElement
(
"
returnValue
"
);
if
(!function.
returnValue
.
type
.
isNull
())
xmlWriter.
writeAttribute
(
"
type
"
, function.
returnValue
.
type
);
if
(function.
returnValue
.
container
>=
0
)
xmlWriter.
writeAttribute
(
"
container
"
,
QString::number
(function.
returnValue
.
container
));
if
(!function.
returnValue
.
value
.
isNull
())
xmlWriter.
writeCharacters
(function.
returnValue
.
value
);
xmlWriter.
writeEndElement
();
}
if
(function.
noreturn
!= CppcheckLibraryData::Function::Unknown)
xmlWriter.
writeTextElement
(
"
noreturn
"
, (function.
noreturn
== CppcheckLibraryData::Function::True) ?
"
true
"
:
"
false
"
);
if
(function.
leakignore
)
xmlWriter.
writeEmptyElement
(
"
leak-ignore
"
);
//
Argument info..
foreach
(
const
CppcheckLibraryData::Function::Arg &arg, function.
args
) {
if
(arg.
formatstr
) {
xmlWriter.
writeStartElement
(
"
formatstr
"
);
if
(!function.
formatstr
.
scan
.
isNull
())
xmlWriter.
writeAttribute
(
"
scan
"
, function.
formatstr
.
scan
);
if
(!function.
formatstr
.
secure
.
isNull
())
xmlWriter.
writeAttribute
(
"
secure
"
, function.
formatstr
.
secure
);
xmlWriter.
writeEndElement
();
}
xmlWriter.
writeStartElement
(
"
arg
"
);
if
(arg.
nr
== CppcheckLibraryData::Function::Arg::
ANY
)
xmlWriter.
writeAttribute
(
"
nr
"
,
"
any
"
);
else
if
(arg.
nr
== CppcheckLibraryData::Function::Arg::
VARIADIC
)
xmlWriter.
writeAttribute
(
"
nr
"
,
"
variadic
"
);
else
xmlWriter.
writeAttribute
(
"
nr
"
,
QString::number
(arg.
nr
));
if
(!arg.
defaultValue
.
isNull
())
xmlWriter.
writeAttribute
(
"
default
"
, arg.
defaultValue
);
if
(arg.
formatstr
)
xmlWriter.
writeEmptyElement
(
"
formatstr
"
);
if
(arg.
notnull
)
xmlWriter.
writeEmptyElement
(
"
not-null
"
);
if
(arg.
notuninit
)
xmlWriter.
writeEmptyElement
(
"
not-uninit
"
);
if
(arg.
notbool
)
xmlWriter.
writeEmptyElement
(
"
not-bool
"
);
if
(arg.
strz
)
xmlWriter.
writeEmptyElement
(
"
strz
"
);
if
(!arg.
valid
.
isEmpty
())
xmlWriter.
writeTextElement
(
"
valid
"
,arg.
valid
);
foreach
(
const
CppcheckLibraryData::Function::Arg::MinSize &minsize, arg.
minsizes
) {
xmlWriter.
writeStartElement
(
"
minsize
"
);
xmlWriter.
writeAttribute
(
"
type
"
, minsize.
type
);
xmlWriter.
writeAttribute
(
"
arg
"
, minsize.
arg
);
if
(!minsize.
arg2
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
arg2
"
, minsize.
arg2
);
xmlWriter.
writeEndElement
();
}
if
(arg.
iterator
.
container
>=
0
|| !arg.
iterator
.
type
.
isNull
()) {
xmlWriter.
writeStartElement
(
"
iterator
"
);
if
(arg.
iterator
.
container
>=
0
)
xmlWriter.
writeAttribute
(
"
container
"
,
QString::number
(arg.
iterator
.
container
));
if
(!arg.
iterator
.
type
.
isNull
())
xmlWriter.
writeAttribute
(
"
type
"
, arg.
iterator
.
type
);
xmlWriter.
writeEndElement
();
}
xmlWriter.
writeEndElement
();
}
if
(!function.
warn
.
isEmpty
()) {
xmlWriter.
writeStartElement
(
"
warn
"
);
if
(!function.
warn
.
severity
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
severity
"
, function.
warn
.
severity
);
if
(!function.
warn
.
cstd
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
cstd
"
, function.
warn
.
cstd
);
if
(!function.
warn
.
alternatives
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
alternatives
"
, function.
warn
.
alternatives
);
if
(!function.
warn
.
reason
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
reason
"
, function.
warn
.
reason
);
if
(!function.
warn
.
msg
.
isEmpty
())
xmlWriter.
writeCharacters
(function.
warn
.
msg
);
xmlWriter.
writeEndElement
();
}
xmlWriter.
writeEndElement
();
}
static
void
writeMemoryResource
(QXmlStreamWriter &xmlWriter,
const
CppcheckLibraryData::MemoryResource &mr)
{
xmlWriter.
writeStartElement
(mr.
type
);
foreach
(
const
CppcheckLibraryData::MemoryResource::Alloc &alloc, mr.
alloc
) {
xmlWriter.
writeStartElement
(
"
alloc
"
);
xmlWriter.
writeAttribute
(
"
init
"
, alloc.
init
?
"
true
"
:
"
false
"
);
xmlWriter.
writeCharacters
(alloc.
name
);
xmlWriter.
writeEndElement
();
}
foreach
(
const
QString &dealloc, mr.
dealloc
) {
xmlWriter.
writeTextElement
(
"
dealloc
"
, dealloc);
}
foreach
(
const
QString &use, mr.
use
) {
xmlWriter.
writeTextElement
(
"
use
"
, use);
}
xmlWriter.
writeEndElement
();
}
QString
CppcheckLibraryData::toString
()
const
{
QString outputString;
QXmlStreamWriter
xmlWriter
(&outputString);
xmlWriter.
setAutoFormatting
(
true
);
xmlWriter.
setAutoFormattingIndent
(
2
);
xmlWriter.
writeStartDocument
(
"
1.0
"
);
xmlWriter.
writeStartElement
(
"
def
"
);
xmlWriter.
writeAttribute
(
"
format
"
,
"
2
"
);
foreach
(
const
Define &define, defines) {
xmlWriter.
writeStartElement
(
"
define
"
);
xmlWriter.
writeAttribute
(
"
name
"
, define.
name
);
xmlWriter.
writeAttribute
(
"
value
"
, define.
value
);
xmlWriter.
writeEndElement
();
}
foreach
(
const
Function &function, functions) {
writeFunction
(xmlWriter, function);
}
foreach
(
const
MemoryResource &mr, memoryresource) {
writeMemoryResource
(xmlWriter, mr);
}
foreach
(
const
Container &container, containers) {
writeContainer
(xmlWriter, container);
}
foreach
(
const
PodType &podtype, podtypes) {
xmlWriter.
writeStartElement
(
"
podtype
"
);
xmlWriter.
writeAttribute
(
"
name
"
, podtype.
name
);
if
(!podtype.
sign
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
sign
"
, podtype.
sign
);
if
(!podtype.
size
.
isEmpty
())
xmlWriter.
writeAttribute
(
"
size
"
, podtype.
size
);
xmlWriter.
writeEndElement
();
}
xmlWriter.
writeEndElement
();
return
outputString;
}
Back
|
FazBrowse Home
|
New Git URL