Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2012 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 | | - |
76 | QT_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 | | - |
85 | namespace { | - |
86 | class HandlersManager | - |
87 | { | - |
88 | static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount]; | - |
89 | public: | - |
90 | const QVariant::Handler *operator[] (const uint typeId) const | - |
91 | { | - |
92 | return Handlers[QModulesPrivate::moduleForType(typeId)]; executed: return Handlers[QModulesPrivate::moduleForType(typeId)]; Execution Count:12340862 | 12340862 |
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:94 | 94 |
99 | }; | - |
100 | } // namespace | - |
101 | | - |
102 | namespace { | - |
103 | struct 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 | | - |
111 | namespace { // annonymous used to hide QVariant handlers | - |
112 | | - |
113 | static 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:4481524 | 4481524 |
118 | | - |
119 | static 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:5598442 | 5598442 |
124 | | - |
125 | static 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:321424 | 321424 |
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 | */ | - |
137 | static 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:92045 | 92045 |
141 | } | - |
142 | | - |
143 | /*! | - |
144 | \internal | - |
145 | */ | - |
146 | static 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:29348 | 29348 |
151 | case QMetaType::LongLong: | - |
152 | return d->data.ll; executed: return d->data.ll; Execution Count:3022 | 3022 |
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:87 | 87 |
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 | | - |
170 | static 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:112 | 112 |
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 | | - |
188 | static 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:591 | 591 |
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:9952 | 9952 |
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:850 | 850 |
220 | } | - |
221 | | - |
222 | static 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:60 | 60 |
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:5 | 5 |
250 | } | - |
251 | | - |
252 | *ok = false; never executed (the execution status of this line is deduced): *ok = false; | - |
253 | return Q_UINT64_C(0); never executed: return static_cast<unsigned long long>(0ULL); | 0 |
254 | } | - |
255 | | - |
256 | template<typename TInput, typename LiteralWrapper> | - |
257 | inline 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 | */ | - |
268 | static 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 yes Evaluation Count:188226 | yes Evaluation Count:259 |
| 259-188226 |
275 | ok = &dummy; executed: ok = &dummy; Execution Count:188226 | 188226 |
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:222 | 222 |
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:22019 | 22019 |
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:24 | 24 |
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 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:8923 | 8923 |
349 | } | - |
350 | break; executed: break; Execution Count:22506 | 22506 |
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 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 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 yes Evaluation Count:9819 | yes Evaluation Count:2 |
| 2-9819 |
441 | *dt = v_cast<QDateTime>(d)->date(); executed: *dt = v_cast<QDateTime>(d)->date(); Execution Count:9819 | 9819 |
442 | #ifndef QT_NO_DATESTRING | - |
443 | else if (d->type == QVariant::String) partially evaluated: d->type == QVariant::String 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:9821 | 9821 |
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:9206 | 9206 |
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:9208 | 9208 |
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:433 | 433 |
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:79 | 79 |
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; | 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:179 | 179 |
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:75 | 75 |
517 | } | - |
518 | } | - |
519 | break; executed: break; Execution Count:269 | 269 |
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:4094 | 4094 |
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:76 | 76 |
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:7326 | 7326 |
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:20 | 20 |
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:227 | 227 |
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:55 | 55 |
583 | default: | - |
584 | *b = false; executed (the execution status of this line is deduced): *b = false; | - |
585 | return false; executed: return false; Execution Count:2535 | 2535 |
586 | } | - |
587 | break; executed: break; Execution Count:313 | 313 |
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:96 | 96 |
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:243 | 243 |
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; | 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 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() 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 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 { | 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 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 { | 0 |
679 | return false; executed: return false; Execution Count:2 | 2 |
680 | } | - |
681 | 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 { | 0 |
687 | return false; never executed: return false; | 0 |
688 | } | - |
689 | break; | 0 |
690 | #ifndef QT_NO_GEOM_VARIANT | - |
691 | case QVariant::Rect: | - |
692 | if (d->type == QVariant::RectF) partially evaluated: d->type == QVariant::RectF 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 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; | 0 |
709 | case QVariant::Point: | - |
710 | if (d->type == QVariant::PointF) partially evaluated: d->type == QVariant::PointF 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:122531 | 122531 |
732 | } | - |
733 | return true; executed: return true; Execution Count:23395 | 23395 |
734 | } | - |
735 | | - |
736 | #if !defined(QT_NO_DEBUG_STREAM) | - |
737 | static 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 | | - |
745 | const 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 | | - |
763 | static void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false, "QVariant", "Trying to construct an unknown type"); } | 0 |
764 | static void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); } | 0 |
765 | static 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 |
766 | static 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 |
767 | static 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) | - |
769 | static void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); } | 0 |
770 | #endif | - |
771 | const 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 | | - |
789 | static 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 yes Evaluation Count:14 | yes Evaluation Count:16355 |
| 14-16355 |
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:14 | 14 |
797 | } | - |
798 | | - |
799 | // this logic should match with QVariantIntegrator::CanUseInternalSpace | - |
800 | if (size <= sizeof(QVariant::Private::Data) evaluated: size <= sizeof(QVariant::Private::Data) yes Evaluation Count:15350 | yes Evaluation Count:1005 |
| 1005-15350 |
801 | && (type.flags() & QMetaType::MovableType)) { evaluated: (type.flags() & QMetaType::MovableType) yes Evaluation Count:13095 | yes Evaluation Count:2255 |
| 2255-13095 |
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:13095 | 13095 |
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:3260 | 3260 |
809 | } | - |
810 | | - |
811 | static void customClear(QVariant::Private *d) | - |
812 | { | - |
813 | if (!d->is_shared) { evaluated: !d->is_shared yes Evaluation Count:16711 | yes Evaluation Count:3408 |
| 3408-16711 |
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:16711 | 16711 |
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:3408 | 3408 |
819 | } | - |
820 | | - |
821 | static bool customIsNull(const QVariant::Private *d) | - |
822 | { | - |
823 | return d->is_null; executed: return d->is_null; Execution Count:271 | 271 |
824 | } | - |
825 | | - |
826 | static 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) no Evaluation Count:0 | yes Evaluation Count:76 |
never evaluated: __builtin_expect(!!(!QMetaType::isRegistered(a->type)), true) | 0-76 |
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 yes Evaluation Count:6 | yes Evaluation Count:70 |
| 6-70 |
833 | const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr); evaluated: b->is_shared yes Evaluation Count:6 | yes Evaluation Count:70 |
| 6-70 |
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 yes Evaluation Count:76 | no Evaluation Count:0 |
evaluated: typeName[typeNameLen - 1] == '*' yes Evaluation Count:15 | yes Evaluation Count:61 |
| 0-76 |
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 no Evaluation Count:0 | yes Evaluation Count:61 |
never evaluated: b->is_null | 0-61 |
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:61 | 61 |
843 | } | - |
844 | | - |
845 | static bool customConvert(const QVariant::Private *, int, void *, bool *ok) | - |
846 | { | - |
847 | if (ok) partially evaluated: ok 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) | - |
853 | static 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 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 | | - |
865 | const 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 | | - |
885 | static HandlersManager handlerManager; | - |
886 | Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0"); | - |
887 | const 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 | | - |
891 | Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler() | - |
892 | { | - |
893 | return &qt_kernel_variant_handler; executed: return &qt_kernel_variant_handler; Execution Count:121354 | 121354 |
894 | } | - |
895 | | - |
896 | Q_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:94 | 94 |
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 QtCore library, it cannot provide | - |
953 | conversion functions to data types defined in QtGui, 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 | | - |
1096 | void 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:748441 | 748441 |
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 | | - |
1113 | QVariant::~QVariant() | - |
1114 | { | - |
1115 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char)) evaluated: d.is_shared yes Evaluation Count:3249470 | yes Evaluation Count:8687125 |
evaluated: !d.data.shared->ref.deref() yes Evaluation Count:638415 | yes Evaluation Count:2611055 |
evaluated: !d.is_shared yes Evaluation Count:8687125 | yes Evaluation Count:2611055 |
evaluated: d.type > Char yes Evaluation Count:5626367 | yes Evaluation Count:3060756 |
| 638415-8687125 |
1116 | handlerManager[d.type]->clear(&d); executed: handlerManager[d.type]->clear(&d); Execution Count:6264782 | 6264782 |
1117 | } executed: } Execution Count:11936593 | 11936593 |
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 | | - |
1126 | QVariant::QVariant(const QVariant &p) | - |
1127 | : d(p.d) | - |
1128 | { | - |
1129 | if (d.is_shared) { evaluated: d.is_shared yes Evaluation Count:2610227 | yes Evaluation Count:5580697 |
| 2610227-5580697 |
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:2610227 evaluated: p.d.type > Char yes Evaluation Count:4401950 | yes Evaluation Count:1178747 |
| 1178747-4401950 |
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:4401950 | 4401950 |
1135 | } | - |
1136 | | - |
1137 | #ifndef QT_NO_DATASTREAM | - |
1138 | /*! | - |
1139 | Reads the variant from the data stream, \a s. | - |
1140 | */ | - |
1141 | QVariant::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 | } | 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 | - |
1176 | QVariant::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:10268 | 10268 |
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 ®Exp) | - |
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 | | - |
1410 | QVariant::QVariant(Type type) | - |
1411 | { create(type, 0); } executed: } Execution Count:7764 | 7764 |
1412 | QVariant::QVariant(int typeId, const void *copy) | - |
1413 | { create(typeId, copy); d.is_null = false; } executed: } Execution Count:710087 | 710087 |
1414 | | - |
1415 | /*! | - |
1416 | \internal | - |
1417 | flags is true if it is a pointer type | - |
1418 | */ | - |
1419 | QVariant::QVariant(int typeId, const void *copy, uint flags) | - |
1420 | { | - |
1421 | if (flags) { //type is a pointer type evaluated: flags yes Evaluation Count:3627 | yes Evaluation Count:7755 |
| 3627-7755 |
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:3627 | 3627 |
1425 | create(typeId, copy); executed (the execution status of this line is deduced): create(typeId, copy); | - |
1426 | } executed: } Execution Count:7755 | 7755 |
1427 | d.is_null = false; executed (the execution status of this line is deduced): d.is_null = false; | - |
1428 | } executed: } Execution Count:11382 | 11382 |
1429 | | - |
1430 | QVariant::QVariant(int val) | - |
1431 | : d(Int) | - |
1432 | { d.data.i = val; } executed: } Execution Count:393665 | 393665 |
1433 | QVariant::QVariant(uint val) | - |
1434 | : d(UInt) | - |
1435 | { d.data.u = val; } executed: } Execution Count:391 | 391 |
1436 | QVariant::QVariant(qlonglong val) | - |
1437 | : d(LongLong) | - |
1438 | { d.data.ll = val; } executed: } Execution Count:39810 | 39810 |
1439 | QVariant::QVariant(qulonglong val) | - |
1440 | : d(ULongLong) | - |
1441 | { d.data.ull = val; } executed: } Execution Count:28 | 28 |
1442 | QVariant::QVariant(bool val) | - |
1443 | : d(Bool) | - |
1444 | { d.data.b = val; } executed: } Execution Count:87406 | 87406 |
1445 | QVariant::QVariant(double val) | - |
1446 | : d(Double) | - |
1447 | { d.data.d = val; } executed: } Execution Count:55183 | 55183 |
1448 | QVariant::QVariant(float val) | - |
1449 | : d(QMetaType::Float) | - |
1450 | { d.data.f = val; } executed: } Execution Count:139 | 139 |
1451 | | - |
1452 | QVariant::QVariant(const QByteArray &val) | - |
1453 | : d(ByteArray) | - |
1454 | { v_construct<QByteArray>(&d, val); } executed: } Execution Count:932 | 932 |
1455 | QVariant::QVariant(const QBitArray &val) | - |
1456 | : d(BitArray) | - |
1457 | { v_construct<QBitArray>(&d, val); } executed: } Execution Count:6 | 6 |
1458 | QVariant::QVariant(const QString &val) | - |
1459 | : d(String) | - |
1460 | { v_construct<QString>(&d, val); } executed: } Execution Count:1137326 | 1137326 |
1461 | QVariant::QVariant(QChar val) | - |
1462 | : d(Char) | - |
1463 | { v_construct<QChar>(&d, val); } executed: } Execution Count:233 | 233 |
1464 | QVariant::QVariant(QLatin1String val) | - |
1465 | : d(String) | - |
1466 | { v_construct<QString>(&d, val); } executed: } Execution Count:126 | 126 |
1467 | QVariant::QVariant(const QStringList &val) | - |
1468 | : d(StringList) | - |
1469 | { v_construct<QStringList>(&d, val); } executed: } Execution Count:159 | 159 |
1470 | | - |
1471 | QVariant::QVariant(const QDate &val) | - |
1472 | : d(Date) | - |
1473 | { v_construct<QDate>(&d, val); } executed: } Execution Count:1576 | 1576 |
1474 | QVariant::QVariant(const QTime &val) | - |
1475 | : d(Time) | - |
1476 | { v_construct<QTime>(&d, val); } executed: } Execution Count:1555 | 1555 |
1477 | QVariant::QVariant(const QDateTime &val) | - |
1478 | : d(DateTime) | - |
1479 | { v_construct<QDateTime>(&d, val); } executed: } Execution Count:15833 | 15833 |
1480 | #ifndef QT_BOOTSTRAPPED | - |
1481 | QVariant::QVariant(const QEasingCurve &val) | - |
1482 | : d(EasingCurve) | - |
1483 | { v_construct<QEasingCurve>(&d, val); } executed: } Execution Count:3 | 3 |
1484 | #endif | - |
1485 | QVariant::QVariant(const QList<QVariant> &list) | - |
1486 | : d(List) | - |
1487 | { v_construct<QVariantList>(&d, list); } executed: } Execution Count:264 | 264 |
1488 | QVariant::QVariant(const QMap<QString, QVariant> &map) | - |
1489 | : d(Map) | - |
1490 | { v_construct<QVariantMap>(&d, map); } executed: } Execution Count:887 | 887 |
1491 | QVariant::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 | - |
1495 | QVariant::QVariant(const QPoint &pt) | - |
1496 | : d(Point) | - |
1497 | { v_construct<QPoint>(&d, pt); } executed: } Execution Count:3 | 3 |
1498 | QVariant::QVariant(const QPointF &pt) | - |
1499 | : d(PointF) | - |
1500 | { v_construct<QPointF>(&d, pt); } executed: } Execution Count:32 | 32 |
1501 | QVariant::QVariant(const QRectF &r) | - |
1502 | : d(RectF) | - |
1503 | { v_construct<QRectF>(&d, r); } executed: } Execution Count:9 | 9 |
1504 | QVariant::QVariant(const QLineF &l) | - |
1505 | : d(LineF) | - |
1506 | { v_construct<QLineF>(&d, l); } executed: } Execution Count:5 | 5 |
1507 | QVariant::QVariant(const QLine &l) | - |
1508 | : d(Line) | - |
1509 | { v_construct<QLine>(&d, l); } executed: } Execution Count:5 | 5 |
1510 | QVariant::QVariant(const QRect &r) | - |
1511 | : d(Rect) | - |
1512 | { v_construct<QRect>(&d, r); } executed: } Execution Count:771 | 771 |
1513 | QVariant::QVariant(const QSize &s) | - |
1514 | : d(Size) | - |
1515 | { v_construct<QSize>(&d, s); } executed: } Execution Count:323 | 323 |
1516 | QVariant::QVariant(const QSizeF &s) | - |
1517 | : d(SizeF) | - |
1518 | { v_construct<QSizeF>(&d, s); } executed: } Execution Count:16 | 16 |
1519 | #endif | - |
1520 | #ifndef QT_BOOTSTRAPPED | - |
1521 | QVariant::QVariant(const QUrl &u) | - |
1522 | : d(Url) | - |
1523 | { v_construct<QUrl>(&d, u); } executed: } Execution Count:2502 | 2502 |
1524 | #endif | - |
1525 | QVariant::QVariant(const QLocale &l) | - |
1526 | : d(Locale) | - |
1527 | { v_construct<QLocale>(&d, l); } executed: } Execution Count:2 | 2 |
1528 | #ifndef QT_NO_REGEXP | - |
1529 | QVariant::QVariant(const QRegExp ®Exp) | - |
1530 | : d(RegExp) | - |
1531 | { v_construct<QRegExp>(&d, regExp); } executed: } Execution Count:46 | 46 |
1532 | #ifndef QT_BOOTSTRAPPED | - |
1533 | QVariant::QVariant(const QRegularExpression &re) | - |
1534 | : d(RegularExpression) | - |
1535 | { v_construct<QRegularExpression>(&d, re); } executed: } Execution Count:4 | 4 |
1536 | QVariant::QVariant(const QUuid &uuid) | - |
1537 | : d(Uuid) | - |
1538 | { v_construct<QUuid>(&d, uuid); } executed: } Execution Count:1 | 1 |
1539 | QVariant::QVariant(const QModelIndex &modelIndex) | - |
1540 | : d(ModelIndex) | - |
1541 | { v_construct<QModelIndex>(&d, modelIndex); } executed: } Execution Count:1 | 1 |
1542 | QVariant::QVariant(const QJsonValue &jsonValue) | - |
1543 | : d(QMetaType::QJsonValue) | - |
1544 | { v_construct<QJsonValue>(&d, jsonValue); } executed: } Execution Count:1 | 1 |
1545 | QVariant::QVariant(const QJsonObject &jsonObject) | - |
1546 | : d(QMetaType::QJsonObject) | - |
1547 | { v_construct<QJsonObject>(&d, jsonObject); } executed: } Execution Count:1 | 1 |
1548 | QVariant::QVariant(const QJsonArray &jsonArray) | - |
1549 | : d(QMetaType::QJsonArray) | - |
1550 | { v_construct<QJsonArray>(&d, jsonArray); } executed: } Execution Count:1 | 1 |
1551 | QVariant::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 | | - |
1589 | QVariant::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:317017 | 317017 |
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 | | - |
1601 | int QVariant::userType() const | - |
1602 | { | - |
1603 | return d.type; executed: return d.type; Execution Count:572078 | 572078 |
1604 | } | - |
1605 | | - |
1606 | /*! | - |
1607 | Assigns the value of the variant \a variant to this variant. | - |
1608 | */ | - |
1609 | QVariant& QVariant::operator=(const QVariant &variant) | - |
1610 | { | - |
1611 | if (this == &variant) evaluated: this == &variant yes Evaluation Count:255 | yes Evaluation Count:314404 |
| 255-314404 |
1612 | return *this; executed: return *this; Execution Count:255 | 255 |
1613 | | - |
1614 | clear(); executed (the execution status of this line is deduced): clear(); | - |
1615 | if (variant.d.is_shared) { evaluated: variant.d.is_shared yes Evaluation Count:950 | yes Evaluation Count:313454 |
| 950-313454 |
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:950 evaluated: variant.d.type > Char yes Evaluation Count:150625 | yes Evaluation Count:162829 |
| 950-162829 |
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:150625 | 150625 |
1623 | d = variant.d; executed (the execution status of this line is deduced): d = variant.d; | - |
1624 | } executed: } Execution Count:162829 | 162829 |
1625 | | - |
1626 | return *this; executed: return *this; Execution Count:314404 | 314404 |
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 | | - |
1643 | void QVariant::detach() | - |
1644 | { | - |
1645 | if (!d.is_shared || d.data.shared->ref.load() == 1) evaluated: !d.is_shared yes Evaluation Count:3431 | yes Evaluation Count:1470 |
evaluated: d.data.shared->ref.load() == 1 yes Evaluation Count:1449 | yes Evaluation Count:21 |
| 21-3431 |
1646 | return; executed: return; Execution Count:4880 | 4880 |
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() 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 | */ | - |
1668 | const char *QVariant::typeName() const | - |
1669 | { | - |
1670 | return QMetaType::typeName(d.type); executed: return QMetaType::typeName(d.type); Execution Count:878 | 878 |
1671 | } | - |
1672 | | - |
1673 | /*! | - |
1674 | Convert this variant to type Invalid and free up any resources | - |
1675 | used. | - |
1676 | */ | - |
1677 | void QVariant::clear() | - |
1678 | { | - |
1679 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char)) evaluated: d.is_shared yes Evaluation Count:265 | yes Evaluation Count:332318 |
evaluated: !d.data.shared->ref.deref() yes Evaluation Count:166 | yes Evaluation Count:99 |
evaluated: !d.is_shared yes Evaluation Count:332318 | yes Evaluation Count:99 |
evaluated: d.type > Char yes Evaluation Count:129680 | yes Evaluation Count:202638 |
| 99-332318 |
1680 | handlerManager[d.type]->clear(&d); executed: handlerManager[d.type]->clear(&d); Execution Count:129846 | 129846 |
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:332583 | 332583 |
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 | */ | - |
1692 | const 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 | */ | - |
1705 | QVariant::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 | - |
1712 | enum { MapFromThreeCount = 36 }; | - |
1713 | static 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 | */ | - |
1759 | void 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 yes Evaluation Count:1 | yes Evaluation Count:12317 |
| 1-12317 |
1766 | if (typeId >= MapFromThreeCount) partially evaluated: typeId >= MapFromThreeCount no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1767 | 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 yes Evaluation Count:83 | yes Evaluation Count:12234 |
| 1-12234 |
1770 | if (typeId == 127 /* QVariant::UserType */) { partially evaluated: typeId == 127 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 yes Evaluation Count:16 | yes Evaluation Count:67 |
partially evaluated: typeId != QVariant::UserType 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 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 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 | } | 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 yes Evaluation Count:12309 | yes Evaluation Count:9 |
| 9-12309 |
1787 | s >> is_null; executed: s >> is_null; Execution Count:12309 | 12309 |
1788 | if (typeId == QVariant::UserType) { evaluated: typeId == QVariant::UserType yes Evaluation Count:3 | yes Evaluation Count:12315 |
| 3-12315 |
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 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; | 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() yes Evaluation Count:13 | yes Evaluation Count:12305 |
| 13-12305 |
1801 | if (s.version() < QDataStream::Qt_5_0) { evaluated: s.version() < QDataStream::Qt_5_0 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())) yes Evaluation Count:1 | yes Evaluation Count:12304 |
| 1-12304 |
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:12305 | 12305 |
1816 | | - |
1817 | /*! | - |
1818 | Internal function for saving a variant to the stream \a s. Use the | - |
1819 | stream operators instead. | - |
1820 | | - |
1821 | \internal | - |
1822 | */ | - |
1823 | void 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 yes Evaluation Count:9 | yes Evaluation Count:12318 |
| 9-12318 |
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 yes Evaluation Count:76 | yes Evaluation Count:1 |
| 1-76 |
1829 | if (mapIdFromQt3ToCurrent[i] == typeId) { evaluated: mapIdFromQt3ToCurrent[i] == typeId 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 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 yes Evaluation Count:96 | yes Evaluation Count:12222 |
| 8-12222 |
1839 | if (typeId == QMetaType::User) { partially evaluated: typeId == QMetaType::User 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 yes Evaluation Count:9 | yes Evaluation Count:87 |
evaluated: typeId <= LastCoreType 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 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 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 | } | 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 yes Evaluation Count:12264 | yes Evaluation Count:62 |
| 62-12264 |
1854 | s << qint8(d.is_null); executed: s << qint8(d.is_null); Execution Count:12264 | 12264 |
1855 | if (d.type >= QVariant::UserType) { evaluated: d.type >= QVariant::UserType yes Evaluation Count:2 | yes Evaluation Count:12324 |
| 2-12324 |
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() yes Evaluation Count:18 | yes Evaluation Count:12308 |
| 18-12308 |
1860 | if (s.version() < QDataStream::Qt_5_0) evaluated: s.version() < QDataStream::Qt_5_0 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()) no Evaluation Count:0 | yes Evaluation Count:12308 |
| 0-12308 |
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 | } | 0 |
1869 | } executed: } Execution Count:12308 | 12308 |
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 | */ | - |
1878 | QDataStream& 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:12316 | 12316 |
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 | */ | - |
1889 | QDataStream& 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:12327 | 12327 |
1893 | } | - |
1894 | | - |
1895 | /*! | - |
1896 | Reads a variant type \a p in enum representation from the stream \a s. | - |
1897 | */ | - |
1898 | QDataStream& 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 | */ | - |
1910 | QDataStream& 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 | | - |
1926 | template <typename T> | - |
1927 | inline 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 yes Evaluation Count:450971 | yes Evaluation Count:50936 |
| 50936-450971 |
1931 | return *v_cast<T>(&d); executed: return *v_cast<T>(&d); Execution Count:450971 | 450971 |
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:50936 | 50936 |
1936 | } | - |
1937 | | - |
1938 | /*! | - |
1939 | \fn QStringList QVariant::toStringList() const | - |
1940 | | - |
1941 | Returns the variant as a QStringList if the variant has type() | - |
1942 | StringList, \l String, or \l List of a type that can be converted | - |
1943 | to QString; otherwise returns an empty list. | - |
1944 | | - |
1945 | \sa canConvert(), convert() | - |
1946 | */ | - |
1947 | QStringList QVariant::toStringList() const | - |
1948 | { | - |
1949 | return qVariantToHelper<QStringList>(d, handlerManager); executed: return qVariantToHelper<QStringList>(d, handlerManager); Execution Count:129 | 129 |
1950 | } | - |
1951 | | - |
1952 | /*! | - |
1953 | Returns the variant as a QString if the variant has type() \l | - |
1954 | String, \l Bool, \l ByteArray, \l Char, \l Date, \l DateTime, \l | - |
1955 | Double, \l Int, \l LongLong, \l StringList, \l Time, \l UInt, or | - |
1956 | \l ULongLong; otherwise returns an empty string. | - |
1957 | | - |
1958 | \sa canConvert(), convert() | - |
1959 | */ | - |
1960 | QString QVariant::toString() const | - |
1961 | { | - |
1962 | return qVariantToHelper<QString>(d, handlerManager); executed: return qVariantToHelper<QString>(d, handlerManager); Execution Count:385213 | 385213 |
1963 | } | - |
1964 | | - |
1965 | /*! | - |
1966 | Returns the variant as a QMap<QString, QVariant> if the variant | - |
1967 | has type() \l Map; otherwise returns an empty map. | - |
1968 | | - |
1969 | \sa canConvert(), convert() | - |
1970 | */ | - |
1971 | QVariantMap QVariant::toMap() const | - |
1972 | { | - |
1973 | return qVariantToHelper<QVariantMap>(d, handlerManager); executed: return qVariantToHelper<QVariantMap>(d, handlerManager); Execution Count:4 | 4 |
1974 | } | - |
1975 | | - |
1976 | /*! | - |
1977 | Returns the variant as a QHash<QString, QVariant> if the variant | - |
1978 | has type() \l Hash; otherwise returns an empty map. | - |
1979 | | - |
1980 | \sa canConvert(), convert() | - |
1981 | */ | - |
1982 | QVariantHash QVariant::toHash() const | - |
1983 | { | - |
1984 | return qVariantToHelper<QVariantHash>(d, handlerManager); never executed: return qVariantToHelper<QVariantHash>(d, handlerManager); | 0 |
1985 | } | - |
1986 | | - |
1987 | /*! | - |
1988 | \fn QDate QVariant::toDate() const | - |
1989 | | - |
1990 | Returns the variant as a QDate if the variant has type() \l Date, | - |
1991 | \l DateTime, or \l String; otherwise returns an invalid date. | - |
1992 | | - |
1993 | If the type() is \l String, an invalid date will be returned if the | - |
1994 | string cannot be parsed as a Qt::ISODate format date. | - |
1995 | | - |
1996 | \sa canConvert(), convert() | - |
1997 | */ | - |
1998 | QDate QVariant::toDate() const | - |
1999 | { | - |
2000 | return qVariantToHelper<QDate>(d, handlerManager); executed: return qVariantToHelper<QDate>(d, handlerManager); Execution Count:11391 | 11391 |
2001 | } | - |
2002 | | - |
2003 | /*! | - |
2004 | \fn QTime QVariant::toTime() const | - |
2005 | | - |
2006 | Returns the variant as a QTime if the variant has type() \l Time, | - |
2007 | \l DateTime, or \l String; otherwise returns an invalid time. | - |
2008 | | - |
2009 | If the type() is \l String, an invalid time will be returned if | - |
2010 | the string cannot be parsed as a Qt::ISODate format time. | - |
2011 | | - |
2012 | \sa canConvert(), convert() | - |
2013 | */ | - |
2014 | QTime QVariant::toTime() const | - |
2015 | { | - |
2016 | return qVariantToHelper<QTime>(d, handlerManager); executed: return qVariantToHelper<QTime>(d, handlerManager); Execution Count:10758 | 10758 |
2017 | } | - |
2018 | | - |
2019 | /*! | - |
2020 | \fn QDateTime QVariant::toDateTime() const | - |
2021 | | - |
2022 | Returns the variant as a QDateTime if the variant has type() \l | - |
2023 | DateTime, \l Date, or \l String; otherwise returns an invalid | - |
2024 | date/time. | - |
2025 | | - |
2026 | If the type() is \l String, an invalid date/time will be returned | - |
2027 | if the string cannot be parsed as a Qt::ISODate format date/time. | - |
2028 | | - |
2029 | \sa canConvert(), convert() | - |
2030 | */ | - |
2031 | QDateTime QVariant::toDateTime() const | - |
2032 | { | - |
2033 | return qVariantToHelper<QDateTime>(d, handlerManager); executed: return qVariantToHelper<QDateTime>(d, handlerManager); Execution Count:88175 | 88175 |
2034 | } | - |
2035 | | - |
2036 | /*! | - |
2037 | \since 4.7 | - |
2038 | \fn QEasingCurve QVariant::toEasingCurve() const | - |
2039 | | - |
2040 | Returns the variant as a QEasingCurve if the variant has type() \l | - |
2041 | EasingCurve; otherwise returns a default easing curve. | - |
2042 | | - |
2043 | \sa canConvert(), convert() | - |
2044 | */ | - |
2045 | #ifndef QT_BOOTSTRAPPED | - |
2046 | QEasingCurve QVariant::toEasingCurve() const | - |
2047 | { | - |
2048 | return qVariantToHelper<QEasingCurve>(d, handlerManager); executed: return qVariantToHelper<QEasingCurve>(d, handlerManager); Execution Count:3 | 3 |
2049 | } | - |
2050 | #endif | - |
2051 | | - |
2052 | /*! | - |
2053 | \fn QByteArray QVariant::toByteArray() const | - |
2054 | | - |
2055 | Returns the variant as a QByteArray if the variant has type() \l | - |
2056 | ByteArray or \l String (converted using QString::fromUtf8()); | - |
2057 | otherwise returns an empty byte array. | - |
2058 | | - |
2059 | \sa canConvert(), convert() | - |
2060 | */ | - |
2061 | QByteArray QVariant::toByteArray() const | - |
2062 | { | - |
2063 | return qVariantToHelper<QByteArray>(d, handlerManager); executed: return qVariantToHelper<QByteArray>(d, handlerManager); Execution Count:1101 | 1101 |
2064 | } | - |
2065 | | - |
2066 | #ifndef QT_NO_GEOM_VARIANT | - |
2067 | /*! | - |
2068 | \fn QPoint QVariant::toPoint() const | - |
2069 | | - |
2070 | Returns the variant as a QPoint if the variant has type() | - |
2071 | \l Point or \l PointF; otherwise returns a null QPoint. | - |
2072 | | - |
2073 | \sa canConvert(), convert() | - |
2074 | */ | - |
2075 | QPoint QVariant::toPoint() const | - |
2076 | { | - |
2077 | return qVariantToHelper<QPoint>(d, handlerManager); executed: return qVariantToHelper<QPoint>(d, handlerManager); Execution Count:6 | 6 |
2078 | } | - |
2079 | | - |
2080 | /*! | - |
2081 | \fn QRect QVariant::toRect() const | - |
2082 | | - |
2083 | Returns the variant as a QRect if the variant has type() \l Rect; | - |
2084 | otherwise returns an invalid QRect. | - |
2085 | | - |
2086 | \sa canConvert(), convert() | - |
2087 | */ | - |
2088 | QRect QVariant::toRect() const | - |
2089 | { | - |
2090 | return qVariantToHelper<QRect>(d, handlerManager); executed: return qVariantToHelper<QRect>(d, handlerManager); Execution Count:115 | 115 |
2091 | } | - |
2092 | | - |
2093 | /*! | - |
2094 | \fn QSize QVariant::toSize() const | - |
2095 | | - |
2096 | Returns the variant as a QSize if the variant has type() \l Size; | - |
2097 | otherwise returns an invalid QSize. | - |
2098 | | - |
2099 | \sa canConvert(), convert() | - |
2100 | */ | - |
2101 | QSize QVariant::toSize() const | - |
2102 | { | - |
2103 | return qVariantToHelper<QSize>(d, handlerManager); executed: return qVariantToHelper<QSize>(d, handlerManager); Execution Count:88 | 88 |
2104 | } | - |
2105 | | - |
2106 | /*! | - |
2107 | \fn QSizeF QVariant::toSizeF() const | - |
2108 | | - |
2109 | Returns the variant as a QSizeF if the variant has type() \l | - |
2110 | SizeF; otherwise returns an invalid QSizeF. | - |
2111 | | - |
2112 | \sa canConvert(), convert() | - |
2113 | */ | - |
2114 | QSizeF QVariant::toSizeF() const | - |
2115 | { | - |
2116 | return qVariantToHelper<QSizeF>(d, handlerManager); executed: return qVariantToHelper<QSizeF>(d, handlerManager); Execution Count:16 | 16 |
2117 | } | - |
2118 | | - |
2119 | /*! | - |
2120 | \fn QRectF QVariant::toRectF() const | - |
2121 | | - |
2122 | Returns the variant as a QRectF if the variant has type() \l Rect | - |
2123 | or \l RectF; otherwise returns an invalid QRectF. | - |
2124 | | - |
2125 | \sa canConvert(), convert() | - |
2126 | */ | - |
2127 | QRectF QVariant::toRectF() const | - |
2128 | { | - |
2129 | return qVariantToHelper<QRectF>(d, handlerManager); executed: return qVariantToHelper<QRectF>(d, handlerManager); Execution Count:4 | 4 |
2130 | } | - |
2131 | | - |
2132 | /*! | - |
2133 | \fn QLineF QVariant::toLineF() const | - |
2134 | | - |
2135 | Returns the variant as a QLineF if the variant has type() \l | - |
2136 | LineF; otherwise returns an invalid QLineF. | - |
2137 | | - |
2138 | \sa canConvert(), convert() | - |
2139 | */ | - |
2140 | QLineF QVariant::toLineF() const | - |
2141 | { | - |
2142 | return qVariantToHelper<QLineF>(d, handlerManager); executed: return qVariantToHelper<QLineF>(d, handlerManager); Execution Count:5 | 5 |
2143 | } | - |
2144 | | - |
2145 | /*! | - |
2146 | \fn QLine QVariant::toLine() const | - |
2147 | | - |
2148 | Returns the variant as a QLine if the variant has type() \l Line; | - |
2149 | otherwise returns an invalid QLine. | - |
2150 | | - |
2151 | \sa canConvert(), convert() | - |
2152 | */ | - |
2153 | QLine QVariant::toLine() const | - |
2154 | { | - |
2155 | return qVariantToHelper<QLine>(d, handlerManager); executed: return qVariantToHelper<QLine>(d, handlerManager); Execution Count:5 | 5 |
2156 | } | - |
2157 | | - |
2158 | /*! | - |
2159 | \fn QPointF QVariant::toPointF() const | - |
2160 | | - |
2161 | Returns the variant as a QPointF if the variant has type() \l | - |
2162 | Point or \l PointF; otherwise returns a null QPointF. | - |
2163 | | - |
2164 | \sa canConvert(), convert() | - |
2165 | */ | - |
2166 | QPointF QVariant::toPointF() const | - |
2167 | { | - |
2168 | return qVariantToHelper<QPointF>(d, handlerManager); executed: return qVariantToHelper<QPointF>(d, handlerManager); Execution Count:757 | 757 |
2169 | } | - |
2170 | | - |
2171 | #endif // QT_NO_GEOM_VARIANT | - |
2172 | | - |
2173 | #ifndef QT_BOOTSTRAPPED | - |
2174 | /*! | - |
2175 | \fn QUrl QVariant::toUrl() const | - |
2176 | | - |
2177 | Returns the variant as a QUrl if the variant has type() | - |
2178 | \l Url; otherwise returns an invalid QUrl. | - |
2179 | | - |
2180 | \sa canConvert(), convert() | - |
2181 | */ | - |
2182 | QUrl QVariant::toUrl() const | - |
2183 | { | - |
2184 | return qVariantToHelper<QUrl>(d, handlerManager); executed: return qVariantToHelper<QUrl>(d, handlerManager); Execution Count:3958 | 3958 |
2185 | } | - |
2186 | #endif | - |
2187 | | - |
2188 | /*! | - |
2189 | \fn QLocale QVariant::toLocale() const | - |
2190 | | - |
2191 | Returns the variant as a QLocale if the variant has type() | - |
2192 | \l Locale; otherwise returns an invalid QLocale. | - |
2193 | | - |
2194 | \sa canConvert(), convert() | - |
2195 | */ | - |
2196 | QLocale QVariant::toLocale() const | - |
2197 | { | - |
2198 | return qVariantToHelper<QLocale>(d, handlerManager); executed: return qVariantToHelper<QLocale>(d, handlerManager); Execution Count:3 | 3 |
2199 | } | - |
2200 | | - |
2201 | /*! | - |
2202 | \fn QRegExp QVariant::toRegExp() const | - |
2203 | \since 4.1 | - |
2204 | | - |
2205 | Returns the variant as a QRegExp if the variant has type() \l | - |
2206 | RegExp; otherwise returns an empty QRegExp. | - |
2207 | | - |
2208 | \sa canConvert(), convert() | - |
2209 | */ | - |
2210 | #ifndef QT_NO_REGEXP | - |
2211 | QRegExp QVariant::toRegExp() const | - |
2212 | { | - |
2213 | return qVariantToHelper<QRegExp>(d, handlerManager); executed: return qVariantToHelper<QRegExp>(d, handlerManager); Execution Count:45 | 45 |
2214 | } | - |
2215 | #endif | - |
2216 | | - |
2217 | /*! | - |
2218 | \fn QRegularExpression QVariant::toRegularExpression() const | - |
2219 | \since 5.0 | - |
2220 | | - |
2221 | Returns the variant as a QRegularExpression if the variant has type() \l | - |
2222 | QRegularExpression; otherwise returns an empty QRegularExpression. | - |
2223 | | - |
2224 | \sa canConvert(), convert() | - |
2225 | */ | - |
2226 | #ifndef QT_BOOTSTRAPPED | - |
2227 | #ifndef QT_NO_REGEXP | - |
2228 | QRegularExpression QVariant::toRegularExpression() const | - |
2229 | { | - |
2230 | return qVariantToHelper<QRegularExpression>(d, handlerManager); executed: return qVariantToHelper<QRegularExpression>(d, handlerManager); Execution Count:3 | 3 |
2231 | } | - |
2232 | #endif | - |
2233 | | - |
2234 | /*! | - |
2235 | \since 5.0 | - |
2236 | | - |
2237 | Returns the variant as a QUuid if the variant has type() \l | - |
2238 | QUuid; otherwise returns a default constructed QUuid. | - |
2239 | | - |
2240 | \sa canConvert(), convert() | - |
2241 | */ | - |
2242 | QUuid QVariant::toUuid() const | - |
2243 | { | - |
2244 | return qVariantToHelper<QUuid>(d, handlerManager); executed: return qVariantToHelper<QUuid>(d, handlerManager); Execution Count:1 | 1 |
2245 | } | - |
2246 | | - |
2247 | /*! | - |
2248 | \since 5.0 | - |
2249 | | - |
2250 | Returns the variant as a QModelIndex if the variant has type() \l | - |
2251 | QModelIndex; otherwise returns a default constructed QModelIndex. | - |
2252 | | - |
2253 | \sa canConvert(), convert() | - |
2254 | */ | - |
2255 | QModelIndex QVariant::toModelIndex() const | - |
2256 | { | - |
2257 | return qVariantToHelper<QModelIndex>(d, handlerManager); executed: return qVariantToHelper<QModelIndex>(d, handlerManager); Execution Count:1 | 1 |
2258 | } | - |
2259 | | - |
2260 | /*! | - |
2261 | \since 5.0 | - |
2262 | | - |
2263 | Returns the variant as a QJsonValue if the variant has type() \l | - |
2264 | QJsonValue; otherwise returns a default constructed QJsonValue. | - |
2265 | | - |
2266 | \sa canConvert(), convert() | - |
2267 | */ | - |
2268 | QJsonValue QVariant::toJsonValue() const | - |
2269 | { | - |
2270 | return qVariantToHelper<QJsonValue>(d, handlerManager); executed: return qVariantToHelper<QJsonValue>(d, handlerManager); Execution Count:1 | 1 |
2271 | } | - |
2272 | | - |
2273 | /*! | - |
2274 | \since 5.0 | - |
2275 | | - |
2276 | Returns the variant as a QJsonObject if the variant has type() \l | - |
2277 | QJsonObject; otherwise returns a default constructed QJsonObject. | - |
2278 | | - |
2279 | \sa canConvert(), convert() | - |
2280 | */ | - |
2281 | QJsonObject QVariant::toJsonObject() const | - |
2282 | { | - |
2283 | return qVariantToHelper<QJsonObject>(d, handlerManager); executed: return qVariantToHelper<QJsonObject>(d, handlerManager); Execution Count:1 | 1 |
2284 | } | - |
2285 | | - |
2286 | /*! | - |
2287 | \since 5.0 | - |
2288 | | - |
2289 | Returns the variant as a QJsonArray if the variant has type() \l | - |
2290 | QJsonArray; otherwise returns a default constructed QJsonArray. | - |
2291 | | - |
2292 | \sa canConvert(), convert() | - |
2293 | */ | - |
2294 | QJsonArray QVariant::toJsonArray() const | - |
2295 | { | - |
2296 | return qVariantToHelper<QJsonArray>(d, handlerManager); executed: return qVariantToHelper<QJsonArray>(d, handlerManager); Execution Count:1 | 1 |
2297 | } | - |
2298 | | - |
2299 | /*! | - |
2300 | \since 5.0 | - |
2301 | | - |
2302 | Returns the variant as a QJsonDocument if the variant has type() \l | - |
2303 | QJsonDocument; otherwise returns a default constructed QJsonDocument. | - |
2304 | | - |
2305 | \sa canConvert(), convert() | - |
2306 | */ | - |
2307 | QJsonDocument QVariant::toJsonDocument() const | - |
2308 | { | - |
2309 | return qVariantToHelper<QJsonDocument>(d, handlerManager); executed: return qVariantToHelper<QJsonDocument>(d, handlerManager); Execution Count:1 | 1 |
2310 | } | - |
2311 | #endif | - |
2312 | | - |
2313 | /*! | - |
2314 | \fn QChar QVariant::toChar() const | - |
2315 | | - |
2316 | Returns the variant as a QChar if the variant has type() \l Char, | - |
2317 | \l Int, or \l UInt; otherwise returns an invalid QChar. | - |
2318 | | - |
2319 | \sa canConvert(), convert() | - |
2320 | */ | - |
2321 | QChar QVariant::toChar() const | - |
2322 | { | - |
2323 | return qVariantToHelper<QChar>(d, handlerManager); executed: return qVariantToHelper<QChar>(d, handlerManager); Execution Count:3 | 3 |
2324 | } | - |
2325 | | - |
2326 | /*! | - |
2327 | Returns the variant as a QBitArray if the variant has type() | - |
2328 | \l BitArray; otherwise returns an empty bit array. | - |
2329 | | - |
2330 | \sa canConvert(), convert() | - |
2331 | */ | - |
2332 | QBitArray QVariant::toBitArray() const | - |
2333 | { | - |
2334 | return qVariantToHelper<QBitArray>(d, handlerManager); executed: return qVariantToHelper<QBitArray>(d, handlerManager); Execution Count:1 | 1 |
2335 | } | - |
2336 | | - |
2337 | template <typename T> | - |
2338 | inline T qNumVariantToHelper(const QVariant::Private &d, | - |
2339 | const HandlersManager &handlerManager, bool *ok, const T& val) | - |
2340 | { | - |
2341 | uint t = qMetaTypeId<T>(); executed (the execution status of this line is deduced): uint t = qMetaTypeId<T>(); | - |
2342 | if (ok) evaluated: ok yes Evaluation Count:879 | yes Evaluation Count:338708 |
| 879-338708 |
2343 | *ok = true; executed: *ok = true; Execution Count:879 | 879 |
2344 | if (d.type == t) evaluated: d.type == t yes Evaluation Count:327826 | yes Evaluation Count:11761 |
| 11761-327826 |
2345 | return val; executed: return val; Execution Count:327826 | 327826 |
2346 | | - |
2347 | T ret = 0; executed (the execution status of this line is deduced): T ret = 0; | - |
2348 | if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok) evaluated: !handlerManager[d.type]->convert(&d, t, &ret, ok) yes Evaluation Count:983 | yes Evaluation Count:10778 |
evaluated: ok yes Evaluation Count:8 | yes Evaluation Count:975 |
| 8-10778 |
2349 | *ok = false; executed: *ok = false; Execution Count:8 | 8 |
2350 | return ret; executed: return ret; Execution Count:11761 | 11761 |
2351 | } | - |
2352 | | - |
2353 | /*! | - |
2354 | Returns the variant as an int if the variant has type() \l Int, | - |
2355 | \l Bool, \l ByteArray, \l Char, \l Double, \l LongLong, \l | - |
2356 | String, \l UInt, or \l ULongLong; otherwise returns 0. | - |
2357 | | - |
2358 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - |
2359 | converted to an int; otherwise \c{*}\a{ok} is set to false. | - |
2360 | | - |
2361 | \b{Warning:} If the value is convertible to a \l LongLong but is too | - |
2362 | large to be represented in an int, the resulting arithmetic overflow will | - |
2363 | not be reflected in \a ok. A simple workaround is to use QString::toInt(). | - |
2364 | | - |
2365 | \sa canConvert(), convert() | - |
2366 | */ | - |
2367 | int QVariant::toInt(bool *ok) const | - |
2368 | { | - |
2369 | return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i); executed: return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i); Execution Count:291097 | 291097 |
2370 | } | - |
2371 | | - |
2372 | /*! | - |
2373 | Returns the variant as an unsigned int if the variant has type() | - |
2374 | \l UInt, \l Bool, \l ByteArray, \l Char, \l Double, \l Int, \l | - |
2375 | LongLong, \l String, or \l ULongLong; otherwise returns 0. | - |
2376 | | - |
2377 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - |
2378 | converted to an unsigned int; otherwise \c{*}\a{ok} is set to false. | - |
2379 | | - |
2380 | \b{Warning:} If the value is convertible to a \l ULongLong but is too | - |
2381 | large to be represented in an unsigned int, the resulting arithmetic overflow will | - |
2382 | not be reflected in \a ok. A simple workaround is to use QString::toUInt(). | - |
2383 | | - |
2384 | \sa canConvert(), convert() | - |
2385 | */ | - |
2386 | uint QVariant::toUInt(bool *ok) const | - |
2387 | { | - |
2388 | return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u); executed: return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u); Execution Count:221 | 221 |
2389 | } | - |
2390 | | - |
2391 | /*! | - |
2392 | Returns the variant as a long long int if the variant has type() | - |
2393 | \l LongLong, \l Bool, \l ByteArray, \l Char, \l Double, \l Int, | - |
2394 | \l String, \l UInt, or \l ULongLong; otherwise returns 0. | - |
2395 | | - |
2396 | If \a ok is non-null: \c{*}\c{ok} is set to true if the value could be | - |
2397 | converted to an int; otherwise \c{*}\c{ok} is set to false. | - |
2398 | | - |
2399 | \sa canConvert(), convert() | - |
2400 | */ | - |
2401 | qlonglong QVariant::toLongLong(bool *ok) const | - |
2402 | { | - |
2403 | return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll); executed: return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll); Execution Count:9197 | 9197 |
2404 | } | - |
2405 | | - |
2406 | /*! | - |
2407 | Returns the variant as as an unsigned long long int if the | - |
2408 | variant has type() \l ULongLong, \l Bool, \l ByteArray, \l Char, | - |
2409 | \l Double, \l Int, \l LongLong, \l String, or \l UInt; otherwise | - |
2410 | returns 0. | - |
2411 | | - |
2412 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - |
2413 | converted to an int; otherwise \c{*}\a{ok} is set to false. | - |
2414 | | - |
2415 | \sa canConvert(), convert() | - |
2416 | */ | - |
2417 | qulonglong QVariant::toULongLong(bool *ok) const | - |
2418 | { | - |
2419 | return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull); executed: return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull); Execution Count:22 | 22 |
2420 | } | - |
2421 | | - |
2422 | /*! | - |
2423 | Returns the variant as a bool if the variant has type() Bool. | - |
2424 | | - |
2425 | Returns true if the variant has type() \l Bool, \l Char, \l Double, | - |
2426 | \l Int, \l LongLong, \l UInt, or \l ULongLong and the value is | - |
2427 | non-zero, or if the variant has type \l String or \l ByteArray and | - |
2428 | its lower-case content is not one of the following: empty, "0" | - |
2429 | or "false"; otherwise returns false. | - |
2430 | | - |
2431 | \sa canConvert(), convert() | - |
2432 | */ | - |
2433 | bool QVariant::toBool() const | - |
2434 | { | - |
2435 | if (d.type == Bool) evaluated: d.type == Bool yes Evaluation Count:23389 | yes Evaluation Count:2955 |
| 2955-23389 |
2436 | return d.data.b; executed: return d.data.b; Execution Count:23389 | 23389 |
2437 | | - |
2438 | bool res = false; executed (the execution status of this line is deduced): bool res = false; | - |
2439 | 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); | - |
2440 | | - |
2441 | return res; executed: return res; Execution Count:2955 | 2955 |
2442 | } | - |
2443 | | - |
2444 | /*! | - |
2445 | Returns the variant as a double if the variant has type() \l | - |
2446 | Double, \l QMetaType::Float, \l Bool, \l ByteArray, \l Int, \l LongLong, \l String, \l | - |
2447 | UInt, or \l ULongLong; otherwise returns 0.0. | - |
2448 | | - |
2449 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - |
2450 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - |
2451 | | - |
2452 | \sa canConvert(), convert() | - |
2453 | */ | - |
2454 | double QVariant::toDouble(bool *ok) const | - |
2455 | { | - |
2456 | return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d); executed: return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d); Execution Count:30273 | 30273 |
2457 | } | - |
2458 | | - |
2459 | /*! | - |
2460 | Returns the variant as a float if the variant has type() \l | - |
2461 | Double, \l QMetaType::Float, \l Bool, \l ByteArray, \l Int, \l LongLong, \l String, \l | - |
2462 | UInt, or \l ULongLong; otherwise returns 0.0. | - |
2463 | | - |
2464 | \since 4.6 | - |
2465 | | - |
2466 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - |
2467 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - |
2468 | | - |
2469 | \sa canConvert(), convert() | - |
2470 | */ | - |
2471 | float QVariant::toFloat(bool *ok) const | - |
2472 | { | - |
2473 | return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f); executed: return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f); Execution Count:130 | 130 |
2474 | } | - |
2475 | | - |
2476 | /*! | - |
2477 | Returns the variant as a qreal if the variant has type() \l | - |
2478 | Double, \l QMetaType::Float, \l Bool, \l ByteArray, \l Int, \l LongLong, \l String, \l | - |
2479 | UInt, or \l ULongLong; otherwise returns 0.0. | - |
2480 | | - |
2481 | \since 4.6 | - |
2482 | | - |
2483 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - |
2484 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - |
2485 | | - |
2486 | \sa canConvert(), convert() | - |
2487 | */ | - |
2488 | qreal QVariant::toReal(bool *ok) const | - |
2489 | { | - |
2490 | return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real); executed: return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real); Execution Count:8647 | 8647 |
2491 | } | - |
2492 | | - |
2493 | /*! | - |
2494 | Returns the variant as a QVariantList if the variant has type() | - |
2495 | \l List or \l StringList; otherwise returns an empty list. | - |
2496 | | - |
2497 | \sa canConvert(), convert() | - |
2498 | */ | - |
2499 | QVariantList QVariant::toList() const | - |
2500 | { | - |
2501 | return qVariantToHelper<QVariantList>(d, handlerManager); executed: return qVariantToHelper<QVariantList>(d, handlerManager); Execution Count:118 | 118 |
2502 | } | - |
2503 | | - |
2504 | | - |
2505 | static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = | - |
2506 | { | - |
2507 | /*Invalid*/ 0, | - |
2508 | | - |
2509 | /*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt | - |
2510 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray | - |
2511 | | 1 << QVariant::String | 1 << QVariant::Char, | - |
2512 | | - |
2513 | /*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double | - |
2514 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - |
2515 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - |
2516 | | - |
2517 | /*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - |
2518 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - |
2519 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - |
2520 | | - |
2521 | /*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - |
2522 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong | - |
2523 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - |
2524 | | - |
2525 | /*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - |
2526 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - |
2527 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - |
2528 | | - |
2529 | /*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong | - |
2530 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - |
2531 | | 1 << QVariant::ByteArray, | - |
2532 | | - |
2533 | /*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong | - |
2534 | | 1 << QVariant::ULongLong, | - |
2535 | | - |
2536 | /*QMap*/ 0, | - |
2537 | | - |
2538 | /*QList*/ 1 << QVariant::StringList, | - |
2539 | | - |
2540 | /*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int | - |
2541 | | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double | - |
2542 | | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime | - |
2543 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char | - |
2544 | | 1 << QVariant::Url | 1 << QVariant::Uuid, | - |
2545 | | - |
2546 | /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, | - |
2547 | | - |
2548 | /*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool | - |
2549 | | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, | - |
2550 | | - |
2551 | /*QBitArray*/ 0, | - |
2552 | | - |
2553 | /*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime, | - |
2554 | | - |
2555 | /*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime, | - |
2556 | | - |
2557 | /*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, | - |
2558 | | - |
2559 | /*QUrl*/ 1 << QVariant::String, | - |
2560 | | - |
2561 | /*QLocale*/ 0, | - |
2562 | | - |
2563 | /*QRect*/ 1 << QVariant::RectF, | - |
2564 | | - |
2565 | /*QRectF*/ 1 << QVariant::Rect, | - |
2566 | | - |
2567 | /*QSize*/ 1 << QVariant::SizeF, | - |
2568 | | - |
2569 | /*QSizeF*/ 1 << QVariant::Size, | - |
2570 | | - |
2571 | /*QLine*/ 1 << QVariant::LineF, | - |
2572 | | - |
2573 | /*QLineF*/ 1 << QVariant::Line, | - |
2574 | | - |
2575 | /*QPoint*/ 1 << QVariant::PointF, | - |
2576 | | - |
2577 | /*QPointF*/ 1 << QVariant::Point, | - |
2578 | | - |
2579 | /*QRegExp*/ 0, | - |
2580 | | - |
2581 | /*QHash*/ 0, | - |
2582 | | - |
2583 | /*QEasingCurve*/ 0, | - |
2584 | | - |
2585 | /*QUuid*/ 1 << QVariant::String | - |
2586 | }; | - |
2587 | | - |
2588 | #ifndef QT_BOOTSTRAPPED | - |
2589 | /*! | - |
2590 | Returns true if from inherits to. | - |
2591 | */ | - |
2592 | static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to) | - |
2593 | { | - |
2594 | if (from && to == &QObject::staticMetaObject) partially evaluated: from yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: to == &QObject::staticMetaObject yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
2595 | return true; executed: return true; Execution Count:4 | 4 |
2596 | | - |
2597 | while (from) { | 0 |
2598 | if (from == to) never evaluated: from == to | 0 |
2599 | return true; never executed: return true; | 0 |
2600 | from = from->superClass(); never executed (the execution status of this line is deduced): from = from->superClass(); | - |
2601 | } | 0 |
2602 | | - |
2603 | return false; never executed: return false; | 0 |
2604 | } | - |
2605 | #endif | - |
2606 | | - |
2607 | static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) | - |
2608 | { | - |
2609 | #ifndef QT_BOOTSTRAPPED | - |
2610 | QMetaType toType(toId); executed (the execution status of this line is deduced): QMetaType toType(toId); | - |
2611 | if ((QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) { evaluated: (QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject) yes Evaluation Count:8 | yes Evaluation Count:48 |
partially evaluated: (toType.flags() & QMetaType::PointerToQObject) yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-48 |
2612 | if (!fromObject) evaluated: !fromObject yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
2613 | return true; executed: return true; Execution Count:4 | 4 |
2614 | return canConvertMetaObject(fromObject->metaObject(), toType.metaObject()); executed: return canConvertMetaObject(fromObject->metaObject(), toType.metaObject()); Execution Count:4 | 4 |
2615 | } | - |
2616 | #else | - |
2617 | Q_UNUSED(fromId); | - |
2618 | Q_UNUSED(toId); | - |
2619 | Q_UNUSED(fromObject); | - |
2620 | #endif | - |
2621 | return false; executed: return false; Execution Count:48 | 48 |
2622 | } | - |
2623 | | - |
2624 | | - |
2625 | /*! | - |
2626 | Returns true if the variant's type can be cast to the requested | - |
2627 | type, \a targetTypeId. Such casting is done automatically when calling the | - |
2628 | toInt(), toBool(), ... methods. | - |
2629 | | - |
2630 | The following casts are done automatically: | - |
2631 | | - |
2632 | \table | - |
2633 | \header \li Type \li Automatically Cast To | - |
2634 | \row \li \l Bool \li \l Char, \l Double, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong | - |
2635 | \row \li \l ByteArray \li \l Double, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong | - |
2636 | \row \li \l Char \li \l Bool, \l Int, \l UInt, \l LongLong, \l ULongLong | - |
2637 | \row \li \l Color \li \l String | - |
2638 | \row \li \l Date \li \l DateTime, \l String | - |
2639 | \row \li \l DateTime \li \l Date, \l String, \l Time | - |
2640 | \row \li \l Double \li \l Bool, \l Int, \l LongLong, \l String, \l UInt, \l ULongLong | - |
2641 | \row \li \l Font \li \l String | - |
2642 | \row \li \l Int \li \l Bool, \l Char, \l Double, \l LongLong, \l String, \l UInt, \l ULongLong | - |
2643 | \row \li \l KeySequence \li \l Int, \l String | - |
2644 | \row \li \l List \li \l StringList (if the list's items can be converted to strings) | - |
2645 | \row \li \l LongLong \li \l Bool, \l ByteArray, \l Char, \l Double, \l Int, \l String, \l UInt, \l ULongLong | - |
2646 | \row \li \l Point \li PointF | - |
2647 | \row \li \l Rect \li RectF | - |
2648 | \row \li \l String \li \l Bool, \l ByteArray, \l Char, \l Color, \l Date, \l DateTime, \l Double, | - |
2649 | \l Font, \l Int, \l KeySequence, \l LongLong, \l StringList, \l Time, \l UInt, | - |
2650 | \l ULongLong | - |
2651 | \row \li \l StringList \li \l List, \l String (if the list contains exactly one item) | - |
2652 | \row \li \l Time \li \l String | - |
2653 | \row \li \l UInt \li \l Bool, \l Char, \l Double, \l Int, \l LongLong, \l String, \l ULongLong | - |
2654 | \row \li \l ULongLong \li \l Bool, \l Char, \l Double, \l Int, \l LongLong, \l String, \l UInt | - |
2655 | \endtable | - |
2656 | | - |
2657 | A QVariant containing a pointer to a type derived from QObject will also return true for this | - |
2658 | function if a qobject_cast to the type described by \a targetTypeId would succeed. Note that | - |
2659 | this only works for QObject subclasses which use the Q_OBJECT macro. | - |
2660 | | - |
2661 | \sa convert() | - |
2662 | */ | - |
2663 | bool QVariant::canConvert(int targetTypeId) const | - |
2664 | { | - |
2665 | // TODO Reimplement this function, currently it works but it is a historical mess. | - |
2666 | uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type); evaluated: (d.type == QMetaType::Float) yes Evaluation Count:55 | yes Evaluation Count:109083 |
| 55-109083 |
2667 | if (currentType == QMetaType::SChar || currentType == QMetaType::Char) evaluated: currentType == QMetaType::SChar yes Evaluation Count:46 | yes Evaluation Count:109092 |
evaluated: currentType == QMetaType::Char yes Evaluation Count:45 | yes Evaluation Count:109047 |
| 45-109092 |
2668 | currentType = QMetaType::UInt; executed: currentType = QMetaType::UInt; Execution Count:91 | 91 |
2669 | if (targetTypeId == QMetaType::SChar || currentType == QMetaType::Char) evaluated: targetTypeId == QMetaType::SChar yes Evaluation Count:1 | yes Evaluation Count:109137 |
partially evaluated: currentType == QMetaType::Char no Evaluation Count:0 | yes Evaluation Count:109137 |
| 0-109137 |
2670 | targetTypeId = QMetaType::UInt; executed: targetTypeId = QMetaType::UInt; Execution Count:1 | 1 |
2671 | if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double; executed: targetTypeId = QVariant::Double; Execution Count:41 evaluated: uint(targetTypeId) == uint(QMetaType::Float) yes Evaluation Count:41 | yes Evaluation Count:109097 |
| 41-109097 |
2672 | | - |
2673 | | - |
2674 | if (currentType == uint(targetTypeId)) evaluated: currentType == uint(targetTypeId) yes Evaluation Count:280 | yes Evaluation Count:108858 |
| 280-108858 |
2675 | return true; executed: return true; Execution Count:280 | 280 |
2676 | | - |
2677 | if (targetTypeId < 0) evaluated: targetTypeId < 0 yes Evaluation Count:66 | yes Evaluation Count:108792 |
| 66-108792 |
2678 | return false; executed: return false; Execution Count:66 | 66 |
2679 | if (targetTypeId >= QMetaType::User) evaluated: targetTypeId >= QMetaType::User yes Evaluation Count:24 | yes Evaluation Count:108768 |
| 24-108768 |
2680 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); executed: return canConvertMetaObject(currentType, targetTypeId, d.data.o); Execution Count:24 | 24 |
2681 | | - |
2682 | // FIXME It should be LastCoreType intead of Uuid | - |
2683 | if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { evaluated: currentType > int(QMetaType::QUuid) yes Evaluation Count:9495 | yes Evaluation Count:99273 |
evaluated: targetTypeId > int(QMetaType::QUuid) yes Evaluation Count:95652 | yes Evaluation Count:3621 |
| 3621-99273 |
2684 | switch (uint(targetTypeId)) { | - |
2685 | case QVariant::Int: | - |
2686 | if (currentType == QVariant::KeySequence) evaluated: currentType == QVariant::KeySequence yes Evaluation Count:2 | yes Evaluation Count:21 |
| 2-21 |
2687 | return true; executed: return true; Execution Count:2 | 2 |
2688 | // fall through | - |
2689 | case QVariant::UInt: | - |
2690 | 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:34 | 34 |
2691 | || 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:34 | 34 |
2692 | || 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:34 | 34 |
2693 | || 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:34 | 34 |
2694 | || 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:34 | 34 |
2695 | || 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:34 | 34 |
2696 | || 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:34 | 34 |
2697 | case QVariant::Image: | - |
2698 | return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap; executed: return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap; Execution Count:34 | 34 |
2699 | case QVariant::Pixmap: | - |
2700 | return currentType == QVariant::Image || currentType == QVariant::Bitmap executed: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush; Execution Count:35 | 35 |
2701 | || currentType == QVariant::Brush; executed: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush; Execution Count:35 | 35 |
2702 | case QVariant::Bitmap: | - |
2703 | return currentType == QVariant::Pixmap || currentType == QVariant::Image; executed: return currentType == QVariant::Pixmap || currentType == QVariant::Image; Execution Count:34 | 34 |
2704 | case QVariant::ByteArray: | - |
2705 | return currentType == QVariant::Color; executed: return currentType == QVariant::Color; Execution Count:13 | 13 |
2706 | case QVariant::String: | - |
2707 | return currentType == QVariant::KeySequence || currentType == QVariant::Font executed: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color; Execution Count:230 | 230 |
2708 | || currentType == QVariant::Color; executed: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color; Execution Count:230 | 230 |
2709 | case QVariant::KeySequence: | - |
2710 | return currentType == QVariant::String || currentType == QVariant::Int; executed: return currentType == QVariant::String || currentType == QVariant::Int; Execution Count:36 | 36 |
2711 | case QVariant::Font: | - |
2712 | return currentType == QVariant::String; executed: return currentType == QVariant::String; Execution Count:55 | 55 |
2713 | case QVariant::Color: | - |
2714 | return currentType == QVariant::String || currentType == QVariant::ByteArray executed: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush; Execution Count:105 | 105 |
2715 | || currentType == QVariant::Brush; executed: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush; Execution Count:105 | 105 |
2716 | case QVariant::Brush: | - |
2717 | return currentType == QVariant::Color || currentType == QVariant::Pixmap; executed: return currentType == QVariant::Color || currentType == QVariant::Pixmap; Execution Count:104075 | 104075 |
2718 | case QMetaType::Long: | - |
2719 | case QMetaType::Char: | - |
2720 | case QMetaType::SChar: | - |
2721 | case QMetaType::UChar: | - |
2722 | case QMetaType::ULong: | - |
2723 | case QMetaType::Short: | - |
2724 | case QMetaType::UShort: | - |
2725 | return qCanConvertMatrix[QVariant::Int] & (1 << currentType) || currentType == QVariant::Int; executed: return qCanConvertMatrix[QVariant::Int] & (1 << currentType) || currentType == QVariant::Int; Execution Count:3 | 3 |
2726 | case QMetaType::QObjectStar: | - |
2727 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); executed: return canConvertMetaObject(currentType, targetTypeId, d.data.o); Execution Count:32 | 32 |
2728 | default: | - |
2729 | return false; executed: return false; Execution Count:459 | 459 |
2730 | } | - |
2731 | } | 0 |
2732 | | - |
2733 | if (targetTypeId == String && currentType == StringList) evaluated: targetTypeId == String yes Evaluation Count:603 | yes Evaluation Count:3018 |
evaluated: currentType == StringList yes Evaluation Count:16 | yes Evaluation Count:587 |
| 16-3018 |
2734 | return v_cast<QStringList>(&d)->count() == 1; executed: return v_cast<QStringList>(&d)->count() == 1; Execution Count:16 | 16 |
2735 | return qCanConvertMatrix[targetTypeId] & (1 << currentType); executed: return qCanConvertMatrix[targetTypeId] & (1 << currentType); Execution Count:3605 | 3605 |
2736 | } | - |
2737 | | - |
2738 | /*! | - |
2739 | Casts the variant to the requested type, \a targetTypeId. If the cast cannot be | - |
2740 | done, the variant is cleared. Returns true if the current type of | - |
2741 | the variant was successfully cast; otherwise returns false. | - |
2742 | | - |
2743 | A QVariant containing a pointer to a type derived from QObject will also convert | - |
2744 | and return true for this function if a qobject_cast to the type described | - |
2745 | by \a targetTypeId would succeed. Note that this only works for QObject subclasses | - |
2746 | which use the Q_OBJECT macro. | - |
2747 | | - |
2748 | \warning For historical reasons, converting a null QVariant results | - |
2749 | in a null value of the desired type (e.g., an empty string for | - |
2750 | QString) and a result of false. | - |
2751 | | - |
2752 | \sa canConvert(), clear() | - |
2753 | */ | - |
2754 | | - |
2755 | bool QVariant::convert(int targetTypeId) | - |
2756 | { | - |
2757 | if (d.type == uint(targetTypeId)) evaluated: d.type == uint(targetTypeId) yes Evaluation Count:593 | yes Evaluation Count:1632 |
| 593-1632 |
2758 | return true; executed: return true; Execution Count:593 | 593 |
2759 | | - |
2760 | QVariant oldValue = *this; executed (the execution status of this line is deduced): QVariant oldValue = *this; | - |
2761 | | - |
2762 | clear(); executed (the execution status of this line is deduced): clear(); | - |
2763 | if (!oldValue.canConvert(targetTypeId)) evaluated: !oldValue.canConvert(targetTypeId) yes Evaluation Count:1385 | yes Evaluation Count:247 |
| 247-1385 |
2764 | return false; executed: return false; Execution Count:1385 | 1385 |
2765 | | - |
2766 | create(targetTypeId, 0); executed (the execution status of this line is deduced): create(targetTypeId, 0); | - |
2767 | if (oldValue.isNull()) partially evaluated: oldValue.isNull() no Evaluation Count:0 | yes Evaluation Count:247 |
| 0-247 |
2768 | return false; never executed: return false; | 0 |
2769 | | - |
2770 | if ((QMetaType::typeFlags(d.type) & QMetaType::PointerToQObject) && (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject)) { evaluated: (QMetaType::typeFlags(d.type) & QMetaType::PointerToQObject) yes Evaluation Count:2 | yes Evaluation Count:245 |
partially evaluated: (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-245 |
2771 | create(targetTypeId, &oldValue.d.data.o); executed (the execution status of this line is deduced): create(targetTypeId, &oldValue.d.data.o); | - |
2772 | return true; executed: return true; Execution Count:2 | 2 |
2773 | } | - |
2774 | | - |
2775 | bool isOk = true; executed (the execution status of this line is deduced): bool isOk = true; | - |
2776 | if (!handlerManager[d.type]->convert(&oldValue.d, targetTypeId, data(), &isOk)) evaluated: !handlerManager[d.type]->convert(&oldValue.d, targetTypeId, data(), &isOk) yes Evaluation Count:12 | yes Evaluation Count:233 |
| 12-233 |
2777 | isOk = false; executed: isOk = false; Execution Count:12 | 12 |
2778 | d.is_null = !isOk; executed (the execution status of this line is deduced): d.is_null = !isOk; | - |
2779 | return isOk; executed: return isOk; Execution Count:245 | 245 |
2780 | } | - |
2781 | | - |
2782 | /*! | - |
2783 | \fn bool QVariant::convert(const int type, void *ptr) const | - |
2784 | \internal | - |
2785 | Created for qvariant_cast() usage | - |
2786 | */ | - |
2787 | bool QVariant::convert(const int type, void *ptr) const | - |
2788 | { | - |
2789 | Q_ASSERT(type < int(QMetaType::User)); executed (the execution status of this line is deduced): qt_noop(); | - |
2790 | return handlerManager[type]->convert(&d, type, ptr, 0); executed: return handlerManager[type]->convert(&d, type, ptr, 0); Execution Count:156003 | 156003 |
2791 | } | - |
2792 | | - |
2793 | | - |
2794 | /*! | - |
2795 | \fn bool operator==(const QVariant &v1, const QVariant &v2) | - |
2796 | | - |
2797 | \relates QVariant | - |
2798 | | - |
2799 | Returns true if \a v1 and \a v2 are equal; otherwise returns false. | - |
2800 | | - |
2801 | If \a v1 and \a v2 have the same \l{QVariant::}{type()}, the | - |
2802 | type's equality operator is used for comparison. If not, it is | - |
2803 | attempted to \l{QVariant::}{convert()} \a v2 to the same type as | - |
2804 | \a v1. See \l{QVariant::}{canConvert()} for a list of possible | - |
2805 | conversions. | - |
2806 | | - |
2807 | The result of the function is not affected by the result of QVariant::isNull, | - |
2808 | which means that two values can be equal even if one of them is null and | - |
2809 | another is not. | - |
2810 | | - |
2811 | \warning This function doesn't support custom types registered | - |
2812 | with qRegisterMetaType(). | - |
2813 | */ | - |
2814 | /*! | - |
2815 | \fn bool operator!=(const QVariant &v1, const QVariant &v2) | - |
2816 | | - |
2817 | \relates QVariant | - |
2818 | | - |
2819 | Returns false if \a v1 and \a v2 are equal; otherwise returns true. | - |
2820 | | - |
2821 | \warning This function doesn't support custom types registered | - |
2822 | with qRegisterMetaType(). | - |
2823 | */ | - |
2824 | | - |
2825 | /*! \fn bool QVariant::operator==(const QVariant &v) const | - |
2826 | | - |
2827 | Compares this QVariant with \a v and returns true if they are | - |
2828 | equal; otherwise returns false. | - |
2829 | | - |
2830 | QVariant uses the equality operator of the type() it contains to | - |
2831 | check for equality. QVariant will try to convert() \a v if its | - |
2832 | type is not the same as this variant's type. See canConvert() for | - |
2833 | a list of possible conversions. | - |
2834 | | - |
2835 | \warning This function doesn't support custom types registered | - |
2836 | with qRegisterMetaType(). | - |
2837 | */ | - |
2838 | | - |
2839 | /*! | - |
2840 | \fn bool QVariant::operator!=(const QVariant &v) const | - |
2841 | | - |
2842 | Compares this QVariant with \a v and returns true if they are not | - |
2843 | equal; otherwise returns false. | - |
2844 | | - |
2845 | \warning This function doesn't support custom types registered | - |
2846 | with qRegisterMetaType(). | - |
2847 | */ | - |
2848 | | - |
2849 | static bool qIsNumericType(uint tp) | - |
2850 | { | - |
2851 | return (tp >= QVariant::Bool && tp <= QVariant::Double) executed: return (tp >= QVariant::Bool && tp <= QVariant::Double) || (tp >= QMetaType::Long && tp <= QMetaType::Float); Execution Count:3318 | 3318 |
2852 | || (tp >= QMetaType::Long && tp <= QMetaType::Float); executed: return (tp >= QVariant::Bool && tp <= QVariant::Double) || (tp >= QMetaType::Long && tp <= QMetaType::Float); Execution Count:3318 | 3318 |
2853 | } | - |
2854 | | - |
2855 | static bool qIsFloatingPoint(uint tp) | - |
2856 | { | - |
2857 | return tp == QVariant::Double || tp == QMetaType::Float; executed: return tp == QVariant::Double || tp == QMetaType::Float; Execution Count:2008 | 2008 |
2858 | } | - |
2859 | | - |
2860 | /*! | - |
2861 | \internal | - |
2862 | */ | - |
2863 | bool QVariant::cmp(const QVariant &v) const | - |
2864 | { | - |
2865 | QVariant v2 = v; executed (the execution status of this line is deduced): QVariant v2 = v; | - |
2866 | if (d.type != v2.d.type) { evaluated: d.type != v2.d.type yes Evaluation Count:2250 | yes Evaluation Count:92802 |
| 2250-92802 |
2867 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) { evaluated: qIsNumericType(d.type) yes Evaluation Count:1068 | yes Evaluation Count:1182 |
evaluated: qIsNumericType(v.d.type) yes Evaluation Count:1007 | yes Evaluation Count:61 |
| 61-1182 |
2868 | if (qIsFloatingPoint(d.type) || qIsFloatingPoint(v.d.type)) evaluated: qIsFloatingPoint(d.type) yes Evaluation Count:6 | yes Evaluation Count:1001 |
partially evaluated: qIsFloatingPoint(v.d.type) no Evaluation Count:0 | yes Evaluation Count:1001 |
| 0-1001 |
2869 | return qFuzzyCompare(toReal(), v.toReal()); executed: return qFuzzyCompare(toReal(), v.toReal()); Execution Count:6 | 6 |
2870 | else | - |
2871 | return toLongLong() == v.toLongLong(); executed: return toLongLong() == v.toLongLong(); Execution Count:1001 | 1001 |
2872 | } | - |
2873 | if (!v2.canConvert(d.type) || !v2.convert(d.type)) evaluated: !v2.canConvert(d.type) yes Evaluation Count:1165 | yes Evaluation Count:78 |
evaluated: !v2.convert(d.type) yes Evaluation Count:3 | yes Evaluation Count:75 |
| 3-1165 |
2874 | return false; executed: return false; Execution Count:1168 | 1168 |
2875 | } executed: } Execution Count:75 | 75 |
2876 | return handlerManager[d.type]->compare(&d, &v2.d); executed: return handlerManager[d.type]->compare(&d, &v2.d); Execution Count:92877 | 92877 |
2877 | } | - |
2878 | | - |
2879 | /*! | - |
2880 | \internal | - |
2881 | */ | - |
2882 | | - |
2883 | const void *QVariant::constData() const | - |
2884 | { | - |
2885 | 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:4750775 | 4750775 |
2886 | } | - |
2887 | | - |
2888 | /*! | - |
2889 | \fn const void* QVariant::data() const | - |
2890 | | - |
2891 | \internal | - |
2892 | */ | - |
2893 | | - |
2894 | /*! | - |
2895 | \internal | - |
2896 | */ | - |
2897 | void* QVariant::data() | - |
2898 | { | - |
2899 | detach(); executed (the execution status of this line is deduced): detach(); | - |
2900 | return const_cast<void *>(constData()); executed: return const_cast<void *>(constData()); Execution Count:4900 | 4900 |
2901 | } | - |
2902 | | - |
2903 | | - |
2904 | /*! | - |
2905 | Returns true if this is a null variant, false otherwise. A variant is | - |
2906 | considered null if it contains a default constructed value or a built-in | - |
2907 | type instance that has an isNull method, in which case the result | - |
2908 | would be the same as calling isNull on the wrapped object. | - |
2909 | | - |
2910 | \warning The result of the function doesn't affect == operator, which means | - |
2911 | that two values can be equal even if one of them is null and another is not. | - |
2912 | */ | - |
2913 | bool QVariant::isNull() const | - |
2914 | { | - |
2915 | return handlerManager[d.type]->isNull(&d); executed: return handlerManager[d.type]->isNull(&d); Execution Count:330344 | 330344 |
2916 | } | - |
2917 | | - |
2918 | #ifndef QT_NO_DEBUG_STREAM | - |
2919 | QDebug operator<<(QDebug dbg, const QVariant &v) | - |
2920 | { | - |
2921 | const uint typeId = v.d.type; executed (the execution status of this line is deduced): const uint typeId = v.d.type; | - |
2922 | dbg.nospace() << "QVariant("; executed (the execution status of this line is deduced): dbg.nospace() << "QVariant("; | - |
2923 | if (typeId != QMetaType::UnknownType) { evaluated: typeId != QMetaType::UnknownType yes Evaluation Count:76 | yes Evaluation Count:2 |
| 2-76 |
2924 | dbg.nospace() << QMetaType::typeName(typeId) << ", "; executed (the execution status of this line is deduced): dbg.nospace() << QMetaType::typeName(typeId) << ", "; | - |
2925 | handlerManager[typeId]->debugStream(dbg, v); executed (the execution status of this line is deduced): handlerManager[typeId]->debugStream(dbg, v); | - |
2926 | } else { executed: } Execution Count:76 | 76 |
2927 | dbg.nospace() << "Invalid"; executed (the execution status of this line is deduced): dbg.nospace() << "Invalid"; | - |
2928 | } executed: } Execution Count:2 | 2 |
2929 | dbg.nospace() << ')'; executed (the execution status of this line is deduced): dbg.nospace() << ')'; | - |
2930 | return dbg.space(); executed: return dbg.space(); Execution Count:78 | 78 |
2931 | } | - |
2932 | | - |
2933 | QDebug operator<<(QDebug dbg, const QVariant::Type p) | - |
2934 | { | - |
2935 | dbg.nospace() << "QVariant::" executed (the execution status of this line is deduced): dbg.nospace() << "QVariant::" | - |
2936 | << (int(p) != int(QMetaType::UnknownType) executed (the execution status of this line is deduced): << (int(p) != int(QMetaType::UnknownType) | - |
2937 | ? QMetaType::typeName(p) executed (the execution status of this line is deduced): ? QMetaType::typeName(p) | - |
2938 | : "Invalid"); executed (the execution status of this line is deduced): : "Invalid"); | - |
2939 | return dbg.space(); executed: return dbg.space(); Execution Count:52 | 52 |
2940 | } | - |
2941 | #endif | - |
2942 | | - |
2943 | | - |
2944 | /*! \fn void QVariant::setValue(const T &value) | - |
2945 | | - |
2946 | Stores a copy of \a value. If \c{T} is a type that QVariant | - |
2947 | doesn't support, QMetaType is used to store the value. A compile | - |
2948 | error will occur if QMetaType doesn't handle the type. | - |
2949 | | - |
2950 | Example: | - |
2951 | | - |
2952 | \snippet code/src_corelib_kernel_qvariant.cpp 4 | - |
2953 | | - |
2954 | \sa value(), fromValue(), canConvert() | - |
2955 | */ | - |
2956 | | - |
2957 | /*! \fn T QVariant::value() const | - |
2958 | | - |
2959 | Returns the stored value converted to the template type \c{T}. | - |
2960 | Call canConvert() to find out whether a type can be converted. | - |
2961 | If the value cannot be converted, \l{default-constructed value} | - |
2962 | will be returned. | - |
2963 | | - |
2964 | If the type \c{T} is supported by QVariant, this function behaves | - |
2965 | exactly as toString(), toInt() etc. | - |
2966 | | - |
2967 | Example: | - |
2968 | | - |
2969 | \snippet code/src_corelib_kernel_qvariant.cpp 5 | - |
2970 | | - |
2971 | If the QVariant contains a pointer to a type derived from QObject then | - |
2972 | \c{T} may be any QObject type. If the pointer stored in the QVariant can be | - |
2973 | qobject_cast to T, then that result is returned. Otherwise a null pointer is | - |
2974 | returned. Note that this only works for QObject subclasses which use the | - |
2975 | Q_OBJECT macro. | - |
2976 | | - |
2977 | \sa setValue(), fromValue(), canConvert() | - |
2978 | */ | - |
2979 | | - |
2980 | /*! \fn bool QVariant::canConvert() const | - |
2981 | | - |
2982 | Returns true if the variant can be converted to the template type \c{T}, | - |
2983 | otherwise false. | - |
2984 | | - |
2985 | Example: | - |
2986 | | - |
2987 | \snippet code/src_corelib_kernel_qvariant.cpp 6 | - |
2988 | | - |
2989 | A QVariant containing a pointer to a type derived from QObject will also return true for this | - |
2990 | function if a qobject_cast to the template type \c{T} would succeed. Note that this only works | - |
2991 | for QObject subclasses which use the Q_OBJECT macro. | - |
2992 | | - |
2993 | \sa convert() | - |
2994 | */ | - |
2995 | | - |
2996 | /*! \fn static QVariant QVariant::fromValue(const T &value) | - |
2997 | | - |
2998 | Returns a QVariant containing a copy of \a value. Behaves | - |
2999 | exactly like setValue() otherwise. | - |
3000 | | - |
3001 | Example: | - |
3002 | | - |
3003 | \snippet code/src_corelib_kernel_qvariant.cpp 7 | - |
3004 | | - |
3005 | \note If you are working with custom types, you should use | - |
3006 | the Q_DECLARE_METATYPE() macro to register your custom type. | - |
3007 | | - |
3008 | \sa setValue(), value() | - |
3009 | */ | - |
3010 | | - |
3011 | /*! | - |
3012 | \fn QVariant qVariantFromValue(const T &value) | - |
3013 | \relates QVariant | - |
3014 | \obsolete | - |
3015 | | - |
3016 | Returns a variant containing a copy of the given \a value | - |
3017 | with template type \c{T}. | - |
3018 | | - |
3019 | This function is equivalent to QVariant::fromValue(\a value). | - |
3020 | | - |
3021 | \note This function was provided as a workaround for MSVC 6 | - |
3022 | which did not support member template functions. It is advised | - |
3023 | to use the other form in new code. | - |
3024 | | - |
3025 | For example, a QObject pointer can be stored in a variant with the | - |
3026 | following code: | - |
3027 | | - |
3028 | \snippet code/src_corelib_kernel_qvariant.cpp 8 | - |
3029 | | - |
3030 | \sa QVariant::fromValue() | - |
3031 | */ | - |
3032 | | - |
3033 | /*! \fn void qVariantSetValue(QVariant &variant, const T &value) | - |
3034 | \relates QVariant | - |
3035 | \obsolete | - |
3036 | | - |
3037 | Sets the contents of the given \a variant to a copy of the | - |
3038 | \a value with the specified template type \c{T}. | - |
3039 | | - |
3040 | This function is equivalent to QVariant::setValue(\a value). | - |
3041 | | - |
3042 | \note This function was provided as a workaround for MSVC 6 | - |
3043 | which did not support member template functions. It is advised | - |
3044 | to use the other form in new code. | - |
3045 | | - |
3046 | \sa QVariant::setValue() | - |
3047 | */ | - |
3048 | | - |
3049 | /*! | - |
3050 | \fn T qvariant_cast(const QVariant &value) | - |
3051 | \relates QVariant | - |
3052 | | - |
3053 | Returns the given \a value converted to the template type \c{T}. | - |
3054 | | - |
3055 | This function is equivalent to QVariant::value(). | - |
3056 | | - |
3057 | \sa QVariant::value() | - |
3058 | */ | - |
3059 | | - |
3060 | /*! \fn T qVariantValue(const QVariant &value) | - |
3061 | \relates QVariant | - |
3062 | \obsolete | - |
3063 | | - |
3064 | Returns the given \a value converted to the template type \c{T}. | - |
3065 | | - |
3066 | This function is equivalent to | - |
3067 | \l{QVariant::value()}{QVariant::value}<T>(\a value). | - |
3068 | | - |
3069 | \note This function was provided as a workaround for MSVC 6 | - |
3070 | which did not support member template functions. It is advised | - |
3071 | to use the other form in new code. | - |
3072 | | - |
3073 | \sa QVariant::value(), qvariant_cast() | - |
3074 | */ | - |
3075 | | - |
3076 | /*! \fn bool qVariantCanConvert(const QVariant &value) | - |
3077 | \relates QVariant | - |
3078 | \obsolete | - |
3079 | | - |
3080 | Returns true if the given \a value can be converted to the | - |
3081 | template type specified; otherwise returns false. | - |
3082 | | - |
3083 | This function is equivalent to QVariant::canConvert(\a value). | - |
3084 | | - |
3085 | \note This function was provided as a workaround for MSVC 6 | - |
3086 | which did not support member template functions. It is advised | - |
3087 | to use the other form in new code. | - |
3088 | | - |
3089 | \sa QVariant::canConvert() | - |
3090 | */ | - |
3091 | | - |
3092 | /*! | - |
3093 | \typedef QVariantList | - |
3094 | \relates QVariant | - |
3095 | | - |
3096 | Synonym for QList<QVariant>. | - |
3097 | */ | - |
3098 | | - |
3099 | /*! | - |
3100 | \typedef QVariantMap | - |
3101 | \relates QVariant | - |
3102 | | - |
3103 | Synonym for QMap<QString, QVariant>. | - |
3104 | */ | - |
3105 | | - |
3106 | /*! | - |
3107 | \typedef QVariantHash | - |
3108 | \relates QVariant | - |
3109 | \since 4.5 | - |
3110 | | - |
3111 | Synonym for QHash<QString, QVariant>. | - |
3112 | */ | - |
3113 | | - |
3114 | /*! | - |
3115 | \typedef QVariant::DataPtr | - |
3116 | \internal | - |
3117 | */ | - |
3118 | | - |
3119 | /*! | - |
3120 | \fn DataPtr &QVariant::data_ptr() | - |
3121 | \internal | - |
3122 | */ | - |
3123 | | - |
3124 | /*! | - |
3125 | \fn const DataPtr &QVariant::data_ptr() const | - |
3126 | \internal | - |
3127 | */ | - |
3128 | | - |
3129 | QT_END_NAMESPACE | - |
3130 | | - |
| | |