kernel/qvariant.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9namespace { -
10class HandlersManager -
11{ -
12 static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount]; -
13public: -
14 const QVariant::Handler *operator[] (const uint typeId) const -
15 { -
16 return Handlers[QModulesPrivate::moduleForType(typeId)];
executed: return Handlers[QModulesPrivate::moduleForType(typeId)];
Execution Count:48828080
48828080
17 } -
18 -
19 void registerHandler(const QModulesPrivate::Names name, const QVariant::Handler *handler) -
20 { -
21 Handlers[name] = handler; -
22 }
executed: }
Execution Count:186
186
23}; -
24} -
25 -
26namespace { -
27struct CoreTypesFilter { -
28 template<typename T> -
29 struct Acceptor { -
30 static const bool IsAccepted = QModulesPrivate::QTypeModuleInfo<T>::IsCore && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable; -
31 }; -
32}; -
33} -
34 -
35namespace { -
36 -
37static void construct(QVariant::Private *x, const void *copy) -
38{ -
39 QVariantConstructor<CoreTypesFilter> constructor(x, copy); -
40 QMetaTypeSwitcher::switcher<void>(constructor, x->type, 0); -
41}
executed: }
Execution Count:18350473
18350473
42 -
43static void clear(QVariant::Private *d) -
44{ -
45 QVariantDestructor<CoreTypesFilter> cleaner(d); -
46 QMetaTypeSwitcher::switcher<void>(cleaner, d->type, 0); -
47}
executed: }
Execution Count:22283138
22283138
48 -
49static bool isNull(const QVariant::Private *d) -
50{ -
51 QVariantIsNull<CoreTypesFilter> isNull(d); -
52 return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0);
executed: return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0);
Execution Count:399722
399722
53} -
54 -
55 -
56 -
57 -
58 -
59 -
60 -
61static bool compare(const QVariant::Private *a, const QVariant::Private *b) -
62{ -
63 QVariantComparator<CoreTypesFilter> comparator(a, b); -
64 return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0);
executed: return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0);
Execution Count:93163
93163
65} -
66 -
67 -
68 -
69 -
70static qlonglong qMetaTypeNumber(const QVariant::Private *d) -
71{ -
72 switch (d->type) { -
73 case QMetaType::Int: -
74 return d->data.i;
executed: return d->data.i;
Execution Count:34207
34207
75 case QMetaType::LongLong: -
76 return d->data.ll;
executed: return d->data.ll;
Execution Count:3137
3137
77 case QMetaType::Char: -
78 return qlonglong(d->data.c);
executed: return qlonglong(d->data.c);
Execution Count:11
11
79 case QMetaType::SChar: -
80 return qlonglong(d->data.sc);
executed: return qlonglong(d->data.sc);
Execution Count:18
18
81 case QMetaType::Short: -
82 return qlonglong(d->data.s);
executed: return qlonglong(d->data.s);
Execution Count:33
33
83 case QMetaType::Long: -
84 return qlonglong(d->data.l);
executed: return qlonglong(d->data.l);
Execution Count:5
5
85 case QMetaType::Float: -
86 return qRound64(d->data.f);
executed: return qRound64(d->data.f);
Execution Count:15
15
87 case QVariant::Double: -
88 return qRound64(d->data.d);
executed: return qRound64(d->data.d);
Execution Count:82
82
89 } -
90 qt_noop(); -
91 return 0;
never executed: return 0;
0
92} -
93 -
94static qulonglong qMetaTypeUNumber(const QVariant::Private *d) -
95{ -
96 switch (d->type) { -
97 case QVariant::UInt: -
98 return d->data.u;
executed: return d->data.u;
Execution Count:143
143
99 case QVariant::ULongLong: -
100 return d->data.ull;
executed: return d->data.ull;
Execution Count:53
53
101 case QMetaType::UChar: -
102 return d->data.uc;
executed: return d->data.uc;
Execution Count:18
18
103 case QMetaType::UShort: -
104 return d->data.us;
executed: return d->data.us;
Execution Count:28
28
105 case QMetaType::ULong: -
106 return d->data.ul;
executed: return d->data.ul;
Execution Count:2
2
107 } -
108 qt_noop(); -
109 return 0;
never executed: return 0;
0
110} -
111 -
112static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) -
113{ -
114 *ok = true; -
115 -
116 switch (uint(d->type)) { -
117 case QVariant::String: -
118 return v_cast<QString>(d)->toLongLong(ok);
executed: return v_cast<QString>(d)->toLongLong(ok);
Execution Count:614
614
119 case QVariant::Char: -
120 return v_cast<QChar>(d)->unicode();
executed: return v_cast<QChar>(d)->unicode();
Execution Count:2
2
121 case QVariant::ByteArray: -
122 return v_cast<QByteArray>(d)->toLongLong(ok);
executed: return v_cast<QByteArray>(d)->toLongLong(ok);
Execution Count:5
5
123 case QVariant::Bool: -
124 return qlonglong(d->data.b);
executed: return qlonglong(d->data.b);
Execution Count:10
10
125 case QVariant::Double: -
126 case QVariant::Int: -
127 case QMetaType::Char: -
128 case QMetaType::SChar: -
129 case QMetaType::Short: -
130 case QMetaType::Long: -
131 case QMetaType::Float: -
132 case QMetaType::LongLong: -
133 return qMetaTypeNumber(d);
executed: return qMetaTypeNumber(d);
Execution Count:10266
10266
134 case QVariant::ULongLong: -
135 case QVariant::UInt: -
136 case QMetaType::UChar: -
137 case QMetaType::UShort: -
138 case QMetaType::ULong: -
139 return qlonglong(qMetaTypeUNumber(d));
executed: return qlonglong(qMetaTypeUNumber(d));
Execution Count:18
18
140 } -
141 -
142 *ok = false; -
143 return static_cast<long long>(0LL);
executed: return static_cast<long long>(0LL);
Execution Count:858
858
144} -
145 -
146static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) -
147{ -
148 *ok = true; -
149 -
150 switch (uint(d->type)) { -
151 case QVariant::String: -
152 return v_cast<QString>(d)->toULongLong(ok);
executed: return v_cast<QString>(d)->toULongLong(ok);
Execution Count:29
29
153 case QVariant::Char: -
154 return v_cast<QChar>(d)->unicode();
executed: return v_cast<QChar>(d)->unicode();
Execution Count:2
2
155 case QVariant::ByteArray: -
156 return v_cast<QByteArray>(d)->toULongLong(ok);
executed: return v_cast<QByteArray>(d)->toULongLong(ok);
Execution Count:4
4
157 case QVariant::Bool: -
158 return qulonglong(d->data.b);
never executed: return qulonglong(d->data.b);
0
159 case QVariant::Double: -
160 case QVariant::Int: -
161 case QMetaType::Char: -
162 case QMetaType::SChar: -
163 case QMetaType::Short: -
164 case QMetaType::Long: -
165 case QMetaType::Float: -
166 case QMetaType::LongLong: -
167 return qulonglong(qMetaTypeNumber(d));
executed: return qulonglong(qMetaTypeNumber(d));
Execution Count:61
61
168 case QVariant::ULongLong: -
169 case QVariant::UInt: -
170 case QMetaType::UChar: -
171 case QMetaType::UShort: -
172 case QMetaType::ULong: -
173 return qMetaTypeUNumber(d);
executed: return qMetaTypeUNumber(d);
Execution Count:17
17
174 } -
175 -
176 *ok = false; -
177 return static_cast<unsigned long long>(0ULL);
executed: return static_cast<unsigned long long>(0ULL);
Execution Count:48
48
178} -
179 -
180template<typename TInput, typename LiteralWrapper> -
181inline bool qt_convertToBool(const QVariant::Private *const d) -
182{ -
183 TInput str = v_cast<TInput>(d)->toLower(); -
184 return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty());
executed: return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty());
Execution Count:29
29
185} -
186 -
187 -
188 -
189 -
190 -
191 -
192static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) -
193{ -
194 qt_noop(); -
195 qt_noop(); -
196 -
197 bool dummy; -
198 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:291506
yes
Evaluation Count:248
248-291506
199 ok = &dummy;
executed: ok = &dummy;
Execution Count:291506
291506
200 -
201 switch (uint(t)) { -
202 -
203 case QVariant::Url: -
204 switch (d->type) { -
205 case QVariant::String: -
206 *static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d)); -
207 break;
executed: break;
Execution Count:1
1
208 default: -
209 return false;
never executed: return false;
0
210 } -
211 break;
executed: break;
Execution Count:1
1
212 -
213 case QVariant::String: { -
214 QString *str = static_cast<QString *>(result); -
215 switch (d->type) { -
216 case QVariant::Char: -
217 *str = QString(*v_cast<QChar>(d)); -
218 break;
executed: break;
Execution Count:227
227
219 case QMetaType::Char: -
220 case QMetaType::SChar: -
221 case QMetaType::UChar: -
222 *str = QChar::fromLatin1(d->data.c); -
223 break;
executed: break;
Execution Count:39
39
224 case QMetaType::Short: -
225 case QMetaType::Long: -
226 case QVariant::Int: -
227 case QVariant::LongLong: -
228 *str = QString::number(qMetaTypeNumber(d)); -
229 break;
executed: break;
Execution Count:26408
26408
230 case QVariant::UInt: -
231 case QVariant::ULongLong: -
232 case QMetaType::UShort: -
233 case QMetaType::ULong: -
234 *str = QString::number(qMetaTypeUNumber(d)); -
235 break;
executed: break;
Execution Count:96
96
236 case QMetaType::Float: -
237 *str = QString::number(d->data.f, 'g', 6); -
238 break;
executed: break;
Execution Count:12
12
239 case QVariant::Double: -
240 *str = QString::number(d->data.d, 'g', 15); -
241 break;
executed: break;
Execution Count:58
58
242 -
243 case QVariant::Date: -
244 *str = v_cast<QDate>(d)->toString(Qt::ISODate); -
245 break;
executed: break;
Execution Count:5
5
246 case QVariant::Time: -
247 *str = v_cast<QTime>(d)->toString(Qt::ISODate); -
248 break;
executed: break;
Execution Count:3
3
249 case QVariant::DateTime: -
250 *str = v_cast<QDateTime>(d)->toString(Qt::ISODate); -
251 break;
executed: break;
Execution Count:12
12
252 -
253 case QVariant::Bool: -
254 *str = QLatin1String(d->data.b ? "true" : "false"); -
255 break;
executed: break;
Execution Count:37
37
256 case QVariant::ByteArray: -
257 *str = QString::fromUtf8(v_cast<QByteArray>(d)->constData()); -
258 break;
executed: break;
Execution Count:3
3
259 case QVariant::StringList: -
260 if (v_cast<QStringList>(d)->count() == 1)
evaluated: v_cast<QStringList>(d)->count() == 1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
261 *str = v_cast<QStringList>(d)->at(0);
executed: *str = v_cast<QStringList>(d)->at(0);
Execution Count:3
3
262 break;
executed: break;
Execution Count:6
6
263 -
264 case QVariant::Url: -
265 *str = v_cast<QUrl>(d)->toString(); -
266 break;
executed: break;
Execution Count:5
5
267 -
268 case QVariant::Uuid: -
269 *str = v_cast<QUuid>(d)->toString(); -
270 break;
executed: break;
Execution Count:2
2
271 default: -
272 return false;
executed: return false;
Execution Count:14786
14786
273 } -
274 break;
executed: break;
Execution Count:26913
26913
275 } -
276 case QVariant::Char: { -
277 QChar *c = static_cast<QChar *>(result); -
278 switch (d->type) { -
279 case QVariant::Int: -
280 case QVariant::LongLong: -
281 case QMetaType::Char: -
282 case QMetaType::SChar: -
283 case QMetaType::Short: -
284 case QMetaType::Long: -
285 case QMetaType::Float: -
286 *c = QChar(ushort(qMetaTypeNumber(d))); -
287 break;
executed: break;
Execution Count:1
1
288 case QVariant::UInt: -
289 case QVariant::ULongLong: -
290 case QMetaType::UChar: -
291 case QMetaType::UShort: -
292 case QMetaType::ULong: -
293 *c = QChar(ushort(qMetaTypeUNumber(d))); -
294 break;
executed: break;
Execution Count:1
1
295 default: -
296 return false;
never executed: return false;
0
297 } -
298 break;
executed: break;
Execution Count:2
2
299 } -
300 -
301 case QVariant::Size: { -
302 QSize *s = static_cast<QSize *>(result); -
303 switch (d->type) { -
304 case QVariant::SizeF: -
305 *s = v_cast<QSizeF>(d)->toSize(); -
306 break;
executed: break;
Execution Count:4
4
307 default: -
308 return false;
executed: return false;
Execution Count:3
3
309 } -
310 break;
executed: break;
Execution Count:4
4
311 } -
312 -
313 case QVariant::SizeF: { -
314 QSizeF *s = static_cast<QSizeF *>(result); -
315 switch (d->type) { -
316 case QVariant::Size: -
317 *s = QSizeF(*(v_cast<QSize>(d))); -
318 break;
executed: break;
Execution Count:4
4
319 default: -
320 return false;
never executed: return false;
0
321 } -
322 break;
executed: break;
Execution Count:4
4
323 } -
324 -
325 case QVariant::Line: { -
326 QLine *s = static_cast<QLine *>(result); -
327 switch (d->type) { -
328 case QVariant::LineF: -
329 *s = v_cast<QLineF>(d)->toLine(); -
330 break;
executed: break;
Execution Count:4
4
331 default: -
332 return false;
never executed: return false;
0
333 } -
334 break;
executed: break;
Execution Count:4
4
335 } -
336 -
337 case QVariant::LineF: { -
338 QLineF *s = static_cast<QLineF *>(result); -
339 switch (d->type) { -
340 case QVariant::Line: -
341 *s = QLineF(*(v_cast<QLine>(d))); -
342 break;
executed: break;
Execution Count:4
4
343 default: -
344 return false;
never executed: return false;
0
345 } -
346 break;
executed: break;
Execution Count:4
4
347 } -
348 -
349 case QVariant::StringList: -
350 if (d->type == QVariant::List) {
partially evaluated: d->type == QVariant::List
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
351 QStringList *slst = static_cast<QStringList *>(result); -
352 const QVariantList *list = v_cast<QVariantList >(d); -
353 for (int i = 0; i < list->size(); ++i)
never evaluated: i < list->size()
0
354 slst->append(list->at(i).toString());
never executed: slst->append(list->at(i).toString());
0
355 } else if (d->type == QVariant::String) {
evaluated: d->type == QVariant::String
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
never executed: }
0-2
356 QStringList *slst = static_cast<QStringList *>(result); -
357 *slst = QStringList(*v_cast<QString>(d)); -
358 } else {
executed: }
Execution Count:2
2
359 return false;
executed: return false;
Execution Count:2
2
360 } -
361 break;
executed: break;
Execution Count:2
2
362 case QVariant::Date: { -
363 QDate *dt = static_cast<QDate *>(result); -
364 if (d->type == QVariant::DateTime)
evaluated: d->type == QVariant::DateTime
TRUEFALSE
yes
Evaluation Count:9883
yes
Evaluation Count:2
2-9883
365 *dt = v_cast<QDateTime>(d)->date();
executed: *dt = v_cast<QDateTime>(d)->date();
Execution Count:9883
9883
366 -
367 else if (d->type == QVariant::String)
partially evaluated: d->type == QVariant::String
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
368 *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
executed: *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
Execution Count:2
2
369 -
370 else -
371 return false;
never executed: return false;
0
372 -
373 return dt->isValid();
executed: return dt->isValid();
Execution Count:9885
9885
374 } -
375 case QVariant::Time: { -
376 QTime *t = static_cast<QTime *>(result); -
377 switch (d->type) { -
378 case QVariant::DateTime: -
379 *t = v_cast<QDateTime>(d)->time(); -
380 break;
executed: break;
Execution Count:9271
9271
381 -
382 case QVariant::String: -
383 *t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate); -
384 break;
executed: break;
Execution Count:2
2
385 -
386 default: -
387 return false;
never executed: return false;
0
388 } -
389 return t->isValid();
executed: return t->isValid();
Execution Count:9273
9273
390 } -
391 case QVariant::DateTime: { -
392 QDateTime *dt = static_cast<QDateTime *>(result); -
393 switch (d->type) { -
394 -
395 case QVariant::String: -
396 *dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate); -
397 break;
executed: break;
Execution Count:9
9
398 -
399 case QVariant::Date: -
400 *dt = QDateTime(*v_cast<QDate>(d)); -
401 break;
executed: break;
Execution Count:2
2
402 default: -
403 return false;
executed: return false;
Execution Count:497
497
404 } -
405 return dt->isValid();
executed: return dt->isValid();
Execution Count:11
11
406 } -
407 case QVariant::ByteArray: { -
408 QByteArray *ba = static_cast<QByteArray *>(result); -
409 switch (d->type) { -
410 case QVariant::String: -
411 *ba = v_cast<QString>(d)->toUtf8(); -
412 break;
executed: break;
Execution Count:99
99
413 case QVariant::Double: -
414 *ba = QByteArray::number(d->data.d, 'g', 15); -
415 break;
executed: break;
Execution Count:2
2
416 case QMetaType::Float: -
417 *ba = QByteArray::number(d->data.f, 'g', 6); -
418 break;
executed: break;
Execution Count:2
2
419 case QMetaType::Char: -
420 case QMetaType::SChar: -
421 case QMetaType::UChar: -
422 *ba = QByteArray(1, d->data.c); -
423 break;
never executed: break;
0
424 case QVariant::Int: -
425 case QVariant::LongLong: -
426 case QMetaType::Short: -
427 case QMetaType::Long: -
428 *ba = QByteArray::number(qMetaTypeNumber(d)); -
429 break;
executed: break;
Execution Count:218
218
430 case QVariant::UInt: -
431 case QVariant::ULongLong: -
432 case QMetaType::UShort: -
433 case QMetaType::ULong: -
434 *ba = QByteArray::number(qMetaTypeUNumber(d)); -
435 break;
executed: break;
Execution Count:4
4
436 case QVariant::Bool: -
437 *ba = QByteArray(d->data.b ? "true" : "false"); -
438 break;
executed: break;
Execution Count:3
3
439 default: -
440 return false;
executed: return false;
Execution Count:85
85
441 } -
442 } -
443 break;
executed: break;
Execution Count:328
328
444 case QMetaType::Short: -
445 *static_cast<short *>(result) = short(qConvertToNumber(d, ok)); -
446 return *ok;
executed: return *ok;
Execution Count:5
5
447 case QMetaType::Long: -
448 *static_cast<long *>(result) = long(qConvertToNumber(d, ok)); -
449 return *ok;
executed: return *ok;
Execution Count:1
1
450 case QMetaType::UShort: -
451 *static_cast<ushort *>(result) = ushort(qConvertToUnsignedNumber(d, ok)); -
452 return *ok;
executed: return *ok;
Execution Count:2
2
453 case QMetaType::ULong: -
454 *static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok)); -
455 return *ok;
executed: return *ok;
Execution Count:1
1
456 case QVariant::Int: -
457 *static_cast<int *>(result) = int(qConvertToNumber(d, ok)); -
458 return *ok;
executed: return *ok;
Execution Count:4190
4190
459 case QVariant::UInt: -
460 *static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok)); -
461 return *ok;
executed: return *ok;
Execution Count:79
79
462 case QVariant::LongLong: -
463 *static_cast<qlonglong *>(result) = qConvertToNumber(d, ok); -
464 return *ok;
executed: return *ok;
Execution Count:7575
7575
465 case QVariant::ULongLong: { -
466 *static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok); -
467 return *ok;
executed: return *ok;
Execution Count:78
78
468 } -
469 case QMetaType::SChar: { -
470 signed char s = qConvertToNumber(d, ok); -
471 *static_cast<signed char*>(result) = s; -
472 return *ok;
executed: return *ok;
Execution Count:1
1
473 } -
474 case QMetaType::UChar: { -
475 *static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok); -
476 return *ok;
executed: return *ok;
Execution Count:1
1
477 } -
478 case QVariant::Bool: { -
479 bool *b = static_cast<bool *>(result); -
480 switch(d->type) { -
481 case QVariant::ByteArray: -
482 *b = qt_convertToBool<QByteArray, QByteArray>(d); -
483 break;
executed: break;
Execution Count:10
10
484 case QVariant::String: -
485 *b = qt_convertToBool<QString, QLatin1String>(d); -
486 break;
executed: break;
Execution Count:19
19
487 case QVariant::Char: -
488 *b = !v_cast<QChar>(d)->isNull(); -
489 break;
executed: break;
Execution Count:2
2
490 case QVariant::Double: -
491 case QVariant::Int: -
492 case QVariant::LongLong: -
493 case QMetaType::Char: -
494 case QMetaType::SChar: -
495 case QMetaType::Short: -
496 case QMetaType::Long: -
497 case QMetaType::Float: -
498 *b = qMetaTypeNumber(d) != static_cast<long long>(0LL); -
499 break;
executed: break;
Execution Count:458
458
500 case QVariant::UInt: -
501 case QVariant::ULongLong: -
502 case QMetaType::UChar: -
503 case QMetaType::UShort: -
504 case QMetaType::ULong: -
505 *b = qMetaTypeUNumber(d) != static_cast<unsigned long long>(0ULL); -
506 break;
executed: break;
Execution Count:74
74
507 default: -
508 *b = false; -
509 return false;
executed: return false;
Execution Count:12242
12242
510 } -
511 break;
executed: break;
Execution Count:563
563
512 } -
513 case QVariant::Double: { -
514 double *f = static_cast<double *>(result); -
515 switch (d->type) { -
516 case QVariant::String: -
517 *f = v_cast<QString>(d)->toDouble(ok); -
518 break;
executed: break;
Execution Count:95
95
519 case QVariant::ByteArray: -
520 *f = v_cast<QByteArray>(d)->toDouble(ok); -
521 break;
executed: break;
Execution Count:2
2
522 case QVariant::Bool: -
523 *f = double(d->data.b); -
524 break;
executed: break;
Execution Count:8
8
525 case QMetaType::Float: -
526 *f = double(d->data.f); -
527 break;
executed: break;
Execution Count:10
10
528 case QVariant::LongLong: -
529 case QVariant::Int: -
530 case QMetaType::Char: -
531 case QMetaType::SChar: -
532 case QMetaType::Short: -
533 case QMetaType::Long: -
534 *f = double(qMetaTypeNumber(d)); -
535 break;
executed: break;
Execution Count:91
91
536 case QVariant::UInt: -
537 case QVariant::ULongLong: -
538 case QMetaType::UChar: -
539 case QMetaType::UShort: -
540 case QMetaType::ULong: -
541 *f = double(qMetaTypeUNumber(d)); -
542 break;
executed: break;
Execution Count:32
32
543 default: -
544 *f = 0.0; -
545 return false;
executed: return false;
Execution Count:16
16
546 } -
547 break;
executed: break;
Execution Count:238
238
548 } -
549 case QMetaType::Float: { -
550 float *f = static_cast<float *>(result); -
551 switch (d->type) { -
552 case QVariant::String: -
553 *f = v_cast<QString>(d)->toFloat(ok); -
554 break;
executed: break;
Execution Count:6
6
555 case QVariant::ByteArray: -
556 *f = v_cast<QByteArray>(d)->toFloat(ok); -
557 break;
executed: break;
Execution Count:1
1
558 case QVariant::Bool: -
559 *f = float(d->data.b); -
560 break;
never executed: break;
0
561 case QVariant::Double: -
562 *f = float(d->data.d); -
563 break;
executed: break;
Execution Count:3
3
564 case QVariant::LongLong: -
565 case QVariant::Int: -
566 case QMetaType::Char: -
567 case QMetaType::SChar: -
568 case QMetaType::Short: -
569 case QMetaType::Long: -
570 *f = float(qMetaTypeNumber(d)); -
571 break;
executed: break;
Execution Count:5
5
572 case QVariant::UInt: -
573 case QVariant::ULongLong: -
574 case QMetaType::UChar: -
575 case QMetaType::UShort: -
576 case QMetaType::ULong: -
577 *f = float(qMetaTypeUNumber(d)); -
578 break;
executed: break;
Execution Count:2
2
579 default: -
580 *f = 0.0f; -
581 return false;
never executed: return false;
0
582 } -
583 break;
executed: break;
Execution Count:17
17
584 } -
585 case QVariant::List: -
586 if (d->type == QVariant::StringList) {
evaluated: d->type == QVariant::StringList
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-13
587 QVariantList *lst = static_cast<QVariantList *>(result); -
588 const QStringList *slist = v_cast<QStringList>(d); -
589 for (int i = 0; i < slist->size(); ++i)
evaluated: i < slist->size()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:13
13-27
590 lst->append(QVariant(slist->at(i)));
executed: lst->append(QVariant(slist->at(i)));
Execution Count:27
27
591 } else if (qstrcmp(QMetaType::typeName(d->type), "QList<QVariant>") == 0) {
executed: }
Execution Count:13
partially evaluated: qstrcmp(QMetaType::typeName(d->type), "QList<QVariant>") == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-13
592 *static_cast<QVariantList *>(result) = -
593 *static_cast<QList<QVariant> *>(d->data.shared->ptr); -
594 } else {
never executed: }
0
595 return false;
executed: return false;
Execution Count:2
2
596 } -
597 break;
executed: break;
Execution Count:13
13
598 case QVariant::Map: -
599 if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0) {
partially evaluated: qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
600 *static_cast<QVariantMap *>(result) = -
601 *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr); -
602 } else {
never executed: }
0
603 return false;
executed: return false;
Execution Count:2
2
604 } -
605 break;
never executed: break;
0
606 case QVariant::Hash: -
607 if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) {
never evaluated: qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0
0
608 *static_cast<QVariantHash *>(result) = -
609 *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr); -
610 } else {
never executed: }
0
611 return false;
never executed: return false;
0
612 } -
613 break;
never executed: break;
0
614 -
615 case QVariant::Rect: -
616 if (d->type == QVariant::RectF)
partially evaluated: d->type == QVariant::RectF
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
617 *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();
executed: *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();
Execution Count:6
6
618 else -
619 return false;
never executed: return false;
0
620 break;
executed: break;
Execution Count:6
6
621 case QVariant::RectF: -
622 if (d->type == QVariant::Rect)
partially evaluated: d->type == QVariant::Rect
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
623 *static_cast<QRectF *>(result) = *v_cast<QRect>(d);
executed: *static_cast<QRectF *>(result) = *v_cast<QRect>(d);
Execution Count:1
1
624 else -
625 return false;
never executed: return false;
0
626 break;
executed: break;
Execution Count:1
1
627 case QVariant::PointF: -
628 if (d->type == QVariant::Point)
never evaluated: d->type == QVariant::Point
0
629 *static_cast<QPointF *>(result) = *v_cast<QPoint>(d);
never executed: *static_cast<QPointF *>(result) = *v_cast<QPoint>(d);
0
630 else -
631 return false;
never executed: return false;
0
632 break;
never executed: break;
0
633 case QVariant::Point: -
634 if (d->type == QVariant::PointF)
partially evaluated: d->type == QVariant::PointF
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
635 *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();
executed: *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();
Execution Count:5
5
636 else -
637 return false;
never executed: return false;
0
638 break;
executed: break;
Execution Count:5
5
639 case QMetaType::Char: -
640 { -
641 *static_cast<qint8 *>(result) = qint8(qConvertToNumber(d, ok)); -
642 return *ok;
executed: return *ok;
Execution Count:1
1
643 } -
644 -
645 case QVariant::Uuid: -
646 switch (d->type) { -
647 case QVariant::String: -
648 *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d)); -
649 break;
executed: break;
Execution Count:1
1
650 default: -
651 return false;
never executed: return false;
0
652 } -
653 break;
executed: break;
Execution Count:1
1
654 default: -
655 return false;
executed: return false;
Execution Count:204910
204910
656 } -
657 return true;
executed: return true;
Execution Count:28106
28106
658} -
659 -
660 -
661static void streamDebug(QDebug dbg, const QVariant &v) -
662{ -
663 QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); -
664 QVariantDebugStream<CoreTypesFilter> stream(dbg, d); -
665 QMetaTypeSwitcher::switcher<void>(stream, d->type, 0); -
666}
executed: }
Execution Count:50
50
667 -
668 -
669const QVariant::Handler qt_kernel_variant_handler = { -
670 construct, -
671 clear, -
672 isNull, -
673 -
674 0, -
675 0, -
676 -
677 compare, -
678 convert, -
679 0, -
680 -
681 streamDebug -
682 -
683 -
684 -
685}; -
686 -
687static void dummyConstruct(QVariant::Private *, const void *) { qt_noop(); }
never executed: }
0
688static void dummyClear(QVariant::Private *) { qt_noop(); }
never executed: }
0
689static bool dummyIsNull(const QVariant::Private *d) { qt_noop(); return d->is_null; }
never executed: return d->is_null;
0
690static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { qt_noop(); return false; }
never executed: return false;
0
691static bool dummyConvert(const QVariant::Private *, int, void *, bool *) { qt_noop(); return false; }
never executed: return false;
0
692 -
693static void dummyStreamDebug(QDebug, const QVariant &) { qt_noop(); }
never executed: }
0
694 -
695const QVariant::Handler qt_dummy_variant_handler = { -
696 dummyConstruct, -
697 dummyClear, -
698 dummyIsNull, -
699 -
700 0, -
701 0, -
702 -
703 dummyCompare, -
704 dummyConvert, -
705 0, -
706 -
707 dummyStreamDebug -
708 -
709 -
710 -
711}; -
712 -
713static void customConstruct(QVariant::Private *d, const void *copy) -
714{ -
715 const QMetaType type(d->type); -
716 const uint size = type.sizeOf(); -
717 if (!size) {
evaluated: !size
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:41689
18-41689
718 QMessageLogger("kernel/qvariant.cpp", 794, __PRETTY_FUNCTION__).warning("Trying to construct an instance of an invalid type, type id: %i", d->type); -
719 d->type = QVariant::Invalid; -
720 return;
executed: return;
Execution Count:18
18
721 } -
722 -
723 -
724 if (size <= sizeof(QVariant::Private::Data)
evaluated: size <= sizeof(QVariant::Private::Data)
TRUEFALSE
yes
Evaluation Count:40431
yes
Evaluation Count:1258
1258-40431
725 && (type.flags() & QMetaType::MovableType)) {
evaluated: (type.flags() & QMetaType::MovableType)
TRUEFALSE
yes
Evaluation Count:38194
yes
Evaluation Count:2237
2237-38194
726 type.construct(&d->data.ptr, copy); -
727 d->is_shared = false; -
728 } else {
executed: }
Execution Count:38194
38194
729 void *ptr = type.create(copy); -
730 d->is_shared = true; -
731 d->data.shared = new QVariant::PrivateShared(ptr); -
732 }
executed: }
Execution Count:3495
3495
733} -
734 -
735static void customClear(QVariant::Private *d) -
736{ -
737 if (!d->is_shared) {
evaluated: !d->is_shared
TRUEFALSE
yes
Evaluation Count:42457
yes
Evaluation Count:3467
3467-42457
738 QMetaType::destruct(d->type, &d->data.ptr); -
739 } else {
executed: }
Execution Count:42457
42457
740 QMetaType::destroy(d->type, d->data.shared->ptr); -
741 delete d->data.shared; -
742 }
executed: }
Execution Count:3467
3467
743} -
744 -
745static bool customIsNull(const QVariant::Private *d) -
746{ -
747 return d->is_null;
executed: return d->is_null;
Execution Count:273
273
748} -
749 -
750static bool customCompare(const QVariant::Private *a, const QVariant::Private *b) -
751{ -
752 const char *const typeName = QMetaType::typeName(a->type); -
753 if (__builtin_expect(!!(!typeName), false) && __builtin_expect(!!(!QMetaType::isRegistered(a->type)), true))
partially evaluated: __builtin_expect(!!(!typeName), false)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:77
never evaluated: __builtin_expect(!!(!QMetaType::isRegistered(a->type)), true)
0-77
754 QMessageLogger("kernel/qvariant.cpp", 830, __PRETTY_FUNCTION__).fatal("QVariant::compare: type %d unknown to QVariant.", a->type);
never executed: QMessageLogger("kernel/qvariant.cpp", 830, __PRETTY_FUNCTION__).fatal("QVariant::compare: type %d unknown to QVariant.", a->type);
0
755 -
756 const void *a_ptr = a->is_shared ? a->data.shared->ptr : &(a->data.ptr);
evaluated: a->is_shared
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:71
6-71
757 const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr);
evaluated: b->is_shared
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:71
6-71
758 -
759 uint typeNameLen = qstrlen(typeName); -
760 if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*')
partially evaluated: typeNameLen > 0
TRUEFALSE
yes
Evaluation Count:77
no
Evaluation Count:0
evaluated: typeName[typeNameLen - 1] == '*'
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:62
0-77
761 return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr);
executed: return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr);
Execution Count:15
15
762 -
763 if (a->is_null && b->is_null)
partially evaluated: a->is_null
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:62
never evaluated: b->is_null
0-62
764 return true;
never executed: return true;
0
765 -
766 return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type));
executed: return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type));
Execution Count:62
62
767} -
768 -
769static bool customConvert(const QVariant::Private *, int, void *, bool *ok) -
770{ -
771 if (ok)
partially evaluated: ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:366
0-366
772 *ok = false;
never executed: *ok = false;
0
773 return false;
executed: return false;
Execution Count:366
366
774} -
775 -
776 -
777static void customStreamDebug(QDebug dbg, const QVariant &variant) { -
778 -
779 QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType()); -
780 if (flags & QMetaType::PointerToQObject)
evaluated: flags & QMetaType::PointerToQObject
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
781 dbg.nospace() << variant.value<QObject*>();
executed: dbg.nospace() << variant.value<QObject*>();
Execution Count:1
1
782 -
783 -
784 -
785 -
786}
executed: }
Execution Count:3
3
787 -
788 -
789const QVariant::Handler qt_custom_variant_handler = { -
790 customConstruct, -
791 customClear, -
792 customIsNull, -
793 -
794 0, -
795 0, -
796 -
797 customCompare, -
798 customConvert, -
799 0, -
800 -
801 customStreamDebug -
802 -
803 -
804 -
805}; -
806 -
807} -
808 -
809static HandlersManager handlerManager; -
810static_assert(bool(!QModulesPrivate::Core), "Initialization assumes that ModulesNames::Core is 0"); -
811const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount] -
812 = { &qt_kernel_variant_handler, &qt_dummy_variant_handler, -
813 &qt_dummy_variant_handler, &qt_custom_variant_handler }; -
814 -
815__attribute__((visibility("default"))) const QVariant::Handler *qcoreVariantHandler() -
816{ -
817 return &qt_kernel_variant_handler;
executed: return &qt_kernel_variant_handler;
Execution Count:203138
203138
818} -
819 -
820__attribute__((visibility("default"))) void QVariantPrivate::registerHandler(const int name, const QVariant::Handler *handler) -
821{ -
822 handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler); -
823}
executed: }
Execution Count:186
186
824void QVariant::create(int type, const void *copy) -
825{ -
826 d.type = type; -
827 handlerManager[type]->construct(&d, copy); -
828}
executed: }
Execution Count:3565831
3565831
829QVariant::~QVariant() -
830{ -
831 if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
evaluated: d.is_shared
TRUEFALSE
yes
Evaluation Count:17121824
yes
Evaluation Count:26318968
evaluated: !d.data.shared->ref.deref()
TRUEFALSE
yes
Evaluation Count:3426665
yes
Evaluation Count:13695159
evaluated: !d.is_shared
TRUEFALSE
yes
Evaluation Count:26318968
yes
Evaluation Count:13695159
evaluated: d.type > Char
TRUEFALSE
yes
Evaluation Count:22372463
yes
Evaluation Count:3946505
3426665-26318968
832 handlerManager[d.type]->clear(&d);
executed: handlerManager[d.type]->clear(&d);
Execution Count:25799128
25799128
833}
executed: }
Execution Count:43440792
43440792
834QVariant::QVariant(const QVariant &p) -
835 : d(p.d) -
836{ -
837 if (d.is_shared) {
evaluated: d.is_shared
TRUEFALSE
yes
Evaluation Count:13694132
yes
Evaluation Count:19596524
13694132-19596524
838 d.data.shared->ref.ref(); -
839 } else if (p.d.type > Char) {
executed: }
Execution Count:13694132
evaluated: p.d.type > Char
TRUEFALSE
yes
Evaluation Count:18274264
yes
Evaluation Count:1322259
1322259-18274264
840 handlerManager[d.type]->construct(&d, p.constData()); -
841 d.is_null = p.d.is_null; -
842 }
executed: }
Execution Count:18274265
18274265
843} -
844 -
845 -
846 -
847 -
848 -
849QVariant::QVariant(QDataStream &s) -
850{ -
851 d.is_null = true; -
852 s >> *this; -
853}
never executed: }
0
854QVariant::QVariant(const char *val) -
855{ -
856 QString s = QString::fromUtf8(val); -
857 create(String, &s); -
858}
executed: }
Execution Count:10292
10292
859QVariant::QVariant(Type type) -
860{ create(type, 0); }
executed: }
Execution Count:7981
7981
861QVariant::QVariant(int typeId, const void *copy) -
862{ create(typeId, copy); d.is_null = false; }
executed: }
Execution Count:3503126
3503126
863 -
864 -
865 -
866 -
867 -
868QVariant::QVariant(int typeId, const void *copy, uint flags) -
869{ -
870 if (flags) {
evaluated: flags
TRUEFALSE
yes
Evaluation Count:4276
yes
Evaluation Count:31846
4276-31846
871 d.type = typeId; -
872 d.data.ptr = *reinterpret_cast<void *const*>(copy); -
873 } else {
executed: }
Execution Count:4276
4276
874 create(typeId, copy); -
875 }
executed: }
Execution Count:31846
31846
876 d.is_null = false; -
877}
executed: }
Execution Count:36122
36122
878 -
879QVariant::QVariant(int val) -
880 : d(Int) -
881{ d.data.i = val; }
executed: }
Execution Count:488230
488230
882QVariant::QVariant(uint val) -
883 : d(UInt) -
884{ d.data.u = val; }
executed: }
Execution Count:486
486
885QVariant::QVariant(qlonglong val) -
886 : d(LongLong) -
887{ d.data.ll = val; }
executed: }
Execution Count:40047
40047
888QVariant::QVariant(qulonglong val) -
889 : d(ULongLong) -
890{ d.data.ull = val; }
executed: }
Execution Count:28
28
891QVariant::QVariant(bool val) -
892 : d(Bool) -
893{ d.data.b = val; }
executed: }
Execution Count:99974
99974
894QVariant::QVariant(double val) -
895 : d(Double) -
896{ d.data.d = val; }
executed: }
Execution Count:60485
60485
897QVariant::QVariant(float val) -
898 : d(QMetaType::Float) -
899{ d.data.f = val; }
executed: }
Execution Count:139
139
900 -
901QVariant::QVariant(const QByteArray &val) -
902 : d(ByteArray) -
903{ v_construct<QByteArray>(&d, val); }
executed: }
Execution Count:1071
1071
904QVariant::QVariant(const QBitArray &val) -
905 : d(BitArray) -
906{ v_construct<QBitArray>(&d, val); }
executed: }
Execution Count:6
6
907QVariant::QVariant(const QString &val) -
908 : d(String) -
909{ v_construct<QString>(&d, val); }
executed: }
Execution Count:3926317
3926317
910QVariant::QVariant(QChar val) -
911 : d(Char) -
912{ v_construct<QChar>(&d, val); }
executed: }
Execution Count:238
238
913QVariant::QVariant(QLatin1String val) -
914 : d(String) -
915{ v_construct<QString>(&d, val); }
executed: }
Execution Count:126
126
916QVariant::QVariant(const QStringList &val) -
917 : d(StringList) -
918{ v_construct<QStringList>(&d, val); }
executed: }
Execution Count:213
213
919 -
920QVariant::QVariant(const QDate &val) -
921 : d(Date) -
922{ v_construct<QDate>(&d, val); }
executed: }
Execution Count:1703
1703
923QVariant::QVariant(const QTime &val) -
924 : d(Time) -
925{ v_construct<QTime>(&d, val); }
executed: }
Execution Count:1681
1681
926QVariant::QVariant(const QDateTime &val) -
927 : d(DateTime) -
928{ v_construct<QDateTime>(&d, val); }
executed: }
Execution Count:16030
16030
929 -
930QVariant::QVariant(const QEasingCurve &val) -
931 : d(EasingCurve) -
932{ v_construct<QEasingCurve>(&d, val); }
executed: }
Execution Count:3
3
933 -
934QVariant::QVariant(const QList<QVariant> &list) -
935 : d(List) -
936{ v_construct<QVariantList>(&d, list); }
executed: }
Execution Count:273
273
937QVariant::QVariant(const QMap<QString, QVariant> &map) -
938 : d(Map) -
939{ v_construct<QVariantMap>(&d, map); }
executed: }
Execution Count:887
887
940QVariant::QVariant(const QHash<QString, QVariant> &hash) -
941 : d(Hash) -
942{ v_construct<QVariantHash>(&d, hash); }
executed: }
Execution Count:13
13
943 -
944QVariant::QVariant(const QPoint &pt) -
945 : d(Point) -
946{ v_construct<QPoint>(&d, pt); }
executed: }
Execution Count:3
3
947QVariant::QVariant(const QPointF &pt) -
948 : d(PointF) -
949{ v_construct<QPointF>(&d, pt); }
executed: }
Execution Count:32
32
950QVariant::QVariant(const QRectF &r) -
951 : d(RectF) -
952{ v_construct<QRectF>(&d, r); }
executed: }
Execution Count:15
15
953QVariant::QVariant(const QLineF &l) -
954 : d(LineF) -
955{ v_construct<QLineF>(&d, l); }
executed: }
Execution Count:5
5
956QVariant::QVariant(const QLine &l) -
957 : d(Line) -
958{ v_construct<QLine>(&d, l); }
executed: }
Execution Count:5
5
959QVariant::QVariant(const QRect &r) -
960 : d(Rect) -
961{ v_construct<QRect>(&d, r); }
executed: }
Execution Count:961
961
962QVariant::QVariant(const QSize &s) -
963 : d(Size) -
964{ v_construct<QSize>(&d, s); }
executed: }
Execution Count:323
323
965QVariant::QVariant(const QSizeF &s) -
966 : d(SizeF) -
967{ v_construct<QSizeF>(&d, s); }
executed: }
Execution Count:16
16
968 -
969 -
970QVariant::QVariant(const QUrl &u) -
971 : d(Url) -
972{ v_construct<QUrl>(&d, u); }
executed: }
Execution Count:2960
2960
973 -
974QVariant::QVariant(const QLocale &l) -
975 : d(Locale) -
976{ v_construct<QLocale>(&d, l); }
executed: }
Execution Count:2
2
977 -
978QVariant::QVariant(const QRegExp &regExp) -
979 : d(RegExp) -
980{ v_construct<QRegExp>(&d, regExp); }
executed: }
Execution Count:46
46
981 -
982QVariant::QVariant(const QRegularExpression &re) -
983 : d(RegularExpression) -
984{ v_construct<QRegularExpression>(&d, re); }
executed: }
Execution Count:4
4
985QVariant::QVariant(const QUuid &uuid) -
986 : d(Uuid) -
987{ v_construct<QUuid>(&d, uuid); }
executed: }
Execution Count:1
1
988QVariant::QVariant(const QModelIndex &modelIndex) -
989 : d(ModelIndex) -
990{ v_construct<QModelIndex>(&d, modelIndex); }
executed: }
Execution Count:1
1
991QVariant::QVariant(const QJsonValue &jsonValue) -
992 : d(QMetaType::QJsonValue) -
993{ v_construct<QJsonValue>(&d, jsonValue); }
executed: }
Execution Count:1
1
994QVariant::QVariant(const QJsonObject &jsonObject) -
995 : d(QMetaType::QJsonObject) -
996{ v_construct<QJsonObject>(&d, jsonObject); }
executed: }
Execution Count:1
1
997QVariant::QVariant(const QJsonArray &jsonArray) -
998 : d(QMetaType::QJsonArray) -
999{ v_construct<QJsonArray>(&d, jsonArray); }
executed: }
Execution Count:1
1
1000QVariant::QVariant(const QJsonDocument &jsonDocument) -
1001 : d(QMetaType::QJsonDocument) -
1002{ v_construct<QJsonDocument>(&d, jsonDocument); }
executed: }
Execution Count:1
1
1003QVariant::Type QVariant::type() const -
1004{ -
1005 return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type);
executed: return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type);
Execution Count:350398
350398
1006} -
1007int QVariant::userType() const -
1008{ -
1009 return d.type;
executed: return d.type;
Execution Count:956224
956224
1010} -
1011 -
1012 -
1013 -
1014 -
1015QVariant& QVariant::operator=(const QVariant &variant) -
1016{ -
1017 if (this == &variant)
evaluated: this == &variant
TRUEFALSE
yes
Evaluation Count:266
yes
Evaluation Count:322241
266-322241
1018 return *this;
executed: return *this;
Execution Count:266
266
1019 -
1020 clear(); -
1021 if (variant.d.is_shared) {
evaluated: variant.d.is_shared
TRUEFALSE
yes
Evaluation Count:1147
yes
Evaluation Count:321094
1147-321094
1022 variant.d.data.shared->ref.ref(); -
1023 d = variant.d; -
1024 } else if (variant.d.type > Char) {
executed: }
Execution Count:1147
evaluated: variant.d.type > Char
TRUEFALSE
yes
Evaluation Count:152526
yes
Evaluation Count:168568
1147-168568
1025 d.type = variant.d.type; -
1026 handlerManager[d.type]->construct(&d, variant.constData()); -
1027 d.is_null = variant.d.is_null; -
1028 } else {
executed: }
Execution Count:152526
152526
1029 d = variant.d; -
1030 }
executed: }
Execution Count:168568
168568
1031 -
1032 return *this;
executed: return *this;
Execution Count:322241
322241
1033} -
1034void QVariant::detach() -
1035{ -
1036 if (!d.is_shared || d.data.shared->ref.load() == 1)
evaluated: !d.is_shared
TRUEFALSE
yes
Evaluation Count:15817
yes
Evaluation Count:1848
evaluated: d.data.shared->ref.load() == 1
TRUEFALSE
yes
Evaluation Count:1827
yes
Evaluation Count:21
21-15817
1037 return;
executed: return;
Execution Count:17644
17644
1038 -
1039 Private dd; -
1040 dd.type = d.type; -
1041 handlerManager[d.type]->construct(&dd, constData()); -
1042 if (!d.data.shared->ref.deref())
partially evaluated: !d.data.shared->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
1043 handlerManager[d.type]->clear(&d);
never executed: handlerManager[d.type]->clear(&d);
0
1044 d.data.shared = dd.data.shared; -
1045}
executed: }
Execution Count:21
21
1046const char *QVariant::typeName() const -
1047{ -
1048 return QMetaType::typeName(d.type);
executed: return QMetaType::typeName(d.type);
Execution Count:906
906
1049} -
1050 -
1051 -
1052 -
1053 -
1054 -
1055void QVariant::clear() -
1056{ -
1057 if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
evaluated: d.is_shared
TRUEFALSE
yes
Evaluation Count:265
yes
Evaluation Count:340514
evaluated: !d.data.shared->ref.deref()
TRUEFALSE
yes
Evaluation Count:166
yes
Evaluation Count:99
evaluated: !d.is_shared
TRUEFALSE
yes
Evaluation Count:340514
yes
Evaluation Count:99
evaluated: d.type > Char
TRUEFALSE
yes
Evaluation Count:130216
yes
Evaluation Count:210298
99-340514
1058 handlerManager[d.type]->clear(&d);
executed: handlerManager[d.type]->clear(&d);
Execution Count:130382
130382
1059 d.type = Invalid; -
1060 d.is_null = true; -
1061 d.is_shared = false; -
1062}
executed: }
Execution Count:340779
340779
1063 -
1064 -
1065 -
1066 -
1067 -
1068 -
1069 -
1070const char *QVariant::typeToName(int typeId) -
1071{ -
1072 return QMetaType::typeName(typeId);
executed: return QMetaType::typeName(typeId);
Execution Count:193
193
1073} -
1074QVariant::Type QVariant::nameToType(const char *name) -
1075{ -
1076 int metaType = QMetaType::type(name); -
1077 return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
executed: return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
Execution Count:79
79
1078} -
1079 -
1080 -
1081enum { MapFromThreeCount = 36 }; -
1082static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = -
1083{ -
1084 QVariant::Invalid, -
1085 QVariant::Map, -
1086 QVariant::List, -
1087 QVariant::String, -
1088 QVariant::StringList, -
1089 QVariant::Font, -
1090 QVariant::Pixmap, -
1091 QVariant::Brush, -
1092 QVariant::Rect, -
1093 QVariant::Size, -
1094 QVariant::Color, -
1095 QVariant::Palette, -
1096 0, -
1097 QVariant::Icon, -
1098 QVariant::Point, -
1099 QVariant::Image, -
1100 QVariant::Int, -
1101 QVariant::UInt, -
1102 QVariant::Bool, -
1103 QVariant::Double, -
1104 0, -
1105 QVariant::Polygon, -
1106 QVariant::Region, -
1107 QVariant::Bitmap, -
1108 QVariant::Cursor, -
1109 QVariant::SizePolicy, -
1110 QVariant::Date, -
1111 QVariant::Time, -
1112 QVariant::DateTime, -
1113 QVariant::ByteArray, -
1114 QVariant::BitArray, -
1115 QVariant::KeySequence, -
1116 QVariant::Pen, -
1117 QVariant::LongLong, -
1118 QVariant::ULongLong, -
1119 QVariant::EasingCurve -
1120}; -
1121 -
1122 -
1123 -
1124 -
1125 -
1126 -
1127 -
1128void QVariant::load(QDataStream &s) -
1129{ -
1130 clear(); -
1131 -
1132 quint32 typeId; -
1133 s >> typeId; -
1134 if (s.version() < QDataStream::Qt_4_0) {
evaluated: s.version() < QDataStream::Qt_4_0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12318
1-12318
1135 if (typeId >= MapFromThreeCount)
partially evaluated: typeId >= MapFromThreeCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1136 return;
never executed: return;
0
1137 typeId = mapIdFromQt3ToCurrent[typeId]; -
1138 } else if (s.version() < QDataStream::Qt_5_0) {
executed: }
Execution Count:1
evaluated: s.version() < QDataStream::Qt_5_0
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:12235
1-12235
1139 if (typeId == 127 ) {
partially evaluated: typeId == 127
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83
0-83
1140 typeId = QMetaType::User; -
1141 } else if (typeId >= 128 && typeId != QVariant::UserType) {
never executed: }
evaluated: typeId >= 128
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:67
partially evaluated: typeId != QVariant::UserType
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-67
1142 -
1143 -
1144 typeId -= 97; -
1145 } else if (typeId == 75 ) {
executed: }
Execution Count:16
partially evaluated: typeId == 75
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:67
0-67
1146 typeId = QMetaType::QSizePolicy; -
1147 } else if (typeId > 75 && typeId <= 86) {
never executed: }
partially evaluated: typeId > 75
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:67
never evaluated: typeId <= 86
0-67
1148 -
1149 -
1150 typeId -=1; -
1151 }
never executed: }
0
1152 } -
1153 -
1154 qint8 is_null = false; -
1155 if (s.version() >= QDataStream::Qt_4_2)
evaluated: s.version() >= QDataStream::Qt_4_2
TRUEFALSE
yes
Evaluation Count:12310
yes
Evaluation Count:9
9-12310
1156 s >> is_null;
executed: s >> is_null;
Execution Count:12310
12310
1157 if (typeId == QVariant::UserType) {
evaluated: typeId == QVariant::UserType
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:12316
3-12316
1158 QByteArray name; -
1159 s >> name; -
1160 typeId = QMetaType::type(name.constData()); -
1161 if (typeId == QMetaType::UnknownType) {
partially evaluated: typeId == QMetaType::UnknownType
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1162 s.setStatus(QDataStream::ReadCorruptData); -
1163 return;
never executed: return;
0
1164 } -
1165 }
executed: }
Execution Count:3
3
1166 create(typeId, 0); -
1167 d.is_null = is_null; -
1168 -
1169 if (!isValid()) {
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:12306
13-12306
1170 if (s.version() < QDataStream::Qt_5_0) {
evaluated: s.version() < QDataStream::Qt_5_0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:10
3-10
1171 -
1172 QString x; -
1173 s >> x; -
1174 }
executed: }
Execution Count:3
3
1175 d.is_null = true; -
1176 return;
executed: return;
Execution Count:13
13
1177 } -
1178 -
1179 -
1180 if (!QMetaType::load(s, d.type, const_cast<void *>(constData()))) {
evaluated: !QMetaType::load(s, d.type, const_cast<void *>(constData()))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:12305
1-12305
1181 s.setStatus(QDataStream::ReadCorruptData); -
1182 QMessageLogger("kernel/qvariant.cpp", 1813, __PRETTY_FUNCTION__).warning("QVariant::load: unable to load type %d.", d.type); -
1183 }
executed: }
Execution Count:1
1
1184}
executed: }
Execution Count:12306
12306
1185 -
1186 -
1187 -
1188 -
1189 -
1190 -
1191 -
1192void QVariant::save(QDataStream &s) const -
1193{ -
1194 quint32 typeId = type(); -
1195 if (s.version() < QDataStream::Qt_4_0) {
evaluated: s.version() < QDataStream::Qt_4_0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:12319
9-12319
1196 int i; -
1197 for (i = 0; i <= MapFromThreeCount - 1; ++i) {
evaluated: i <= MapFromThreeCount - 1
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:1
1-76
1198 if (mapIdFromQt3ToCurrent[i] == typeId) {
evaluated: mapIdFromQt3ToCurrent[i] == typeId
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:68
8-68
1199 typeId = i; -
1200 break;
executed: break;
Execution Count:8
8
1201 } -
1202 }
executed: }
Execution Count:68
68
1203 if (i >= MapFromThreeCount) {
evaluated: i >= MapFromThreeCount
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
1204 s << QVariant(); -
1205 return;
executed: return;
Execution Count:1
1
1206 } -
1207 } else if (s.version() < QDataStream::Qt_5_0) {
executed: }
Execution Count:8
evaluated: s.version() < QDataStream::Qt_5_0
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:12223
8-12223
1208 if (typeId == QMetaType::User) {
partially evaluated: typeId == QMetaType::User
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:96
0-96
1209 typeId = 127; -
1210 } else if (typeId >= 128 - 97 && typeId <= LastCoreType) {
never executed: }
evaluated: typeId >= 128 - 97
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:87
evaluated: typeId <= LastCoreType
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1
0-87
1211 -
1212 -
1213 typeId += 97; -
1214 } else if (typeId == QMetaType::QSizePolicy) {
executed: }
Execution Count:8
partially evaluated: typeId == QMetaType::QSizePolicy
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:88
0-88
1215 typeId = 75; -
1216 } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) {
never executed: }
partially evaluated: typeId >= QMetaType::QKeySequence
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:88
never evaluated: typeId <= QMetaType::QQuaternion
0-88
1217 -
1218 typeId +=1; -
1219 }
never executed: }
0
1220 } -
1221 s << typeId; -
1222 if (s.version() >= QDataStream::Qt_4_2)
evaluated: s.version() >= QDataStream::Qt_4_2
TRUEFALSE
yes
Evaluation Count:12265
yes
Evaluation Count:62
62-12265
1223 s << qint8(d.is_null);
executed: s << qint8(d.is_null);
Execution Count:12265
12265
1224 if (d.type >= QVariant::UserType) {
evaluated: d.type >= QVariant::UserType
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:12325
2-12325
1225 s << QMetaType::typeName(userType()); -
1226 }
executed: }
Execution Count:2
2
1227 -
1228 if (!isValid()) {
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:12309
18-12309
1229 if (s.version() < QDataStream::Qt_5_0)
evaluated: s.version() < QDataStream::Qt_5_0
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:5
5-13
1230 s << QString();
executed: s << QString();
Execution Count:13
13
1231 return;
executed: return;
Execution Count:18
18
1232 } -
1233 -
1234 if (!QMetaType::save(s, d.type, constData())) {
partially evaluated: !QMetaType::save(s, d.type, constData())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12309
0-12309
1235 QMessageLogger("kernel/qvariant.cpp", 1866, __PRETTY_FUNCTION__).warning("QVariant::save: unable to save type '%s' (type id: %d).\n", QMetaType::typeName(d.type), d.type); -
1236 qt_noop(); -
1237 }
never executed: }
0
1238}
executed: }
Execution Count:12309
12309
1239QDataStream& operator>>(QDataStream &s, QVariant &p) -
1240{ -
1241 p.load(s); -
1242 return s;
executed: return s;
Execution Count:12317
12317
1243} -
1244 -
1245 -
1246 -
1247 -
1248 -
1249 -
1250QDataStream& operator<<(QDataStream &s, const QVariant &p) -
1251{ -
1252 p.save(s); -
1253 return s;
executed: return s;
Execution Count:12328
12328
1254} -
1255 -
1256 -
1257 -
1258 -
1259QDataStream& operator>>(QDataStream &s, QVariant::Type &p) -
1260{ -
1261 quint32 u; -
1262 s >> u; -
1263 p = (QVariant::Type)u; -
1264 -
1265 return s;
never executed: return s;
0
1266} -
1267 -
1268 -
1269 -
1270 -
1271QDataStream& operator<<(QDataStream &s, const QVariant::Type p) -
1272{ -
1273 s << static_cast<quint32>(p); -
1274 -
1275 return s;
never executed: return s;
0
1276} -
1277template <typename T> -
1278inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager) -
1279{ -
1280 const uint targetType = qMetaTypeId<T>(); -
1281 if (d.type == targetType)
evaluated: d.type == targetType
TRUEFALSE
yes
Evaluation Count:535554
yes
Evaluation Count:61489
61489-535554
1282 return *v_cast<T>(&d);
executed: return *v_cast<T>(&d);
Execution Count:535554
535554
1283 -
1284 T ret; -
1285 handlerManager[d.type]->convert(&d, targetType, &ret, 0); -
1286 return ret;
executed: return ret;
Execution Count:61489
61489
1287} -
1288QStringList QVariant::toStringList() const -
1289{ -
1290 return qVariantToHelper<QStringList>(d, handlerManager);
executed: return qVariantToHelper<QStringList>(d, handlerManager);
Execution Count:191
191
1291} -
1292QString QVariant::toString() const -
1293{ -
1294 return qVariantToHelper<QString>(d, handlerManager);
executed: return qVariantToHelper<QString>(d, handlerManager);
Execution Count:477952
477952
1295} -
1296 -
1297 -
1298 -
1299 -
1300 -
1301 -
1302 -
1303QVariantMap QVariant::toMap() const -
1304{ -
1305 return qVariantToHelper<QVariantMap>(d, handlerManager);
executed: return qVariantToHelper<QVariantMap>(d, handlerManager);
Execution Count:4
4
1306} -
1307 -
1308 -
1309 -
1310 -
1311 -
1312 -
1313 -
1314QVariantHash QVariant::toHash() const -
1315{ -
1316 return qVariantToHelper<QVariantHash>(d, handlerManager);
never executed: return qVariantToHelper<QVariantHash>(d, handlerManager);
0
1317} -
1318QDate QVariant::toDate() const -
1319{ -
1320 return qVariantToHelper<QDate>(d, handlerManager);
executed: return qVariantToHelper<QDate>(d, handlerManager);
Execution Count:11588
11588
1321} -
1322QTime QVariant::toTime() const -
1323{ -
1324 return qVariantToHelper<QTime>(d, handlerManager);
executed: return qVariantToHelper<QTime>(d, handlerManager);
Execution Count:10955
10955
1325} -
1326QDateTime QVariant::toDateTime() const -
1327{ -
1328 return qVariantToHelper<QDateTime>(d, handlerManager);
executed: return qVariantToHelper<QDateTime>(d, handlerManager);
Execution Count:89174
89174
1329} -
1330QEasingCurve QVariant::toEasingCurve() const -
1331{ -
1332 return qVariantToHelper<QEasingCurve>(d, handlerManager);
executed: return qVariantToHelper<QEasingCurve>(d, handlerManager);
Execution Count:3
3
1333} -
1334QByteArray QVariant::toByteArray() const -
1335{ -
1336 return qVariantToHelper<QByteArray>(d, handlerManager);
executed: return qVariantToHelper<QByteArray>(d, handlerManager);
Execution Count:1291
1291
1337} -
1338QPoint QVariant::toPoint() const -
1339{ -
1340 return qVariantToHelper<QPoint>(d, handlerManager);
executed: return qVariantToHelper<QPoint>(d, handlerManager);
Execution Count:6
6
1341} -
1342QRect QVariant::toRect() const -
1343{ -
1344 return qVariantToHelper<QRect>(d, handlerManager);
executed: return qVariantToHelper<QRect>(d, handlerManager);
Execution Count:116
116
1345} -
1346QSize QVariant::toSize() const -
1347{ -
1348 return qVariantToHelper<QSize>(d, handlerManager);
executed: return qVariantToHelper<QSize>(d, handlerManager);
Execution Count:88
88
1349} -
1350QSizeF QVariant::toSizeF() const -
1351{ -
1352 return qVariantToHelper<QSizeF>(d, handlerManager);
executed: return qVariantToHelper<QSizeF>(d, handlerManager);
Execution Count:16
16
1353} -
1354QRectF QVariant::toRectF() const -
1355{ -
1356 return qVariantToHelper<QRectF>(d, handlerManager);
executed: return qVariantToHelper<QRectF>(d, handlerManager);
Execution Count:9
9
1357} -
1358QLineF QVariant::toLineF() const -
1359{ -
1360 return qVariantToHelper<QLineF>(d, handlerManager);
executed: return qVariantToHelper<QLineF>(d, handlerManager);
Execution Count:5
5
1361} -
1362QLine QVariant::toLine() const -
1363{ -
1364 return qVariantToHelper<QLine>(d, handlerManager);
executed: return qVariantToHelper<QLine>(d, handlerManager);
Execution Count:5
5
1365} -
1366QPointF QVariant::toPointF() const -
1367{ -
1368 return qVariantToHelper<QPointF>(d, handlerManager);
executed: return qVariantToHelper<QPointF>(d, handlerManager);
Execution Count:757
757
1369} -
1370QUrl QVariant::toUrl() const -
1371{ -
1372 return qVariantToHelper<QUrl>(d, handlerManager);
executed: return qVariantToHelper<QUrl>(d, handlerManager);
Execution Count:4696
4696
1373} -
1374QLocale QVariant::toLocale() const -
1375{ -
1376 return qVariantToHelper<QLocale>(d, handlerManager);
executed: return qVariantToHelper<QLocale>(d, handlerManager);
Execution Count:3
3
1377} -
1378QRegExp QVariant::toRegExp() const -
1379{ -
1380 return qVariantToHelper<QRegExp>(d, handlerManager);
executed: return qVariantToHelper<QRegExp>(d, handlerManager);
Execution Count:45
45
1381} -
1382QRegularExpression QVariant::toRegularExpression() const -
1383{ -
1384 return qVariantToHelper<QRegularExpression>(d, handlerManager);
executed: return qVariantToHelper<QRegularExpression>(d, handlerManager);
Execution Count:3
3
1385} -
1386QUuid QVariant::toUuid() const -
1387{ -
1388 return qVariantToHelper<QUuid>(d, handlerManager);
executed: return qVariantToHelper<QUuid>(d, handlerManager);
Execution Count:1
1
1389} -
1390QModelIndex QVariant::toModelIndex() const -
1391{ -
1392 return qVariantToHelper<QModelIndex>(d, handlerManager);
executed: return qVariantToHelper<QModelIndex>(d, handlerManager);
Execution Count:1
1
1393} -
1394QJsonValue QVariant::toJsonValue() const -
1395{ -
1396 return qVariantToHelper<QJsonValue>(d, handlerManager);
executed: return qVariantToHelper<QJsonValue>(d, handlerManager);
Execution Count:1
1
1397} -
1398QJsonObject QVariant::toJsonObject() const -
1399{ -
1400 return qVariantToHelper<QJsonObject>(d, handlerManager);
executed: return qVariantToHelper<QJsonObject>(d, handlerManager);
Execution Count:1
1
1401} -
1402QJsonArray QVariant::toJsonArray() const -
1403{ -
1404 return qVariantToHelper<QJsonArray>(d, handlerManager);
executed: return qVariantToHelper<QJsonArray>(d, handlerManager);
Execution Count:1
1
1405} -
1406QJsonDocument QVariant::toJsonDocument() const -
1407{ -
1408 return qVariantToHelper<QJsonDocument>(d, handlerManager);
executed: return qVariantToHelper<QJsonDocument>(d, handlerManager);
Execution Count:1
1
1409} -
1410QChar QVariant::toChar() const -
1411{ -
1412 return qVariantToHelper<QChar>(d, handlerManager);
executed: return qVariantToHelper<QChar>(d, handlerManager);
Execution Count:3
3
1413} -
1414 -
1415 -
1416 -
1417 -
1418 -
1419 -
1420 -
1421QBitArray QVariant::toBitArray() const -
1422{ -
1423 return qVariantToHelper<QBitArray>(d, handlerManager);
executed: return qVariantToHelper<QBitArray>(d, handlerManager);
Execution Count:1
1
1424} -
1425 -
1426template <typename T> -
1427inline T qNumVariantToHelper(const QVariant::Private &d, -
1428 const HandlersManager &handlerManager, bool *ok, const T& val) -
1429{ -
1430 uint t = qMetaTypeId<T>(); -
1431 if (ok)
evaluated: ok
TRUEFALSE
yes
Evaluation Count:2175
yes
Evaluation Count:409317
2175-409317
1432 *ok = true;
executed: *ok = true;
Execution Count:2175
2175
1433 if (d.type == t)
evaluated: d.type == t
TRUEFALSE
yes
Evaluation Count:399398
yes
Evaluation Count:12094
12094-399398
1434 return val;
executed: return val;
Execution Count:399398
399398
1435 -
1436 T ret = 0; -
1437 if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok)
evaluated: !handlerManager[d.type]->convert(&d, t, &ret, ok)
TRUEFALSE
yes
Evaluation Count:993
yes
Evaluation Count:11101
evaluated: ok
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:985
8-11101
1438 *ok = false;
executed: *ok = false;
Execution Count:8
8
1439 return ret;
executed: return ret;
Execution Count:12094
12094
1440} -
1441int QVariant::toInt(bool *ok) const -
1442{ -
1443 return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);
executed: return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);
Execution Count:359892
359892
1444} -
1445uint QVariant::toUInt(bool *ok) const -
1446{ -
1447 return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u);
executed: return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u);
Execution Count:266
266
1448} -
1449qlonglong QVariant::toLongLong(bool *ok) const -
1450{ -
1451 return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll);
executed: return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll);
Execution Count:9548
9548
1452} -
1453qulonglong QVariant::toULongLong(bool *ok) const -
1454{ -
1455 return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull);
executed: return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull);
Execution Count:34
34
1456} -
1457bool QVariant::toBool() const -
1458{ -
1459 if (d.type == Bool)
evaluated: d.type == Bool
TRUEFALSE
yes
Evaluation Count:30089
yes
Evaluation Count:12912
12912-30089
1460 return d.data.b;
executed: return d.data.b;
Execution Count:30089
30089
1461 -
1462 bool res = false; -
1463 handlerManager[d.type]->convert(&d, Bool, &res, 0); -
1464 -
1465 return res;
executed: return res;
Execution Count:12912
12912
1466} -
1467double QVariant::toDouble(bool *ok) const -
1468{ -
1469 return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d);
executed: return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d);
Execution Count:32196
32196
1470} -
1471float QVariant::toFloat(bool *ok) const -
1472{ -
1473 return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f);
executed: return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f);
Execution Count:130
130
1474} -
1475qreal QVariant::toReal(bool *ok) const -
1476{ -
1477 return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real);
executed: return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real);
Execution Count:9427
9427
1478} -
1479QVariantList QVariant::toList() const -
1480{ -
1481 return qVariantToHelper<QVariantList>(d, handlerManager);
executed: return qVariantToHelper<QVariantList>(d, handlerManager);
Execution Count:126
126
1482} -
1483 -
1484 -
1485static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = -
1486{ -
1487 0, -
1488 -
1489 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt -
1490 | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray -
1491 | 1 << QVariant::String | 1 << QVariant::Char, -
1492 -
1493 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double -
1494 | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong -
1495 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
1496 -
1497 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double -
1498 | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong -
1499 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
1500 -
1501 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double -
1502 | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong -
1503 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
1504 -
1505 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double -
1506 | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong -
1507 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
1508 -
1509 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong -
1510 | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong -
1511 | 1 << QVariant::ByteArray, -
1512 -
1513 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong -
1514 | 1 << QVariant::ULongLong, -
1515 -
1516 0, -
1517 -
1518 1 << QVariant::StringList, -
1519 -
1520 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int -
1521 | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double -
1522 | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime -
1523 | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char -
1524 | 1 << QVariant::Url | 1 << QVariant::Uuid, -
1525 -
1526 1 << QVariant::List | 1 << QVariant::String, -
1527 -
1528 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool -
1529 | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, -
1530 -
1531 0, -
1532 -
1533 1 << QVariant::String | 1 << QVariant::DateTime, -
1534 -
1535 1 << QVariant::String | 1 << QVariant::DateTime, -
1536 -
1537 1 << QVariant::String | 1 << QVariant::Date, -
1538 -
1539 1 << QVariant::String, -
1540 -
1541 0, -
1542 -
1543 1 << QVariant::RectF, -
1544 -
1545 1 << QVariant::Rect, -
1546 -
1547 1 << QVariant::SizeF, -
1548 -
1549 1 << QVariant::Size, -
1550 -
1551 1 << QVariant::LineF, -
1552 -
1553 1 << QVariant::Line, -
1554 -
1555 1 << QVariant::PointF, -
1556 -
1557 1 << QVariant::Point, -
1558 -
1559 0, -
1560 -
1561 0, -
1562 -
1563 0, -
1564 -
1565 1 << QVariant::String -
1566}; -
1567 -
1568 -
1569 -
1570 -
1571 -
1572static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to) -
1573{ -
1574 if (from && to == &QObject::staticMetaObject)
partially evaluated: from
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
evaluated: to == &QObject::staticMetaObject
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:6
0-18
1575 return true;
executed: return true;
Execution Count:12
12
1576 -
1577 while (from) {
partially evaluated: from
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
1578 if (from == to)
evaluated: from == to
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
1579 return true;
executed: return true;
Execution Count:6
6
1580 from = from->superClass(); -
1581 }
executed: }
Execution Count:3
3
1582 -
1583 return false;
never executed: return false;
0
1584} -
1585 -
1586 -
1587static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) -
1588{ -
1589 -
1590 QMetaType toType(toId); -
1591 if ((QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) {
evaluated: (QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject)
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:48
partially evaluated: (toType.flags() & QMetaType::PointerToQObject)
TRUEFALSE
yes
Evaluation Count:22
no
Evaluation Count:0
0-48
1592 if (!fromObject)
evaluated: !fromObject
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:18
4-18
1593 return true;
executed: return true;
Execution Count:4
4
1594 return canConvertMetaObject(fromObject->metaObject(), toType.metaObject());
executed: return canConvertMetaObject(fromObject->metaObject(), toType.metaObject());
Execution Count:18
18
1595 } -
1596 -
1597 -
1598 -
1599 -
1600 -
1601 return false;
executed: return false;
Execution Count:48
48
1602} -
1603bool QVariant::canConvert(int targetTypeId) const -
1604{ -
1605 -
1606 uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type);
evaluated: (d.type == QMetaType::Float)
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:183175
55-183175
1607 if (currentType == QMetaType::SChar || currentType == QMetaType::Char)
evaluated: currentType == QMetaType::SChar
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:183184
evaluated: currentType == QMetaType::Char
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:183139
45-183184
1608 currentType = QMetaType::UInt;
executed: currentType = QMetaType::UInt;
Execution Count:91
91
1609 if (targetTypeId == QMetaType::SChar || currentType == QMetaType::Char)
evaluated: targetTypeId == QMetaType::SChar
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:183229
partially evaluated: currentType == QMetaType::Char
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:183229
0-183229
1610 targetTypeId = QMetaType::UInt;
executed: targetTypeId = QMetaType::UInt;
Execution Count:1
1
1611 if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double;
executed: targetTypeId = QVariant::Double;
Execution Count:42
evaluated: uint(targetTypeId) == uint(QMetaType::Float)
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:183188
42-183188
1612 -
1613 -
1614 if (currentType == uint(targetTypeId))
evaluated: currentType == uint(targetTypeId)
TRUEFALSE
yes
Evaluation Count:279
yes
Evaluation Count:182951
279-182951
1615 return true;
executed: return true;
Execution Count:279
279
1616 -
1617 if (targetTypeId < 0)
evaluated: targetTypeId < 0
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:182885
66-182885
1618 return false;
executed: return false;
Execution Count:66
66
1619 if (targetTypeId >= QMetaType::User)
evaluated: targetTypeId >= QMetaType::User
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:182855
30-182855
1620 return canConvertMetaObject(currentType, targetTypeId, d.data.o);
executed: return canConvertMetaObject(currentType, targetTypeId, d.data.o);
Execution Count:30
30
1621 -
1622 -
1623 if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
evaluated: currentType > int(QMetaType::QUuid)
TRUEFALSE
yes
Evaluation Count:59360
yes
Evaluation Count:123495
evaluated: targetTypeId > int(QMetaType::QUuid)
TRUEFALSE
yes
Evaluation Count:119612
yes
Evaluation Count:3883
3883-123495
1624 switch (uint(targetTypeId)) { -
1625 case QVariant::Int: -
1626 if (currentType == QVariant::KeySequence)
evaluated: currentType == QVariant::KeySequence
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:22
2-22
1627 return true;
executed: return true;
Execution Count:2
2
1628 -
1629 case QVariant::UInt: -
1630 return currentType == QMetaType::ULong 36
1631 || currentType == QMetaType::Long 36
1632 || currentType == QMetaType::UShort 36
1633 || currentType == QMetaType::UChar 36
1634 || currentType == QMetaType::Char 36
1635 || currentType == QMetaType::SChar 36
1636 || currentType == QMetaType::Short;
executed: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short;
Execution Count:36
36
1637 case QVariant::Image: -
1638 return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap;
executed: return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap;
Execution Count:35
35
1639 case QVariant::Pixmap: -
1640 return currentType == QVariant::Image || currentType == QVariant::Bitmap 36
1641 || currentType == QVariant::Brush;
executed: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush;
Execution Count:36
36
1642 case QVariant::Bitmap: -
1643 return currentType == QVariant::Pixmap || currentType == QVariant::Image;
executed: return currentType == QVariant::Pixmap || currentType == QVariant::Image;
Execution Count:35
35
1644 case QVariant::ByteArray: -
1645 return currentType == QVariant::Color;
executed: return currentType == QVariant::Color;
Execution Count:14
14
1646 case QVariant::String: -
1647 return currentType == QVariant::KeySequence || currentType == QVariant::Font 231
1648 || currentType == QVariant::Color;
executed: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color;
Execution Count:231
231
1649 case QVariant::KeySequence: -
1650 return currentType == QVariant::String || currentType == QVariant::Int;
executed: return currentType == QVariant::String || currentType == QVariant::Int;
Execution Count:37
37
1651 case QVariant::Font: -
1652 return currentType == QVariant::String;
executed: return currentType == QVariant::String;
Execution Count:56
56
1653 case QVariant::Color: -
1654 return currentType == QVariant::String || currentType == QVariant::ByteArray 107
1655 || currentType == QVariant::Brush;
executed: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush;
Execution Count:107
107
1656 case QVariant::Brush: -
1657 return currentType == QVariant::Color || currentType == QVariant::Pixmap;
executed: return currentType == QVariant::Color || currentType == QVariant::Pixmap;
Execution Count:177861
177861
1658 case QMetaType::Long: -
1659 case QMetaType::Char: -
1660 case QMetaType::SChar: -
1661 case QMetaType::UChar: -
1662 case QMetaType::ULong: -
1663 case QMetaType::Short: -
1664 case QMetaType::UShort: -
1665 return qCanConvertMatrix[QVariant::Int] & (1 << currentType) || currentType == QVariant::Int;
executed: return qCanConvertMatrix[QVariant::Int] & (1 << currentType) || currentType == QVariant::Int;
Execution Count:3
3
1666 case QMetaType::QObjectStar: -
1667 return canConvertMetaObject(currentType, targetTypeId, d.data.o);
executed: return canConvertMetaObject(currentType, targetTypeId, d.data.o);
Execution Count:40
40
1668 default: -
1669 return false;
executed: return false;
Execution Count:479
479
1670 } -
1671 }
never executed: }
0
1672 -
1673 if (targetTypeId == String && currentType == StringList)
evaluated: targetTypeId == String
TRUEFALSE
yes
Evaluation Count:528
yes
Evaluation Count:3355
evaluated: currentType == StringList
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:512
16-3355
1674 return v_cast<QStringList>(&d)->count() == 1;
executed: return v_cast<QStringList>(&d)->count() == 1;
Execution Count:16
16
1675 return qCanConvertMatrix[targetTypeId] & (1 << currentType);
executed: return qCanConvertMatrix[targetTypeId] & (1 << currentType);
Execution Count:3867
3867
1676} -
1677bool QVariant::convert(int targetTypeId) -
1678{ -
1679 if (d.type == uint(targetTypeId))
evaluated: d.type == uint(targetTypeId)
TRUEFALSE
yes
Evaluation Count:657
yes
Evaluation Count:1902
657-1902
1680 return true;
executed: return true;
Execution Count:657
657
1681 -
1682 QVariant oldValue = *this; -
1683 -
1684 clear(); -
1685 if (!oldValue.canConvert(targetTypeId))
evaluated: !oldValue.canConvert(targetTypeId)
TRUEFALSE
yes
Evaluation Count:1641
yes
Evaluation Count:261
261-1641
1686 return false;
executed: return false;
Execution Count:1641
1641
1687 -
1688 create(targetTypeId, 0); -
1689 if (oldValue.isNull())
evaluated: oldValue.isNull()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:241
20-241
1690 return false;
executed: return false;
Execution Count:20
20
1691 -
1692 if ((QMetaType::typeFlags(d.type) & QMetaType::PointerToQObject) && (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject)) {
evaluated: (QMetaType::typeFlags(d.type) & QMetaType::PointerToQObject)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:235
partially evaluated: (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-235
1693 create(targetTypeId, &oldValue.d.data.o); -
1694 return true;
executed: return true;
Execution Count:6
6
1695 } -
1696 -
1697 bool isOk = true; -
1698 if (!handlerManager[d.type]->convert(&oldValue.d, targetTypeId, data(), &isOk))
evaluated: !handlerManager[d.type]->convert(&oldValue.d, targetTypeId, data(), &isOk)
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:200
35-200
1699 isOk = false;
executed: isOk = false;
Execution Count:35
35
1700 d.is_null = !isOk; -
1701 return isOk;
executed: return isOk;
Execution Count:235
235
1702} -
1703 -
1704 -
1705 -
1706 -
1707 -
1708 -
1709bool QVariant::convert(const int type, void *ptr) const -
1710{ -
1711 qt_noop(); -
1712 return handlerManager[type]->convert(&d, type, ptr, 0);
executed: return handlerManager[type]->convert(&d, type, ptr, 0);
Execution Count:293017
293017
1713} -
1714static bool qIsNumericType(uint tp) -
1715{ -
1716 return (tp >= QVariant::Bool && tp <= QVariant::Double) 3475
1717 || (tp >= QMetaType::Long && tp <= QMetaType::Float);
executed: return (tp >= QVariant::Bool && tp <= QVariant::Double) || (tp >= QMetaType::Long && tp <= QMetaType::Float);
Execution Count:3475
3475
1718} -
1719 -
1720static bool qIsFloatingPoint(uint tp) -
1721{ -
1722 return tp == QVariant::Double || tp == QMetaType::Float;
executed: return tp == QVariant::Double || tp == QMetaType::Float;
Execution Count:2124
2124
1723} -
1724 -
1725 -
1726 -
1727 -
1728bool QVariant::cmp(const QVariant &v) const -
1729{ -
1730 QVariant v2 = v; -
1731 if (d.type != v2.d.type) {
evaluated: d.type != v2.d.type
TRUEFALSE
yes
Evaluation Count:2309
yes
Evaluation Count:94079
2309-94079
1732 if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) {
evaluated: qIsNumericType(d.type)
TRUEFALSE
yes
Evaluation Count:1166
yes
Evaluation Count:1143
evaluated: qIsNumericType(v.d.type)
TRUEFALSE
yes
Evaluation Count:1065
yes
Evaluation Count:101
101-1166
1733 if (qIsFloatingPoint(d.type) || qIsFloatingPoint(v.d.type))
evaluated: qIsFloatingPoint(d.type)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1059
partially evaluated: qIsFloatingPoint(v.d.type)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1059
0-1059
1734 return qFuzzyCompare(toReal(), v.toReal());
executed: return qFuzzyCompare(toReal(), v.toReal());
Execution Count:6
6
1735 else -
1736 return toLongLong() == v.toLongLong();
executed: return toLongLong() == v.toLongLong();
Execution Count:1059
1059
1737 } -
1738 if (!v2.canConvert(d.type) || !v2.convert(d.type))
evaluated: !v2.canConvert(d.type)
TRUEFALSE
yes
Evaluation Count:1165
yes
Evaluation Count:79
evaluated: !v2.convert(d.type)
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:33
33-1165
1739 return false;
executed: return false;
Execution Count:1211
1211
1740 }
executed: }
Execution Count:33
33
1741 return handlerManager[d.type]->compare(&d, &v2.d);
executed: return handlerManager[d.type]->compare(&d, &v2.d);
Execution Count:94112
94112
1742} -
1743 -
1744 -
1745 -
1746 -
1747 -
1748const void *QVariant::constData() const -
1749{ -
1750 return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr);
executed: return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr);
Execution Count:18689723
18689723
1751} -
1752void* QVariant::data() -
1753{ -
1754 detach(); -
1755 return const_cast<void *>(constData());
executed: return const_cast<void *>(constData());
Execution Count:17664
17664
1756} -
1757bool QVariant::isNull() const -
1758{ -
1759 return handlerManager[d.type]->isNull(&d);
executed: return handlerManager[d.type]->isNull(&d);
Execution Count:431991
431991
1760} -
1761 -
1762 -
1763QDebug operator<<(QDebug dbg, const QVariant &v) -
1764{ -
1765 const uint typeId = v.d.type; -
1766 dbg.nospace() << "QVariant("; -
1767 if (typeId != QMetaType::UnknownType) {
evaluated: typeId != QMetaType::UnknownType
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:2
2-77
1768 dbg.nospace() << QMetaType::typeName(typeId) << ", "; -
1769 handlerManager[typeId]->debugStream(dbg, v); -
1770 } else {
executed: }
Execution Count:77
77
1771 dbg.nospace() << "Invalid"; -
1772 }
executed: }
Execution Count:2
2
1773 dbg.nospace() << ')'; -
1774 return dbg.space();
executed: return dbg.space();
Execution Count:79
79
1775} -
1776 -
1777QDebug operator<<(QDebug dbg, const QVariant::Type p) -
1778{ -
1779 dbg.nospace() << "QVariant::" -
1780 << (int(p) != int(QMetaType::UnknownType) -
1781 ? QMetaType::typeName(p) -
1782 : "Invalid"); -
1783 return dbg.space();
executed: return dbg.space();
Execution Count:52
52
1784} -
1785 -
1786 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial