kernel/qvariant.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qvariant.h" -
43#include "qbitarray.h" -
44#include "qbytearray.h" -
45#include "qdatastream.h" -
46#include "qdebug.h" -
47#include "qmap.h" -
48#include "qdatetime.h" -
49#include "qeasingcurve.h" -
50#include "qlist.h" -
51#include "qregularexpression.h" -
52#include "qstring.h" -
53#include "qstringlist.h" -
54#include "qurl.h" -
55#include "qlocale.h" -
56#include "quuid.h" -
57#ifndef QT_BOOTSTRAPPED -
58#include "qabstractitemmodel.h" -
59#include "qjsonvalue.h" -
60#include "qjsonobject.h" -
61#include "qjsonarray.h" -
62#include "qjsondocument.h" -
63#endif -
64#include "private/qvariant_p.h" -
65#include "qmetatype_p.h" -
66 -
67#ifndef QT_NO_GEOM_VARIANT -
68#include "qsize.h" -
69#include "qpoint.h" -
70#include "qrect.h" -
71#include "qline.h" -
72#endif -
73 -
74#include <float.h> -
75 -
76QT_BEGIN_NAMESPACE -
77 -
78#ifndef DBL_DIG -
79# define DBL_DIG 10 -
80#endif -
81#ifndef FLT_DIG -
82# define FLT_DIG 6 -
83#endif -
84 -
85namespace { -
86class HandlersManager -
87{ -
88 static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount]; -
89public: -
90 const QVariant::Handler *operator[] (const uint typeId) const -
91 { -
92 return Handlers[QModulesPrivate::moduleForType(typeId)];
executed: return Handlers[QModulesPrivate::moduleForType(typeId)];
Execution Count:48828080
48828080
93 } -
94 -
95 void registerHandler(const QModulesPrivate::Names name, const QVariant::Handler *handler) -
96 { -
97 Handlers[name] = handler;
executed (the execution status of this line is deduced): Handlers[name] = handler;
-
98 }
executed: }
Execution Count:186
186
99}; -
100} // namespace -
101 -
102namespace { -
103struct CoreTypesFilter { -
104 template<typename T> -
105 struct Acceptor { -
106 static const bool IsAccepted = QModulesPrivate::QTypeModuleInfo<T>::IsCore && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable; -
107 }; -
108}; -
109} // annonymous -
110 -
111namespace { // annonymous used to hide QVariant handlers -
112 -
113static void construct(QVariant::Private *x, const void *copy) -
114{ -
115 QVariantConstructor<CoreTypesFilter> constructor(x, copy);
executed (the execution status of this line is deduced): QVariantConstructor<CoreTypesFilter> constructor(x, copy);
-
116 QMetaTypeSwitcher::switcher<void>(constructor, x->type, 0);
executed (the execution status of this line is deduced): QMetaTypeSwitcher::switcher<void>(constructor, x->type, 0);
-
117}
executed: }
Execution Count:18350473
18350473
118 -
119static void clear(QVariant::Private *d) -
120{ -
121 QVariantDestructor<CoreTypesFilter> cleaner(d);
executed (the execution status of this line is deduced): QVariantDestructor<CoreTypesFilter> cleaner(d);
-
122 QMetaTypeSwitcher::switcher<void>(cleaner, d->type, 0);
executed (the execution status of this line is deduced): QMetaTypeSwitcher::switcher<void>(cleaner, d->type, 0);
-
123}
executed: }
Execution Count:22283138
22283138
124 -
125static bool isNull(const QVariant::Private *d) -
126{ -
127 QVariantIsNull<CoreTypesFilter> isNull(d);
executed (the execution status of this line is deduced): QVariantIsNull<CoreTypesFilter> isNull(d);
-
128 return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0);
executed: return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0);
Execution Count:399722
399722
129} -
130 -
131/*! -
132 \internal -
133 -
134 Compares \a a to \a b. The caller guarantees that \a a and \a b -
135 are of the same type. -
136 */ -
137static bool compare(const QVariant::Private *a, const QVariant::Private *b) -
138{ -
139 QVariantComparator<CoreTypesFilter> comparator(a, b);
executed (the execution status of this line is deduced): QVariantComparator<CoreTypesFilter> comparator(a, b);
-
140 return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0);
executed: return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0);
Execution Count:93163
93163
141} -
142 -
143/*! -
144 \internal -
145 */ -
146static qlonglong qMetaTypeNumber(const QVariant::Private *d) -
147{ -
148 switch (d->type) { -
149 case QMetaType::Int: -
150 return d->data.i;
executed: return d->data.i;
Execution Count:34207
34207
151 case QMetaType::LongLong: -
152 return d->data.ll;
executed: return d->data.ll;
Execution Count:3137
3137
153 case QMetaType::Char: -
154 return qlonglong(d->data.c);
executed: return qlonglong(d->data.c);
Execution Count:11
11
155 case QMetaType::SChar: -
156 return qlonglong(d->data.sc);
executed: return qlonglong(d->data.sc);
Execution Count:18
18
157 case QMetaType::Short: -
158 return qlonglong(d->data.s);
executed: return qlonglong(d->data.s);
Execution Count:33
33
159 case QMetaType::Long: -
160 return qlonglong(d->data.l);
executed: return qlonglong(d->data.l);
Execution Count:5
5
161 case QMetaType::Float: -
162 return qRound64(d->data.f);
executed: return qRound64(d->data.f);
Execution Count:15
15
163 case QVariant::Double: -
164 return qRound64(d->data.d);
executed: return qRound64(d->data.d);
Execution Count:82
82
165 } -
166 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
167 return 0;
never executed: return 0;
0
168} -
169 -
170static qulonglong qMetaTypeUNumber(const QVariant::Private *d) -
171{ -
172 switch (d->type) { -
173 case QVariant::UInt: -
174 return d->data.u;
executed: return d->data.u;
Execution Count:143
143
175 case QVariant::ULongLong: -
176 return d->data.ull;
executed: return d->data.ull;
Execution Count:53
53
177 case QMetaType::UChar: -
178 return d->data.uc;
executed: return d->data.uc;
Execution Count:18
18
179 case QMetaType::UShort: -
180 return d->data.us;
executed: return d->data.us;
Execution Count:28
28
181 case QMetaType::ULong: -
182 return d->data.ul;
executed: return d->data.ul;
Execution Count:2
2
183 } -
184 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
185 return 0;
never executed: return 0;
0
186} -
187 -
188static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) -
189{ -
190 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
191 -
192 switch (uint(d->type)) { -
193 case QVariant::String: -
194 return v_cast<QString>(d)->toLongLong(ok);
executed: return v_cast<QString>(d)->toLongLong(ok);
Execution Count:614
614
195 case QVariant::Char: -
196 return v_cast<QChar>(d)->unicode();
executed: return v_cast<QChar>(d)->unicode();
Execution Count:2
2
197 case QVariant::ByteArray: -
198 return v_cast<QByteArray>(d)->toLongLong(ok);
executed: return v_cast<QByteArray>(d)->toLongLong(ok);
Execution Count:5
5
199 case QVariant::Bool: -
200 return qlonglong(d->data.b);
executed: return qlonglong(d->data.b);
Execution Count:10
10
201 case QVariant::Double: -
202 case QVariant::Int: -
203 case QMetaType::Char: -
204 case QMetaType::SChar: -
205 case QMetaType::Short: -
206 case QMetaType::Long: -
207 case QMetaType::Float: -
208 case QMetaType::LongLong: -
209 return qMetaTypeNumber(d);
executed: return qMetaTypeNumber(d);
Execution Count:10266
10266
210 case QVariant::ULongLong: -
211 case QVariant::UInt: -
212 case QMetaType::UChar: -
213 case QMetaType::UShort: -
214 case QMetaType::ULong: -
215 return qlonglong(qMetaTypeUNumber(d));
executed: return qlonglong(qMetaTypeUNumber(d));
Execution Count:18
18
216 } -
217 -
218 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
219 return Q_INT64_C(0);
executed: return static_cast<long long>(0LL);
Execution Count:858
858
220} -
221 -
222static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) -
223{ -
224 *ok = true;
executed (the execution status of this line is deduced): *ok = true;
-
225 -
226 switch (uint(d->type)) { -
227 case QVariant::String: -
228 return v_cast<QString>(d)->toULongLong(ok);
executed: return v_cast<QString>(d)->toULongLong(ok);
Execution Count:29
29
229 case QVariant::Char: -
230 return v_cast<QChar>(d)->unicode();
executed: return v_cast<QChar>(d)->unicode();
Execution Count:2
2
231 case QVariant::ByteArray: -
232 return v_cast<QByteArray>(d)->toULongLong(ok);
executed: return v_cast<QByteArray>(d)->toULongLong(ok);
Execution Count:4
4
233 case QVariant::Bool: -
234 return qulonglong(d->data.b);
never executed: return qulonglong(d->data.b);
0
235 case QVariant::Double: -
236 case QVariant::Int: -
237 case QMetaType::Char: -
238 case QMetaType::SChar: -
239 case QMetaType::Short: -
240 case QMetaType::Long: -
241 case QMetaType::Float: -
242 case QMetaType::LongLong: -
243 return qulonglong(qMetaTypeNumber(d));
executed: return qulonglong(qMetaTypeNumber(d));
Execution Count:61
61
244 case QVariant::ULongLong: -
245 case QVariant::UInt: -
246 case QMetaType::UChar: -
247 case QMetaType::UShort: -
248 case QMetaType::ULong: -
249 return qMetaTypeUNumber(d);
executed: return qMetaTypeUNumber(d);
Execution Count:17
17
250 } -
251 -
252 *ok = false;
executed (the execution status of this line is deduced): *ok = false;
-
253 return Q_UINT64_C(0);
executed: return static_cast<unsigned long long>(0ULL);
Execution Count:48
48
254} -
255 -
256template<typename TInput, typename LiteralWrapper> -
257inline bool qt_convertToBool(const QVariant::Private *const d) -
258{ -
259 TInput str = v_cast<TInput>(d)->toLower();
executed (the execution status of this line is deduced): TInput str = v_cast<TInput>(d)->toLower();
-
260 return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty());
executed: return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty());
Execution Count:29
29
261} -
262 -
263/*! -
264 \internal -
265 -
266 Converts \a d to type \a t, which is placed in \a result. -
267 */ -
268static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) -
269{ -
270 Q_ASSERT(d->type != uint(t));
executed (the execution status of this line is deduced): qt_noop();
-
271 Q_ASSERT(result);
executed (the execution status of this line is deduced): qt_noop();
-
272 -
273 bool dummy;
executed (the execution status of this line is deduced): bool dummy;
-
274 if (!ok)
evaluated: !ok
TRUEFALSE
yes
Evaluation Count:291506
yes
Evaluation Count:248
248-291506
275 ok = &dummy;
executed: ok = &dummy;
Execution Count:291506
291506
276 -
277 switch (uint(t)) { -
278#ifndef QT_BOOTSTRAPPED -
279 case QVariant::Url: -
280 switch (d->type) { -
281 case QVariant::String: -
282 *static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d));
executed (the execution status of this line is deduced): *static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d));
-
283 break;
executed: break;
Execution Count:1
1
284 default: -
285 return false;
never executed: return false;
0
286 } -
287 break;
executed: break;
Execution Count:1
1
288#endif -
289 case QVariant::String: { -
290 QString *str = static_cast<QString *>(result);
executed (the execution status of this line is deduced): QString *str = static_cast<QString *>(result);
-
291 switch (d->type) { -
292 case QVariant::Char: -
293 *str = QString(*v_cast<QChar>(d));
executed (the execution status of this line is deduced): *str = QString(*v_cast<QChar>(d));
-
294 break;
executed: break;
Execution Count:227
227
295 case QMetaType::Char: -
296 case QMetaType::SChar: -
297 case QMetaType::UChar: -
298 *str = QChar::fromLatin1(d->data.c);
executed (the execution status of this line is deduced): *str = QChar::fromLatin1(d->data.c);
-
299 break;
executed: break;
Execution Count:39
39
300 case QMetaType::Short: -
301 case QMetaType::Long: -
302 case QVariant::Int: -
303 case QVariant::LongLong: -
304 *str = QString::number(qMetaTypeNumber(d));
executed (the execution status of this line is deduced): *str = QString::number(qMetaTypeNumber(d));
-
305 break;
executed: break;
Execution Count:26408
26408
306 case QVariant::UInt: -
307 case QVariant::ULongLong: -
308 case QMetaType::UShort: -
309 case QMetaType::ULong: -
310 *str = QString::number(qMetaTypeUNumber(d));
executed (the execution status of this line is deduced): *str = QString::number(qMetaTypeUNumber(d));
-
311 break;
executed: break;
Execution Count:96
96
312 case QMetaType::Float: -
313 *str = QString::number(d->data.f, 'g', FLT_DIG);
executed (the execution status of this line is deduced): *str = QString::number(d->data.f, 'g', 6);
-
314 break;
executed: break;
Execution Count:12
12
315 case QVariant::Double: -
316 *str = QString::number(d->data.d, 'g', DBL_DIG);
executed (the execution status of this line is deduced): *str = QString::number(d->data.d, 'g', 15);
-
317 break;
executed: break;
Execution Count:58
58
318#if !defined(QT_NO_DATESTRING) -
319 case QVariant::Date: -
320 *str = v_cast<QDate>(d)->toString(Qt::ISODate);
executed (the execution status of this line is deduced): *str = v_cast<QDate>(d)->toString(Qt::ISODate);
-
321 break;
executed: break;
Execution Count:5
5
322 case QVariant::Time: -
323 *str = v_cast<QTime>(d)->toString(Qt::ISODate);
executed (the execution status of this line is deduced): *str = v_cast<QTime>(d)->toString(Qt::ISODate);
-
324 break;
executed: break;
Execution Count:3
3
325 case QVariant::DateTime: -
326 *str = v_cast<QDateTime>(d)->toString(Qt::ISODate);
executed (the execution status of this line is deduced): *str = v_cast<QDateTime>(d)->toString(Qt::ISODate);
-
327 break;
executed: break;
Execution Count:12
12
328#endif -
329 case QVariant::Bool: -
330 *str = QLatin1String(d->data.b ? "true" : "false");
executed (the execution status of this line is deduced): *str = QLatin1String(d->data.b ? "true" : "false");
-
331 break;
executed: break;
Execution Count:37
37
332 case QVariant::ByteArray: -
333 *str = QString::fromUtf8(v_cast<QByteArray>(d)->constData());
executed (the execution status of this line is deduced): *str = QString::fromUtf8(v_cast<QByteArray>(d)->constData());
-
334 break;
executed: break;
Execution Count:3
3
335 case QVariant::StringList: -
336 if (v_cast<QStringList>(d)->count() == 1)
evaluated: v_cast<QStringList>(d)->count() == 1
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
337 *str = v_cast<QStringList>(d)->at(0);
executed: *str = v_cast<QStringList>(d)->at(0);
Execution Count:3
3
338 break;
executed: break;
Execution Count:6
6
339#ifndef QT_BOOTSTRAPPED -
340 case QVariant::Url: -
341 *str = v_cast<QUrl>(d)->toString();
executed (the execution status of this line is deduced): *str = v_cast<QUrl>(d)->toString();
-
342 break;
executed: break;
Execution Count:5
5
343#endif -
344 case QVariant::Uuid: -
345 *str = v_cast<QUuid>(d)->toString();
executed (the execution status of this line is deduced): *str = v_cast<QUuid>(d)->toString();
-
346 break;
executed: break;
Execution Count:2
2
347 default: -
348 return false;
executed: return false;
Execution Count:14786
14786
349 } -
350 break;
executed: break;
Execution Count:26913
26913
351 } -
352 case QVariant::Char: { -
353 QChar *c = static_cast<QChar *>(result);
executed (the execution status of this line is deduced): QChar *c = static_cast<QChar *>(result);
-
354 switch (d->type) { -
355 case QVariant::Int: -
356 case QVariant::LongLong: -
357 case QMetaType::Char: -
358 case QMetaType::SChar: -
359 case QMetaType::Short: -
360 case QMetaType::Long: -
361 case QMetaType::Float: -
362 *c = QChar(ushort(qMetaTypeNumber(d)));
executed (the execution status of this line is deduced): *c = QChar(ushort(qMetaTypeNumber(d)));
-
363 break;
executed: break;
Execution Count:1
1
364 case QVariant::UInt: -
365 case QVariant::ULongLong: -
366 case QMetaType::UChar: -
367 case QMetaType::UShort: -
368 case QMetaType::ULong: -
369 *c = QChar(ushort(qMetaTypeUNumber(d)));
executed (the execution status of this line is deduced): *c = QChar(ushort(qMetaTypeUNumber(d)));
-
370 break;
executed: break;
Execution Count:1
1
371 default: -
372 return false;
never executed: return false;
0
373 } -
374 break;
executed: break;
Execution Count:2
2
375 } -
376#ifndef QT_NO_GEOM_VARIANT -
377 case QVariant::Size: { -
378 QSize *s = static_cast<QSize *>(result);
executed (the execution status of this line is deduced): QSize *s = static_cast<QSize *>(result);
-
379 switch (d->type) { -
380 case QVariant::SizeF: -
381 *s = v_cast<QSizeF>(d)->toSize();
executed (the execution status of this line is deduced): *s = v_cast<QSizeF>(d)->toSize();
-
382 break;
executed: break;
Execution Count:4
4
383 default: -
384 return false;
executed: return false;
Execution Count:3
3
385 } -
386 break;
executed: break;
Execution Count:4
4
387 } -
388 -
389 case QVariant::SizeF: { -
390 QSizeF *s = static_cast<QSizeF *>(result);
executed (the execution status of this line is deduced): QSizeF *s = static_cast<QSizeF *>(result);
-
391 switch (d->type) { -
392 case QVariant::Size: -
393 *s = QSizeF(*(v_cast<QSize>(d)));
executed (the execution status of this line is deduced): *s = QSizeF(*(v_cast<QSize>(d)));
-
394 break;
executed: break;
Execution Count:4
4
395 default: -
396 return false;
never executed: return false;
0
397 } -
398 break;
executed: break;
Execution Count:4
4
399 } -
400 -
401 case QVariant::Line: { -
402 QLine *s = static_cast<QLine *>(result);
executed (the execution status of this line is deduced): QLine *s = static_cast<QLine *>(result);
-
403 switch (d->type) { -
404 case QVariant::LineF: -
405 *s = v_cast<QLineF>(d)->toLine();
executed (the execution status of this line is deduced): *s = v_cast<QLineF>(d)->toLine();
-
406 break;
executed: break;
Execution Count:4
4
407 default: -
408 return false;
never executed: return false;
0
409 } -
410 break;
executed: break;
Execution Count:4
4
411 } -
412 -
413 case QVariant::LineF: { -
414 QLineF *s = static_cast<QLineF *>(result);
executed (the execution status of this line is deduced): QLineF *s = static_cast<QLineF *>(result);
-
415 switch (d->type) { -
416 case QVariant::Line: -
417 *s = QLineF(*(v_cast<QLine>(d)));
executed (the execution status of this line is deduced): *s = QLineF(*(v_cast<QLine>(d)));
-
418 break;
executed: break;
Execution Count:4
4
419 default: -
420 return false;
never executed: return false;
0
421 } -
422 break;
executed: break;
Execution Count:4
4
423 } -
424#endif -
425 case QVariant::StringList: -
426 if (d->type == QVariant::List) {
partially evaluated: d->type == QVariant::List
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
427 QStringList *slst = static_cast<QStringList *>(result);
never executed (the execution status of this line is deduced): QStringList *slst = static_cast<QStringList *>(result);
-
428 const QVariantList *list = v_cast<QVariantList >(d);
never executed (the execution status of this line is deduced): const QVariantList *list = v_cast<QVariantList >(d);
-
429 for (int i = 0; i < list->size(); ++i)
never evaluated: i < list->size()
0
430 slst->append(list->at(i).toString());
never executed: slst->append(list->at(i).toString());
0
431 } else if (d->type == QVariant::String) {
never executed: }
evaluated: d->type == QVariant::String
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
0-2
432 QStringList *slst = static_cast<QStringList *>(result);
executed (the execution status of this line is deduced): QStringList *slst = static_cast<QStringList *>(result);
-
433 *slst = QStringList(*v_cast<QString>(d));
executed (the execution status of this line is deduced): *slst = QStringList(*v_cast<QString>(d));
-
434 } else {
executed: }
Execution Count:2
2
435 return false;
executed: return false;
Execution Count:2
2
436 } -
437 break;
executed: break;
Execution Count:2
2
438 case QVariant::Date: { -
439 QDate *dt = static_cast<QDate *>(result);
executed (the execution status of this line is deduced): QDate *dt = static_cast<QDate *>(result);
-
440 if (d->type == QVariant::DateTime)
evaluated: d->type == QVariant::DateTime
TRUEFALSE
yes
Evaluation Count:9883
yes
Evaluation Count:2
2-9883
441 *dt = v_cast<QDateTime>(d)->date();
executed: *dt = v_cast<QDateTime>(d)->date();
Execution Count:9883
9883
442#ifndef QT_NO_DATESTRING -
443 else if (d->type == QVariant::String)
partially evaluated: d->type == QVariant::String
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
444 *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
executed: *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
Execution Count:2
2
445#endif -
446 else -
447 return false;
never executed: return false;
0
448 -
449 return dt->isValid();
executed: return dt->isValid();
Execution Count:9885
9885
450 } -
451 case QVariant::Time: { -
452 QTime *t = static_cast<QTime *>(result);
executed (the execution status of this line is deduced): QTime *t = static_cast<QTime *>(result);
-
453 switch (d->type) { -
454 case QVariant::DateTime: -
455 *t = v_cast<QDateTime>(d)->time();
executed (the execution status of this line is deduced): *t = v_cast<QDateTime>(d)->time();
-
456 break;
executed: break;
Execution Count:9271
9271
457#ifndef QT_NO_DATESTRING -
458 case QVariant::String: -
459 *t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate);
executed (the execution status of this line is deduced): *t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate);
-
460 break;
executed: break;
Execution Count:2
2
461#endif -
462 default: -
463 return false;
never executed: return false;
0
464 } -
465 return t->isValid();
executed: return t->isValid();
Execution Count:9273
9273
466 } -
467 case QVariant::DateTime: { -
468 QDateTime *dt = static_cast<QDateTime *>(result);
executed (the execution status of this line is deduced): QDateTime *dt = static_cast<QDateTime *>(result);
-
469 switch (d->type) { -
470#ifndef QT_NO_DATESTRING -
471 case QVariant::String: -
472 *dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate);
executed (the execution status of this line is deduced): *dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate);
-
473 break;
executed: break;
Execution Count:9
9
474#endif -
475 case QVariant::Date: -
476 *dt = QDateTime(*v_cast<QDate>(d));
executed (the execution status of this line is deduced): *dt = QDateTime(*v_cast<QDate>(d));
-
477 break;
executed: break;
Execution Count:2
2
478 default: -
479 return false;
executed: return false;
Execution Count:497
497
480 } -
481 return dt->isValid();
executed: return dt->isValid();
Execution Count:11
11
482 } -
483 case QVariant::ByteArray: { -
484 QByteArray *ba = static_cast<QByteArray *>(result);
executed (the execution status of this line is deduced): QByteArray *ba = static_cast<QByteArray *>(result);
-
485 switch (d->type) { -
486 case QVariant::String: -
487 *ba = v_cast<QString>(d)->toUtf8();
executed (the execution status of this line is deduced): *ba = v_cast<QString>(d)->toUtf8();
-
488 break;
executed: break;
Execution Count:99
99
489 case QVariant::Double: -
490 *ba = QByteArray::number(d->data.d, 'g', DBL_DIG);
executed (the execution status of this line is deduced): *ba = QByteArray::number(d->data.d, 'g', 15);
-
491 break;
executed: break;
Execution Count:2
2
492 case QMetaType::Float: -
493 *ba = QByteArray::number(d->data.f, 'g', FLT_DIG);
executed (the execution status of this line is deduced): *ba = QByteArray::number(d->data.f, 'g', 6);
-
494 break;
executed: break;
Execution Count:2
2
495 case QMetaType::Char: -
496 case QMetaType::SChar: -
497 case QMetaType::UChar: -
498 *ba = QByteArray(1, d->data.c);
never executed (the execution status of this line is deduced): *ba = QByteArray(1, d->data.c);
-
499 break;
never executed: break;
0
500 case QVariant::Int: -
501 case QVariant::LongLong: -
502 case QMetaType::Short: -
503 case QMetaType::Long: -
504 *ba = QByteArray::number(qMetaTypeNumber(d));
executed (the execution status of this line is deduced): *ba = QByteArray::number(qMetaTypeNumber(d));
-
505 break;
executed: break;
Execution Count:218
218
506 case QVariant::UInt: -
507 case QVariant::ULongLong: -
508 case QMetaType::UShort: -
509 case QMetaType::ULong: -
510 *ba = QByteArray::number(qMetaTypeUNumber(d));
executed (the execution status of this line is deduced): *ba = QByteArray::number(qMetaTypeUNumber(d));
-
511 break;
executed: break;
Execution Count:4
4
512 case QVariant::Bool: -
513 *ba = QByteArray(d->data.b ? "true" : "false");
executed (the execution status of this line is deduced): *ba = QByteArray(d->data.b ? "true" : "false");
-
514 break;
executed: break;
Execution Count:3
3
515 default: -
516 return false;
executed: return false;
Execution Count:85
85
517 } -
518 } -
519 break;
executed: break;
Execution Count:328
328
520 case QMetaType::Short: -
521 *static_cast<short *>(result) = short(qConvertToNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<short *>(result) = short(qConvertToNumber(d, ok));
-
522 return *ok;
executed: return *ok;
Execution Count:5
5
523 case QMetaType::Long: -
524 *static_cast<long *>(result) = long(qConvertToNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<long *>(result) = long(qConvertToNumber(d, ok));
-
525 return *ok;
executed: return *ok;
Execution Count:1
1
526 case QMetaType::UShort: -
527 *static_cast<ushort *>(result) = ushort(qConvertToUnsignedNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<ushort *>(result) = ushort(qConvertToUnsignedNumber(d, ok));
-
528 return *ok;
executed: return *ok;
Execution Count:2
2
529 case QMetaType::ULong: -
530 *static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok));
-
531 return *ok;
executed: return *ok;
Execution Count:1
1
532 case QVariant::Int: -
533 *static_cast<int *>(result) = int(qConvertToNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<int *>(result) = int(qConvertToNumber(d, ok));
-
534 return *ok;
executed: return *ok;
Execution Count:4190
4190
535 case QVariant::UInt: -
536 *static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok));
-
537 return *ok;
executed: return *ok;
Execution Count:79
79
538 case QVariant::LongLong: -
539 *static_cast<qlonglong *>(result) = qConvertToNumber(d, ok);
executed (the execution status of this line is deduced): *static_cast<qlonglong *>(result) = qConvertToNumber(d, ok);
-
540 return *ok;
executed: return *ok;
Execution Count:7575
7575
541 case QVariant::ULongLong: { -
542 *static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok);
executed (the execution status of this line is deduced): *static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok);
-
543 return *ok;
executed: return *ok;
Execution Count:78
78
544 } -
545 case QMetaType::SChar: { -
546 signed char s = qConvertToNumber(d, ok);
executed (the execution status of this line is deduced): signed char s = qConvertToNumber(d, ok);
-
547 *static_cast<signed char*>(result) = s;
executed (the execution status of this line is deduced): *static_cast<signed char*>(result) = s;
-
548 return *ok;
executed: return *ok;
Execution Count:1
1
549 } -
550 case QMetaType::UChar: { -
551 *static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok);
executed (the execution status of this line is deduced): *static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok);
-
552 return *ok;
executed: return *ok;
Execution Count:1
1
553 } -
554 case QVariant::Bool: { -
555 bool *b = static_cast<bool *>(result);
executed (the execution status of this line is deduced): bool *b = static_cast<bool *>(result);
-
556 switch(d->type) { -
557 case QVariant::ByteArray: -
558 *b = qt_convertToBool<QByteArray, QByteArray>(d);
executed (the execution status of this line is deduced): *b = qt_convertToBool<QByteArray, QByteArray>(d);
-
559 break;
executed: break;
Execution Count:10
10
560 case QVariant::String: -
561 *b = qt_convertToBool<QString, QLatin1String>(d);
executed (the execution status of this line is deduced): *b = qt_convertToBool<QString, QLatin1String>(d);
-
562 break;
executed: break;
Execution Count:19
19
563 case QVariant::Char: -
564 *b = !v_cast<QChar>(d)->isNull();
executed (the execution status of this line is deduced): *b = !v_cast<QChar>(d)->isNull();
-
565 break;
executed: break;
Execution Count:2
2
566 case QVariant::Double: -
567 case QVariant::Int: -
568 case QVariant::LongLong: -
569 case QMetaType::Char: -
570 case QMetaType::SChar: -
571 case QMetaType::Short: -
572 case QMetaType::Long: -
573 case QMetaType::Float: -
574 *b = qMetaTypeNumber(d) != Q_INT64_C(0);
executed (the execution status of this line is deduced): *b = qMetaTypeNumber(d) != static_cast<long long>(0LL);
-
575 break;
executed: break;
Execution Count:458
458
576 case QVariant::UInt: -
577 case QVariant::ULongLong: -
578 case QMetaType::UChar: -
579 case QMetaType::UShort: -
580 case QMetaType::ULong: -
581 *b = qMetaTypeUNumber(d) != Q_UINT64_C(0);
executed (the execution status of this line is deduced): *b = qMetaTypeUNumber(d) != static_cast<unsigned long long>(0ULL);
-
582 break;
executed: break;
Execution Count:74
74
583 default: -
584 *b = false;
executed (the execution status of this line is deduced): *b = false;
-
585 return false;
executed: return false;
Execution Count:12242
12242
586 } -
587 break;
executed: break;
Execution Count:563
563
588 } -
589 case QVariant::Double: { -
590 double *f = static_cast<double *>(result);
executed (the execution status of this line is deduced): double *f = static_cast<double *>(result);
-
591 switch (d->type) { -
592 case QVariant::String: -
593 *f = v_cast<QString>(d)->toDouble(ok);
executed (the execution status of this line is deduced): *f = v_cast<QString>(d)->toDouble(ok);
-
594 break;
executed: break;
Execution Count:95
95
595 case QVariant::ByteArray: -
596 *f = v_cast<QByteArray>(d)->toDouble(ok);
executed (the execution status of this line is deduced): *f = v_cast<QByteArray>(d)->toDouble(ok);
-
597 break;
executed: break;
Execution Count:2
2
598 case QVariant::Bool: -
599 *f = double(d->data.b);
executed (the execution status of this line is deduced): *f = double(d->data.b);
-
600 break;
executed: break;
Execution Count:8
8
601 case QMetaType::Float: -
602 *f = double(d->data.f);
executed (the execution status of this line is deduced): *f = double(d->data.f);
-
603 break;
executed: break;
Execution Count:10
10
604 case QVariant::LongLong: -
605 case QVariant::Int: -
606 case QMetaType::Char: -
607 case QMetaType::SChar: -
608 case QMetaType::Short: -
609 case QMetaType::Long: -
610 *f = double(qMetaTypeNumber(d));
executed (the execution status of this line is deduced): *f = double(qMetaTypeNumber(d));
-
611 break;
executed: break;
Execution Count:91
91
612 case QVariant::UInt: -
613 case QVariant::ULongLong: -
614 case QMetaType::UChar: -
615 case QMetaType::UShort: -
616 case QMetaType::ULong: -
617 *f = double(qMetaTypeUNumber(d));
executed (the execution status of this line is deduced): *f = double(qMetaTypeUNumber(d));
-
618 break;
executed: break;
Execution Count:32
32
619 default: -
620 *f = 0.0;
executed (the execution status of this line is deduced): *f = 0.0;
-
621 return false;
executed: return false;
Execution Count:16
16
622 } -
623 break;
executed: break;
Execution Count:238
238
624 } -
625 case QMetaType::Float: { -
626 float *f = static_cast<float *>(result);
executed (the execution status of this line is deduced): float *f = static_cast<float *>(result);
-
627 switch (d->type) { -
628 case QVariant::String: -
629 *f = v_cast<QString>(d)->toFloat(ok);
executed (the execution status of this line is deduced): *f = v_cast<QString>(d)->toFloat(ok);
-
630 break;
executed: break;
Execution Count:6
6
631 case QVariant::ByteArray: -
632 *f = v_cast<QByteArray>(d)->toFloat(ok);
executed (the execution status of this line is deduced): *f = v_cast<QByteArray>(d)->toFloat(ok);
-
633 break;
executed: break;
Execution Count:1
1
634 case QVariant::Bool: -
635 *f = float(d->data.b);
never executed (the execution status of this line is deduced): *f = float(d->data.b);
-
636 break;
never executed: break;
0
637 case QVariant::Double: -
638 *f = float(d->data.d);
executed (the execution status of this line is deduced): *f = float(d->data.d);
-
639 break;
executed: break;
Execution Count:3
3
640 case QVariant::LongLong: -
641 case QVariant::Int: -
642 case QMetaType::Char: -
643 case QMetaType::SChar: -
644 case QMetaType::Short: -
645 case QMetaType::Long: -
646 *f = float(qMetaTypeNumber(d));
executed (the execution status of this line is deduced): *f = float(qMetaTypeNumber(d));
-
647 break;
executed: break;
Execution Count:5
5
648 case QVariant::UInt: -
649 case QVariant::ULongLong: -
650 case QMetaType::UChar: -
651 case QMetaType::UShort: -
652 case QMetaType::ULong: -
653 *f = float(qMetaTypeUNumber(d));
executed (the execution status of this line is deduced): *f = float(qMetaTypeUNumber(d));
-
654 break;
executed: break;
Execution Count:2
2
655 default: -
656 *f = 0.0f;
never executed (the execution status of this line is deduced): *f = 0.0f;
-
657 return false;
never executed: return false;
0
658 } -
659 break;
executed: break;
Execution Count:17
17
660 } -
661 case QVariant::List: -
662 if (d->type == QVariant::StringList) {
evaluated: d->type == QVariant::StringList
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-13
663 QVariantList *lst = static_cast<QVariantList *>(result);
executed (the execution status of this line is deduced): QVariantList *lst = static_cast<QVariantList *>(result);
-
664 const QStringList *slist = v_cast<QStringList>(d);
executed (the execution status of this line is deduced): const QStringList *slist = v_cast<QStringList>(d);
-
665 for (int i = 0; i < slist->size(); ++i)
evaluated: i < slist->size()
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:13
13-27
666 lst->append(QVariant(slist->at(i)));
executed: lst->append(QVariant(slist->at(i)));
Execution Count:27
27
667 } 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
668 *static_cast<QVariantList *>(result) =
never executed (the execution status of this line is deduced): *static_cast<QVariantList *>(result) =
-
669 *static_cast<QList<QVariant> *>(d->data.shared->ptr);
never executed (the execution status of this line is deduced): *static_cast<QList<QVariant> *>(d->data.shared->ptr);
-
670 } else {
never executed: }
0
671 return false;
executed: return false;
Execution Count:2
2
672 } -
673 break;
executed: break;
Execution Count:13
13
674 case QVariant::Map: -
675 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
676 *static_cast<QVariantMap *>(result) =
never executed (the execution status of this line is deduced): *static_cast<QVariantMap *>(result) =
-
677 *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr);
never executed (the execution status of this line is deduced): *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr);
-
678 } else {
never executed: }
0
679 return false;
executed: return false;
Execution Count:2
2
680 } -
681 break;
never executed: break;
0
682 case QVariant::Hash: -
683 if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) {
never evaluated: qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0
0
684 *static_cast<QVariantHash *>(result) =
never executed (the execution status of this line is deduced): *static_cast<QVariantHash *>(result) =
-
685 *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr);
never executed (the execution status of this line is deduced): *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr);
-
686 } else {
never executed: }
0
687 return false;
never executed: return false;
0
688 } -
689 break;
never executed: break;
0
690#ifndef QT_NO_GEOM_VARIANT -
691 case QVariant::Rect: -
692 if (d->type == QVariant::RectF)
partially evaluated: d->type == QVariant::RectF
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
693 *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();
executed: *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();
Execution Count:6
6
694 else -
695 return false;
never executed: return false;
0
696 break;
executed: break;
Execution Count:6
6
697 case QVariant::RectF: -
698 if (d->type == QVariant::Rect)
partially evaluated: d->type == QVariant::Rect
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
699 *static_cast<QRectF *>(result) = *v_cast<QRect>(d);
executed: *static_cast<QRectF *>(result) = *v_cast<QRect>(d);
Execution Count:1
1
700 else -
701 return false;
never executed: return false;
0
702 break;
executed: break;
Execution Count:1
1
703 case QVariant::PointF: -
704 if (d->type == QVariant::Point)
never evaluated: d->type == QVariant::Point
0
705 *static_cast<QPointF *>(result) = *v_cast<QPoint>(d);
never executed: *static_cast<QPointF *>(result) = *v_cast<QPoint>(d);
0
706 else -
707 return false;
never executed: return false;
0
708 break;
never executed: break;
0
709 case QVariant::Point: -
710 if (d->type == QVariant::PointF)
partially evaluated: d->type == QVariant::PointF
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
711 *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();
executed: *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();
Execution Count:5
5
712 else -
713 return false;
never executed: return false;
0
714 break;
executed: break;
Execution Count:5
5
715 case QMetaType::Char: -
716 { -
717 *static_cast<qint8 *>(result) = qint8(qConvertToNumber(d, ok));
executed (the execution status of this line is deduced): *static_cast<qint8 *>(result) = qint8(qConvertToNumber(d, ok));
-
718 return *ok;
executed: return *ok;
Execution Count:1
1
719 } -
720#endif -
721 case QVariant::Uuid: -
722 switch (d->type) { -
723 case QVariant::String: -
724 *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d));
executed (the execution status of this line is deduced): *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d));
-
725 break;
executed: break;
Execution Count:1
1
726 default: -
727 return false;
never executed: return false;
0
728 } -
729 break;
executed: break;
Execution Count:1
1
730 default: -
731 return false;
executed: return false;
Execution Count:204910
204910
732 } -
733 return true;
executed: return true;
Execution Count:28106
28106
734} -
735 -
736#if !defined(QT_NO_DEBUG_STREAM) -
737static void streamDebug(QDebug dbg, const QVariant &v) -
738{ -
739 QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
executed (the execution status of this line is deduced): QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr());
-
740 QVariantDebugStream<CoreTypesFilter> stream(dbg, d);
executed (the execution status of this line is deduced): QVariantDebugStream<CoreTypesFilter> stream(dbg, d);
-
741 QMetaTypeSwitcher::switcher<void>(stream, d->type, 0);
executed (the execution status of this line is deduced): QMetaTypeSwitcher::switcher<void>(stream, d->type, 0);
-
742}
executed: }
Execution Count:50
50
743#endif -
744 -
745const QVariant::Handler qt_kernel_variant_handler = { -
746 construct, -
747 clear, -
748 isNull, -
749#ifndef QT_NO_DATASTREAM -
750 0, -
751 0, -
752#endif -
753 compare, -
754 convert, -
755 0, -
756#if !defined(QT_NO_DEBUG_STREAM) -
757 streamDebug -
758#else -
759 0 -
760#endif -
761}; -
762 -
763static void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false, "QVariant", "Trying to construct an unknown type"); }
never executed: }
0
764static void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); }
never executed: }
0
765static bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; }
never executed: return d->is_null;
0
766static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; }
never executed: return false;
0
767static bool dummyConvert(const QVariant::Private *, int, void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; }
never executed: return false;
0
768#if !defined(QT_NO_DEBUG_STREAM) -
769static void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); }
never executed: }
0
770#endif -
771const QVariant::Handler qt_dummy_variant_handler = { -
772 dummyConstruct, -
773 dummyClear, -
774 dummyIsNull, -
775#ifndef QT_NO_DATASTREAM -
776 0, -
777 0, -
778#endif -
779 dummyCompare, -
780 dummyConvert, -
781 0, -
782#if !defined(QT_NO_DEBUG_STREAM) -
783 dummyStreamDebug -
784#else -
785 0 -
786#endif -
787}; -
788 -
789static void customConstruct(QVariant::Private *d, const void *copy) -
790{ -
791 const QMetaType type(d->type);
executed (the execution status of this line is deduced): const QMetaType type(d->type);
-
792 const uint size = type.sizeOf();
executed (the execution status of this line is deduced): const uint size = type.sizeOf();
-
793 if (!size) {
evaluated: !size
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:41689
18-41689
794 qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type);
executed (the execution status of this line is deduced): QMessageLogger("kernel/qvariant.cpp", 794, __PRETTY_FUNCTION__).warning("Trying to construct an instance of an invalid type, type id: %i", d->type);
-
795 d->type = QVariant::Invalid;
executed (the execution status of this line is deduced): d->type = QVariant::Invalid;
-
796 return;
executed: return;
Execution Count:18
18
797 } -
798 -
799 // this logic should match with QVariantIntegrator::CanUseInternalSpace -
800 if (size <= sizeof(QVariant::Private::Data)
evaluated: size <= sizeof(QVariant::Private::Data)
TRUEFALSE
yes
Evaluation Count:40431
yes
Evaluation Count:1258
1258-40431
801 && (type.flags() & QMetaType::MovableType)) {
evaluated: (type.flags() & QMetaType::MovableType)
TRUEFALSE
yes
Evaluation Count:38194
yes
Evaluation Count:2237
2237-38194
802 type.construct(&d->data.ptr, copy);
executed (the execution status of this line is deduced): type.construct(&d->data.ptr, copy);
-
803 d->is_shared = false;
executed (the execution status of this line is deduced): d->is_shared = false;
-
804 } else {
executed: }
Execution Count:38194
38194
805 void *ptr = type.create(copy);
executed (the execution status of this line is deduced): void *ptr = type.create(copy);
-
806 d->is_shared = true;
executed (the execution status of this line is deduced): d->is_shared = true;
-
807 d->data.shared = new QVariant::PrivateShared(ptr);
executed (the execution status of this line is deduced): d->data.shared = new QVariant::PrivateShared(ptr);
-
808 }
executed: }
Execution Count:3495
3495
809} -
810 -
811static void customClear(QVariant::Private *d) -
812{ -
813 if (!d->is_shared) {
evaluated: !d->is_shared
TRUEFALSE
yes
Evaluation Count:42457
yes
Evaluation Count:3467
3467-42457
814 QMetaType::destruct(d->type, &d->data.ptr);
executed (the execution status of this line is deduced): QMetaType::destruct(d->type, &d->data.ptr);
-
815 } else {
executed: }
Execution Count:42457
42457
816 QMetaType::destroy(d->type, d->data.shared->ptr);
executed (the execution status of this line is deduced): QMetaType::destroy(d->type, d->data.shared->ptr);
-
817 delete d->data.shared;
executed (the execution status of this line is deduced): delete d->data.shared;
-
818 }
executed: }
Execution Count:3467
3467
819} -
820 -
821static bool customIsNull(const QVariant::Private *d) -
822{ -
823 return d->is_null;
executed: return d->is_null;
Execution Count:273
273
824} -
825 -
826static bool customCompare(const QVariant::Private *a, const QVariant::Private *b) -
827{ -
828 const char *const typeName = QMetaType::typeName(a->type);
executed (the execution status of this line is deduced): const char *const typeName = QMetaType::typeName(a->type);
-
829 if (Q_UNLIKELY(!typeName) && Q_LIKELY(!QMetaType::isRegistered(a->type)))
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
830 qFatal("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
831 -
832 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
833 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
834 -
835 uint typeNameLen = qstrlen(typeName);
executed (the execution status of this line is deduced): uint typeNameLen = qstrlen(typeName);
-
836 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
837 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
838 -
839 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
840 return true;
never executed: return true;
0
841 -
842 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
843} -
844 -
845static bool customConvert(const QVariant::Private *, int, void *, bool *ok) -
846{ -
847 if (ok)
partially evaluated: ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:366
0-366
848 *ok = false;
never executed: *ok = false;
0
849 return false;
executed: return false;
Execution Count:366
366
850} -
851 -
852#if !defined(QT_NO_DEBUG_STREAM) -
853static void customStreamDebug(QDebug dbg, const QVariant &variant) { -
854#ifndef QT_BOOTSTRAPPED -
855 QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType());
executed (the execution status of this line is deduced): QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType());
-
856 if (flags & QMetaType::PointerToQObject)
evaluated: flags & QMetaType::PointerToQObject
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
857 dbg.nospace() << variant.value<QObject*>();
executed: dbg.nospace() << variant.value<QObject*>();
Execution Count:1
1
858#else -
859 Q_UNUSED(dbg); -
860 Q_UNUSED(variant); -
861#endif -
862}
executed: }
Execution Count:3
3
863#endif -
864 -
865const QVariant::Handler qt_custom_variant_handler = { -
866 customConstruct, -
867 customClear, -
868 customIsNull, -
869#ifndef QT_NO_DATASTREAM -
870 0, -
871 0, -
872#endif -
873 customCompare, -
874 customConvert, -
875 0, -
876#if !defined(QT_NO_DEBUG_STREAM) -
877 customStreamDebug -
878#else -
879 0 -
880#endif -
881}; -
882 -
883} // annonymous used to hide QVariant handlers -
884 -
885static HandlersManager handlerManager; -
886Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0"); -
887const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount] -
888 = { &qt_kernel_variant_handler, &qt_dummy_variant_handler, -
889 &qt_dummy_variant_handler, &qt_custom_variant_handler }; -
890 -
891Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler() -
892{ -
893 return &qt_kernel_variant_handler;
executed: return &qt_kernel_variant_handler;
Execution Count:203138
203138
894} -
895 -
896Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names */name, const QVariant::Handler *handler) -
897{ -
898 handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler);
executed (the execution status of this line is deduced): handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler);
-
899}
executed: }
Execution Count:186
186
900 -
901/*! -
902 \class QVariant -
903 \inmodule QtCore -
904 \brief The QVariant class acts like a union for the most common Qt data types. -
905 -
906 \ingroup objectmodel -
907 \ingroup shared -
908 -
909 -
910 Because C++ forbids unions from including types that have -
911 non-default constructors or destructors, most interesting Qt -
912 classes cannot be used in unions. Without QVariant, this would be -
913 a problem for QObject::property() and for database work, etc. -
914 -
915 A QVariant object holds a single value of a single type() at a -
916 time. (Some type()s are multi-valued, for example a string list.) -
917 You can find out what type, T, the variant holds, convert it to a -
918 different type using convert(), get its value using one of the -
919 toT() functions (e.g., toSize()) and check whether the type can -
920 be converted to a particular type using canConvert(). -
921 -
922 The methods named toT() (e.g., toInt(), toString()) are const. If -
923 you ask for the stored type, they return a copy of the stored -
924 object. If you ask for a type that can be generated from the -
925 stored type, toT() copies and converts and leaves the object -
926 itself unchanged. If you ask for a type that cannot be generated -
927 from the stored type, the result depends on the type; see the -
928 function documentation for details. -
929 -
930 Here is some example code to demonstrate the use of QVariant: -
931 -
932 \snippet code/src_corelib_kernel_qvariant.cpp 0 -
933 -
934 You can even store QList<QVariant> and QMap<QString, QVariant> -
935 values in a variant, so you can easily construct arbitrarily -
936 complex data structures of arbitrary types. This is very powerful -
937 and versatile, but may prove less memory and speed efficient than -
938 storing specific types in standard data structures. -
939 -
940 QVariant also supports the notion of null values, where you can -
941 have a defined type with no value set. However, note that QVariant -
942 types can only be cast when they have had a value set. -
943 -
944 \snippet code/src_corelib_kernel_qvariant.cpp 1 -
945 -
946 QVariant can be extended to support other types than those -
947 mentioned in the \l Type enum. See the \l QMetaType documentation -
948 for details. -
949 -
950 \section1 A Note on GUI Types -
951 -
952 Because QVariant is part of the Qt Core module, it cannot provide -
953 conversion functions to data types defined in Qt GUI, such as -
954 QColor, QImage, and QPixmap. In other words, there is no \c -
955 toColor() function. Instead, you can use the QVariant::value() or -
956 the qvariant_cast() template function. For example: -
957 -
958 \snippet code/src_corelib_kernel_qvariant.cpp 2 -
959 -
960 The inverse conversion (e.g., from QColor to QVariant) is -
961 automatic for all data types supported by QVariant, including -
962 GUI-related types: -
963 -
964 \snippet code/src_corelib_kernel_qvariant.cpp 3 -
965 -
966 \section1 Using canConvert() and convert() Consecutively -
967 -
968 When using canConvert() and convert() consecutively, it is possible for -
969 canConvert() to return true, but convert() to return false. This -
970 is typically because canConvert() only reports the general ability of -
971 QVariant to convert between types given suitable data; it is still -
972 possible to supply data which cannot actually be converted. -
973 -
974 For example, canConvert() would return true when called on a variant -
975 containing a string because, in principle, QVariant is able to convert -
976 strings of numbers to integers. -
977 However, if the string contains non-numeric characters, it cannot be -
978 converted to an integer, and any attempt to convert it will fail. -
979 Hence, it is important to have both functions return true for a -
980 successful conversion. -
981 -
982 \sa QMetaType -
983*/ -
984 -
985/*! -
986 \obsolete Use QMetaType::Type instead -
987 \enum QVariant::Type -
988 -
989 This enum type defines the types of variable that a QVariant can -
990 contain. -
991 -
992 \value Invalid no type -
993 \value BitArray a QBitArray -
994 \value Bitmap a QBitmap -
995 \value Bool a bool -
996 \value Brush a QBrush -
997 \value ByteArray a QByteArray -
998 \value Char a QChar -
999 \value Color a QColor -
1000 \value Cursor a QCursor -
1001 \value Date a QDate -
1002 \value DateTime a QDateTime -
1003 \value Double a double -
1004 \value EasingCurve a QEasingCurve -
1005 \value Uuid a QUuid -
1006 \value ModelIndex a QModelIndex -
1007 \value Font a QFont -
1008 \value Hash a QVariantHash -
1009 \value Icon a QIcon -
1010 \value Image a QImage -
1011 \value Int an int -
1012 \value KeySequence a QKeySequence -
1013 \value Line a QLine -
1014 \value LineF a QLineF -
1015 \value List a QVariantList -
1016 \value Locale a QLocale -
1017 \value LongLong a \l qlonglong -
1018 \value Map a QVariantMap -
1019 \value Matrix a QMatrix -
1020 \value Transform a QTransform -
1021 \value Matrix4x4 a QMatrix4x4 -
1022 \value Palette a QPalette -
1023 \value Pen a QPen -
1024 \value Pixmap a QPixmap -
1025 \value Point a QPoint -
1026 \value PointF a QPointF -
1027 \value Polygon a QPolygon -
1028 \value PolygonF a QPolygonF -
1029 \value Quaternion a QQuaternion -
1030 \value Rect a QRect -
1031 \value RectF a QRectF -
1032 \value RegExp a QRegExp -
1033 \value RegularExpression a QRegularExpression -
1034 \value Region a QRegion -
1035 \value Size a QSize -
1036 \value SizeF a QSizeF -
1037 \value SizePolicy a QSizePolicy -
1038 \value String a QString -
1039 \value StringList a QStringList -
1040 \value TextFormat a QTextFormat -
1041 \value TextLength a QTextLength -
1042 \value Time a QTime -
1043 \value UInt a \l uint -
1044 \value ULongLong a \l qulonglong -
1045 \value Url a QUrl -
1046 \value Vector2D a QVector2D -
1047 \value Vector3D a QVector3D -
1048 \value Vector4D a QVector4D -
1049 -
1050 \value UserType Base value for user-defined types. -
1051 -
1052 \omitvalue LastGuiType -
1053 \omitvalue LastCoreType -
1054 \omitvalue LastType -
1055*/ -
1056 -
1057/*! -
1058 \fn QVariant::QVariant() -
1059 -
1060 Constructs an invalid variant. -
1061*/ -
1062 -
1063 -
1064/*! -
1065 \fn QVariant::QVariant(int typeId, const void *copy) -
1066 -
1067 Constructs variant of type \a typeId, and initializes with -
1068 \a copy if \a copy is not 0. -
1069 -
1070 Note that you have to pass the address of the variable you want stored. -
1071 -
1072 Usually, you never have to use this constructor, use QVariant::fromValue() -
1073 instead to construct variants from the pointer types represented by -
1074 \c QMetaType::VoidStar, and \c QMetaType::QObjectStar. -
1075 -
1076 \sa QVariant::fromValue(), Type -
1077*/ -
1078 -
1079/*! -
1080 \fn QVariant::QVariant(Type type) -
1081 -
1082 Constructs a null variant of type \a type. -
1083*/ -
1084 -
1085 -
1086 -
1087/*! -
1088 \fn QVariant::create(int type, const void *copy) -
1089 -
1090 \internal -
1091 -
1092 Constructs a variant private of type \a type, and initializes with \a copy if -
1093 \a copy is not 0. -
1094*/ -
1095 -
1096void QVariant::create(int type, const void *copy) -
1097{ -
1098 d.type = type;
executed (the execution status of this line is deduced): d.type = type;
-
1099 handlerManager[type]->construct(&d, copy);
executed (the execution status of this line is deduced): handlerManager[type]->construct(&d, copy);
-
1100}
executed: }
Execution Count:3565831
3565831
1101 -
1102/*! -
1103 \fn QVariant::~QVariant() -
1104 -
1105 Destroys the QVariant and the contained object. -
1106 -
1107 Note that subclasses that reimplement clear() should reimplement -
1108 the destructor to call clear(). This destructor calls clear(), but -
1109 because it is the destructor, QVariant::clear() is called rather -
1110 than a subclass's clear(). -
1111*/ -
1112 -
1113QVariant::~QVariant() -
1114{ -
1115 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
1116 handlerManager[d.type]->clear(&d);
executed: handlerManager[d.type]->clear(&d);
Execution Count:25799128
25799128
1117}
executed: }
Execution Count:43440792
43440792
1118 -
1119/*! -
1120 \fn QVariant::QVariant(const QVariant &p) -
1121 -
1122 Constructs a copy of the variant, \a p, passed as the argument to -
1123 this constructor. -
1124*/ -
1125 -
1126QVariant::QVariant(const QVariant &p) -
1127 : d(p.d) -
1128{ -
1129 if (d.is_shared) {
evaluated: d.is_shared
TRUEFALSE
yes
Evaluation Count:13694132
yes
Evaluation Count:19596524
13694132-19596524
1130 d.data.shared->ref.ref();
executed (the execution status of this line is deduced): d.data.shared->ref.ref();
-
1131 } 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
1132 handlerManager[d.type]->construct(&d, p.constData());
executed (the execution status of this line is deduced): handlerManager[d.type]->construct(&d, p.constData());
-
1133 d.is_null = p.d.is_null;
executed (the execution status of this line is deduced): d.is_null = p.d.is_null;
-
1134 }
executed: }
Execution Count:18274265
18274265
1135} -
1136 -
1137#ifndef QT_NO_DATASTREAM -
1138/*! -
1139 Reads the variant from the data stream, \a s. -
1140*/ -
1141QVariant::QVariant(QDataStream &s) -
1142{ -
1143 d.is_null = true;
never executed (the execution status of this line is deduced): d.is_null = true;
-
1144 s >> *this;
never executed (the execution status of this line is deduced): s >> *this;
-
1145}
never executed: }
0
1146#endif //QT_NO_DATASTREAM -
1147 -
1148/*! -
1149 \fn QVariant::QVariant(const QString &val) -
1150 -
1151 Constructs a new variant with a string value, \a val. -
1152*/ -
1153 -
1154/*! -
1155 \fn QVariant::QVariant(QLatin1String val) -
1156 -
1157 Constructs a new variant with a string value, \a val. -
1158*/ -
1159 -
1160/*! -
1161 \fn QVariant::QVariant(const char *val) -
1162 -
1163 Constructs a new variant with a string value of \a val. -
1164 The variant creates a deep copy of \a val into a QString assuming -
1165 UTF-8 encoding on the input \a val. -
1166 -
1167 Note that \a val is converted to a QString for storing in the -
1168 variant and QVariant::userType() will return QMetaType::QString for -
1169 the variant. -
1170 -
1171 You can disable this operator by defining \c -
1172 QT_NO_CAST_FROM_ASCII when you compile your applications. -
1173*/ -
1174 -
1175#ifndef QT_NO_CAST_FROM_ASCII -
1176QVariant::QVariant(const char *val) -
1177{ -
1178 QString s = QString::fromUtf8(val);
executed (the execution status of this line is deduced): QString s = QString::fromUtf8(val);
-
1179 create(String, &s);
executed (the execution status of this line is deduced): create(String, &s);
-
1180}
executed: }
Execution Count:10292
10292
1181#endif -
1182 -
1183/*! -
1184 \fn QVariant::QVariant(const QStringList &val) -
1185 -
1186 Constructs a new variant with a string list value, \a val. -
1187*/ -
1188 -
1189/*! -
1190 \fn QVariant::QVariant(const QMap<QString, QVariant> &val) -
1191 -
1192 Constructs a new variant with a map of QVariants, \a val. -
1193*/ -
1194 -
1195/*! -
1196 \fn QVariant::QVariant(const QHash<QString, QVariant> &val) -
1197 -
1198 Constructs a new variant with a hash of QVariants, \a val. -
1199*/ -
1200 -
1201/*! -
1202 \fn QVariant::QVariant(const QDate &val) -
1203 -
1204 Constructs a new variant with a date value, \a val. -
1205*/ -
1206 -
1207/*! -
1208 \fn QVariant::QVariant(const QTime &val) -
1209 -
1210 Constructs a new variant with a time value, \a val. -
1211*/ -
1212 -
1213/*! -
1214 \fn QVariant::QVariant(const QDateTime &val) -
1215 -
1216 Constructs a new variant with a date/time value, \a val. -
1217*/ -
1218 -
1219/*! -
1220 \since 4.7 -
1221 \fn QVariant::QVariant(const QEasingCurve &val) -
1222 -
1223 Constructs a new variant with an easing curve value, \a val. -
1224*/ -
1225 -
1226/*! -
1227 \since 5.0 -
1228 \fn QVariant::QVariant(const QUuid &val) -
1229 -
1230 Constructs a new variant with an uuid value, \a val. -
1231*/ -
1232 -
1233/*! -
1234 \since 5.0 -
1235 \fn QVariant::QVariant(const QModelIndex &val) -
1236 -
1237 Constructs a new variant with an modelIndex value, \a val. -
1238*/ -
1239 -
1240/*! -
1241 \since 5.0 -
1242 \fn QVariant::QVariant(const QJsonValue &val) -
1243 -
1244 Constructs a new variant with a json value, \a val. -
1245*/ -
1246 -
1247/*! -
1248 \since 5.0 -
1249 \fn QVariant::QVariant(const QJsonObject &val) -
1250 -
1251 Constructs a new variant with a json object value, \a val. -
1252*/ -
1253 -
1254/*! -
1255 \since 5.0 -
1256 \fn QVariant::QVariant(const QJsonArray &val) -
1257 -
1258 Constructs a new variant with a json array value, \a val. -
1259*/ -
1260 -
1261/*! -
1262 \since 5.0 -
1263 \fn QVariant::QVariant(const QJsonDocument &val) -
1264 -
1265 Constructs a new variant with a json document value, \a val. -
1266*/ -
1267 -
1268/*! -
1269 \fn QVariant::QVariant(const QByteArray &val) -
1270 -
1271 Constructs a new variant with a bytearray value, \a val. -
1272*/ -
1273 -
1274/*! -
1275 \fn QVariant::QVariant(const QBitArray &val) -
1276 -
1277 Constructs a new variant with a bitarray value, \a val. -
1278*/ -
1279 -
1280/*! -
1281 \fn QVariant::QVariant(const QPoint &val) -
1282 -
1283 Constructs a new variant with a point value of \a val. -
1284 */ -
1285 -
1286/*! -
1287 \fn QVariant::QVariant(const QPointF &val) -
1288 -
1289 Constructs a new variant with a point value of \a val. -
1290 */ -
1291 -
1292/*! -
1293 \fn QVariant::QVariant(const QRectF &val) -
1294 -
1295 Constructs a new variant with a rect value of \a val. -
1296 */ -
1297 -
1298/*! -
1299 \fn QVariant::QVariant(const QLineF &val) -
1300 -
1301 Constructs a new variant with a line value of \a val. -
1302 */ -
1303 -
1304/*! -
1305 \fn QVariant::QVariant(const QLine &val) -
1306 -
1307 Constructs a new variant with a line value of \a val. -
1308 */ -
1309 -
1310/*! -
1311 \fn QVariant::QVariant(const QRect &val) -
1312 -
1313 Constructs a new variant with a rect value of \a val. -
1314 */ -
1315 -
1316/*! -
1317 \fn QVariant::QVariant(const QSize &val) -
1318 -
1319 Constructs a new variant with a size value of \a val. -
1320 */ -
1321 -
1322/*! -
1323 \fn QVariant::QVariant(const QSizeF &val) -
1324 -
1325 Constructs a new variant with a size value of \a val. -
1326 */ -
1327 -
1328/*! -
1329 \fn QVariant::QVariant(const QUrl &val) -
1330 -
1331 Constructs a new variant with a url value of \a val. -
1332 */ -
1333 -
1334/*! -
1335 \fn QVariant::QVariant(int val) -
1336 -
1337 Constructs a new variant with an integer value, \a val. -
1338*/ -
1339 -
1340/*! -
1341 \fn QVariant::QVariant(uint val) -
1342 -
1343 Constructs a new variant with an unsigned integer value, \a val. -
1344*/ -
1345 -
1346/*! -
1347 \fn QVariant::QVariant(qlonglong val) -
1348 -
1349 Constructs a new variant with a long long integer value, \a val. -
1350*/ -
1351 -
1352/*! -
1353 \fn QVariant::QVariant(qulonglong val) -
1354 -
1355 Constructs a new variant with an unsigned long long integer value, \a val. -
1356*/ -
1357 -
1358 -
1359/*! -
1360 \fn QVariant::QVariant(bool val) -
1361 -
1362 Constructs a new variant with a boolean value, \a val. -
1363*/ -
1364 -
1365/*! -
1366 \fn QVariant::QVariant(double val) -
1367 -
1368 Constructs a new variant with a floating point value, \a val. -
1369*/ -
1370 -
1371/*! -
1372 \fn QVariant::QVariant(float val) -
1373 -
1374 Constructs a new variant with a floating point value, \a val. -
1375 \since 4.6 -
1376*/ -
1377 -
1378/*! -
1379 \fn QVariant::QVariant(const QList<QVariant> &val) -
1380 -
1381 Constructs a new variant with a list value, \a val. -
1382*/ -
1383 -
1384/*! -
1385 \fn QVariant::QVariant(QChar c) -
1386 -
1387 Constructs a new variant with a char value, \a c. -
1388*/ -
1389 -
1390/*! -
1391 \fn QVariant::QVariant(const QLocale &l) -
1392 -
1393 Constructs a new variant with a locale value, \a l. -
1394*/ -
1395 -
1396/*! -
1397 \fn QVariant::QVariant(const QRegExp &regExp) -
1398 -
1399 Constructs a new variant with the regexp value \a regExp. -
1400*/ -
1401 -
1402/*! -
1403 \fn QVariant::QVariant(const QRegularExpression &re) -
1404 -
1405 \since 5.0 -
1406 -
1407 Constructs a new variant with the regular expression value \a re. -
1408*/ -
1409 -
1410QVariant::QVariant(Type type) -
1411{ create(type, 0); }
executed: }
Execution Count:7981
7981
1412QVariant::QVariant(int typeId, const void *copy) -
1413{ create(typeId, copy); d.is_null = false; }
executed: }
Execution Count:3503126
3503126
1414 -
1415/*! -
1416 \internal -
1417 flags is true if it is a pointer type -
1418 */ -
1419QVariant::QVariant(int typeId, const void *copy, uint flags) -
1420{ -
1421 if (flags) { //type is a pointer type
evaluated: flags
TRUEFALSE
yes
Evaluation Count:4276
yes
Evaluation Count:31846
4276-31846
1422 d.type = typeId;
executed (the execution status of this line is deduced): d.type = typeId;
-
1423 d.data.ptr = *reinterpret_cast<void *const*>(copy);
executed (the execution status of this line is deduced): d.data.ptr = *reinterpret_cast<void *const*>(copy);
-
1424 } else {
executed: }
Execution Count:4276
4276
1425 create(typeId, copy);
executed (the execution status of this line is deduced): create(typeId, copy);
-
1426 }
executed: }
Execution Count:31846
31846
1427 d.is_null = false;
executed (the execution status of this line is deduced): d.is_null = false;
-
1428}
executed: }
Execution Count:36122
36122
1429 -
1430QVariant::QVariant(int val) -
1431 : d(Int) -
1432{ d.data.i = val; }
executed: }
Execution Count:488230
488230
1433QVariant::QVariant(uint val) -
1434 : d(UInt) -
1435{ d.data.u = val; }
executed: }
Execution Count:486
486
1436QVariant::QVariant(qlonglong val) -
1437 : d(LongLong) -
1438{ d.data.ll = val; }
executed: }
Execution Count:40047
40047
1439QVariant::QVariant(qulonglong val) -
1440 : d(ULongLong) -
1441{ d.data.ull = val; }
executed: }
Execution Count:28
28
1442QVariant::QVariant(bool val) -
1443 : d(Bool) -
1444{ d.data.b = val; }
executed: }
Execution Count:99974
99974
1445QVariant::QVariant(double val) -
1446 : d(Double) -
1447{ d.data.d = val; }
executed: }
Execution Count:60485
60485
1448QVariant::QVariant(float val) -
1449 : d(QMetaType::Float) -
1450{ d.data.f = val; }
executed: }
Execution Count:139
139
1451 -
1452QVariant::QVariant(const QByteArray &val) -
1453 : d(ByteArray) -
1454{ v_construct<QByteArray>(&d, val); }
executed: }
Execution Count:1071
1071
1455QVariant::QVariant(const QBitArray &val) -
1456 : d(BitArray) -
1457{ v_construct<QBitArray>(&d, val); }
executed: }
Execution Count:6
6
1458QVariant::QVariant(const QString &val) -
1459 : d(String) -
1460{ v_construct<QString>(&d, val); }
executed: }
Execution Count:3926317
3926317
1461QVariant::QVariant(QChar val) -
1462 : d(Char) -
1463{ v_construct<QChar>(&d, val); }
executed: }
Execution Count:238
238
1464QVariant::QVariant(QLatin1String val) -
1465 : d(String) -
1466{ v_construct<QString>(&d, val); }
executed: }
Execution Count:126
126
1467QVariant::QVariant(const QStringList &val) -
1468 : d(StringList) -
1469{ v_construct<QStringList>(&d, val); }
executed: }
Execution Count:213
213
1470 -
1471QVariant::QVariant(const QDate &val) -
1472 : d(Date) -
1473{ v_construct<QDate>(&d, val); }
executed: }
Execution Count:1703
1703
1474QVariant::QVariant(const QTime &val) -
1475 : d(Time) -
1476{ v_construct<QTime>(&d, val); }
executed: }
Execution Count:1681
1681
1477QVariant::QVariant(const QDateTime &val) -
1478 : d(DateTime) -
1479{ v_construct<QDateTime>(&d, val); }
executed: }
Execution Count:16030
16030
1480#ifndef QT_BOOTSTRAPPED -
1481QVariant::QVariant(const QEasingCurve &val) -
1482 : d(EasingCurve) -
1483{ v_construct<QEasingCurve>(&d, val); }
executed: }
Execution Count:3
3
1484#endif -
1485QVariant::QVariant(const QList<QVariant> &list) -
1486 : d(List) -
1487{ v_construct<QVariantList>(&d, list); }
executed: }
Execution Count:273
273
1488QVariant::QVariant(const QMap<QString, QVariant> &map) -
1489 : d(Map) -
1490{ v_construct<QVariantMap>(&d, map); }
executed: }
Execution Count:887
887
1491QVariant::QVariant(const QHash<QString, QVariant> &hash) -
1492 : d(Hash) -
1493{ v_construct<QVariantHash>(&d, hash); }
executed: }
Execution Count:13
13
1494#ifndef QT_NO_GEOM_VARIANT -
1495QVariant::QVariant(const QPoint &pt) -
1496 : d(Point) -
1497{ v_construct<QPoint>(&d, pt); }
executed: }
Execution Count:3
3
1498QVariant::QVariant(const QPointF &pt) -
1499 : d(PointF) -
1500{ v_construct<QPointF>(&d, pt); }
executed: }
Execution Count:32
32
1501QVariant::QVariant(const QRectF &r) -
1502 : d(RectF) -
1503{ v_construct<QRectF>(&d, r); }
executed: }
Execution Count:15
15
1504QVariant::QVariant(const QLineF &l) -
1505 : d(LineF) -
1506{ v_construct<QLineF>(&d, l); }
executed: }
Execution Count:5
5
1507QVariant::QVariant(const QLine &l) -
1508 : d(Line) -
1509{ v_construct<QLine>(&d, l); }
executed: }
Execution Count:5
5
1510QVariant::QVariant(const QRect &r) -
1511 : d(Rect) -
1512{ v_construct<QRect>(&d, r); }
executed: }
Execution Count:961
961
1513QVariant::QVariant(const QSize &s) -
1514 : d(Size) -
1515{ v_construct<QSize>(&d, s); }
executed: }
Execution Count:323
323
1516QVariant::QVariant(const QSizeF &s) -
1517 : d(SizeF) -
1518{ v_construct<QSizeF>(&d, s); }
executed: }
Execution Count:16
16
1519#endif -
1520#ifndef QT_BOOTSTRAPPED -
1521QVariant::QVariant(const QUrl &u) -
1522 : d(Url) -
1523{ v_construct<QUrl>(&d, u); }
executed: }
Execution Count:2960
2960
1524#endif -
1525QVariant::QVariant(const QLocale &l) -
1526 : d(Locale) -
1527{ v_construct<QLocale>(&d, l); }
executed: }
Execution Count:2
2
1528#ifndef QT_NO_REGEXP -
1529QVariant::QVariant(const QRegExp &regExp) -
1530 : d(RegExp) -
1531{ v_construct<QRegExp>(&d, regExp); }
executed: }
Execution Count:46
46
1532#ifndef QT_BOOTSTRAPPED -
1533QVariant::QVariant(const QRegularExpression &re) -
1534 : d(RegularExpression) -
1535{ v_construct<QRegularExpression>(&d, re); }
executed: }
Execution Count:4
4
1536QVariant::QVariant(const QUuid &uuid) -
1537 : d(Uuid) -
1538{ v_construct<QUuid>(&d, uuid); }
executed: }
Execution Count:1
1
1539QVariant::QVariant(const QModelIndex &modelIndex) -
1540 : d(ModelIndex) -
1541{ v_construct<QModelIndex>(&d, modelIndex); }
executed: }
Execution Count:1
1
1542QVariant::QVariant(const QJsonValue &jsonValue) -
1543 : d(QMetaType::QJsonValue) -
1544{ v_construct<QJsonValue>(&d, jsonValue); }
executed: }
Execution Count:1
1
1545QVariant::QVariant(const QJsonObject &jsonObject) -
1546 : d(QMetaType::QJsonObject) -
1547{ v_construct<QJsonObject>(&d, jsonObject); }
executed: }
Execution Count:1
1
1548QVariant::QVariant(const QJsonArray &jsonArray) -
1549 : d(QMetaType::QJsonArray) -
1550{ v_construct<QJsonArray>(&d, jsonArray); }
executed: }
Execution Count:1
1
1551QVariant::QVariant(const QJsonDocument &jsonDocument) -
1552 : d(QMetaType::QJsonDocument) -
1553{ v_construct<QJsonDocument>(&d, jsonDocument); }
executed: }
Execution Count:1
1
1554#endif // QT_BOOTSTRAPPED -
1555#endif // QT_NO_REGEXP -
1556 -
1557/*! -
1558 Returns the storage type of the value stored in the variant. -
1559 Although this function is declared as returning QVariant::Type, -
1560 the return value should be interpreted as QMetaType::Type. In -
1561 particular, QVariant::UserType is returned here only if the value -
1562 is equal or greater than QMetaType::User. -
1563 -
1564 Note that return values in the ranges QVariant::Char through -
1565 QVariant::RegExp and QVariant::Font through QVariant::Transform -
1566 correspond to the values in the ranges QMetaType::QChar through -
1567 QMetaType::QRegExp and QMetaType::QFont through QMetaType::QQuaternion. -
1568 -
1569 Pay particular attention when working with char and QChar -
1570 variants. Note that there is no QVariant constructor specifically -
1571 for type char, but there is one for QChar. For a variant of type -
1572 QChar, this function returns QVariant::Char, which is the same as -
1573 QMetaType::QChar, but for a variant of type \c char, this function -
1574 returns QMetaType::Char, which is \e not the same as -
1575 QVariant::Char. -
1576 -
1577 Also note that the types \c void*, \c long, \c short, \c unsigned -
1578 \c long, \c unsigned \c short, \c unsigned \c char, \c float, \c -
1579 QObject*, and \c QWidget* are represented in QMetaType::Type but -
1580 not in QVariant::Type, and they can be returned by this function. -
1581 However, they are considered to be user defined types when tested -
1582 against QVariant::Type. -
1583 -
1584 To test whether an instance of QVariant contains a data type that -
1585 is compatible with the data type you are interested in, use -
1586 canConvert(). -
1587*/ -
1588 -
1589QVariant::Type QVariant::type() const -
1590{ -
1591 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
1592} -
1593 -
1594/*! -
1595 Returns the storage type of the value stored in the variant. For -
1596 non-user types, this is the same as type(). -
1597 -
1598 \sa type() -
1599*/ -
1600 -
1601int QVariant::userType() const -
1602{ -
1603 return d.type;
executed: return d.type;
Execution Count:956224
956224
1604} -
1605 -
1606/*! -
1607 Assigns the value of the variant \a variant to this variant. -
1608*/ -
1609QVariant& QVariant::operator=(const QVariant &variant) -
1610{ -
1611 if (this == &variant)
evaluated: this == &variant
TRUEFALSE
yes
Evaluation Count:266
yes
Evaluation Count:322241
266-322241
1612 return *this;
executed: return *this;
Execution Count:266
266
1613 -
1614 clear();
executed (the execution status of this line is deduced): clear();
-
1615 if (variant.d.is_shared) {
evaluated: variant.d.is_shared
TRUEFALSE
yes
Evaluation Count:1147
yes
Evaluation Count:321094
1147-321094
1616 variant.d.data.shared->ref.ref();
executed (the execution status of this line is deduced): variant.d.data.shared->ref.ref();
-
1617 d = variant.d;
executed (the execution status of this line is deduced): d = variant.d;
-
1618 } 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
1619 d.type = variant.d.type;
executed (the execution status of this line is deduced): d.type = variant.d.type;
-
1620 handlerManager[d.type]->construct(&d, variant.constData());
executed (the execution status of this line is deduced): handlerManager[d.type]->construct(&d, variant.constData());
-
1621 d.is_null = variant.d.is_null;
executed (the execution status of this line is deduced): d.is_null = variant.d.is_null;
-
1622 } else {
executed: }
Execution Count:152526
152526
1623 d = variant.d;
executed (the execution status of this line is deduced): d = variant.d;
-
1624 }
executed: }
Execution Count:168568
168568
1625 -
1626 return *this;
executed: return *this;
Execution Count:322241
322241
1627} -
1628 -
1629/*! -
1630 \fn void QVariant::swap(QVariant &other) -
1631 \since 4.8 -
1632 -
1633 Swaps variant \a other with this variant. This operation is very -
1634 fast and never fails. -
1635*/ -
1636 -
1637/*! -
1638 \fn void QVariant::detach() -
1639 -
1640 \internal -
1641*/ -
1642 -
1643void QVariant::detach() -
1644{ -
1645 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
1646 return;
executed: return;
Execution Count:17644
17644
1647 -
1648 Private dd;
executed (the execution status of this line is deduced): Private dd;
-
1649 dd.type = d.type;
executed (the execution status of this line is deduced): dd.type = d.type;
-
1650 handlerManager[d.type]->construct(&dd, constData());
executed (the execution status of this line is deduced): handlerManager[d.type]->construct(&dd, constData());
-
1651 if (!d.data.shared->ref.deref())
partially evaluated: !d.data.shared->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
0-21
1652 handlerManager[d.type]->clear(&d);
never executed: handlerManager[d.type]->clear(&d);
0
1653 d.data.shared = dd.data.shared;
executed (the execution status of this line is deduced): d.data.shared = dd.data.shared;
-
1654}
executed: }
Execution Count:21
21
1655 -
1656/*! -
1657 \fn bool QVariant::isDetached() const -
1658 -
1659 \internal -
1660*/ -
1661 -
1662/*! -
1663 Returns the name of the type stored in the variant. The returned -
1664 strings describe the C++ datatype used to store the data: for -
1665 example, "QFont", "QString", or "QVariantList". An Invalid -
1666 variant returns 0. -
1667*/ -
1668const char *QVariant::typeName() const -
1669{ -
1670 return QMetaType::typeName(d.type);
executed: return QMetaType::typeName(d.type);
Execution Count:906
906
1671} -
1672 -
1673/*! -
1674 Convert this variant to type Invalid and free up any resources -
1675 used. -
1676*/ -
1677void QVariant::clear() -
1678{ -
1679 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
1680 handlerManager[d.type]->clear(&d);
executed: handlerManager[d.type]->clear(&d);
Execution Count:130382
130382
1681 d.type = Invalid;
executed (the execution status of this line is deduced): d.type = Invalid;
-
1682 d.is_null = true;
executed (the execution status of this line is deduced): d.is_null = true;
-
1683 d.is_shared = false;
executed (the execution status of this line is deduced): d.is_shared = false;
-
1684}
executed: }
Execution Count:340779
340779
1685 -
1686/*! -
1687 Converts the int representation of the storage type, \a typeId, to -
1688 its string representation. -
1689 -
1690 Returns a null pointer if the type is QVariant::Invalid or doesn't exist. -
1691*/ -
1692const char *QVariant::typeToName(int typeId) -
1693{ -
1694 return QMetaType::typeName(typeId);
executed: return QMetaType::typeName(typeId);
Execution Count:193
193
1695} -
1696 -
1697 -
1698/*! -
1699 Converts the string representation of the storage type given in \a -
1700 name, to its enum representation. -
1701 -
1702 If the string representation cannot be converted to any enum -
1703 representation, the variant is set to \c Invalid. -
1704*/ -
1705QVariant::Type QVariant::nameToType(const char *name) -
1706{ -
1707 int metaType = QMetaType::type(name);
executed (the execution status of this line is deduced): int metaType = QMetaType::type(name);
-
1708 return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
executed: return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType;
Execution Count:79
79
1709} -
1710 -
1711#ifndef QT_NO_DATASTREAM -
1712enum { MapFromThreeCount = 36 }; -
1713static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = -
1714{ -
1715 QVariant::Invalid, -
1716 QVariant::Map, -
1717 QVariant::List, -
1718 QVariant::String, -
1719 QVariant::StringList, -
1720 QVariant::Font, -
1721 QVariant::Pixmap, -
1722 QVariant::Brush, -
1723 QVariant::Rect, -
1724 QVariant::Size, -
1725 QVariant::Color, -
1726 QVariant::Palette, -
1727 0, // ColorGroup -
1728 QVariant::Icon, -
1729 QVariant::Point, -
1730 QVariant::Image, -
1731 QVariant::Int, -
1732 QVariant::UInt, -
1733 QVariant::Bool, -
1734 QVariant::Double, -
1735 0, // Buggy ByteArray, QByteArray never had id == 20 -
1736 QVariant::Polygon, -
1737 QVariant::Region, -
1738 QVariant::Bitmap, -
1739 QVariant::Cursor, -
1740 QVariant::SizePolicy, -
1741 QVariant::Date, -
1742 QVariant::Time, -
1743 QVariant::DateTime, -
1744 QVariant::ByteArray, -
1745 QVariant::BitArray, -
1746 QVariant::KeySequence, -
1747 QVariant::Pen, -
1748 QVariant::LongLong, -
1749 QVariant::ULongLong, -
1750 QVariant::EasingCurve -
1751}; -
1752 -
1753/*! -
1754 Internal function for loading a variant from stream \a s. Use the -
1755 stream operators instead. -
1756 -
1757 \internal -
1758*/ -
1759void QVariant::load(QDataStream &s) -
1760{ -
1761 clear();
executed (the execution status of this line is deduced): clear();
-
1762 -
1763 quint32 typeId;
executed (the execution status of this line is deduced): quint32 typeId;
-
1764 s >> typeId;
executed (the execution status of this line is deduced): s >> typeId;
-
1765 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
1766 if (typeId >= MapFromThreeCount)
partially evaluated: typeId >= MapFromThreeCount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1767 return;
never executed: return;
0
1768 typeId = mapIdFromQt3ToCurrent[typeId];
executed (the execution status of this line is deduced): typeId = mapIdFromQt3ToCurrent[typeId];
-
1769 } 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
1770 if (typeId == 127 /* QVariant::UserType */) {
partially evaluated: typeId == 127
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:83
0-83
1771 typeId = QMetaType::User;
never executed (the execution status of this line is deduced): typeId = QMetaType::User;
-
1772 } 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
1773 // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes -
1774 // by moving all ids down by 97. -
1775 typeId -= 97;
executed (the execution status of this line is deduced): typeId -= 97;
-
1776 } else if (typeId == 75 /* QSizePolicy */) {
executed: }
Execution Count:16
partially evaluated: typeId == 75
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:67
0-67
1777 typeId = QMetaType::QSizePolicy;
never executed (the execution status of this line is deduced): typeId = QMetaType::QSizePolicy;
-
1778 } 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
1779 // and as a result these types received lower ids too -
1780 // QKeySequence QPen QTextLength QTextFormat QMatrix QTransform QMatrix4x4 QVector2D QVector3D QVector4D QQuaternion -
1781 typeId -=1;
never executed (the execution status of this line is deduced): typeId -=1;
-
1782 }
never executed: }
0
1783 } -
1784 -
1785 qint8 is_null = false;
executed (the execution status of this line is deduced): qint8 is_null = false;
-
1786 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
1787 s >> is_null;
executed: s >> is_null;
Execution Count:12310
12310
1788 if (typeId == QVariant::UserType) {
evaluated: typeId == QVariant::UserType
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:12316
3-12316
1789 QByteArray name;
executed (the execution status of this line is deduced): QByteArray name;
-
1790 s >> name;
executed (the execution status of this line is deduced): s >> name;
-
1791 typeId = QMetaType::type(name.constData());
executed (the execution status of this line is deduced): typeId = QMetaType::type(name.constData());
-
1792 if (typeId == QMetaType::UnknownType) {
partially evaluated: typeId == QMetaType::UnknownType
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1793 s.setStatus(QDataStream::ReadCorruptData);
never executed (the execution status of this line is deduced): s.setStatus(QDataStream::ReadCorruptData);
-
1794 return;
never executed: return;
0
1795 } -
1796 }
executed: }
Execution Count:3
3
1797 create(typeId, 0);
executed (the execution status of this line is deduced): create(typeId, 0);
-
1798 d.is_null = is_null;
executed (the execution status of this line is deduced): d.is_null = is_null;
-
1799 -
1800 if (!isValid()) {
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:12306
13-12306
1801 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
1802 // Since we wrote something, we should read something -
1803 QString x;
executed (the execution status of this line is deduced): QString x;
-
1804 s >> x;
executed (the execution status of this line is deduced): s >> x;
-
1805 }
executed: }
Execution Count:3
3
1806 d.is_null = true;
executed (the execution status of this line is deduced): d.is_null = true;
-
1807 return;
executed: return;
Execution Count:13
13
1808 } -
1809 -
1810 // const cast is safe since we operate on a newly constructed variant -
1811 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
1812 s.setStatus(QDataStream::ReadCorruptData);
executed (the execution status of this line is deduced): s.setStatus(QDataStream::ReadCorruptData);
-
1813 qWarning("QVariant::load: unable to load type %d.", d.type);
executed (the execution status of this line is deduced): QMessageLogger("kernel/qvariant.cpp", 1813, __PRETTY_FUNCTION__).warning("QVariant::load: unable to load type %d.", d.type);
-
1814 }
executed: }
Execution Count:1
1
1815}
executed: }
Execution Count:12306
12306
1816 -
1817/*! -
1818 Internal function for saving a variant to the stream \a s. Use the -
1819 stream operators instead. -
1820 -
1821 \internal -
1822*/ -
1823void QVariant::save(QDataStream &s) const -
1824{ -
1825 quint32 typeId = type();
executed (the execution status of this line is deduced): quint32 typeId = type();
-
1826 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
1827 int i;
executed (the execution status of this line is deduced): int i;
-
1828 for (i = 0; i <= MapFromThreeCount - 1; ++i) {
evaluated: i <= MapFromThreeCount - 1
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:1
1-76
1829 if (mapIdFromQt3ToCurrent[i] == typeId) {
evaluated: mapIdFromQt3ToCurrent[i] == typeId
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:68
8-68
1830 typeId = i;
executed (the execution status of this line is deduced): typeId = i;
-
1831 break;
executed: break;
Execution Count:8
8
1832 } -
1833 }
executed: }
Execution Count:68
68
1834 if (i >= MapFromThreeCount) {
evaluated: i >= MapFromThreeCount
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
1835 s << QVariant();
executed (the execution status of this line is deduced): s << QVariant();
-
1836 return;
executed: return;
Execution Count:1
1
1837 } -
1838 } 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
1839 if (typeId == QMetaType::User) {
partially evaluated: typeId == QMetaType::User
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:96
0-96
1840 typeId = 127; // QVariant::UserType had this value in Qt4
never executed (the execution status of this line is deduced): typeId = 127;
-
1841 } 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
1842 // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes -
1843 // by moving all ids down by 97. -
1844 typeId += 97;
executed (the execution status of this line is deduced): typeId += 97;
-
1845 } 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
1846 typeId = 75;
never executed (the execution status of this line is deduced): typeId = 75;
-
1847 } 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
1848 // and as a result these types received lower ids too -
1849 typeId +=1;
never executed (the execution status of this line is deduced): typeId +=1;
-
1850 }
never executed: }
0
1851 } -
1852 s << typeId;
executed (the execution status of this line is deduced): s << typeId;
-
1853 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
1854 s << qint8(d.is_null);
executed: s << qint8(d.is_null);
Execution Count:12265
12265
1855 if (d.type >= QVariant::UserType) {
evaluated: d.type >= QVariant::UserType
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:12325
2-12325
1856 s << QMetaType::typeName(userType());
executed (the execution status of this line is deduced): s << QMetaType::typeName(userType());
-
1857 }
executed: }
Execution Count:2
2
1858 -
1859 if (!isValid()) {
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:12309
18-12309
1860 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
1861 s << QString();
executed: s << QString();
Execution Count:13
13
1862 return;
executed: return;
Execution Count:18
18
1863 } -
1864 -
1865 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
1866 qWarning("QVariant::save: unable to save type '%s' (type id: %d).\n", QMetaType::typeName(d.type), d.type);
never executed (the execution status of this line is deduced): 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);
-
1867 Q_ASSERT_X(false, "QVariant::save", "Invalid type to save");
never executed (the execution status of this line is deduced): qt_noop();
-
1868 }
never executed: }
0
1869}
executed: }
Execution Count:12309
12309
1870 -
1871/*! -
1872 \since 4.4 -
1873 -
1874 Reads a variant \a p from the stream \a s. -
1875 -
1876 \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -
1877*/ -
1878QDataStream& operator>>(QDataStream &s, QVariant &p) -
1879{ -
1880 p.load(s);
executed (the execution status of this line is deduced): p.load(s);
-
1881 return s;
executed: return s;
Execution Count:12317
12317
1882} -
1883 -
1884/*! -
1885 Writes a variant \a p to the stream \a s. -
1886 -
1887 \sa{Serializing Qt Data Types}{Format of the QDataStream operators} -
1888*/ -
1889QDataStream& operator<<(QDataStream &s, const QVariant &p) -
1890{ -
1891 p.save(s);
executed (the execution status of this line is deduced): p.save(s);
-
1892 return s;
executed: return s;
Execution Count:12328
12328
1893} -
1894 -
1895/*! -
1896 Reads a variant type \a p in enum representation from the stream \a s. -
1897*/ -
1898QDataStream& operator>>(QDataStream &s, QVariant::Type &p) -
1899{ -
1900 quint32 u;
never executed (the execution status of this line is deduced): quint32 u;
-
1901 s >> u;
never executed (the execution status of this line is deduced): s >> u;
-
1902 p = (QVariant::Type)u;
never executed (the execution status of this line is deduced): p = (QVariant::Type)u;
-
1903 -
1904 return s;
never executed: return s;
0
1905} -
1906 -
1907/*! -
1908 Writes a variant type \a p to the stream \a s. -
1909*/ -
1910QDataStream& operator<<(QDataStream &s, const QVariant::Type p) -
1911{ -
1912 s << static_cast<quint32>(p);
never executed (the execution status of this line is deduced): s << static_cast<quint32>(p);
-
1913 -
1914 return s;
never executed: return s;
0
1915} -
1916 -
1917#endif //QT_NO_DATASTREAM -
1918 -
1919/*! -
1920 \fn bool QVariant::isValid() const -
1921 -
1922 Returns true if the storage type of this variant is not -
1923 QVariant::Invalid; otherwise returns false. -
1924*/ -
1925 -
1926template <typename T> -
1927inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager) -
1928{ -
1929 const uint targetType = qMetaTypeId<T>();
executed (the execution status of this line is deduced): const uint targetType = qMetaTypeId<T>();
-
1930 if (d.type == targetType)
evaluated: d.type == targetType
TRUEFALSE
yes
Evaluation Count:535554
yes
Evaluation Count:61489
61489-535554
1931 return *v_cast<T>(&d);
executed: return *v_cast<T>(&d);
Execution Count:535554
535554
1932 -
1933 T ret;
executed (the execution status of this line is deduced): T ret;
-
1934 handlerManager[d.type]->convert(&d, targetType, &ret, 0);
executed (the execution status of this line is deduced): handlerManager[d.type]->convert(&d, targetType, &ret, 0);
-
1935 return ret;
executed: return ret;
Execution Count:61489
61489
1936} -
1937 -
1938/*! -
1939 \fn QStringList QVariant::toStringList() const -
1940 -
1941 Returns the variant as a QStringList if the variant has userType() -
1942 \l QMetaType::QStringList, \l QMetaType::QString, or -
1943 \l QMetaType::QVariantList of a type that can be converted to QString; -
1944 otherwise returns an empty list. -
1945 -
1946 \sa canConvert(), convert() -
1947*/ -
1948QStringList QVariant::toStringList() const -
1949{ -
1950 return qVariantToHelper<QStringList>(d, handlerManager);
executed: return qVariantToHelper<QStringList>(d, handlerManager);
Execution Count:191
191
1951} -
1952 -
1953/*! -
1954 Returns the variant as a QString if the variant has userType() \l -
1955 QMetaType::QString, \l QMetaType::Bool, \l QMetaType::QByteArray, -
1956 \l QMetaType::QChar, \l QMetaType::QDate, \l QMetaType::QDateTime, -
1957 \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, -
1958 \l QMetaType::QStringList, \l QMetaType::QTime, \l QMetaType::UInt, or -
1959 \l QMetaType::ULongLong; otherwise returns an empty string. -
1960 -
1961 \sa canConvert(), convert() -
1962*/ -
1963QString QVariant::toString() const -
1964{ -
1965 return qVariantToHelper<QString>(d, handlerManager);
executed: return qVariantToHelper<QString>(d, handlerManager);
Execution Count:477952
477952
1966} -
1967 -
1968/*! -
1969 Returns the variant as a QMap<QString, QVariant> if the variant -
1970 has type() \l QMetaType::QVariantMap; otherwise returns an empty map. -
1971 -
1972 \sa canConvert(), convert() -
1973*/ -
1974QVariantMap QVariant::toMap() const -
1975{ -
1976 return qVariantToHelper<QVariantMap>(d, handlerManager);
executed: return qVariantToHelper<QVariantMap>(d, handlerManager);
Execution Count:4
4
1977} -
1978 -
1979/*! -
1980 Returns the variant as a QHash<QString, QVariant> if the variant -
1981 has type() \l QMetaType::QVariantHash; otherwise returns an empty map. -
1982 -
1983 \sa canConvert(), convert() -
1984*/ -
1985QVariantHash QVariant::toHash() const -
1986{ -
1987 return qVariantToHelper<QVariantHash>(d, handlerManager);
never executed: return qVariantToHelper<QVariantHash>(d, handlerManager);
0
1988} -
1989 -
1990/*! -
1991 \fn QDate QVariant::toDate() const -
1992 -
1993 Returns the variant as a QDate if the variant has userType() -
1994 \l QMetaType::QDate, \l QMetaType::QDateTime, or \l QMetaType::QString; -
1995 otherwise returns an invalid date. -
1996 -
1997 If the type() is \l QMetaType::QString, an invalid date will be returned if -
1998 the string cannot be parsed as a Qt::ISODate format date. -
1999 -
2000 \sa canConvert(), convert() -
2001*/ -
2002QDate QVariant::toDate() const -
2003{ -
2004 return qVariantToHelper<QDate>(d, handlerManager);
executed: return qVariantToHelper<QDate>(d, handlerManager);
Execution Count:11588
11588
2005} -
2006 -
2007/*! -
2008 \fn QTime QVariant::toTime() const -
2009 -
2010 Returns the variant as a QTime if the variant has userType() -
2011 \l QMetaType::QTime, \l QMetaType::QDateTime, or \l QMetaType::QString; -
2012 otherwise returns an invalid time. -
2013 -
2014 If the type() is \l QMetaType::QString, an invalid time will be returned if -
2015 the string cannot be parsed as a Qt::ISODate format time. -
2016 -
2017 \sa canConvert(), convert() -
2018*/ -
2019QTime QVariant::toTime() const -
2020{ -
2021 return qVariantToHelper<QTime>(d, handlerManager);
executed: return qVariantToHelper<QTime>(d, handlerManager);
Execution Count:10955
10955
2022} -
2023 -
2024/*! -
2025 \fn QDateTime QVariant::toDateTime() const -
2026 -
2027 Returns the variant as a QDateTime if the variant has userType() -
2028 \l QMetaType::QDateTime, \l QMetaType::QDate, or \l QMetaType::QString; -
2029 otherwise returns an invalid date/time. -
2030 -
2031 If the type() is \l QMetaType::QString, an invalid date/time will be -
2032 returned if the string cannot be parsed as a Qt::ISODate format date/time. -
2033 -
2034 \sa canConvert(), convert() -
2035*/ -
2036QDateTime QVariant::toDateTime() const -
2037{ -
2038 return qVariantToHelper<QDateTime>(d, handlerManager);
executed: return qVariantToHelper<QDateTime>(d, handlerManager);
Execution Count:89174
89174
2039} -
2040 -
2041/*! -
2042 \since 4.7 -
2043 \fn QEasingCurve QVariant::toEasingCurve() const -
2044 -
2045 Returns the variant as a QEasingCurve if the variant has userType() -
2046 \l QMetaType::QEasingCurve; otherwise returns a default easing curve. -
2047 -
2048 \sa canConvert(), convert() -
2049*/ -
2050#ifndef QT_BOOTSTRAPPED -
2051QEasingCurve QVariant::toEasingCurve() const -
2052{ -
2053 return qVariantToHelper<QEasingCurve>(d, handlerManager);
executed: return qVariantToHelper<QEasingCurve>(d, handlerManager);
Execution Count:3
3
2054} -
2055#endif -
2056 -
2057/*! -
2058 \fn QByteArray QVariant::toByteArray() const -
2059 -
2060 Returns the variant as a QByteArray if the variant has userType() -
2061 \l QMetaType::QByteArray or \l QMetaType::QString (converted using -
2062 QString::fromUtf8()); otherwise returns an empty byte array. -
2063 -
2064 \sa canConvert(), convert() -
2065*/ -
2066QByteArray QVariant::toByteArray() const -
2067{ -
2068 return qVariantToHelper<QByteArray>(d, handlerManager);
executed: return qVariantToHelper<QByteArray>(d, handlerManager);
Execution Count:1291
1291
2069} -
2070 -
2071#ifndef QT_NO_GEOM_VARIANT -
2072/*! -
2073 \fn QPoint QVariant::toPoint() const -
2074 -
2075 Returns the variant as a QPoint if the variant has userType() -
2076 \l QMetaType::QPointF or \l QMetaType::QPointF; otherwise returns a null -
2077 QPoint. -
2078 -
2079 \sa canConvert(), convert() -
2080*/ -
2081QPoint QVariant::toPoint() const -
2082{ -
2083 return qVariantToHelper<QPoint>(d, handlerManager);
executed: return qVariantToHelper<QPoint>(d, handlerManager);
Execution Count:6
6
2084} -
2085 -
2086/*! -
2087 \fn QRect QVariant::toRect() const -
2088 -
2089 Returns the variant as a QRect if the variant has userType() -
2090 \l QMetaType::QRect; otherwise returns an invalid QRect. -
2091 -
2092 \sa canConvert(), convert() -
2093*/ -
2094QRect QVariant::toRect() const -
2095{ -
2096 return qVariantToHelper<QRect>(d, handlerManager);
executed: return qVariantToHelper<QRect>(d, handlerManager);
Execution Count:116
116
2097} -
2098 -
2099/*! -
2100 \fn QSize QVariant::toSize() const -
2101 -
2102 Returns the variant as a QSize if the variant has userType() -
2103 \l QMetaType::QSize; otherwise returns an invalid QSize. -
2104 -
2105 \sa canConvert(), convert() -
2106*/ -
2107QSize QVariant::toSize() const -
2108{ -
2109 return qVariantToHelper<QSize>(d, handlerManager);
executed: return qVariantToHelper<QSize>(d, handlerManager);
Execution Count:88
88
2110} -
2111 -
2112/*! -
2113 \fn QSizeF QVariant::toSizeF() const -
2114 -
2115 Returns the variant as a QSizeF if the variant has userType() \l -
2116 QMetaType::QSizeF; otherwise returns an invalid QSizeF. -
2117 -
2118 \sa canConvert(), convert() -
2119*/ -
2120QSizeF QVariant::toSizeF() const -
2121{ -
2122 return qVariantToHelper<QSizeF>(d, handlerManager);
executed: return qVariantToHelper<QSizeF>(d, handlerManager);
Execution Count:16
16
2123} -
2124 -
2125/*! -
2126 \fn QRectF QVariant::toRectF() const -
2127 -
2128 Returns the variant as a QRectF if the variant has userType() -
2129 \l QMetaType::QRect or \l QMetaType::QRectF; otherwise returns an invalid -
2130 QRectF. -
2131 -
2132 \sa canConvert(), convert() -
2133*/ -
2134QRectF QVariant::toRectF() const -
2135{ -
2136 return qVariantToHelper<QRectF>(d, handlerManager);
executed: return qVariantToHelper<QRectF>(d, handlerManager);
Execution Count:9
9
2137} -
2138 -
2139/*! -
2140 \fn QLineF QVariant::toLineF() const -
2141 -
2142 Returns the variant as a QLineF if the variant has userType() -
2143 \l QMetaType::QLineF; otherwise returns an invalid QLineF. -
2144 -
2145 \sa canConvert(), convert() -
2146*/ -
2147QLineF QVariant::toLineF() const -
2148{ -
2149 return qVariantToHelper<QLineF>(d, handlerManager);
executed: return qVariantToHelper<QLineF>(d, handlerManager);
Execution Count:5
5
2150} -
2151 -
2152/*! -
2153 \fn QLine QVariant::toLine() const -
2154 -
2155 Returns the variant as a QLine if the variant has userType() -
2156 \l QMetaType::QLine; otherwise returns an invalid QLine. -
2157 -
2158 \sa canConvert(), convert() -
2159*/ -
2160QLine QVariant::toLine() const -
2161{ -
2162 return qVariantToHelper<QLine>(d, handlerManager);
executed: return qVariantToHelper<QLine>(d, handlerManager);
Execution Count:5
5
2163} -
2164 -
2165/*! -
2166 \fn QPointF QVariant::toPointF() const -
2167 -
2168 Returns the variant as a QPointF if the variant has userType() \l -
2169 QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null -
2170 QPointF. -
2171 -
2172 \sa canConvert(), convert() -
2173*/ -
2174QPointF QVariant::toPointF() const -
2175{ -
2176 return qVariantToHelper<QPointF>(d, handlerManager);
executed: return qVariantToHelper<QPointF>(d, handlerManager);
Execution Count:757
757
2177} -
2178 -
2179#endif // QT_NO_GEOM_VARIANT -
2180 -
2181#ifndef QT_BOOTSTRAPPED -
2182/*! -
2183 \fn QUrl QVariant::toUrl() const -
2184 -
2185 Returns the variant as a QUrl if the variant has userType() -
2186 \l QMetaType::QUrl; otherwise returns an invalid QUrl. -
2187 -
2188 \sa canConvert(), convert() -
2189*/ -
2190QUrl QVariant::toUrl() const -
2191{ -
2192 return qVariantToHelper<QUrl>(d, handlerManager);
executed: return qVariantToHelper<QUrl>(d, handlerManager);
Execution Count:4696
4696
2193} -
2194#endif -
2195 -
2196/*! -
2197 \fn QLocale QVariant::toLocale() const -
2198 -
2199 Returns the variant as a QLocale if the variant has userType() -
2200 \l QMetaType::QLocale; otherwise returns an invalid QLocale. -
2201 -
2202 \sa canConvert(), convert() -
2203*/ -
2204QLocale QVariant::toLocale() const -
2205{ -
2206 return qVariantToHelper<QLocale>(d, handlerManager);
executed: return qVariantToHelper<QLocale>(d, handlerManager);
Execution Count:3
3
2207} -
2208 -
2209/*! -
2210 \fn QRegExp QVariant::toRegExp() const -
2211 \since 4.1 -
2212 -
2213 Returns the variant as a QRegExp if the variant has userType() -
2214 \l QMetaType::QRegExp; otherwise returns an empty QRegExp. -
2215 -
2216 \sa canConvert(), convert() -
2217*/ -
2218#ifndef QT_NO_REGEXP -
2219QRegExp QVariant::toRegExp() const -
2220{ -
2221 return qVariantToHelper<QRegExp>(d, handlerManager);
executed: return qVariantToHelper<QRegExp>(d, handlerManager);
Execution Count:45
45
2222} -
2223#endif -
2224 -
2225/*! -
2226 \fn QRegularExpression QVariant::toRegularExpression() const -
2227 \since 5.0 -
2228 -
2229 Returns the variant as a QRegularExpression if the variant has userType() \l -
2230 QRegularExpression; otherwise returns an empty QRegularExpression. -
2231 -
2232 \sa canConvert(), convert() -
2233*/ -
2234#ifndef QT_BOOTSTRAPPED -
2235#ifndef QT_NO_REGEXP -
2236QRegularExpression QVariant::toRegularExpression() const -
2237{ -
2238 return qVariantToHelper<QRegularExpression>(d, handlerManager);
executed: return qVariantToHelper<QRegularExpression>(d, handlerManager);
Execution Count:3
3
2239} -
2240#endif -
2241 -
2242/*! -
2243 \since 5.0 -
2244 -
2245 Returns the variant as a QUuid if the variant has userType() \l -
2246 QUuid; otherwise returns a default constructed QUuid. -
2247 -
2248 \sa canConvert(), convert() -
2249*/ -
2250QUuid QVariant::toUuid() const -
2251{ -
2252 return qVariantToHelper<QUuid>(d, handlerManager);
executed: return qVariantToHelper<QUuid>(d, handlerManager);
Execution Count:1
1
2253} -
2254 -
2255/*! -
2256 \since 5.0 -
2257 -
2258 Returns the variant as a QModelIndex if the variant has userType() \l -
2259 QModelIndex; otherwise returns a default constructed QModelIndex. -
2260 -
2261 \sa canConvert(), convert() -
2262*/ -
2263QModelIndex QVariant::toModelIndex() const -
2264{ -
2265 return qVariantToHelper<QModelIndex>(d, handlerManager);
executed: return qVariantToHelper<QModelIndex>(d, handlerManager);
Execution Count:1
1
2266} -
2267 -
2268/*! -
2269 \since 5.0 -
2270 -
2271 Returns the variant as a QJsonValue if the variant has userType() \l -
2272 QJsonValue; otherwise returns a default constructed QJsonValue. -
2273 -
2274 \sa canConvert(), convert() -
2275*/ -
2276QJsonValue QVariant::toJsonValue() const -
2277{ -
2278 return qVariantToHelper<QJsonValue>(d, handlerManager);
executed: return qVariantToHelper<QJsonValue>(d, handlerManager);
Execution Count:1
1
2279} -
2280 -
2281/*! -
2282 \since 5.0 -
2283 -
2284 Returns the variant as a QJsonObject if the variant has userType() \l -
2285 QJsonObject; otherwise returns a default constructed QJsonObject. -
2286 -
2287 \sa canConvert(), convert() -
2288*/ -
2289QJsonObject QVariant::toJsonObject() const -
2290{ -
2291 return qVariantToHelper<QJsonObject>(d, handlerManager);
executed: return qVariantToHelper<QJsonObject>(d, handlerManager);
Execution Count:1
1
2292} -
2293 -
2294/*! -
2295 \since 5.0 -
2296 -
2297 Returns the variant as a QJsonArray if the variant has userType() \l -
2298 QJsonArray; otherwise returns a default constructed QJsonArray. -
2299 -
2300 \sa canConvert(), convert() -
2301*/ -
2302QJsonArray QVariant::toJsonArray() const -
2303{ -
2304 return qVariantToHelper<QJsonArray>(d, handlerManager);
executed: return qVariantToHelper<QJsonArray>(d, handlerManager);
Execution Count:1
1
2305} -
2306 -
2307/*! -
2308 \since 5.0 -
2309 -
2310 Returns the variant as a QJsonDocument if the variant has userType() \l -
2311 QJsonDocument; otherwise returns a default constructed QJsonDocument. -
2312 -
2313 \sa canConvert(), convert() -
2314*/ -
2315QJsonDocument QVariant::toJsonDocument() const -
2316{ -
2317 return qVariantToHelper<QJsonDocument>(d, handlerManager);
executed: return qVariantToHelper<QJsonDocument>(d, handlerManager);
Execution Count:1
1
2318} -
2319#endif -
2320 -
2321/*! -
2322 \fn QChar QVariant::toChar() const -
2323 -
2324 Returns the variant as a QChar if the variant has userType() -
2325 \l QMetaType::QChar, \l QMetaType::Int, or \l QMetaType::UInt; otherwise -
2326 returns an invalid QChar. -
2327 -
2328 \sa canConvert(), convert() -
2329*/ -
2330QChar QVariant::toChar() const -
2331{ -
2332 return qVariantToHelper<QChar>(d, handlerManager);
executed: return qVariantToHelper<QChar>(d, handlerManager);
Execution Count:3
3
2333} -
2334 -
2335/*! -
2336 Returns the variant as a QBitArray if the variant has userType() -
2337 \l QMetaType::QBitArray; otherwise returns an empty bit array. -
2338 -
2339 \sa canConvert(), convert() -
2340*/ -
2341QBitArray QVariant::toBitArray() const -
2342{ -
2343 return qVariantToHelper<QBitArray>(d, handlerManager);
executed: return qVariantToHelper<QBitArray>(d, handlerManager);
Execution Count:1
1
2344} -
2345 -
2346template <typename T> -
2347inline T qNumVariantToHelper(const QVariant::Private &d, -
2348 const HandlersManager &handlerManager, bool *ok, const T& val) -
2349{ -
2350 uint t = qMetaTypeId<T>();
executed (the execution status of this line is deduced): uint t = qMetaTypeId<T>();
-
2351 if (ok)
evaluated: ok
TRUEFALSE
yes
Evaluation Count:2175
yes
Evaluation Count:409317
2175-409317
2352 *ok = true;
executed: *ok = true;
Execution Count:2175
2175
2353 if (d.type == t)
evaluated: d.type == t
TRUEFALSE
yes
Evaluation Count:399398
yes
Evaluation Count:12094
12094-399398
2354 return val;
executed: return val;
Execution Count:399398
399398
2355 -
2356 T ret = 0;
executed (the execution status of this line is deduced): T ret = 0;
-
2357 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
2358 *ok = false;
executed: *ok = false;
Execution Count:8
8
2359 return ret;
executed: return ret;
Execution Count:12094
12094
2360} -
2361 -
2362/*! -
2363 Returns the variant as an int if the variant has userType() -
2364 \l QMetaType::Int, \l QMetaType::Bool, \l QMetaType::QByteArray, -
2365 \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::LongLong, -
2366 \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; -
2367 otherwise returns 0. -
2368 -
2369 If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be -
2370 converted to an int; otherwise \c{*}\a{ok} is set to false. -
2371 -
2372 \b{Warning:} If the value is convertible to a \l QMetaType::LongLong but is -
2373 too large to be represented in an int, the resulting arithmetic overflow -
2374 will not be reflected in \a ok. A simple workaround is to use -
2375 QString::toInt(). -
2376 -
2377 \sa canConvert(), convert() -
2378*/ -
2379int QVariant::toInt(bool *ok) const -
2380{ -
2381 return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);
executed: return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i);
Execution Count:359892
359892
2382} -
2383 -
2384/*! -
2385 Returns the variant as an unsigned int if the variant has userType() -
2386 \l QMetaType::UInt, \l QMetaType::Bool, \l QMetaType::QByteArray, -
2387 \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, -
2388 \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::ULongLong; -
2389 otherwise returns 0. -
2390 -
2391 If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be -
2392 converted to an unsigned int; otherwise \c{*}\a{ok} is set to false. -
2393 -
2394 \b{Warning:} If the value is convertible to a \l QMetaType::ULongLong but is -
2395 too large to be represented in an unsigned int, the resulting arithmetic -
2396 overflow will not be reflected in \a ok. A simple workaround is to use -
2397 QString::toUInt(). -
2398 -
2399 \sa canConvert(), convert() -
2400*/ -
2401uint QVariant::toUInt(bool *ok) const -
2402{ -
2403 return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u);
executed: return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u);
Execution Count:266
266
2404} -
2405 -
2406/*! -
2407 Returns the variant as a long long int if the variant has userType() -
2408 \l QMetaType::LongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, -
2409 \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, -
2410 \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; -
2411 otherwise returns 0. -
2412 -
2413 If \a ok is non-null: \c{*}\c{ok} is set to true if the value could be -
2414 converted to an int; otherwise \c{*}\c{ok} is set to false. -
2415 -
2416 \sa canConvert(), convert() -
2417*/ -
2418qlonglong QVariant::toLongLong(bool *ok) const -
2419{ -
2420 return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll);
executed: return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll);
Execution Count:9548
9548
2421} -
2422 -
2423/*! -
2424 Returns the variant as as an unsigned long long int if the -
2425 variant has type() \l QMetaType::ULongLong, \l QMetaType::Bool, -
2426 \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, -
2427 \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or -
2428 \l QMetaType::UInt; otherwise returns 0. -
2429 -
2430 If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be -
2431 converted to an int; otherwise \c{*}\a{ok} is set to false. -
2432 -
2433 \sa canConvert(), convert() -
2434*/ -
2435qulonglong QVariant::toULongLong(bool *ok) const -
2436{ -
2437 return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull);
executed: return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull);
Execution Count:34
34
2438} -
2439 -
2440/*! -
2441 Returns the variant as a bool if the variant has userType() Bool. -
2442 -
2443 Returns true if the variant has userType() \l QMetaType::Bool, -
2444 \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, -
2445 \l QMetaType::LongLong, \l QMetaType::UInt, or \l QMetaType::ULongLong and -
2446 the value is non-zero, or if the variant has type \l QMetaType::QString or -
2447 \l QMetaType::QByteArray and its lower-case content is not one of the -
2448 following: empty, "0" or "false"; otherwise returns false. -
2449 -
2450 \sa canConvert(), convert() -
2451*/ -
2452bool QVariant::toBool() const -
2453{ -
2454 if (d.type == Bool)
evaluated: d.type == Bool
TRUEFALSE
yes
Evaluation Count:30089
yes
Evaluation Count:12912
12912-30089
2455 return d.data.b;
executed: return d.data.b;
Execution Count:30089
30089
2456 -
2457 bool res = false;
executed (the execution status of this line is deduced): bool res = false;
-
2458 handlerManager[d.type]->convert(&d, Bool, &res, 0);
executed (the execution status of this line is deduced): handlerManager[d.type]->convert(&d, Bool, &res, 0);
-
2459 -
2460 return res;
executed: return res;
Execution Count:12912
12912
2461} -
2462 -
2463/*! -
2464 Returns the variant as a double if the variant has userType() -
2465 \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, -
2466 \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, -
2467 \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; -
2468 otherwise returns 0.0. -
2469 -
2470 If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be -
2471 converted to a double; otherwise \c{*}\a{ok} is set to false. -
2472 -
2473 \sa canConvert(), convert() -
2474*/ -
2475double QVariant::toDouble(bool *ok) const -
2476{ -
2477 return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d);
executed: return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d);
Execution Count:32196
32196
2478} -
2479 -
2480/*! -
2481 Returns the variant as a float if the variant has userType() -
2482 \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, -
2483 \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, -
2484 \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; -
2485 otherwise returns 0.0. -
2486 -
2487 \since 4.6 -
2488 -
2489 If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be -
2490 converted to a double; otherwise \c{*}\a{ok} is set to false. -
2491 -
2492 \sa canConvert(), convert() -
2493*/ -
2494float QVariant::toFloat(bool *ok) const -
2495{ -
2496 return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f);
executed: return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f);
Execution Count:130
130
2497} -
2498 -
2499/*! -
2500 Returns the variant as a qreal if the variant has userType() -
2501 \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, -
2502 \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, -
2503 \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; -
2504 otherwise returns 0.0. -
2505 -
2506 \since 4.6 -
2507 -
2508 If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be -
2509 converted to a double; otherwise \c{*}\a{ok} is set to false. -
2510 -
2511 \sa canConvert(), convert() -
2512*/ -
2513qreal QVariant::toReal(bool *ok) const -
2514{ -
2515 return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real);
executed: return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real);
Execution Count:9427
9427
2516} -
2517 -
2518/*! -
2519 Returns the variant as a QVariantList if the variant has userType() -
2520 \l QMetaType::QVariantList or \l QMetaType::QStringList; otherwise returns -
2521 an empty list. -
2522 -
2523 \sa canConvert(), convert() -
2524*/ -
2525QVariantList QVariant::toList() const -
2526{ -
2527 return qVariantToHelper<QVariantList>(d, handlerManager);
executed: return qVariantToHelper<QVariantList>(d, handlerManager);
Execution Count:126
126
2528} -
2529 -
2530 -
2531static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = -
2532{ -
2533/*Invalid*/ 0, -
2534 -
2535/*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt -
2536 | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray -
2537 | 1 << QVariant::String | 1 << QVariant::Char, -
2538 -
2539/*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double -
2540 | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong -
2541 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
2542 -
2543/*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double -
2544 | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong -
2545 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
2546 -
2547/*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double -
2548 | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong -
2549 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
2550 -
2551/*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double -
2552 | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong -
2553 | 1 << QVariant::Char | 1 << QVariant::ByteArray, -
2554 -
2555/*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong -
2556 | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong -
2557 | 1 << QVariant::ByteArray, -
2558 -
2559/*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong -
2560 | 1 << QVariant::ULongLong, -
2561 -
2562/*QMap*/ 0, -
2563 -
2564/*QList*/ 1 << QVariant::StringList, -
2565 -
2566/*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int -
2567 | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double -
2568 | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime -
2569 | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char -
2570 | 1 << QVariant::Url | 1 << QVariant::Uuid, -
2571 -
2572/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, -
2573 -
2574/*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool -
2575 | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, -
2576 -
2577/*QBitArray*/ 0, -
2578 -
2579/*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime, -
2580 -
2581/*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime, -
2582 -
2583/*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, -
2584 -
2585/*QUrl*/ 1 << QVariant::String, -
2586 -
2587/*QLocale*/ 0, -
2588 -
2589/*QRect*/ 1 << QVariant::RectF, -
2590 -
2591/*QRectF*/ 1 << QVariant::Rect, -
2592 -
2593/*QSize*/ 1 << QVariant::SizeF, -
2594 -
2595/*QSizeF*/ 1 << QVariant::Size, -
2596 -
2597/*QLine*/ 1 << QVariant::LineF, -
2598 -
2599/*QLineF*/ 1 << QVariant::Line, -
2600 -
2601/*QPoint*/ 1 << QVariant::PointF, -
2602 -
2603/*QPointF*/ 1 << QVariant::Point, -
2604 -
2605/*QRegExp*/ 0, -
2606 -
2607/*QHash*/ 0, -
2608 -
2609/*QEasingCurve*/ 0, -
2610 -
2611/*QUuid*/ 1 << QVariant::String -
2612}; -
2613 -
2614#ifndef QT_BOOTSTRAPPED -
2615/*! -
2616 Returns true if from inherits to. -
2617*/ -
2618static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to) -
2619{ -
2620 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
2621 return true;
executed: return true;
Execution Count:12
12
2622 -
2623 while (from) {
partially evaluated: from
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
2624 if (from == to)
evaluated: from == to
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
2625 return true;
executed: return true;
Execution Count:6
6
2626 from = from->superClass();
executed (the execution status of this line is deduced): from = from->superClass();
-
2627 }
executed: }
Execution Count:3
3
2628 -
2629 return false;
never executed: return false;
0
2630} -
2631#endif -
2632 -
2633static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) -
2634{ -
2635#ifndef QT_BOOTSTRAPPED -
2636 QMetaType toType(toId);
executed (the execution status of this line is deduced): QMetaType toType(toId);
-
2637 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
2638 if (!fromObject)
evaluated: !fromObject
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:18
4-18
2639 return true;
executed: return true;
Execution Count:4
4
2640 return canConvertMetaObject(fromObject->metaObject(), toType.metaObject());
executed: return canConvertMetaObject(fromObject->metaObject(), toType.metaObject());
Execution Count:18
18
2641 } -
2642#else -
2643 Q_UNUSED(fromId); -
2644 Q_UNUSED(toId); -
2645 Q_UNUSED(fromObject); -
2646#endif -
2647 return false;
executed: return false;
Execution Count:48
48
2648} -
2649 -
2650 -
2651/*! -
2652 Returns true if the variant's type can be cast to the requested -
2653 type, \a targetTypeId. Such casting is done automatically when calling the -
2654 toInt(), toBool(), ... methods. -
2655 -
2656 The following casts are done automatically: -
2657 -
2658 \table -
2659 \header \li Type \li Automatically Cast To -
2660 \row \li \l QMetaType::Bool \li \l QMetaType::QChar, \l QMetaType::Double, -
2661 \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, -
2662 \l QMetaType::UInt, \l QMetaType::ULongLong -
2663 \row \li \l QMetaType::QByteArray \li \l QMetaType::Double, -
2664 \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, -
2665 \l QMetaType::UInt, \l QMetaType::ULongLong -
2666 \row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int, -
2667 \l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong -
2668 \row \li \l QMetaType::QColor \li \l QMetaType::QString -
2669 \row \li \l QMetaType::QDate \li \l QMetaType::QDateTime, -
2670 \l QMetaType::QString -
2671 \row \li \l QMetaType::QDateTime \li \l QMetaType::QDate, -
2672 \l QMetaType::QString, \l QMetaType::QTime -
2673 \row \li \l QMetaType::Double \li \l QMetaType::Bool, \l QMetaType::Int, -
2674 \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, -
2675 \l QMetaType::ULongLong -
2676 \row \li \l QMetaType::QFont \li \l QMetaType::QString -
2677 \row \li \l QMetaType::Int \li \l QMetaType::Bool, \l QMetaType::QChar, -
2678 \l QMetaType::Double, \l QMetaType::LongLong, \l QMetaType::QString, -
2679 \l QMetaType::UInt, \l QMetaType::ULongLong -
2680 \row \li \l QMetaType::QKeySequence \li \l QMetaType::Int, -
2681 \l QMetaType::QString -
2682 \row \li \l QMetaType::QVariantList \li \l QMetaType::QStringList (if the -
2683 list's items can be converted to QStrings) -
2684 \row \li \l QMetaType::LongLong \li \l QMetaType::Bool, -
2685 \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, -
2686 \l QMetaType::Int, \l QMetaType::QString, \l QMetaType::UInt, -
2687 \l QMetaType::ULongLong -
2688 \row \li \l QMetaType::QPoint \li QMetaType::QPointF -
2689 \row \li \l QMetaType::QRect \li QMetaType::QRectF -
2690 \row \li \l QMetaType::QString \li \l QMetaType::Bool, -
2691 \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::QColor, -
2692 \l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double, -
2693 \l QMetaType::QFont, \l QMetaType::Int, \l QMetaType::QKeySequence, -
2694 \l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime, -
2695 \l QMetaType::UInt, \l QMetaType::ULongLong -
2696 \row \li \l QMetaType::QStringList \li \l QMetaType::QVariantList, -
2697 \l QMetaType::QString (if the list contains exactly one item) -
2698 \row \li \l QMetaType::QTime \li \l QMetaType::QString -
2699 \row \li \l QMetaType::UInt \li \l QMetaType::Bool, \l QMetaType::QChar, -
2700 \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, -
2701 \l QMetaType::QString, \l QMetaType::ULongLong -
2702 \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, -
2703 \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, -
2704 \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt -
2705 \endtable -
2706 -
2707 A QVariant containing a pointer to a type derived from QObject will also return true for this -
2708 function if a qobject_cast to the type described by \a targetTypeId would succeed. Note that -
2709 this only works for QObject subclasses which use the Q_OBJECT macro. -
2710 -
2711 \sa convert() -
2712*/ -
2713bool QVariant::canConvert(int targetTypeId) const -
2714{ -
2715 // TODO Reimplement this function, currently it works but it is a historical mess. -
2716 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
2717 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
2718 currentType = QMetaType::UInt;
executed: currentType = QMetaType::UInt;
Execution Count:91
91
2719 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
2720 targetTypeId = QMetaType::UInt;
executed: targetTypeId = QMetaType::UInt;
Execution Count:1
1
2721 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
2722 -
2723 -
2724 if (currentType == uint(targetTypeId))
evaluated: currentType == uint(targetTypeId)
TRUEFALSE
yes
Evaluation Count:279
yes
Evaluation Count:182951
279-182951
2725 return true;
executed: return true;
Execution Count:279
279
2726 -
2727 if (targetTypeId < 0)
evaluated: targetTypeId < 0
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:182885
66-182885
2728 return false;
executed: return false;
Execution Count:66
66
2729 if (targetTypeId >= QMetaType::User)
evaluated: targetTypeId >= QMetaType::User
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:182855
30-182855
2730 return canConvertMetaObject(currentType, targetTypeId, d.data.o);
executed: return canConvertMetaObject(currentType, targetTypeId, d.data.o);
Execution Count:30
30
2731 -
2732 // FIXME It should be LastCoreType intead of Uuid -
2733 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
2734 switch (uint(targetTypeId)) { -
2735 case QVariant::Int: -
2736 if (currentType == QVariant::KeySequence)
evaluated: currentType == QVariant::KeySequence
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:22
2-22
2737 return true;
executed: return true;
Execution Count:2
2
2738 // fall through -
2739 case QVariant::UInt: -
2740 return currentType == QMetaType::ULong
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
2741 || currentType == QMetaType::Long
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
2742 || currentType == QMetaType::UShort
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
2743 || currentType == QMetaType::UChar
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
2744 || currentType == QMetaType::Char
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
2745 || currentType == QMetaType::SChar
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
2746 || 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
2747 case QVariant::Image: -
2748 return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap;
executed: return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap;
Execution Count:35
35
2749 case QVariant::Pixmap: -
2750 return currentType == QVariant::Image || currentType == QVariant::Bitmap
executed: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush;
Execution Count:36
36
2751 || currentType == QVariant::Brush;
executed: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush;
Execution Count:36
36
2752 case QVariant::Bitmap: -
2753 return currentType == QVariant::Pixmap || currentType == QVariant::Image;
executed: return currentType == QVariant::Pixmap || currentType == QVariant::Image;
Execution Count:35
35
2754 case QVariant::ByteArray: -
2755 return currentType == QVariant::Color;
executed: return currentType == QVariant::Color;
Execution Count:14
14
2756 case QVariant::String: -
2757 return currentType == QVariant::KeySequence || currentType == QVariant::Font
executed: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color;
Execution Count:231
231
2758 || currentType == QVariant::Color;
executed: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color;
Execution Count:231
231
2759 case QVariant::KeySequence: -
2760 return currentType == QVariant::String || currentType == QVariant::Int;
executed: return currentType == QVariant::String || currentType == QVariant::Int;
Execution Count:37
37
2761 case QVariant::Font: -
2762 return currentType == QVariant::String;
executed: return currentType == QVariant::String;
Execution Count:56
56
2763 case QVariant::Color: -
2764 return currentType == QVariant::String || currentType == QVariant::ByteArray
executed: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush;
Execution Count:107
107
2765 || currentType == QVariant::Brush;
executed: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush;
Execution Count:107
107
2766 case QVariant::Brush: -
2767 return currentType == QVariant::Color || currentType == QVariant::Pixmap;
executed: return currentType == QVariant::Color || currentType == QVariant::Pixmap;
Execution Count:177861
177861
2768 case QMetaType::Long: -
2769 case QMetaType::Char: -
2770 case QMetaType::SChar: -
2771 case QMetaType::UChar: -
2772 case QMetaType::ULong: -
2773 case QMetaType::Short: -
2774 case QMetaType::UShort: -
2775 return qCanConvertMatrix[QVariant::Int] & (1 << currentType) || currentType == QVariant::Int;
executed: return qCanConvertMatrix[QVariant::Int] & (1 << currentType) || currentType == QVariant::Int;
Execution Count:3
3
2776 case QMetaType::QObjectStar: -
2777 return canConvertMetaObject(currentType, targetTypeId, d.data.o);
executed: return canConvertMetaObject(currentType, targetTypeId, d.data.o);
Execution Count:40
40
2778 default: -
2779 return false;
executed: return false;
Execution Count:479
479
2780 } -
2781 }
never executed: }
0
2782 -
2783 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
2784 return v_cast<QStringList>(&d)->count() == 1;
executed: return v_cast<QStringList>(&d)->count() == 1;
Execution Count:16
16
2785 return qCanConvertMatrix[targetTypeId] & (1 << currentType);
executed: return qCanConvertMatrix[targetTypeId] & (1 << currentType);
Execution Count:3867
3867
2786} -
2787 -
2788/*! -
2789 Casts the variant to the requested type, \a targetTypeId. If the cast cannot be -
2790 done, the variant is cleared. Returns true if the current type of -
2791 the variant was successfully cast; otherwise returns false. -
2792 -
2793 A QVariant containing a pointer to a type derived from QObject will also convert -
2794 and return true for this function if a qobject_cast to the type described -
2795 by \a targetTypeId would succeed. Note that this only works for QObject subclasses -
2796 which use the Q_OBJECT macro. -
2797 -
2798 \warning For historical reasons, converting a null QVariant results -
2799 in a null value of the desired type (e.g., an empty string for -
2800 QString) and a result of false. -
2801 -
2802 \sa canConvert(), clear() -
2803*/ -
2804 -
2805bool QVariant::convert(int targetTypeId) -
2806{ -
2807 if (d.type == uint(targetTypeId))
evaluated: d.type == uint(targetTypeId)
TRUEFALSE
yes
Evaluation Count:657
yes
Evaluation Count:1902
657-1902
2808 return true;
executed: return true;
Execution Count:657
657
2809 -
2810 QVariant oldValue = *this;
executed (the execution status of this line is deduced): QVariant oldValue = *this;
-
2811 -
2812 clear();
executed (the execution status of this line is deduced): clear();
-
2813 if (!oldValue.canConvert(targetTypeId))
evaluated: !oldValue.canConvert(targetTypeId)
TRUEFALSE
yes
Evaluation Count:1641
yes
Evaluation Count:261
261-1641
2814 return false;
executed: return false;
Execution Count:1641
1641
2815 -
2816 create(targetTypeId, 0);
executed (the execution status of this line is deduced): create(targetTypeId, 0);
-
2817 if (oldValue.isNull())
evaluated: oldValue.isNull()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:241
20-241
2818 return false;
executed: return false;
Execution Count:20
20
2819 -
2820 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
2821 create(targetTypeId, &oldValue.d.data.o);
executed (the execution status of this line is deduced): create(targetTypeId, &oldValue.d.data.o);
-
2822 return true;
executed: return true;
Execution Count:6
6
2823 } -
2824 -
2825 bool isOk = true;
executed (the execution status of this line is deduced): bool isOk = true;
-
2826 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
2827 isOk = false;
executed: isOk = false;
Execution Count:35
35
2828 d.is_null = !isOk;
executed (the execution status of this line is deduced): d.is_null = !isOk;
-
2829 return isOk;
executed: return isOk;
Execution Count:235
235
2830} -
2831 -
2832/*! -
2833 \fn bool QVariant::convert(const int type, void *ptr) const -
2834 \internal -
2835 Created for qvariant_cast() usage -
2836*/ -
2837bool QVariant::convert(const int type, void *ptr) const -
2838{ -
2839 Q_ASSERT(type < int(QMetaType::User));
executed (the execution status of this line is deduced): qt_noop();
-
2840 return handlerManager[type]->convert(&d, type, ptr, 0);
executed: return handlerManager[type]->convert(&d, type, ptr, 0);
Execution Count:293017
293017
2841} -
2842 -
2843 -
2844/*! -
2845 \fn bool operator==(const QVariant &v1, const QVariant &v2) -
2846 -
2847 \relates QVariant -
2848 -
2849 Returns true if \a v1 and \a v2 are equal; otherwise returns false. -
2850 -
2851 If \a v1 and \a v2 have the same \l{QVariant::}{type()}, the -
2852 type's equality operator is used for comparison. If not, it is -
2853 attempted to \l{QVariant::}{convert()} \a v2 to the same type as -
2854 \a v1. See \l{QVariant::}{canConvert()} for a list of possible -
2855 conversions. -
2856 -
2857 The result of the function is not affected by the result of QVariant::isNull, -
2858 which means that two values can be equal even if one of them is null and -
2859 another is not. -
2860 -
2861 \warning This function doesn't support custom types registered -
2862 with qRegisterMetaType(). -
2863*/ -
2864/*! -
2865 \fn bool operator!=(const QVariant &v1, const QVariant &v2) -
2866 -
2867 \relates QVariant -
2868 -
2869 Returns false if \a v1 and \a v2 are equal; otherwise returns true. -
2870 -
2871 \warning This function doesn't support custom types registered -
2872 with qRegisterMetaType(). -
2873*/ -
2874 -
2875/*! \fn bool QVariant::operator==(const QVariant &v) const -
2876 -
2877 Compares this QVariant with \a v and returns true if they are -
2878 equal; otherwise returns false. -
2879 -
2880 QVariant uses the equality operator of the type() it contains to -
2881 check for equality. QVariant will try to convert() \a v if its -
2882 type is not the same as this variant's type. See canConvert() for -
2883 a list of possible conversions. -
2884 -
2885 \warning This function doesn't support custom types registered -
2886 with qRegisterMetaType(). -
2887*/ -
2888 -
2889/*! -
2890 \fn bool QVariant::operator!=(const QVariant &v) const -
2891 -
2892 Compares this QVariant with \a v and returns true if they are not -
2893 equal; otherwise returns false. -
2894 -
2895 \warning This function doesn't support custom types registered -
2896 with qRegisterMetaType(). -
2897*/ -
2898 -
2899static bool qIsNumericType(uint tp) -
2900{ -
2901 return (tp >= QVariant::Bool && tp <= QVariant::Double)
executed: return (tp >= QVariant::Bool && tp <= QVariant::Double) || (tp >= QMetaType::Long && tp <= QMetaType::Float);
Execution Count:3475
3475
2902 || (tp >= QMetaType::Long && tp <= QMetaType::Float);
executed: return (tp >= QVariant::Bool && tp <= QVariant::Double) || (tp >= QMetaType::Long && tp <= QMetaType::Float);
Execution Count:3475
3475
2903} -
2904 -
2905static bool qIsFloatingPoint(uint tp) -
2906{ -
2907 return tp == QVariant::Double || tp == QMetaType::Float;
executed: return tp == QVariant::Double || tp == QMetaType::Float;
Execution Count:2124
2124
2908} -
2909 -
2910/*! -
2911 \internal -
2912 */ -
2913bool QVariant::cmp(const QVariant &v) const -
2914{ -
2915 QVariant v2 = v;
executed (the execution status of this line is deduced): QVariant v2 = v;
-
2916 if (d.type != v2.d.type) {
evaluated: d.type != v2.d.type
TRUEFALSE
yes
Evaluation Count:2309
yes
Evaluation Count:94079
2309-94079
2917 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
2918 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
2919 return qFuzzyCompare(toReal(), v.toReal());
executed: return qFuzzyCompare(toReal(), v.toReal());
Execution Count:6
6
2920 else -
2921 return toLongLong() == v.toLongLong();
executed: return toLongLong() == v.toLongLong();
Execution Count:1059
1059
2922 } -
2923 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
2924 return false;
executed: return false;
Execution Count:1211
1211
2925 }
executed: }
Execution Count:33
33
2926 return handlerManager[d.type]->compare(&d, &v2.d);
executed: return handlerManager[d.type]->compare(&d, &v2.d);
Execution Count:94112
94112
2927} -
2928 -
2929/*! -
2930 \internal -
2931 */ -
2932 -
2933const void *QVariant::constData() const -
2934{ -
2935 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
2936} -
2937 -
2938/*! -
2939 \fn const void* QVariant::data() const -
2940 -
2941 \internal -
2942*/ -
2943 -
2944/*! -
2945 \internal -
2946*/ -
2947void* QVariant::data() -
2948{ -
2949 detach();
executed (the execution status of this line is deduced): detach();
-
2950 return const_cast<void *>(constData());
executed: return const_cast<void *>(constData());
Execution Count:17664
17664
2951} -
2952 -
2953 -
2954/*! -
2955 Returns true if this is a null variant, false otherwise. A variant is -
2956 considered null if it contains a default constructed value or a built-in -
2957 type instance that has an isNull method, in which case the result -
2958 would be the same as calling isNull on the wrapped object. -
2959 -
2960 \warning The result of the function doesn't affect == operator, which means -
2961 that two values can be equal even if one of them is null and another is not. -
2962*/ -
2963bool QVariant::isNull() const -
2964{ -
2965 return handlerManager[d.type]->isNull(&d);
executed: return handlerManager[d.type]->isNull(&d);
Execution Count:431991
431991
2966} -
2967 -
2968#ifndef QT_NO_DEBUG_STREAM -
2969QDebug operator<<(QDebug dbg, const QVariant &v) -
2970{ -
2971 const uint typeId = v.d.type;
executed (the execution status of this line is deduced): const uint typeId = v.d.type;
-
2972 dbg.nospace() << "QVariant(";
executed (the execution status of this line is deduced): dbg.nospace() << "QVariant(";
-
2973 if (typeId != QMetaType::UnknownType) {
evaluated: typeId != QMetaType::UnknownType
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:2
2-77
2974 dbg.nospace() << QMetaType::typeName(typeId) << ", ";
executed (the execution status of this line is deduced): dbg.nospace() << QMetaType::typeName(typeId) << ", ";
-
2975 handlerManager[typeId]->debugStream(dbg, v);
executed (the execution status of this line is deduced): handlerManager[typeId]->debugStream(dbg, v);
-
2976 } else {
executed: }
Execution Count:77
77
2977 dbg.nospace() << "Invalid";
executed (the execution status of this line is deduced): dbg.nospace() << "Invalid";
-
2978 }
executed: }
Execution Count:2
2
2979 dbg.nospace() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << ')';
-
2980 return dbg.space();
executed: return dbg.space();
Execution Count:79
79
2981} -
2982 -
2983QDebug operator<<(QDebug dbg, const QVariant::Type p) -
2984{ -
2985 dbg.nospace() << "QVariant::"
executed (the execution status of this line is deduced): dbg.nospace() << "QVariant::"
-
2986 << (int(p) != int(QMetaType::UnknownType)
executed (the execution status of this line is deduced): << (int(p) != int(QMetaType::UnknownType)
-
2987 ? QMetaType::typeName(p)
executed (the execution status of this line is deduced): ? QMetaType::typeName(p)
-
2988 : "Invalid");
executed (the execution status of this line is deduced): : "Invalid");
-
2989 return dbg.space();
executed: return dbg.space();
Execution Count:52
52
2990} -
2991#endif -
2992 -
2993 -
2994/*! \fn void QVariant::setValue(const T &value) -
2995 -
2996 Stores a copy of \a value. If \c{T} is a type that QVariant -
2997 doesn't support, QMetaType is used to store the value. A compile -
2998 error will occur if QMetaType doesn't handle the type. -
2999 -
3000 Example: -
3001 -
3002 \snippet code/src_corelib_kernel_qvariant.cpp 4 -
3003 -
3004 \sa value(), fromValue(), canConvert() -
3005 */ -
3006 -
3007/*! \fn T QVariant::value() const -
3008 -
3009 Returns the stored value converted to the template type \c{T}. -
3010 Call canConvert() to find out whether a type can be converted. -
3011 If the value cannot be converted, a \l{default-constructed value} -
3012 will be returned. -
3013 -
3014 If the type \c{T} is supported by QVariant, this function behaves -
3015 exactly as toString(), toInt() etc. -
3016 -
3017 Example: -
3018 -
3019 \snippet code/src_corelib_kernel_qvariant.cpp 5 -
3020 -
3021 If the QVariant contains a pointer to a type derived from QObject then -
3022 \c{T} may be any QObject type. If the pointer stored in the QVariant can be -
3023 qobject_cast to T, then that result is returned. Otherwise a null pointer is -
3024 returned. Note that this only works for QObject subclasses which use the -
3025 Q_OBJECT macro. -
3026 -
3027 \sa setValue(), fromValue(), canConvert() -
3028*/ -
3029 -
3030/*! \fn bool QVariant::canConvert() const -
3031 -
3032 Returns true if the variant can be converted to the template type \c{T}, -
3033 otherwise false. -
3034 -
3035 Example: -
3036 -
3037 \snippet code/src_corelib_kernel_qvariant.cpp 6 -
3038 -
3039 A QVariant containing a pointer to a type derived from QObject will also return true for this -
3040 function if a qobject_cast to the template type \c{T} would succeed. Note that this only works -
3041 for QObject subclasses which use the Q_OBJECT macro. -
3042 -
3043 \sa convert() -
3044*/ -
3045 -
3046/*! \fn static QVariant QVariant::fromValue(const T &value) -
3047 -
3048 Returns a QVariant containing a copy of \a value. Behaves -
3049 exactly like setValue() otherwise. -
3050 -
3051 Example: -
3052 -
3053 \snippet code/src_corelib_kernel_qvariant.cpp 7 -
3054 -
3055 \note If you are working with custom types, you should use -
3056 the Q_DECLARE_METATYPE() macro to register your custom type. -
3057 -
3058 \sa setValue(), value() -
3059*/ -
3060 -
3061/*! -
3062 \fn QVariant qVariantFromValue(const T &value) -
3063 \relates QVariant -
3064 \obsolete -
3065 -
3066 Returns a variant containing a copy of the given \a value -
3067 with template type \c{T}. -
3068 -
3069 This function is equivalent to QVariant::fromValue(\a value). -
3070 -
3071 \note This function was provided as a workaround for MSVC 6 -
3072 which did not support member template functions. It is advised -
3073 to use the other form in new code. -
3074 -
3075 For example, a QObject pointer can be stored in a variant with the -
3076 following code: -
3077 -
3078 \snippet code/src_corelib_kernel_qvariant.cpp 8 -
3079 -
3080 \sa QVariant::fromValue() -
3081*/ -
3082 -
3083/*! \fn void qVariantSetValue(QVariant &variant, const T &value) -
3084 \relates QVariant -
3085 \obsolete -
3086 -
3087 Sets the contents of the given \a variant to a copy of the -
3088 \a value with the specified template type \c{T}. -
3089 -
3090 This function is equivalent to QVariant::setValue(\a value). -
3091 -
3092 \note This function was provided as a workaround for MSVC 6 -
3093 which did not support member template functions. It is advised -
3094 to use the other form in new code. -
3095 -
3096 \sa QVariant::setValue() -
3097*/ -
3098 -
3099/*! -
3100 \fn T qvariant_cast(const QVariant &value) -
3101 \relates QVariant -
3102 -
3103 Returns the given \a value converted to the template type \c{T}. -
3104 -
3105 This function is equivalent to QVariant::value(). -
3106 -
3107 \sa QVariant::value() -
3108*/ -
3109 -
3110/*! \fn T qVariantValue(const QVariant &value) -
3111 \relates QVariant -
3112 \obsolete -
3113 -
3114 Returns the given \a value converted to the template type \c{T}. -
3115 -
3116 This function is equivalent to -
3117 \l{QVariant::value()}{QVariant::value}<T>(\a value). -
3118 -
3119 \note This function was provided as a workaround for MSVC 6 -
3120 which did not support member template functions. It is advised -
3121 to use the other form in new code. -
3122 -
3123 \sa QVariant::value(), qvariant_cast() -
3124*/ -
3125 -
3126/*! \fn bool qVariantCanConvert(const QVariant &value) -
3127 \relates QVariant -
3128 \obsolete -
3129 -
3130 Returns true if the given \a value can be converted to the -
3131 template type specified; otherwise returns false. -
3132 -
3133 This function is equivalent to QVariant::canConvert(\a value). -
3134 -
3135 \note This function was provided as a workaround for MSVC 6 -
3136 which did not support member template functions. It is advised -
3137 to use the other form in new code. -
3138 -
3139 \sa QVariant::canConvert() -
3140*/ -
3141 -
3142/*! -
3143 \typedef QVariantList -
3144 \relates QVariant -
3145 -
3146 Synonym for QList<QVariant>. -
3147*/ -
3148 -
3149/*! -
3150 \typedef QVariantMap -
3151 \relates QVariant -
3152 -
3153 Synonym for QMap<QString, QVariant>. -
3154*/ -
3155 -
3156/*! -
3157 \typedef QVariantHash -
3158 \relates QVariant -
3159 \since 4.5 -
3160 -
3161 Synonym for QHash<QString, QVariant>. -
3162*/ -
3163 -
3164/*! -
3165 \typedef QVariant::DataPtr -
3166 \internal -
3167*/ -
3168 -
3169/*! -
3170 \fn DataPtr &QVariant::data_ptr() -
3171 \internal -
3172*/ -
3173 -
3174/*! -
3175 \fn const DataPtr &QVariant::data_ptr() const -
3176 \internal -
3177*/ -
3178 -
3179QT_END_NAMESPACE -
3180 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial