Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qvariant.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||||||||||||||
2 | ** | - | ||||||||||||||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
4 | ** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com> | - | ||||||||||||||||||||||||
5 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
6 | ** | - | ||||||||||||||||||||||||
7 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||||||||||||||
8 | ** | - | ||||||||||||||||||||||||
9 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
10 | ** Commercial License Usage | - | ||||||||||||||||||||||||
11 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
12 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
13 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
14 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
15 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
16 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
17 | ** | - | ||||||||||||||||||||||||
18 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
20 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
21 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
22 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
23 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
24 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
25 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
26 | ** | - | ||||||||||||||||||||||||
27 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
28 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
29 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
30 | ** | - | ||||||||||||||||||||||||
31 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
32 | ** | - | ||||||||||||||||||||||||
33 | ****************************************************************************/ | - | ||||||||||||||||||||||||
34 | - | |||||||||||||||||||||||||
35 | #include "qvariant.h" | - | ||||||||||||||||||||||||
36 | #include "qbitarray.h" | - | ||||||||||||||||||||||||
37 | #include "qbytearray.h" | - | ||||||||||||||||||||||||
38 | #include "qdatastream.h" | - | ||||||||||||||||||||||||
39 | #include "qdebug.h" | - | ||||||||||||||||||||||||
40 | #include "qmap.h" | - | ||||||||||||||||||||||||
41 | #include "qdatetime.h" | - | ||||||||||||||||||||||||
42 | #include "qeasingcurve.h" | - | ||||||||||||||||||||||||
43 | #include "qlist.h" | - | ||||||||||||||||||||||||
44 | #include "qregularexpression.h" | - | ||||||||||||||||||||||||
45 | #include "qstring.h" | - | ||||||||||||||||||||||||
46 | #include "qstringlist.h" | - | ||||||||||||||||||||||||
47 | #include "qurl.h" | - | ||||||||||||||||||||||||
48 | #include "qlocale.h" | - | ||||||||||||||||||||||||
49 | #include "quuid.h" | - | ||||||||||||||||||||||||
50 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
51 | #include "qabstractitemmodel.h" | - | ||||||||||||||||||||||||
52 | #include "qjsonvalue.h" | - | ||||||||||||||||||||||||
53 | #include "qjsonobject.h" | - | ||||||||||||||||||||||||
54 | #include "qjsonarray.h" | - | ||||||||||||||||||||||||
55 | #include "qjsondocument.h" | - | ||||||||||||||||||||||||
56 | #include "qbytearraylist.h" | - | ||||||||||||||||||||||||
57 | #endif | - | ||||||||||||||||||||||||
58 | #include "private/qvariant_p.h" | - | ||||||||||||||||||||||||
59 | #include "qmetatype_p.h" | - | ||||||||||||||||||||||||
60 | #include <qmetaobject.h> | - | ||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||
62 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
63 | #include "qsize.h" | - | ||||||||||||||||||||||||
64 | #include "qpoint.h" | - | ||||||||||||||||||||||||
65 | #include "qrect.h" | - | ||||||||||||||||||||||||
66 | #include "qline.h" | - | ||||||||||||||||||||||||
67 | #endif | - | ||||||||||||||||||||||||
68 | - | |||||||||||||||||||||||||
69 | #include <float.h> | - | ||||||||||||||||||||||||
70 | #include <cstring> | - | ||||||||||||||||||||||||
71 | - | |||||||||||||||||||||||||
72 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||
74 | #ifndef DBL_MANT_DIG | - | ||||||||||||||||||||||||
75 | # define DBL_MANT_DIG 53 | - | ||||||||||||||||||||||||
76 | #endif | - | ||||||||||||||||||||||||
77 | #ifndef FLT_MANT_DIG | - | ||||||||||||||||||||||||
78 | # define FLT_MANT_DIG 24 | - | ||||||||||||||||||||||||
79 | #endif | - | ||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | const int log10_2_10000 = 30103; // log10(2) * 100000 | - | ||||||||||||||||||||||||
82 | // same as C++11 std::numeric_limits<T>::max_digits10 | - | ||||||||||||||||||||||||
83 | const int max_digits10_double = (DBL_MANT_DIG * log10_2_10000) / 100000 + 2; | - | ||||||||||||||||||||||||
84 | const int max_digits10_float = (FLT_MANT_DIG * log10_2_10000) / 100000 + 2; | - | ||||||||||||||||||||||||
85 | - | |||||||||||||||||||||||||
86 | namespace { | - | ||||||||||||||||||||||||
87 | class HandlersManager | - | ||||||||||||||||||||||||
88 | { | - | ||||||||||||||||||||||||
89 | static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount]; | - | ||||||||||||||||||||||||
90 | public: | - | ||||||||||||||||||||||||
91 | const QVariant::Handler *operator[] (const uint typeId) const | - | ||||||||||||||||||||||||
92 | { | - | ||||||||||||||||||||||||
93 | return Handlers[QModulesPrivate::moduleForType(typeId)]; executed 28720924 times by 453 tests: return Handlers[QModulesPrivate::moduleForType(typeId)]; Executed by:
| 28720924 | ||||||||||||||||||||||||
94 | } | - | ||||||||||||||||||||||||
95 | - | |||||||||||||||||||||||||
96 | void registerHandler(const QModulesPrivate::Names name, const QVariant::Handler *handler) | - | ||||||||||||||||||||||||
97 | { | - | ||||||||||||||||||||||||
98 | Handlers[name] = handler; | - | ||||||||||||||||||||||||
99 | } executed 250 times by 5 tests: end of block Executed by:
| 250 | ||||||||||||||||||||||||
100 | }; | - | ||||||||||||||||||||||||
101 | } // namespace | - | ||||||||||||||||||||||||
102 | - | |||||||||||||||||||||||||
103 | namespace { | - | ||||||||||||||||||||||||
104 | struct CoreTypesFilter { | - | ||||||||||||||||||||||||
105 | template<typename T> | - | ||||||||||||||||||||||||
106 | struct Acceptor { | - | ||||||||||||||||||||||||
107 | static const bool IsAccepted = QModulesPrivate::QTypeModuleInfo<T>::IsCore && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable; | - | ||||||||||||||||||||||||
108 | }; | - | ||||||||||||||||||||||||
109 | }; | - | ||||||||||||||||||||||||
110 | } // annonymous | - | ||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||
112 | namespace { // annonymous used to hide QVariant handlers | - | ||||||||||||||||||||||||
113 | - | |||||||||||||||||||||||||
114 | static void construct(QVariant::Private *x, const void *copy) | - | ||||||||||||||||||||||||
115 | { | - | ||||||||||||||||||||||||
116 | QVariantConstructor<CoreTypesFilter> constructor(x, copy); | - | ||||||||||||||||||||||||
117 | QMetaTypeSwitcher::switcher<void>(constructor, x->type, 0); | - | ||||||||||||||||||||||||
118 | } executed 8176452 times by 393 tests: end of block Executed by:
| 8176452 | ||||||||||||||||||||||||
119 | - | |||||||||||||||||||||||||
120 | static void clear(QVariant::Private *d) | - | ||||||||||||||||||||||||
121 | { | - | ||||||||||||||||||||||||
122 | QVariantDestructor<CoreTypesFilter> cleaner(d); | - | ||||||||||||||||||||||||
123 | QMetaTypeSwitcher::switcher<void>(cleaner, d->type, 0); | - | ||||||||||||||||||||||||
124 | } executed 12180706 times by 423 tests: end of block Executed by:
| 12180706 | ||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | static bool isNull(const QVariant::Private *d) | - | ||||||||||||||||||||||||
127 | { | - | ||||||||||||||||||||||||
128 | QVariantIsNull<CoreTypesFilter> isNull(d); | - | ||||||||||||||||||||||||
129 | return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0); executed 409602 times by 135 tests: return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0); Executed by:
| 409602 | ||||||||||||||||||||||||
130 | } | - | ||||||||||||||||||||||||
131 | - | |||||||||||||||||||||||||
132 | /*! | - | ||||||||||||||||||||||||
133 | \internal | - | ||||||||||||||||||||||||
134 | - | |||||||||||||||||||||||||
135 | Compares \a a to \a b. The caller guarantees that \a a and \a b | - | ||||||||||||||||||||||||
136 | are of the same type. | - | ||||||||||||||||||||||||
137 | */ | - | ||||||||||||||||||||||||
138 | static bool compare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||||||||||||||||||||
139 | { | - | ||||||||||||||||||||||||
140 | QVariantComparator<CoreTypesFilter> comparator(a, b); | - | ||||||||||||||||||||||||
141 | return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0); executed 94447 times by 73 tests: return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0); Executed by:
| 94447 | ||||||||||||||||||||||||
142 | } | - | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | /*! | - | ||||||||||||||||||||||||
145 | \internal | - | ||||||||||||||||||||||||
146 | */ | - | ||||||||||||||||||||||||
147 | static qlonglong qMetaTypeNumber(const QVariant::Private *d) | - | ||||||||||||||||||||||||
148 | { | - | ||||||||||||||||||||||||
149 | switch (d->type) { | - | ||||||||||||||||||||||||
150 | case QMetaType::Int: executed 457809 times by 94 tests: case QMetaType::Int: Executed by:
| 457809 | ||||||||||||||||||||||||
151 | return d->data.i; executed 457809 times by 94 tests: return d->data.i; Executed by:
| 457809 | ||||||||||||||||||||||||
152 | case QMetaType::LongLong: executed 5987 times by 21 tests: case QMetaType::LongLong: Executed by:
| 5987 | ||||||||||||||||||||||||
153 | return d->data.ll; executed 5987 times by 21 tests: return d->data.ll; Executed by:
| 5987 | ||||||||||||||||||||||||
154 | case QMetaType::Char: executed 177 times by 1 test: case QMetaType::Char: Executed by:
| 177 | ||||||||||||||||||||||||
155 | return qlonglong(d->data.c); executed 177 times by 1 test: return qlonglong(d->data.c); Executed by:
| 177 | ||||||||||||||||||||||||
156 | case QMetaType::SChar: executed 186 times by 1 test: case QMetaType::SChar: Executed by:
| 186 | ||||||||||||||||||||||||
157 | return qlonglong(d->data.sc); executed 186 times by 1 test: return qlonglong(d->data.sc); Executed by:
| 186 | ||||||||||||||||||||||||
158 | case QMetaType::Short: executed 231 times by 2 tests: case QMetaType::Short: Executed by:
| 231 | ||||||||||||||||||||||||
159 | return qlonglong(d->data.s); executed 231 times by 2 tests: return qlonglong(d->data.s); Executed by:
| 231 | ||||||||||||||||||||||||
160 | case QMetaType::Long: executed 120 times by 1 test: case QMetaType::Long: Executed by:
| 120 | ||||||||||||||||||||||||
161 | return qlonglong(d->data.l); executed 120 times by 1 test: return qlonglong(d->data.l); Executed by:
| 120 | ||||||||||||||||||||||||
162 | case QMetaType::Float: executed 12 times by 1 test: case QMetaType::Float: Executed by:
| 12 | ||||||||||||||||||||||||
163 | return qRound64(d->data.f); executed 12 times by 1 test: return qRound64(d->data.f); Executed by:
| 12 | ||||||||||||||||||||||||
164 | case QVariant::Double: executed 231 times by 13 tests: case QVariant::Double: Executed by:
| 231 | ||||||||||||||||||||||||
165 | return qRound64(d->data.d); executed 231 times by 13 tests: return qRound64(d->data.d); Executed by:
| 231 | ||||||||||||||||||||||||
166 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
167 | case QMetaType::QJsonValue: executed 4 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 4 | ||||||||||||||||||||||||
168 | return v_cast<QJsonValue>(d)->toDouble(); executed 4 times by 1 test: return v_cast<QJsonValue>(d)->toDouble(); Executed by:
| 4 | ||||||||||||||||||||||||
169 | #endif | - | ||||||||||||||||||||||||
170 | } | - | ||||||||||||||||||||||||
171 | Q_ASSERT(false); | - | ||||||||||||||||||||||||
172 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
173 | } | - | ||||||||||||||||||||||||
174 | - | |||||||||||||||||||||||||
175 | static qulonglong qMetaTypeUNumber(const QVariant::Private *d) | - | ||||||||||||||||||||||||
176 | { | - | ||||||||||||||||||||||||
177 | switch (d->type) { | - | ||||||||||||||||||||||||
178 | case QVariant::UInt: executed 2310 times by 23 tests: case QVariant::UInt: Executed by:
| 2310 | ||||||||||||||||||||||||
179 | return d->data.u; executed 2310 times by 23 tests: return d->data.u; Executed by:
| 2310 | ||||||||||||||||||||||||
180 | case QVariant::ULongLong: executed 465 times by 19 tests: case QVariant::ULongLong: Executed by:
| 465 | ||||||||||||||||||||||||
181 | return d->data.ull; executed 465 times by 19 tests: return d->data.ull; Executed by:
| 465 | ||||||||||||||||||||||||
182 | case QMetaType::UChar: executed 153 times by 2 tests: case QMetaType::UChar: Executed by:
| 153 | ||||||||||||||||||||||||
183 | return d->data.uc; executed 153 times by 2 tests: return d->data.uc; Executed by:
| 153 | ||||||||||||||||||||||||
184 | case QMetaType::UShort: executed 183 times by 2 tests: case QMetaType::UShort: Executed by:
| 183 | ||||||||||||||||||||||||
185 | return d->data.us; executed 183 times by 2 tests: return d->data.us; Executed by:
| 183 | ||||||||||||||||||||||||
186 | case QMetaType::ULong: executed 87 times by 1 test: case QMetaType::ULong: Executed by:
| 87 | ||||||||||||||||||||||||
187 | return d->data.ul; executed 87 times by 1 test: return d->data.ul; Executed by:
| 87 | ||||||||||||||||||||||||
188 | } | - | ||||||||||||||||||||||||
189 | Q_ASSERT(false); | - | ||||||||||||||||||||||||
190 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
191 | } | - | ||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||
193 | static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||||||||||||||
194 | { | - | ||||||||||||||||||||||||
195 | *ok = true; | - | ||||||||||||||||||||||||
196 | - | |||||||||||||||||||||||||
197 | switch (uint(d->type)) { | - | ||||||||||||||||||||||||
198 | case QVariant::String: executed 12467 times by 37 tests: case QVariant::String: Executed by:
| 12467 | ||||||||||||||||||||||||
199 | return v_cast<QString>(d)->toLongLong(ok); executed 12467 times by 37 tests: return v_cast<QString>(d)->toLongLong(ok); Executed by:
| 12467 | ||||||||||||||||||||||||
200 | case QVariant::Char: executed 7 times by 2 tests: case QVariant::Char: Executed by:
| 7 | ||||||||||||||||||||||||
201 | return v_cast<QChar>(d)->unicode(); executed 7 times by 2 tests: return v_cast<QChar>(d)->unicode(); Executed by:
| 7 | ||||||||||||||||||||||||
202 | case QVariant::ByteArray: executed 5 times by 1 test: case QVariant::ByteArray: Executed by:
| 5 | ||||||||||||||||||||||||
203 | return v_cast<QByteArray>(d)->toLongLong(ok); executed 5 times by 1 test: return v_cast<QByteArray>(d)->toLongLong(ok); Executed by:
| 5 | ||||||||||||||||||||||||
204 | case QVariant::Bool: executed 541 times by 22 tests: case QVariant::Bool: Executed by:
| 541 | ||||||||||||||||||||||||
205 | return qlonglong(d->data.b); executed 541 times by 22 tests: return qlonglong(d->data.b); Executed by:
| 541 | ||||||||||||||||||||||||
206 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
207 | case QMetaType::QJsonValue: executed 4 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 4 | ||||||||||||||||||||||||
208 | if (!v_cast<QJsonValue>(d)->isDouble())
| 2 | ||||||||||||||||||||||||
209 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
210 | // no break | - | ||||||||||||||||||||||||
211 | #endif | - | ||||||||||||||||||||||||
212 | case QVariant::Double: code before this statement executed 2 times by 1 test: case QVariant::Double: Executed by:
executed 217 times by 13 tests: case QVariant::Double: Executed by:
| 2-217 | ||||||||||||||||||||||||
213 | case QVariant::Int: executed 429310 times by 81 tests: case QVariant::Int: Executed by:
| 429310 | ||||||||||||||||||||||||
214 | case QMetaType::Char: executed 168 times by 1 test: case QMetaType::Char: Executed by:
| 168 | ||||||||||||||||||||||||
215 | case QMetaType::SChar: executed 169 times by 1 test: case QMetaType::SChar: Executed by:
| 169 | ||||||||||||||||||||||||
216 | case QMetaType::Short: executed 201 times by 2 tests: case QMetaType::Short: Executed by:
| 201 | ||||||||||||||||||||||||
217 | case QMetaType::Long: executed 108 times by 1 test: case QMetaType::Long: Executed by:
| 108 | ||||||||||||||||||||||||
218 | case QMetaType::Float: executed 3 times by 1 test: case QMetaType::Float: Executed by:
| 3 | ||||||||||||||||||||||||
219 | case QMetaType::LongLong: executed 5456 times by 20 tests: case QMetaType::LongLong: Executed by:
| 5456 | ||||||||||||||||||||||||
220 | return qMetaTypeNumber(d); executed 435634 times by 86 tests: return qMetaTypeNumber(d); Executed by:
| 435634 | ||||||||||||||||||||||||
221 | case QVariant::ULongLong: executed 323 times by 4 tests: case QVariant::ULongLong: Executed by:
| 323 | ||||||||||||||||||||||||
222 | case QVariant::UInt: executed 742 times by 11 tests: case QVariant::UInt: Executed by:
| 742 | ||||||||||||||||||||||||
223 | case QMetaType::UChar: executed 136 times by 2 tests: case QMetaType::UChar: Executed by:
| 136 | ||||||||||||||||||||||||
224 | case QMetaType::UShort: executed 146 times by 2 tests: case QMetaType::UShort: Executed by:
| 146 | ||||||||||||||||||||||||
225 | case QMetaType::ULong: executed 86 times by 1 test: case QMetaType::ULong: Executed by:
| 86 | ||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | return qlonglong(qMetaTypeUNumber(d)); executed 1433 times by 12 tests: return qlonglong(qMetaTypeUNumber(d)); Executed by:
| 1433 | ||||||||||||||||||||||||
228 | } | - | ||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||
230 | QMetaType typeInfo(d->type); | - | ||||||||||||||||||||||||
231 | if (typeInfo.flags() & QMetaType::IsEnumeration) {
| 116-868 | ||||||||||||||||||||||||
232 | switch (typeInfo.sizeOf()) { | - | ||||||||||||||||||||||||
233 | case 1: executed 10 times by 1 test: case 1: Executed by:
| 10 | ||||||||||||||||||||||||
234 | return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc; executed 10 times by 1 test: return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc; Executed by:
| 0-10 | ||||||||||||||||||||||||
235 | case 2: executed 10 times by 1 test: case 2: Executed by:
| 10 | ||||||||||||||||||||||||
236 | return d->is_shared ? *reinterpret_cast<qint16 *>(d->data.shared->ptr) : d->data.s; executed 10 times by 1 test: return d->is_shared ? *reinterpret_cast<qint16 *>(d->data.shared->ptr) : d->data.s; Executed by:
| 0-10 | ||||||||||||||||||||||||
237 | case 4: executed 32 times by 4 tests: case 4: Executed by:
| 32 | ||||||||||||||||||||||||
238 | return d->is_shared ? *reinterpret_cast<qint32 *>(d->data.shared->ptr) : d->data.i; executed 32 times by 4 tests: return d->is_shared ? *reinterpret_cast<qint32 *>(d->data.shared->ptr) : d->data.i; Executed by:
| 0-32 | ||||||||||||||||||||||||
239 | case 8: executed 64 times by 1 test: case 8: Executed by:
| 64 | ||||||||||||||||||||||||
240 | return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ll; executed 64 times by 1 test: return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ll; Executed by:
| 0-64 | ||||||||||||||||||||||||
241 | } | - | ||||||||||||||||||||||||
242 | } never executed: end of block | 0 | ||||||||||||||||||||||||
243 | - | |||||||||||||||||||||||||
244 | *ok = false; | - | ||||||||||||||||||||||||
245 | return Q_INT64_C(0); executed 868 times by 19 tests: return static_cast<long long>(0LL); Executed by:
| 868 | ||||||||||||||||||||||||
246 | } | - | ||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||||||||||||||
249 | { | - | ||||||||||||||||||||||||
250 | *ok = true; | - | ||||||||||||||||||||||||
251 | switch (uint(d->type)) { | - | ||||||||||||||||||||||||
252 | case QVariant::Double: executed 10981 times by 32 tests: case QVariant::Double: Executed by:
| 10981 | ||||||||||||||||||||||||
253 | return qreal(d->data.d); executed 10981 times by 32 tests: return qreal(d->data.d); Executed by:
| 10981 | ||||||||||||||||||||||||
254 | case QMetaType::Float: executed 301 times by 1 test: case QMetaType::Float: Executed by:
| 301 | ||||||||||||||||||||||||
255 | return qreal(d->data.f); executed 301 times by 1 test: return qreal(d->data.f); Executed by:
| 301 | ||||||||||||||||||||||||
256 | case QVariant::ULongLong: never executed: case QVariant::ULongLong: | 0 | ||||||||||||||||||||||||
257 | case QVariant::UInt: executed 80 times by 1 test: case QVariant::UInt: Executed by:
| 80 | ||||||||||||||||||||||||
258 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
259 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
260 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
261 | return qreal(qMetaTypeUNumber(d)); executed 80 times by 1 test: return qreal(qMetaTypeUNumber(d)); Executed by:
| 80 | ||||||||||||||||||||||||
262 | default: executed 96 times by 3 tests: default: Executed by:
| 96 | ||||||||||||||||||||||||
263 | // includes enum conversion as well as invalid types | - | ||||||||||||||||||||||||
264 | return qreal(qConvertToNumber(d, ok)); executed 96 times by 3 tests: return qreal(qConvertToNumber(d, ok)); Executed by:
| 96 | ||||||||||||||||||||||||
265 | } | - | ||||||||||||||||||||||||
266 | } | - | ||||||||||||||||||||||||
267 | - | |||||||||||||||||||||||||
268 | static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||||||||||||||
269 | { | - | ||||||||||||||||||||||||
270 | *ok = true; | - | ||||||||||||||||||||||||
271 | - | |||||||||||||||||||||||||
272 | switch (uint(d->type)) { | - | ||||||||||||||||||||||||
273 | case QVariant::String: executed 47 times by 3 tests: case QVariant::String: Executed by:
| 47 | ||||||||||||||||||||||||
274 | return v_cast<QString>(d)->toULongLong(ok); executed 47 times by 3 tests: return v_cast<QString>(d)->toULongLong(ok); Executed by:
| 47 | ||||||||||||||||||||||||
275 | case QVariant::Char: executed 2 times by 1 test: case QVariant::Char: Executed by:
| 2 | ||||||||||||||||||||||||
276 | return v_cast<QChar>(d)->unicode(); executed 2 times by 1 test: return v_cast<QChar>(d)->unicode(); Executed by:
| 2 | ||||||||||||||||||||||||
277 | case QVariant::ByteArray: executed 4 times by 1 test: case QVariant::ByteArray: Executed by:
| 4 | ||||||||||||||||||||||||
278 | return v_cast<QByteArray>(d)->toULongLong(ok); executed 4 times by 1 test: return v_cast<QByteArray>(d)->toULongLong(ok); Executed by:
| 4 | ||||||||||||||||||||||||
279 | case QVariant::Bool: never executed: case QVariant::Bool: | 0 | ||||||||||||||||||||||||
280 | return qulonglong(d->data.b); never executed: return qulonglong(d->data.b); | 0 | ||||||||||||||||||||||||
281 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
282 | case QMetaType::QJsonValue: executed 4 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 4 | ||||||||||||||||||||||||
283 | if (!v_cast<QJsonValue>(d)->isDouble())
| 2 | ||||||||||||||||||||||||
284 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
285 | // no break | - | ||||||||||||||||||||||||
286 | #endif | - | ||||||||||||||||||||||||
287 | case QVariant::Double: code before this statement executed 2 times by 1 test: case QVariant::Double: Executed by:
executed 3 times by 1 test: case QVariant::Double: Executed by:
| 2-3 | ||||||||||||||||||||||||
288 | case QVariant::Int: executed 47 times by 6 tests: case QVariant::Int: Executed by:
| 47 | ||||||||||||||||||||||||
289 | case QMetaType::Char: executed 1 time by 1 test: case QMetaType::Char: Executed by:
| 1 | ||||||||||||||||||||||||
290 | case QMetaType::SChar: executed 1 time by 1 test: case QMetaType::SChar: Executed by:
| 1 | ||||||||||||||||||||||||
291 | case QMetaType::Short: executed 2 times by 1 test: case QMetaType::Short: Executed by:
| 2 | ||||||||||||||||||||||||
292 | case QMetaType::Long: executed 7 times by 1 test: case QMetaType::Long: Executed by:
| 7 | ||||||||||||||||||||||||
293 | case QMetaType::Float: executed 3 times by 1 test: case QMetaType::Float: Executed by:
| 3 | ||||||||||||||||||||||||
294 | case QMetaType::LongLong: executed 5 times by 2 tests: case QMetaType::LongLong: Executed by:
| 5 | ||||||||||||||||||||||||
295 | return qulonglong(qMetaTypeNumber(d)); executed 71 times by 7 tests: return qulonglong(qMetaTypeNumber(d)); Executed by:
| 71 | ||||||||||||||||||||||||
296 | case QVariant::ULongLong: executed 75 times by 16 tests: case QVariant::ULongLong: Executed by:
| 75 | ||||||||||||||||||||||||
297 | case QVariant::UInt: executed 34 times by 3 tests: case QVariant::UInt: Executed by:
| 34 | ||||||||||||||||||||||||
298 | case QMetaType::UChar: executed 1 time by 1 test: case QMetaType::UChar: Executed by:
| 1 | ||||||||||||||||||||||||
299 | case QMetaType::UShort: executed 11 times by 1 test: case QMetaType::UShort: Executed by:
| 11 | ||||||||||||||||||||||||
300 | case QMetaType::ULong: executed 1 time by 1 test: case QMetaType::ULong: Executed by:
| 1 | ||||||||||||||||||||||||
301 | return qMetaTypeUNumber(d); executed 122 times by 18 tests: return qMetaTypeUNumber(d); Executed by:
| 122 | ||||||||||||||||||||||||
302 | } | - | ||||||||||||||||||||||||
303 | - | |||||||||||||||||||||||||
304 | QMetaType typeInfo(d->type); | - | ||||||||||||||||||||||||
305 | if (typeInfo.flags() & QMetaType::IsEnumeration) {
| 54-69 | ||||||||||||||||||||||||
306 | switch (typeInfo.sizeOf()) { | - | ||||||||||||||||||||||||
307 | case 1: executed 6 times by 1 test: case 1: Executed by:
| 6 | ||||||||||||||||||||||||
308 | return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc; executed 6 times by 1 test: return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc; Executed by:
| 0-6 | ||||||||||||||||||||||||
309 | case 2: executed 6 times by 1 test: case 2: Executed by:
| 6 | ||||||||||||||||||||||||
310 | return d->is_shared ? *reinterpret_cast<quint16 *>(d->data.shared->ptr) : d->data.us; executed 6 times by 1 test: return d->is_shared ? *reinterpret_cast<quint16 *>(d->data.shared->ptr) : d->data.us; Executed by:
| 0-6 | ||||||||||||||||||||||||
311 | case 4: executed 18 times by 1 test: case 4: Executed by:
| 18 | ||||||||||||||||||||||||
312 | return d->is_shared ? *reinterpret_cast<quint32 *>(d->data.shared->ptr) : d->data.u; executed 18 times by 1 test: return d->is_shared ? *reinterpret_cast<quint32 *>(d->data.shared->ptr) : d->data.u; Executed by:
| 0-18 | ||||||||||||||||||||||||
313 | case 8: executed 39 times by 1 test: case 8: Executed by:
| 39 | ||||||||||||||||||||||||
314 | return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ull; executed 39 times by 1 test: return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ull; Executed by:
| 0-39 | ||||||||||||||||||||||||
315 | } | - | ||||||||||||||||||||||||
316 | } never executed: end of block | 0 | ||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||
318 | *ok = false; | - | ||||||||||||||||||||||||
319 | return Q_UINT64_C(0); executed 54 times by 11 tests: return static_cast<unsigned long long>(0ULL); Executed by:
| 54 | ||||||||||||||||||||||||
320 | } | - | ||||||||||||||||||||||||
321 | - | |||||||||||||||||||||||||
322 | template<typename TInput, typename LiteralWrapper> | - | ||||||||||||||||||||||||
323 | inline bool qt_convertToBool(const QVariant::Private *const d) | - | ||||||||||||||||||||||||
324 | { | - | ||||||||||||||||||||||||
325 | TInput str = v_cast<TInput>(d)->toLower(); | - | ||||||||||||||||||||||||
326 | return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty()); executed 30 times by 3 tests: return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty()); Executed by:
| 1-30 | ||||||||||||||||||||||||
327 | } | - | ||||||||||||||||||||||||
328 | - | |||||||||||||||||||||||||
329 | /*! | - | ||||||||||||||||||||||||
330 | \internal | - | ||||||||||||||||||||||||
331 | Returns the internal data pointer from \a d. | - | ||||||||||||||||||||||||
332 | */ | - | ||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | static const void *constData(const QVariant::Private &d) | - | ||||||||||||||||||||||||
335 | { | - | ||||||||||||||||||||||||
336 | return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.c); executed 2616 times by 33 tests: return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.c); Executed by:
| 373-2616 | ||||||||||||||||||||||||
337 | } | - | ||||||||||||||||||||||||
338 | - | |||||||||||||||||||||||||
339 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
340 | /*! | - | ||||||||||||||||||||||||
341 | \internal | - | ||||||||||||||||||||||||
342 | returns a QMetaEnum for a given meta tape type id if possible | - | ||||||||||||||||||||||||
343 | */ | - | ||||||||||||||||||||||||
344 | static QMetaEnum metaEnumFromType(int type) | - | ||||||||||||||||||||||||
345 | { | - | ||||||||||||||||||||||||
346 | QMetaType t(type); | - | ||||||||||||||||||||||||
347 | if (t.flags() & QMetaType::IsEnumeration) {
| 37-20480 | ||||||||||||||||||||||||
348 | if (const QMetaObject *metaObject = t.metaObject()) {
| 0-37 | ||||||||||||||||||||||||
349 | const char *enumName = QMetaType::typeName(type); | - | ||||||||||||||||||||||||
350 | const char *lastColon = std::strrchr(enumName, ':'); | - | ||||||||||||||||||||||||
351 | if (lastColon)
| 0-37 | ||||||||||||||||||||||||
352 | enumName = lastColon + 1; executed 37 times by 1 test: enumName = lastColon + 1; Executed by:
| 37 | ||||||||||||||||||||||||
353 | return metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); executed 37 times by 1 test: return metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); Executed by:
| 37 | ||||||||||||||||||||||||
354 | } | - | ||||||||||||||||||||||||
355 | } never executed: end of block | 0 | ||||||||||||||||||||||||
356 | return QMetaEnum(); executed 20480 times by 38 tests: return QMetaEnum(); Executed by:
| 20480 | ||||||||||||||||||||||||
357 | } | - | ||||||||||||||||||||||||
358 | #endif | - | ||||||||||||||||||||||||
359 | - | |||||||||||||||||||||||||
360 | /*! | - | ||||||||||||||||||||||||
361 | \internal | - | ||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | Converts \a d to type \a t, which is placed in \a result. | - | ||||||||||||||||||||||||
364 | */ | - | ||||||||||||||||||||||||
365 | static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) | - | ||||||||||||||||||||||||
366 | { | - | ||||||||||||||||||||||||
367 | Q_ASSERT(d->type != uint(t)); | - | ||||||||||||||||||||||||
368 | Q_ASSERT(result); | - | ||||||||||||||||||||||||
369 | - | |||||||||||||||||||||||||
370 | if (d->type >= QMetaType::User || t >= QMetaType::User) {
| 228-419110 | ||||||||||||||||||||||||
371 | const bool isOk = QMetaType::convert(constData(*d), d->type, result, t); | - | ||||||||||||||||||||||||
372 | if (ok)
| 27-807 | ||||||||||||||||||||||||
373 | *ok = isOk; executed 27 times by 1 test: *ok = isOk; Executed by:
| 27 | ||||||||||||||||||||||||
374 | if (isOk)
| 27-807 | ||||||||||||||||||||||||
375 | return true; executed 27 times by 2 tests: return true; Executed by:
| 27 | ||||||||||||||||||||||||
376 | } executed 807 times by 24 tests: end of block Executed by:
| 807 | ||||||||||||||||||||||||
377 | - | |||||||||||||||||||||||||
378 | bool dummy; | - | ||||||||||||||||||||||||
379 | if (!ok)
| 607-419082 | ||||||||||||||||||||||||
380 | ok = &dummy; executed 419082 times by 200 tests: ok = &dummy; Executed by:
| 419082 | ||||||||||||||||||||||||
381 | - | |||||||||||||||||||||||||
382 | switch (uint(t)) { | - | ||||||||||||||||||||||||
383 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
384 | case QVariant::Url: executed 6 times by 3 tests: case QVariant::Url: Executed by:
| 6 | ||||||||||||||||||||||||
385 | switch (d->type) { | - | ||||||||||||||||||||||||
386 | case QVariant::String: executed 6 times by 3 tests: case QVariant::String: Executed by:
| 6 | ||||||||||||||||||||||||
387 | *static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d)); | - | ||||||||||||||||||||||||
388 | break; executed 6 times by 3 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
389 | default: never executed: default: | 0 | ||||||||||||||||||||||||
390 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
391 | } | - | ||||||||||||||||||||||||
392 | break; executed 6 times by 3 tests: break; Executed by:
| 6 | ||||||||||||||||||||||||
393 | case QVariant::ModelIndex: executed 1 time by 1 test: case QVariant::ModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
394 | switch (d->type) { | - | ||||||||||||||||||||||||
395 | case QVariant::PersistentModelIndex: executed 1 time by 1 test: case QVariant::PersistentModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
396 | *static_cast<QModelIndex *>(result) = QModelIndex(*v_cast<QPersistentModelIndex>(d)); | - | ||||||||||||||||||||||||
397 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
398 | default: never executed: default: | 0 | ||||||||||||||||||||||||
399 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
400 | } | - | ||||||||||||||||||||||||
401 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
402 | case QVariant::PersistentModelIndex: executed 1 time by 1 test: case QVariant::PersistentModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
403 | switch (d->type) { | - | ||||||||||||||||||||||||
404 | case QVariant::ModelIndex: executed 1 time by 1 test: case QVariant::ModelIndex: Executed by:
| 1 | ||||||||||||||||||||||||
405 | *static_cast<QPersistentModelIndex *>(result) = QPersistentModelIndex(*v_cast<QModelIndex>(d)); | - | ||||||||||||||||||||||||
406 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
407 | default: never executed: default: | 0 | ||||||||||||||||||||||||
408 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
409 | } | - | ||||||||||||||||||||||||
410 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
411 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
412 | case QVariant::String: { executed 53452 times by 76 tests: case QVariant::String: Executed by:
| 53452 | ||||||||||||||||||||||||
413 | QString *str = static_cast<QString *>(result); | - | ||||||||||||||||||||||||
414 | switch (d->type) { | - | ||||||||||||||||||||||||
415 | case QVariant::Char: executed 3926 times by 13 tests: case QVariant::Char: Executed by:
| 3926 | ||||||||||||||||||||||||
416 | *str = *v_cast<QChar>(d); | - | ||||||||||||||||||||||||
417 | break; executed 3926 times by 13 tests: break; Executed by:
| 3926 | ||||||||||||||||||||||||
418 | case QMetaType::Char: executed 29 times by 1 test: case QMetaType::Char: Executed by:
| 29 | ||||||||||||||||||||||||
419 | case QMetaType::SChar: executed 36 times by 1 test: case QMetaType::SChar: Executed by:
| 36 | ||||||||||||||||||||||||
420 | case QMetaType::UChar: executed 10 times by 1 test: case QMetaType::UChar: Executed by:
| 10 | ||||||||||||||||||||||||
421 | *str = QChar::fromLatin1(d->data.c); | - | ||||||||||||||||||||||||
422 | break; executed 75 times by 1 test: break; Executed by:
| 75 | ||||||||||||||||||||||||
423 | case QMetaType::Short: executed 10 times by 1 test: case QMetaType::Short: Executed by:
| 10 | ||||||||||||||||||||||||
424 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
425 | case QVariant::Int: executed 28359 times by 44 tests: case QVariant::Int: Executed by:
| 28359 | ||||||||||||||||||||||||
426 | case QVariant::LongLong: executed 250 times by 9 tests: case QVariant::LongLong: Executed by:
| 250 | ||||||||||||||||||||||||
427 | *str = QString::number(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
428 | break; executed 28619 times by 46 tests: break; Executed by:
| 28619 | ||||||||||||||||||||||||
429 | case QVariant::UInt: executed 179 times by 5 tests: case QVariant::UInt: Executed by:
| 179 | ||||||||||||||||||||||||
430 | case QVariant::ULongLong: executed 43 times by 2 tests: case QVariant::ULongLong: Executed by:
| 43 | ||||||||||||||||||||||||
431 | case QMetaType::UShort: executed 10 times by 1 test: case QMetaType::UShort: Executed by:
| 10 | ||||||||||||||||||||||||
432 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
433 | *str = QString::number(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
434 | break; executed 232 times by 5 tests: break; Executed by:
| 232 | ||||||||||||||||||||||||
435 | case QMetaType::Float: executed 39 times by 1 test: case QMetaType::Float: Executed by:
| 39 | ||||||||||||||||||||||||
436 | *str = QString::number(d->data.f, 'g', max_digits10_float); | - | ||||||||||||||||||||||||
437 | break; executed 39 times by 1 test: break; Executed by:
| 39 | ||||||||||||||||||||||||
438 | case QVariant::Double: executed 118 times by 12 tests: case QVariant::Double: Executed by:
| 118 | ||||||||||||||||||||||||
439 | *str = QString::number(d->data.d, 'g', max_digits10_double); | - | ||||||||||||||||||||||||
440 | break; executed 118 times by 12 tests: break; Executed by:
| 118 | ||||||||||||||||||||||||
441 | #if !defined(QT_NO_DATESTRING) | - | ||||||||||||||||||||||||
442 | case QVariant::Date: executed 5 times by 2 tests: case QVariant::Date: Executed by:
| 5 | ||||||||||||||||||||||||
443 | *str = v_cast<QDate>(d)->toString(Qt::ISODate); | - | ||||||||||||||||||||||||
444 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||||||||||||||
445 | case QVariant::Time: executed 3 times by 1 test: case QVariant::Time: Executed by:
| 3 | ||||||||||||||||||||||||
446 | *str = v_cast<QTime>(d)->toString(Qt::ISODate); | - | ||||||||||||||||||||||||
447 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
448 | case QVariant::DateTime: executed 11 times by 2 tests: case QVariant::DateTime: Executed by:
| 11 | ||||||||||||||||||||||||
449 | *str = v_cast<QDateTime>(d)->toString(Qt::ISODate); | - | ||||||||||||||||||||||||
450 | break; executed 11 times by 2 tests: break; Executed by:
| 11 | ||||||||||||||||||||||||
451 | #endif | - | ||||||||||||||||||||||||
452 | case QVariant::Bool: executed 77 times by 6 tests: case QVariant::Bool: Executed by:
| 77 | ||||||||||||||||||||||||
453 | *str = QLatin1String(d->data.b ? "true" : "false"); | - | ||||||||||||||||||||||||
454 | break; executed 77 times by 6 tests: break; Executed by:
| 77 | ||||||||||||||||||||||||
455 | case QVariant::ByteArray: executed 25 times by 2 tests: case QVariant::ByteArray: Executed by:
| 25 | ||||||||||||||||||||||||
456 | *str = QString::fromUtf8(v_cast<QByteArray>(d)->constData()); | - | ||||||||||||||||||||||||
457 | break; executed 25 times by 2 tests: break; Executed by:
| 25 | ||||||||||||||||||||||||
458 | case QVariant::StringList: executed 18 times by 2 tests: case QVariant::StringList: Executed by:
| 18 | ||||||||||||||||||||||||
459 | if (v_cast<QStringList>(d)->count() == 1)
| 3-15 | ||||||||||||||||||||||||
460 | *str = v_cast<QStringList>(d)->at(0); executed 3 times by 1 test: *str = v_cast<QStringList>(d)->at(0); Executed by:
| 3 | ||||||||||||||||||||||||
461 | break; executed 18 times by 2 tests: break; Executed by:
| 18 | ||||||||||||||||||||||||
462 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
463 | case QVariant::Url: executed 8 times by 2 tests: case QVariant::Url: Executed by:
| 8 | ||||||||||||||||||||||||
464 | *str = v_cast<QUrl>(d)->toString(); | - | ||||||||||||||||||||||||
465 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
466 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||||||||||||||
467 | if (v_cast<QJsonValue>(d)->isString())
| 1 | ||||||||||||||||||||||||
468 | *str = v_cast<QJsonValue>(d)->toString(); executed 1 time by 1 test: *str = v_cast<QJsonValue>(d)->toString(); Executed by:
| 1 | ||||||||||||||||||||||||
469 | else if (!v_cast<QJsonValue>(d)->isNull())
| 0-1 | ||||||||||||||||||||||||
470 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
471 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
472 | #endif | - | ||||||||||||||||||||||||
473 | case QVariant::Uuid: executed 19 times by 2 tests: case QVariant::Uuid: Executed by:
| 19 | ||||||||||||||||||||||||
474 | *str = v_cast<QUuid>(d)->toString(); | - | ||||||||||||||||||||||||
475 | break; executed 19 times by 2 tests: break; Executed by:
| 19 | ||||||||||||||||||||||||
476 | default: executed 20275 times by 38 tests: default: Executed by:
| 20275 | ||||||||||||||||||||||||
477 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
478 | { | - | ||||||||||||||||||||||||
479 | QMetaEnum en = metaEnumFromType(d->type); | - | ||||||||||||||||||||||||
480 | if (en.isValid()) {
| 10-20265 | ||||||||||||||||||||||||
481 | *str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok))); | - | ||||||||||||||||||||||||
482 | return *ok; executed 10 times by 1 test: return *ok; Executed by:
| 10 | ||||||||||||||||||||||||
483 | } | - | ||||||||||||||||||||||||
484 | } | - | ||||||||||||||||||||||||
485 | #endif | - | ||||||||||||||||||||||||
486 | return false; executed 20265 times by 38 tests: return false; Executed by:
| 20265 | ||||||||||||||||||||||||
487 | } | - | ||||||||||||||||||||||||
488 | break; executed 33177 times by 62 tests: break; Executed by:
| 33177 | ||||||||||||||||||||||||
489 | } | - | ||||||||||||||||||||||||
490 | case QVariant::Char: { executed 4 times by 2 tests: case QVariant::Char: Executed by:
| 4 | ||||||||||||||||||||||||
491 | QChar *c = static_cast<QChar *>(result); | - | ||||||||||||||||||||||||
492 | switch (d->type) { | - | ||||||||||||||||||||||||
493 | case QVariant::Int: executed 2 times by 1 test: case QVariant::Int: Executed by:
| 2 | ||||||||||||||||||||||||
494 | case QVariant::LongLong: executed 1 time by 1 test: case QVariant::LongLong: Executed by:
| 1 | ||||||||||||||||||||||||
495 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
496 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
497 | case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||||||||||||||
498 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
499 | case QMetaType::Float: never executed: case QMetaType::Float: | 0 | ||||||||||||||||||||||||
500 | *c = QChar(ushort(qMetaTypeNumber(d))); | - | ||||||||||||||||||||||||
501 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||||||||||||||
502 | case QVariant::UInt: never executed: case QVariant::UInt: | 0 | ||||||||||||||||||||||||
503 | case QVariant::ULongLong: executed 1 time by 1 test: case QVariant::ULongLong: Executed by:
| 1 | ||||||||||||||||||||||||
504 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
505 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
506 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
507 | *c = QChar(ushort(qMetaTypeUNumber(d))); | - | ||||||||||||||||||||||||
508 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
509 | default: never executed: default: | 0 | ||||||||||||||||||||||||
510 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
511 | } | - | ||||||||||||||||||||||||
512 | break; executed 4 times by 2 tests: break; Executed by:
| 4 | ||||||||||||||||||||||||
513 | } | - | ||||||||||||||||||||||||
514 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
515 | case QVariant::Size: { executed 62 times by 5 tests: case QVariant::Size: Executed by:
| 62 | ||||||||||||||||||||||||
516 | QSize *s = static_cast<QSize *>(result); | - | ||||||||||||||||||||||||
517 | switch (d->type) { | - | ||||||||||||||||||||||||
518 | case QVariant::SizeF: executed 4 times by 1 test: case QVariant::SizeF: Executed by:
| 4 | ||||||||||||||||||||||||
519 | *s = v_cast<QSizeF>(d)->toSize(); | - | ||||||||||||||||||||||||
520 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
521 | default: executed 58 times by 4 tests: default: Executed by:
| 58 | ||||||||||||||||||||||||
522 | return false; executed 58 times by 4 tests: return false; Executed by:
| 58 | ||||||||||||||||||||||||
523 | } | - | ||||||||||||||||||||||||
524 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
525 | } | - | ||||||||||||||||||||||||
526 | - | |||||||||||||||||||||||||
527 | case QVariant::SizeF: { executed 23 times by 3 tests: case QVariant::SizeF: Executed by:
| 23 | ||||||||||||||||||||||||
528 | QSizeF *s = static_cast<QSizeF *>(result); | - | ||||||||||||||||||||||||
529 | switch (d->type) { | - | ||||||||||||||||||||||||
530 | case QVariant::Size: executed 21 times by 2 tests: case QVariant::Size: Executed by:
| 21 | ||||||||||||||||||||||||
531 | *s = QSizeF(*(v_cast<QSize>(d))); | - | ||||||||||||||||||||||||
532 | break; executed 21 times by 2 tests: break; Executed by:
| 21 | ||||||||||||||||||||||||
533 | default: executed 2 times by 1 test: default: Executed by:
| 2 | ||||||||||||||||||||||||
534 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
535 | } | - | ||||||||||||||||||||||||
536 | break; executed 21 times by 2 tests: break; Executed by:
| 21 | ||||||||||||||||||||||||
537 | } | - | ||||||||||||||||||||||||
538 | - | |||||||||||||||||||||||||
539 | case QVariant::Line: { executed 4 times by 1 test: case QVariant::Line: Executed by:
| 4 | ||||||||||||||||||||||||
540 | QLine *s = static_cast<QLine *>(result); | - | ||||||||||||||||||||||||
541 | switch (d->type) { | - | ||||||||||||||||||||||||
542 | case QVariant::LineF: executed 4 times by 1 test: case QVariant::LineF: Executed by:
| 4 | ||||||||||||||||||||||||
543 | *s = v_cast<QLineF>(d)->toLine(); | - | ||||||||||||||||||||||||
544 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
545 | default: never executed: default: | 0 | ||||||||||||||||||||||||
546 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
547 | } | - | ||||||||||||||||||||||||
548 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
549 | } | - | ||||||||||||||||||||||||
550 | - | |||||||||||||||||||||||||
551 | case QVariant::LineF: { executed 6 times by 2 tests: case QVariant::LineF: Executed by:
| 6 | ||||||||||||||||||||||||
552 | QLineF *s = static_cast<QLineF *>(result); | - | ||||||||||||||||||||||||
553 | switch (d->type) { | - | ||||||||||||||||||||||||
554 | case QVariant::Line: executed 4 times by 1 test: case QVariant::Line: Executed by:
| 4 | ||||||||||||||||||||||||
555 | *s = QLineF(*(v_cast<QLine>(d))); | - | ||||||||||||||||||||||||
556 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
557 | default: executed 2 times by 1 test: default: Executed by:
| 2 | ||||||||||||||||||||||||
558 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
559 | } | - | ||||||||||||||||||||||||
560 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
561 | } | - | ||||||||||||||||||||||||
562 | #endif | - | ||||||||||||||||||||||||
563 | case QVariant::StringList: executed 25 times by 25 tests: case QVariant::StringList: Executed by:
| 25 | ||||||||||||||||||||||||
564 | if (d->type == QVariant::List) {
| 0-25 | ||||||||||||||||||||||||
565 | QStringList *slst = static_cast<QStringList *>(result); | - | ||||||||||||||||||||||||
566 | const QVariantList *list = v_cast<QVariantList >(d); | - | ||||||||||||||||||||||||
567 | for (int i = 0; i < list->size(); ++i)
| 0 | ||||||||||||||||||||||||
568 | slst->append(list->at(i).toString()); never executed: slst->append(list->at(i).toString()); | 0 | ||||||||||||||||||||||||
569 | } else if (d->type == QVariant::String) { never executed: end of block
| 0-25 | ||||||||||||||||||||||||
570 | QStringList *slst = static_cast<QStringList *>(result); | - | ||||||||||||||||||||||||
571 | *slst = QStringList(*v_cast<QString>(d)); | - | ||||||||||||||||||||||||
572 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
573 | return false; executed 25 times by 25 tests: return false; Executed by:
| 25 | ||||||||||||||||||||||||
574 | } | - | ||||||||||||||||||||||||
575 | break; never executed: break; | 0 | ||||||||||||||||||||||||
576 | case QVariant::Date: { executed 12673 times by 4 tests: case QVariant::Date: Executed by:
| 12673 | ||||||||||||||||||||||||
577 | QDate *dt = static_cast<QDate *>(result); | - | ||||||||||||||||||||||||
578 | if (d->type == QVariant::DateTime)
| 2-12671 | ||||||||||||||||||||||||
579 | *dt = v_cast<QDateTime>(d)->date(); executed 12671 times by 4 tests: *dt = v_cast<QDateTime>(d)->date(); Executed by:
| 12671 | ||||||||||||||||||||||||
580 | #ifndef QT_NO_DATESTRING | - | ||||||||||||||||||||||||
581 | else if (d->type == QVariant::String)
| 0-2 | ||||||||||||||||||||||||
582 | *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate); executed 2 times by 1 test: *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate); Executed by:
| 2 | ||||||||||||||||||||||||
583 | #endif | - | ||||||||||||||||||||||||
584 | else | - | ||||||||||||||||||||||||
585 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
586 | - | |||||||||||||||||||||||||
587 | return dt->isValid(); executed 12673 times by 4 tests: return dt->isValid(); Executed by:
| 12673 | ||||||||||||||||||||||||
588 | } | - | ||||||||||||||||||||||||
589 | case QVariant::Time: { executed 10943 times by 5 tests: case QVariant::Time: Executed by:
| 10943 | ||||||||||||||||||||||||
590 | QTime *t = static_cast<QTime *>(result); | - | ||||||||||||||||||||||||
591 | switch (d->type) { | - | ||||||||||||||||||||||||
592 | case QVariant::DateTime: executed 10941 times by 5 tests: case QVariant::DateTime: Executed by:
| 10941 | ||||||||||||||||||||||||
593 | *t = v_cast<QDateTime>(d)->time(); | - | ||||||||||||||||||||||||
594 | break; executed 10941 times by 5 tests: break; Executed by:
| 10941 | ||||||||||||||||||||||||
595 | #ifndef QT_NO_DATESTRING | - | ||||||||||||||||||||||||
596 | case QVariant::String: executed 2 times by 1 test: case QVariant::String: Executed by:
| 2 | ||||||||||||||||||||||||
597 | *t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate); | - | ||||||||||||||||||||||||
598 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
599 | #endif | - | ||||||||||||||||||||||||
600 | default: never executed: default: | 0 | ||||||||||||||||||||||||
601 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
602 | } | - | ||||||||||||||||||||||||
603 | return t->isValid(); executed 10943 times by 5 tests: return t->isValid(); Executed by:
| 10943 | ||||||||||||||||||||||||
604 | } | - | ||||||||||||||||||||||||
605 | case QVariant::DateTime: { executed 943 times by 7 tests: case QVariant::DateTime: Executed by:
| 943 | ||||||||||||||||||||||||
606 | QDateTime *dt = static_cast<QDateTime *>(result); | - | ||||||||||||||||||||||||
607 | switch (d->type) { | - | ||||||||||||||||||||||||
608 | #ifndef QT_NO_DATESTRING | - | ||||||||||||||||||||||||
609 | case QVariant::String: executed 12 times by 2 tests: case QVariant::String: Executed by:
| 12 | ||||||||||||||||||||||||
610 | *dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate); | - | ||||||||||||||||||||||||
611 | break; executed 12 times by 2 tests: break; Executed by:
| 12 | ||||||||||||||||||||||||
612 | #endif | - | ||||||||||||||||||||||||
613 | case QVariant::Date: executed 2 times by 2 tests: case QVariant::Date: Executed by:
| 2 | ||||||||||||||||||||||||
614 | *dt = QDateTime(*v_cast<QDate>(d)); | - | ||||||||||||||||||||||||
615 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||||||||||||||
616 | default: executed 929 times by 5 tests: default: Executed by:
| 929 | ||||||||||||||||||||||||
617 | return false; executed 929 times by 5 tests: return false; Executed by:
| 929 | ||||||||||||||||||||||||
618 | } | - | ||||||||||||||||||||||||
619 | return dt->isValid(); executed 14 times by 3 tests: return dt->isValid(); Executed by:
| 14 | ||||||||||||||||||||||||
620 | } | - | ||||||||||||||||||||||||
621 | case QVariant::ByteArray: { executed 609 times by 11 tests: case QVariant::ByteArray: Executed by:
| 609 | ||||||||||||||||||||||||
622 | QByteArray *ba = static_cast<QByteArray *>(result); | - | ||||||||||||||||||||||||
623 | switch (d->type) { | - | ||||||||||||||||||||||||
624 | case QVariant::String: executed 118 times by 6 tests: case QVariant::String: Executed by:
| 118 | ||||||||||||||||||||||||
625 | *ba = v_cast<QString>(d)->toUtf8(); | - | ||||||||||||||||||||||||
626 | break; executed 118 times by 6 tests: break; Executed by:
| 118 | ||||||||||||||||||||||||
627 | case QVariant::Double: executed 3 times by 1 test: case QVariant::Double: Executed by:
| 3 | ||||||||||||||||||||||||
628 | *ba = QByteArray::number(d->data.d, 'g', max_digits10_double); | - | ||||||||||||||||||||||||
629 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
630 | case QMetaType::Float: executed 3 times by 1 test: case QMetaType::Float: Executed by:
| 3 | ||||||||||||||||||||||||
631 | *ba = QByteArray::number(d->data.f, 'g', max_digits10_float); | - | ||||||||||||||||||||||||
632 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
633 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
634 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
635 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
636 | *ba = QByteArray(1, d->data.c); | - | ||||||||||||||||||||||||
637 | break; never executed: break; | 0 | ||||||||||||||||||||||||
638 | case QVariant::Int: executed 6 times by 4 tests: case QVariant::Int: Executed by:
| 6 | ||||||||||||||||||||||||
639 | case QVariant::LongLong: executed 249 times by 5 tests: case QVariant::LongLong: Executed by:
| 249 | ||||||||||||||||||||||||
640 | case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||||||||||||||
641 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
642 | *ba = QByteArray::number(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
643 | break; executed 255 times by 6 tests: break; Executed by:
| 255 | ||||||||||||||||||||||||
644 | case QVariant::UInt: executed 2 times by 1 test: case QVariant::UInt: Executed by:
| 2 | ||||||||||||||||||||||||
645 | case QVariant::ULongLong: executed 2 times by 1 test: case QVariant::ULongLong: Executed by:
| 2 | ||||||||||||||||||||||||
646 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
647 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
648 | *ba = QByteArray::number(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
649 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||||||||||||||
650 | case QVariant::Bool: executed 3 times by 1 test: case QVariant::Bool: Executed by:
| 3 | ||||||||||||||||||||||||
651 | *ba = QByteArray(d->data.b ? "true" : "false"); | - | ||||||||||||||||||||||||
652 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
653 | default: executed 223 times by 4 tests: default: Executed by:
| 223 | ||||||||||||||||||||||||
654 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
655 | { | - | ||||||||||||||||||||||||
656 | QMetaEnum en = metaEnumFromType(d->type); | - | ||||||||||||||||||||||||
657 | if (en.isValid()) {
| 10-213 | ||||||||||||||||||||||||
658 | *ba = en.valueToKey(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
659 | return *ok; executed 10 times by 1 test: return *ok; Executed by:
| 10 | ||||||||||||||||||||||||
660 | } | - | ||||||||||||||||||||||||
661 | } | - | ||||||||||||||||||||||||
662 | #endif | - | ||||||||||||||||||||||||
663 | return false; executed 213 times by 3 tests: return false; Executed by:
| 213 | ||||||||||||||||||||||||
664 | } | - | ||||||||||||||||||||||||
665 | } | - | ||||||||||||||||||||||||
666 | break; executed 386 times by 8 tests: break; Executed by:
| 386 | ||||||||||||||||||||||||
667 | case QMetaType::Short: executed 28 times by 2 tests: case QMetaType::Short: Executed by:
| 28 | ||||||||||||||||||||||||
668 | *static_cast<short *>(result) = short(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
669 | return *ok; executed 28 times by 2 tests: return *ok; Executed by:
| 28 | ||||||||||||||||||||||||
670 | case QMetaType::Long: executed 1 time by 1 test: case QMetaType::Long: Executed by:
| 1 | ||||||||||||||||||||||||
671 | *static_cast<long *>(result) = long(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
672 | return *ok; executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||||||||||||||
673 | case QMetaType::UShort: executed 31 times by 1 test: case QMetaType::UShort: Executed by:
| 31 | ||||||||||||||||||||||||
674 | *static_cast<ushort *>(result) = ushort(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||||||||||||||
675 | return *ok; executed 31 times by 1 test: return *ok; Executed by:
| 31 | ||||||||||||||||||||||||
676 | case QMetaType::ULong: executed 7 times by 1 test: case QMetaType::ULong: Executed by:
| 7 | ||||||||||||||||||||||||
677 | *static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||||||||||||||
678 | return *ok; executed 7 times by 1 test: return *ok; Executed by:
| 7 | ||||||||||||||||||||||||
679 | case QVariant::Int: executed 16282 times by 69 tests: case QVariant::Int: Executed by:
| 16282 | ||||||||||||||||||||||||
680 | *static_cast<int *>(result) = int(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
681 | return *ok; executed 16282 times by 69 tests: return *ok; Executed by:
| 16282 | ||||||||||||||||||||||||
682 | case QVariant::UInt: executed 189 times by 24 tests: case QVariant::UInt: Executed by:
| 189 | ||||||||||||||||||||||||
683 | *static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||||||||||||||
684 | return *ok; executed 189 times by 24 tests: return *ok; Executed by:
| 189 | ||||||||||||||||||||||||
685 | case QVariant::LongLong: executed 10784 times by 15 tests: case QVariant::LongLong: Executed by:
| 10784 | ||||||||||||||||||||||||
686 | *static_cast<qlonglong *>(result) = qConvertToNumber(d, ok); | - | ||||||||||||||||||||||||
687 | return *ok; executed 10784 times by 15 tests: return *ok; Executed by:
| 10784 | ||||||||||||||||||||||||
688 | case QVariant::ULongLong: { executed 141 times by 12 tests: case QVariant::ULongLong: Executed by:
| 141 | ||||||||||||||||||||||||
689 | *static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok); | - | ||||||||||||||||||||||||
690 | return *ok; executed 141 times by 12 tests: return *ok; Executed by:
| 141 | ||||||||||||||||||||||||
691 | } | - | ||||||||||||||||||||||||
692 | case QMetaType::SChar: { executed 1 time by 1 test: case QMetaType::SChar: Executed by:
| 1 | ||||||||||||||||||||||||
693 | signed char s = qConvertToNumber(d, ok); | - | ||||||||||||||||||||||||
694 | *static_cast<signed char*>(result) = s; | - | ||||||||||||||||||||||||
695 | return *ok; executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||||||||||||||
696 | } | - | ||||||||||||||||||||||||
697 | case QMetaType::UChar: { executed 1 time by 1 test: case QMetaType::UChar: Executed by:
| 1 | ||||||||||||||||||||||||
698 | *static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok); | - | ||||||||||||||||||||||||
699 | return *ok; executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||||||||||||||
700 | } | - | ||||||||||||||||||||||||
701 | case QVariant::Bool: { executed 41414 times by 115 tests: case QVariant::Bool: Executed by:
| 41414 | ||||||||||||||||||||||||
702 | bool *b = static_cast<bool *>(result); | - | ||||||||||||||||||||||||
703 | switch(d->type) { | - | ||||||||||||||||||||||||
704 | case QVariant::ByteArray: executed 10 times by 1 test: case QVariant::ByteArray: Executed by:
| 10 | ||||||||||||||||||||||||
705 | *b = qt_convertToBool<QByteArray, QByteArray>(d); | - | ||||||||||||||||||||||||
706 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||||||||||||||
707 | case QVariant::String: executed 20 times by 3 tests: case QVariant::String: Executed by:
| 20 | ||||||||||||||||||||||||
708 | *b = qt_convertToBool<QString, QLatin1String>(d); | - | ||||||||||||||||||||||||
709 | break; executed 20 times by 3 tests: break; Executed by:
| 20 | ||||||||||||||||||||||||
710 | case QVariant::Char: executed 2 times by 1 test: case QVariant::Char: Executed by:
| 2 | ||||||||||||||||||||||||
711 | *b = !v_cast<QChar>(d)->isNull(); | - | ||||||||||||||||||||||||
712 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
713 | case QVariant::Double: executed 11 times by 2 tests: case QVariant::Double: Executed by:
| 11 | ||||||||||||||||||||||||
714 | case QVariant::Int: executed 35 times by 4 tests: case QVariant::Int: Executed by:
| 35 | ||||||||||||||||||||||||
715 | case QVariant::LongLong: executed 16 times by 2 tests: case QVariant::LongLong: Executed by:
| 16 | ||||||||||||||||||||||||
716 | case QMetaType::Char: executed 4 times by 1 test: case QMetaType::Char: Executed by:
| 4 | ||||||||||||||||||||||||
717 | case QMetaType::SChar: executed 8 times by 1 test: case QMetaType::SChar: Executed by:
| 8 | ||||||||||||||||||||||||
718 | case QMetaType::Short: executed 8 times by 1 test: case QMetaType::Short: Executed by:
| 8 | ||||||||||||||||||||||||
719 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
720 | case QMetaType::Float: executed 6 times by 1 test: case QMetaType::Float: Executed by:
| 6 | ||||||||||||||||||||||||
721 | *b = qMetaTypeNumber(d) != Q_INT64_C(0); | - | ||||||||||||||||||||||||
722 | break; executed 88 times by 6 tests: break; Executed by:
| 88 | ||||||||||||||||||||||||
723 | case QVariant::UInt: executed 1266 times by 12 tests: case QVariant::UInt: Executed by:
| 1266 | ||||||||||||||||||||||||
724 | case QVariant::ULongLong: executed 10 times by 1 test: case QVariant::ULongLong: Executed by:
| 10 | ||||||||||||||||||||||||
725 | case QMetaType::UChar: executed 8 times by 1 test: case QMetaType::UChar: Executed by:
| 8 | ||||||||||||||||||||||||
726 | case QMetaType::UShort: executed 8 times by 1 test: case QMetaType::UShort: Executed by:
| 8 | ||||||||||||||||||||||||
727 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
728 | *b = qMetaTypeUNumber(d) != Q_UINT64_C(0); | - | ||||||||||||||||||||||||
729 | break; executed 1292 times by 12 tests: break; Executed by:
| 1292 | ||||||||||||||||||||||||
730 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
731 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||||||||||||||
732 | *b = v_cast<QJsonValue>(d)->toBool(false); | - | ||||||||||||||||||||||||
733 | if (!v_cast<QJsonValue>(d)->isBool())
| 0-2 | ||||||||||||||||||||||||
734 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
735 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
736 | #endif | - | ||||||||||||||||||||||||
737 | default: executed 40000 times by 110 tests: default: Executed by:
| 40000 | ||||||||||||||||||||||||
738 | *b = false; | - | ||||||||||||||||||||||||
739 | return false; executed 40000 times by 110 tests: return false; Executed by:
| 40000 | ||||||||||||||||||||||||
740 | } | - | ||||||||||||||||||||||||
741 | break; executed 1414 times by 17 tests: break; Executed by:
| 1414 | ||||||||||||||||||||||||
742 | } | - | ||||||||||||||||||||||||
743 | case QVariant::Double: { executed 593 times by 17 tests: case QVariant::Double: Executed by:
| 593 | ||||||||||||||||||||||||
744 | double *f = static_cast<double *>(result); | - | ||||||||||||||||||||||||
745 | switch (d->type) { | - | ||||||||||||||||||||||||
746 | case QVariant::String: executed 328 times by 13 tests: case QVariant::String: Executed by:
| 328 | ||||||||||||||||||||||||
747 | *f = v_cast<QString>(d)->toDouble(ok); | - | ||||||||||||||||||||||||
748 | break; executed 328 times by 13 tests: break; Executed by:
| 328 | ||||||||||||||||||||||||
749 | case QVariant::ByteArray: executed 3 times by 1 test: case QVariant::ByteArray: Executed by:
| 3 | ||||||||||||||||||||||||
750 | *f = v_cast<QByteArray>(d)->toDouble(ok); | - | ||||||||||||||||||||||||
751 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
752 | case QVariant::Bool: executed 8 times by 1 test: case QVariant::Bool: Executed by:
| 8 | ||||||||||||||||||||||||
753 | *f = double(d->data.b); | - | ||||||||||||||||||||||||
754 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||||||||||||||
755 | case QMetaType::Float: executed 9 times by 2 tests: case QMetaType::Float: Executed by:
| 9 | ||||||||||||||||||||||||
756 | *f = double(d->data.f); | - | ||||||||||||||||||||||||
757 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||||||||||||||
758 | case QVariant::LongLong: executed 10 times by 2 tests: case QVariant::LongLong: Executed by:
| 10 | ||||||||||||||||||||||||
759 | case QVariant::Int: executed 47 times by 4 tests: case QVariant::Int: Executed by:
| 47 | ||||||||||||||||||||||||
760 | case QMetaType::Char: executed 4 times by 1 test: case QMetaType::Char: Executed by:
| 4 | ||||||||||||||||||||||||
761 | case QMetaType::SChar: executed 8 times by 1 test: case QMetaType::SChar: Executed by:
| 8 | ||||||||||||||||||||||||
762 | case QMetaType::Short: executed 9 times by 1 test: case QMetaType::Short: Executed by:
| 9 | ||||||||||||||||||||||||
763 | case QMetaType::Long: executed 3 times by 1 test: case QMetaType::Long: Executed by:
| 3 | ||||||||||||||||||||||||
764 | *f = double(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
765 | break; executed 81 times by 5 tests: break; Executed by:
| 81 | ||||||||||||||||||||||||
766 | case QVariant::UInt: executed 6 times by 1 test: case QVariant::UInt: Executed by:
| 6 | ||||||||||||||||||||||||
767 | case QVariant::ULongLong: executed 10 times by 1 test: case QVariant::ULongLong: Executed by:
| 10 | ||||||||||||||||||||||||
768 | case QMetaType::UChar: executed 8 times by 1 test: case QMetaType::UChar: Executed by:
| 8 | ||||||||||||||||||||||||
769 | case QMetaType::UShort: executed 8 times by 1 test: case QMetaType::UShort: Executed by:
| 8 | ||||||||||||||||||||||||
770 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
771 | *f = double(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
772 | break; executed 32 times by 1 test: break; Executed by:
| 32 | ||||||||||||||||||||||||
773 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
774 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||||||||||||||
775 | *f = v_cast<QJsonValue>(d)->toDouble(0.0); | - | ||||||||||||||||||||||||
776 | if (!v_cast<QJsonValue>(d)->isDouble())
| 1 | ||||||||||||||||||||||||
777 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
778 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
779 | #endif | - | ||||||||||||||||||||||||
780 | default: executed 130 times by 1 test: default: Executed by:
| 130 | ||||||||||||||||||||||||
781 | *f = 0.0; | - | ||||||||||||||||||||||||
782 | return false; executed 130 times by 1 test: return false; Executed by:
| 130 | ||||||||||||||||||||||||
783 | } | - | ||||||||||||||||||||||||
784 | break; executed 462 times by 17 tests: break; Executed by:
| 462 | ||||||||||||||||||||||||
785 | } | - | ||||||||||||||||||||||||
786 | case QMetaType::Float: { executed 25 times by 3 tests: case QMetaType::Float: Executed by:
| 25 | ||||||||||||||||||||||||
787 | float *f = static_cast<float *>(result); | - | ||||||||||||||||||||||||
788 | switch (d->type) { | - | ||||||||||||||||||||||||
789 | case QVariant::String: executed 7 times by 2 tests: case QVariant::String: Executed by:
| 7 | ||||||||||||||||||||||||
790 | *f = v_cast<QString>(d)->toFloat(ok); | - | ||||||||||||||||||||||||
791 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||||||||||||||
792 | case QVariant::ByteArray: executed 3 times by 1 test: case QVariant::ByteArray: Executed by:
| 3 | ||||||||||||||||||||||||
793 | *f = v_cast<QByteArray>(d)->toFloat(ok); | - | ||||||||||||||||||||||||
794 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
795 | case QVariant::Bool: never executed: case QVariant::Bool: | 0 | ||||||||||||||||||||||||
796 | *f = float(d->data.b); | - | ||||||||||||||||||||||||
797 | break; never executed: break; | 0 | ||||||||||||||||||||||||
798 | case QVariant::Double: executed 3 times by 1 test: case QVariant::Double: Executed by:
| 3 | ||||||||||||||||||||||||
799 | *f = float(d->data.d); | - | ||||||||||||||||||||||||
800 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||||||||||||||
801 | case QVariant::LongLong: never executed: case QVariant::LongLong: | 0 | ||||||||||||||||||||||||
802 | case QVariant::Int: executed 3 times by 1 test: case QVariant::Int: Executed by:
| 3 | ||||||||||||||||||||||||
803 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
804 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
805 | case QMetaType::Short: executed 1 time by 1 test: case QMetaType::Short: Executed by:
| 1 | ||||||||||||||||||||||||
806 | case QMetaType::Long: executed 2 times by 1 test: case QMetaType::Long: Executed by:
| 2 | ||||||||||||||||||||||||
807 | *f = float(qMetaTypeNumber(d)); | - | ||||||||||||||||||||||||
808 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||||||||||||||
809 | case QVariant::UInt: executed 1 time by 1 test: case QVariant::UInt: Executed by:
| 1 | ||||||||||||||||||||||||
810 | case QVariant::ULongLong: executed 1 time by 1 test: case QVariant::ULongLong: Executed by:
| 1 | ||||||||||||||||||||||||
811 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
812 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
813 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
814 | *f = float(qMetaTypeUNumber(d)); | - | ||||||||||||||||||||||||
815 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||||||||||||||
816 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
817 | case QMetaType::QJsonValue: executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||||||||||||||
818 | *f = v_cast<QJsonValue>(d)->toDouble(0.0); | - | ||||||||||||||||||||||||
819 | if (!v_cast<QJsonValue>(d)->isDouble())
| 1 | ||||||||||||||||||||||||
820 | return false; executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||||||||||||||
821 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
822 | #endif | - | ||||||||||||||||||||||||
823 | default: executed 2 times by 1 test: default: Executed by:
| 2 | ||||||||||||||||||||||||
824 | *f = 0.0f; | - | ||||||||||||||||||||||||
825 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
826 | } | - | ||||||||||||||||||||||||
827 | break; executed 22 times by 2 tests: break; Executed by:
| 22 | ||||||||||||||||||||||||
828 | } | - | ||||||||||||||||||||||||
829 | case QVariant::List: executed 487 times by 6 tests: case QVariant::List: Executed by:
| 487 | ||||||||||||||||||||||||
830 | if (d->type == QVariant::StringList) {
| 0-487 | ||||||||||||||||||||||||
831 | QVariantList *lst = static_cast<QVariantList *>(result); | - | ||||||||||||||||||||||||
832 | const QStringList *slist = v_cast<QStringList>(d); | - | ||||||||||||||||||||||||
833 | for (int i = 0; i < slist->size(); ++i)
| 487-810 | ||||||||||||||||||||||||
834 | lst->append(QVariant(slist->at(i))); executed 810 times by 6 tests: lst->append(QVariant(slist->at(i))); Executed by:
| 810 | ||||||||||||||||||||||||
835 | } else if (qstrcmp(QMetaType::typeName(d->type), "QList<QVariant>") == 0) { executed 487 times by 6 tests: end of block Executed by:
| 0-487 | ||||||||||||||||||||||||
836 | *static_cast<QVariantList *>(result) = | - | ||||||||||||||||||||||||
837 | *static_cast<QList<QVariant> *>(d->data.shared->ptr); | - | ||||||||||||||||||||||||
838 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
839 | } else if (d->type == QMetaType::QJsonValue) { never executed: end of block
| 0 | ||||||||||||||||||||||||
840 | if (!v_cast<QJsonValue>(d)->isArray())
| 0 | ||||||||||||||||||||||||
841 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
842 | *static_cast<QVariantList *>(result) = v_cast<QJsonValue>(d)->toArray().toVariantList(); | - | ||||||||||||||||||||||||
843 | } else if (d->type == QMetaType::QJsonArray) { never executed: end of block
| 0 | ||||||||||||||||||||||||
844 | *static_cast<QVariantList *>(result) = v_cast<QJsonArray>(d)->toVariantList(); | - | ||||||||||||||||||||||||
845 | #endif | - | ||||||||||||||||||||||||
846 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
847 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
848 | } | - | ||||||||||||||||||||||||
849 | break; executed 487 times by 6 tests: break; Executed by:
| 487 | ||||||||||||||||||||||||
850 | case QVariant::Map: executed 2 times by 1 test: case QVariant::Map: Executed by:
| 2 | ||||||||||||||||||||||||
851 | if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0) {
| 0-2 | ||||||||||||||||||||||||
852 | *static_cast<QVariantMap *>(result) = | - | ||||||||||||||||||||||||
853 | *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr); | - | ||||||||||||||||||||||||
854 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
855 | } else if (d->type == QMetaType::QJsonValue) { never executed: end of block
| 0-2 | ||||||||||||||||||||||||
856 | if (!v_cast<QJsonValue>(d)->isObject())
| 0 | ||||||||||||||||||||||||
857 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
858 | *static_cast<QVariantMap *>(result) = v_cast<QJsonValue>(d)->toObject().toVariantMap(); | - | ||||||||||||||||||||||||
859 | } else if (d->type == QMetaType::QJsonObject) { never executed: end of block
| 0-2 | ||||||||||||||||||||||||
860 | *static_cast<QVariantMap *>(result) = v_cast<QJsonObject>(d)->toVariantMap(); | - | ||||||||||||||||||||||||
861 | #endif | - | ||||||||||||||||||||||||
862 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
863 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
864 | } | - | ||||||||||||||||||||||||
865 | break; never executed: break; | 0 | ||||||||||||||||||||||||
866 | case QVariant::Hash: never executed: case QVariant::Hash: | 0 | ||||||||||||||||||||||||
867 | if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) {
| 0 | ||||||||||||||||||||||||
868 | *static_cast<QVariantHash *>(result) = | - | ||||||||||||||||||||||||
869 | *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr); | - | ||||||||||||||||||||||||
870 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
871 | } else if (d->type == QMetaType::QJsonValue) { never executed: end of block
| 0 | ||||||||||||||||||||||||
872 | if (!v_cast<QJsonValue>(d)->isObject())
| 0 | ||||||||||||||||||||||||
873 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
874 | *static_cast<QVariantHash *>(result) = v_cast<QJsonValue>(d)->toObject().toVariantHash(); | - | ||||||||||||||||||||||||
875 | } else if (d->type == QMetaType::QJsonObject) { never executed: end of block
| 0 | ||||||||||||||||||||||||
876 | *static_cast<QVariantHash *>(result) = v_cast<QJsonObject>(d)->toVariantHash(); | - | ||||||||||||||||||||||||
877 | #endif | - | ||||||||||||||||||||||||
878 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
879 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
880 | } | - | ||||||||||||||||||||||||
881 | break; never executed: break; | 0 | ||||||||||||||||||||||||
882 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
883 | case QVariant::Rect: executed 8 times by 4 tests: case QVariant::Rect: Executed by:
| 8 | ||||||||||||||||||||||||
884 | if (d->type == QVariant::RectF)
| 0-8 | ||||||||||||||||||||||||
885 | *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect(); executed 8 times by 4 tests: *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect(); Executed by:
| 8 | ||||||||||||||||||||||||
886 | else | - | ||||||||||||||||||||||||
887 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
888 | break; executed 8 times by 4 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
889 | case QVariant::RectF: executed 3 times by 2 tests: case QVariant::RectF: Executed by:
| 3 | ||||||||||||||||||||||||
890 | if (d->type == QVariant::Rect)
| 1-2 | ||||||||||||||||||||||||
891 | *static_cast<QRectF *>(result) = *v_cast<QRect>(d); executed 1 time by 1 test: *static_cast<QRectF *>(result) = *v_cast<QRect>(d); Executed by:
| 1 | ||||||||||||||||||||||||
892 | else | - | ||||||||||||||||||||||||
893 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
894 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||||||||||||||
895 | case QVariant::PointF: executed 2 times by 1 test: case QVariant::PointF: Executed by:
| 2 | ||||||||||||||||||||||||
896 | if (d->type == QVariant::Point)
| 0-2 | ||||||||||||||||||||||||
897 | *static_cast<QPointF *>(result) = *v_cast<QPoint>(d); never executed: *static_cast<QPointF *>(result) = *v_cast<QPoint>(d); | 0 | ||||||||||||||||||||||||
898 | else | - | ||||||||||||||||||||||||
899 | return false; executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||||||||||||||
900 | break; never executed: break; | 0 | ||||||||||||||||||||||||
901 | case QVariant::Point: executed 28 times by 3 tests: case QVariant::Point: Executed by:
| 28 | ||||||||||||||||||||||||
902 | if (d->type == QVariant::PointF)
| 0-28 | ||||||||||||||||||||||||
903 | *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint(); executed 28 times by 3 tests: *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint(); Executed by:
| 28 | ||||||||||||||||||||||||
904 | else | - | ||||||||||||||||||||||||
905 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
906 | break; executed 28 times by 3 tests: break; Executed by:
| 28 | ||||||||||||||||||||||||
907 | case QMetaType::Char: executed 1 time by 1 test: case QMetaType::Char: Executed by:
| 1 | ||||||||||||||||||||||||
908 | { | - | ||||||||||||||||||||||||
909 | *static_cast<qint8 *>(result) = qint8(qConvertToNumber(d, ok)); | - | ||||||||||||||||||||||||
910 | return *ok; executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||||||||||||||
911 | } | - | ||||||||||||||||||||||||
912 | #endif | - | ||||||||||||||||||||||||
913 | case QVariant::Uuid: executed 2 times by 2 tests: case QVariant::Uuid: Executed by:
| 2 | ||||||||||||||||||||||||
914 | switch (d->type) { | - | ||||||||||||||||||||||||
915 | case QVariant::String: executed 2 times by 2 tests: case QVariant::String: Executed by:
| 2 | ||||||||||||||||||||||||
916 | *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d)); | - | ||||||||||||||||||||||||
917 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||||||||||||||
918 | default: never executed: default: | 0 | ||||||||||||||||||||||||
919 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
920 | } | - | ||||||||||||||||||||||||
921 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||||||||||||||
922 | default: executed 270907 times by 98 tests: default: Executed by:
| 270907 | ||||||||||||||||||||||||
923 | #ifndef QT_NO_QOBJECT | - | ||||||||||||||||||||||||
924 | if (d->type == QVariant::String || d->type == QVariant::ByteArray) {
| 7-270895 | ||||||||||||||||||||||||
925 | QMetaEnum en = metaEnumFromType(t); | - | ||||||||||||||||||||||||
926 | if (en.isValid()) {
| 2-17 | ||||||||||||||||||||||||
927 | QByteArray keys = (d->type == QVariant::String) ? v_cast<QString>(d)->toUtf8() : *v_cast<QByteArray>(d);
| 7-10 | ||||||||||||||||||||||||
928 | int value = en.keysToValue(keys.constData(), ok); | - | ||||||||||||||||||||||||
929 | if (*ok) {
| 0-17 | ||||||||||||||||||||||||
930 | switch (QMetaType::sizeOf(t)) { | - | ||||||||||||||||||||||||
931 | case 1: executed 2 times by 1 test: case 1: Executed by:
| 2 | ||||||||||||||||||||||||
932 | *static_cast<signed char *>(result) = value; | - | ||||||||||||||||||||||||
933 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
934 | case 2: executed 2 times by 1 test: case 2: Executed by:
| 2 | ||||||||||||||||||||||||
935 | *static_cast<qint16 *>(result) = value; | - | ||||||||||||||||||||||||
936 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
937 | case 4: executed 4 times by 1 test: case 4: Executed by:
| 4 | ||||||||||||||||||||||||
938 | *static_cast<qint32 *>(result) = value; | - | ||||||||||||||||||||||||
939 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
940 | case 8: executed 9 times by 1 test: case 8: Executed by:
| 9 | ||||||||||||||||||||||||
941 | *static_cast<qint64 *>(result) = value; | - | ||||||||||||||||||||||||
942 | return true; executed 9 times by 1 test: return true; Executed by:
| 9 | ||||||||||||||||||||||||
943 | } | - | ||||||||||||||||||||||||
944 | } never executed: end of block | 0 | ||||||||||||||||||||||||
945 | } never executed: end of block | 0 | ||||||||||||||||||||||||
946 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
947 | #endif | - | ||||||||||||||||||||||||
948 | if (QMetaType::typeFlags(t) & QMetaType::IsEnumeration) {
| 40-270850 | ||||||||||||||||||||||||
949 | qlonglong value = qConvertToNumber(d, ok); | - | ||||||||||||||||||||||||
950 | if (*ok) {
| 0-40 | ||||||||||||||||||||||||
951 | switch (QMetaType::sizeOf(t)) { | - | ||||||||||||||||||||||||
952 | case 1: executed 4 times by 1 test: case 1: Executed by:
| 4 | ||||||||||||||||||||||||
953 | *static_cast<signed char *>(result) = value; | - | ||||||||||||||||||||||||
954 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
955 | case 2: executed 4 times by 1 test: case 2: Executed by:
| 4 | ||||||||||||||||||||||||
956 | *static_cast<qint16 *>(result) = value; | - | ||||||||||||||||||||||||
957 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
958 | case 4: executed 12 times by 1 test: case 4: Executed by:
| 12 | ||||||||||||||||||||||||
959 | *static_cast<qint32 *>(result) = value; | - | ||||||||||||||||||||||||
960 | return true; executed 12 times by 1 test: return true; Executed by:
| 12 | ||||||||||||||||||||||||
961 | case 8: executed 20 times by 1 test: case 8: Executed by:
| 20 | ||||||||||||||||||||||||
962 | *static_cast<qint64 *>(result) = value; | - | ||||||||||||||||||||||||
963 | return true; executed 20 times by 1 test: return true; Executed by:
| 20 | ||||||||||||||||||||||||
964 | } | - | ||||||||||||||||||||||||
965 | } never executed: end of block | 0 | ||||||||||||||||||||||||
966 | return *ok; never executed: return *ok; | 0 | ||||||||||||||||||||||||
967 | } | - | ||||||||||||||||||||||||
968 | return false; executed 270850 times by 98 tests: return false; Executed by:
| 270850 | ||||||||||||||||||||||||
969 | } | - | ||||||||||||||||||||||||
970 | return true; executed 36032 times by 82 tests: return true; Executed by:
| 36032 | ||||||||||||||||||||||||
971 | } | - | ||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||
973 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
974 | static void streamDebug(QDebug dbg, const QVariant &v) | - | ||||||||||||||||||||||||
975 | { | - | ||||||||||||||||||||||||
976 | QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); | - | ||||||||||||||||||||||||
977 | QVariantDebugStream<CoreTypesFilter> stream(dbg, d); | - | ||||||||||||||||||||||||
978 | QMetaTypeSwitcher::switcher<void>(stream, d->type, 0); | - | ||||||||||||||||||||||||
979 | } executed 51 times by 2 tests: end of block Executed by:
| 51 | ||||||||||||||||||||||||
980 | #endif | - | ||||||||||||||||||||||||
981 | - | |||||||||||||||||||||||||
982 | const QVariant::Handler qt_kernel_variant_handler = { | - | ||||||||||||||||||||||||
983 | construct, | - | ||||||||||||||||||||||||
984 | clear, | - | ||||||||||||||||||||||||
985 | isNull, | - | ||||||||||||||||||||||||
986 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
987 | 0, | - | ||||||||||||||||||||||||
988 | 0, | - | ||||||||||||||||||||||||
989 | #endif | - | ||||||||||||||||||||||||
990 | compare, | - | ||||||||||||||||||||||||
991 | convert, | - | ||||||||||||||||||||||||
992 | 0, | - | ||||||||||||||||||||||||
993 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
994 | streamDebug | - | ||||||||||||||||||||||||
995 | #else | - | ||||||||||||||||||||||||
996 | 0 | - | ||||||||||||||||||||||||
997 | #endif | - | ||||||||||||||||||||||||
998 | }; | - | ||||||||||||||||||||||||
999 | - | |||||||||||||||||||||||||
1000 | static never executed: void dummyConstruct(QVariant::Private *, const void *) { Q_ASSERT_X(false, "QVariant", "Trying to construct an unknown type"); }end of block never executed: end of block | 0 | ||||||||||||||||||||||||
1001 | static never executed: void dummyClear(QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to clear an unknown type"); }end of block never executed: end of block | 0 | ||||||||||||||||||||||||
1002 | static never executed: bool dummyIsNull(const QVariant::Private *d) { Q_ASSERT_X(false, "QVariant::isNull", "Trying to call isNull on an unknown type"); return d->is_null; }return d->is_null; never executed: return d->is_null; | 0 | ||||||||||||||||||||||||
1003 | static never executed: bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { Q_ASSERT_X(false, "QVariant", "Trying to compare an unknown types"); return false; }return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1004 | static never executed: bool dummyConvert(const QVariant::Private *, int, void *, bool *) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); return false; }return false; never executed: return false; | 0 | ||||||||||||||||||||||||
1005 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
1006 | static never executed: void dummyStreamDebug(QDebug, const QVariant &) { Q_ASSERT_X(false, "QVariant", "Trying to convert an unknown type"); }end of block never executed: end of block | 0 | ||||||||||||||||||||||||
1007 | #endif | - | ||||||||||||||||||||||||
1008 | const QVariant::Handler qt_dummy_variant_handler = { | - | ||||||||||||||||||||||||
1009 | dummyConstruct, | - | ||||||||||||||||||||||||
1010 | dummyClear, | - | ||||||||||||||||||||||||
1011 | dummyIsNull, | - | ||||||||||||||||||||||||
1012 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1013 | 0, | - | ||||||||||||||||||||||||
1014 | 0, | - | ||||||||||||||||||||||||
1015 | #endif | - | ||||||||||||||||||||||||
1016 | dummyCompare, | - | ||||||||||||||||||||||||
1017 | dummyConvert, | - | ||||||||||||||||||||||||
1018 | 0, | - | ||||||||||||||||||||||||
1019 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
1020 | dummyStreamDebug | - | ||||||||||||||||||||||||
1021 | #else | - | ||||||||||||||||||||||||
1022 | 0 | - | ||||||||||||||||||||||||
1023 | #endif | - | ||||||||||||||||||||||||
1024 | }; | - | ||||||||||||||||||||||||
1025 | - | |||||||||||||||||||||||||
1026 | static void customConstruct(QVariant::Private *d, const void *copy) | - | ||||||||||||||||||||||||
1027 | { | - | ||||||||||||||||||||||||
1028 | const QMetaType type(d->type); | - | ||||||||||||||||||||||||
1029 | const uint size = type.sizeOf(); | - | ||||||||||||||||||||||||
1030 | if (!size) {
| 18-108664 | ||||||||||||||||||||||||
1031 | qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type); | - | ||||||||||||||||||||||||
1032 | d->type = QVariant::Invalid; | - | ||||||||||||||||||||||||
1033 | return; executed 18 times by 3 tests: return; Executed by:
| 18 | ||||||||||||||||||||||||
1034 | } | - | ||||||||||||||||||||||||
1035 | - | |||||||||||||||||||||||||
1036 | // this logic should match with QVariantIntegrator::CanUseInternalSpace | - | ||||||||||||||||||||||||
1037 | if (size <= sizeof(QVariant::Private::Data)
| 3667-104997 | ||||||||||||||||||||||||
1038 | && (type.flags() & (QMetaType::MovableType | QMetaType::IsEnumeration))) { | - | ||||||||||||||||||||||||
1039 | type.construct(&d->data.ptr, copy); | - | ||||||||||||||||||||||||
1040 | d->is_shared = false; | - | ||||||||||||||||||||||||
1041 | } else { executed 104620 times by 121 tests: end of block Executed by:
| 104620 | ||||||||||||||||||||||||
1042 | void *ptr = type.create(copy); | - | ||||||||||||||||||||||||
1043 | d->is_shared = true; | - | ||||||||||||||||||||||||
1044 | d->data.shared = new QVariant::PrivateShared(ptr); | - | ||||||||||||||||||||||||
1045 | } executed 4044 times by 174 tests: end of block Executed by:
| 4044 | ||||||||||||||||||||||||
1046 | } | - | ||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | static void customClear(QVariant::Private *d) | - | ||||||||||||||||||||||||
1049 | { | - | ||||||||||||||||||||||||
1050 | if (!d->is_shared) {
| 4040-146819 | ||||||||||||||||||||||||
1051 | QMetaType::destruct(d->type, &d->data.ptr); | - | ||||||||||||||||||||||||
1052 | } else { executed 146819 times by 144 tests: end of block Executed by:
| 146819 | ||||||||||||||||||||||||
1053 | QMetaType::destroy(d->type, d->data.shared->ptr); | - | ||||||||||||||||||||||||
1054 | delete d->data.shared; | - | ||||||||||||||||||||||||
1055 | } executed 4040 times by 176 tests: end of block Executed by:
| 4040 | ||||||||||||||||||||||||
1056 | } | - | ||||||||||||||||||||||||
1057 | - | |||||||||||||||||||||||||
1058 | static bool customIsNull(const QVariant::Private *d) | - | ||||||||||||||||||||||||
1059 | { | - | ||||||||||||||||||||||||
1060 | return d->is_null; executed 362 times by 8 tests: return d->is_null; Executed by:
| 362 | ||||||||||||||||||||||||
1061 | } | - | ||||||||||||||||||||||||
1062 | - | |||||||||||||||||||||||||
1063 | static bool customCompare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||||||||||||||||||||
1064 | { | - | ||||||||||||||||||||||||
1065 | const char *const typeName = QMetaType::typeName(a->type); | - | ||||||||||||||||||||||||
1066 | if (Q_UNLIKELY(!typeName) && Q_LIKELY(!QMetaType::isRegistered(a->type)))
| 0-345 | ||||||||||||||||||||||||
1067 | qFatal("QVariant::compare: type %d unknown to QVariant.", a->type); never executed: QMessageLogger(__FILE__, 1067, __PRETTY_FUNCTION__).fatal("QVariant::compare: type %d unknown to QVariant.", a->type); | 0 | ||||||||||||||||||||||||
1068 | - | |||||||||||||||||||||||||
1069 | const void *a_ptr = a->is_shared ? a->data.shared->ptr : &(a->data.ptr);
| 37-308 | ||||||||||||||||||||||||
1070 | const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr);
| 37-308 | ||||||||||||||||||||||||
1071 | - | |||||||||||||||||||||||||
1072 | uint typeNameLen = qstrlen(typeName); | - | ||||||||||||||||||||||||
1073 | if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*')
| 0-345 | ||||||||||||||||||||||||
1074 | return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr); executed 19 times by 3 tests: return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr); Executed by:
| 19 | ||||||||||||||||||||||||
1075 | - | |||||||||||||||||||||||||
1076 | if (a->is_null && b->is_null)
| 0-326 | ||||||||||||||||||||||||
1077 | return true; never executed: return true; | 0 | ||||||||||||||||||||||||
1078 | - | |||||||||||||||||||||||||
1079 | return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type)); executed 326 times by 21 tests: return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type)); Executed by:
| 326 | ||||||||||||||||||||||||
1080 | } | - | ||||||||||||||||||||||||
1081 | - | |||||||||||||||||||||||||
1082 | static bool customConvert(const QVariant::Private *d, int t, void *result, bool *ok) | - | ||||||||||||||||||||||||
1083 | { | - | ||||||||||||||||||||||||
1084 | if (d->type >= QMetaType::User || t >= QMetaType::User) {
| 0-482 | ||||||||||||||||||||||||
1085 | if (QMetaType::convert(constData(*d), d->type, result, t)) {
| 103-636 | ||||||||||||||||||||||||
1086 | if (ok)
| 3-100 | ||||||||||||||||||||||||
1087 | *ok = true; executed 3 times by 2 tests: *ok = true; Executed by:
| 3 | ||||||||||||||||||||||||
1088 | return true; executed 103 times by 3 tests: return true; Executed by:
| 103 | ||||||||||||||||||||||||
1089 | } | - | ||||||||||||||||||||||||
1090 | } executed 636 times by 24 tests: end of block Executed by:
| 636 | ||||||||||||||||||||||||
1091 | return convert(d, t, result, ok); executed 636 times by 24 tests: return convert(d, t, result, ok); Executed by:
| 636 | ||||||||||||||||||||||||
1092 | } | - | ||||||||||||||||||||||||
1093 | - | |||||||||||||||||||||||||
1094 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
1095 | static void customStreamDebug(QDebug dbg, const QVariant &variant) { | - | ||||||||||||||||||||||||
1096 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1097 | QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType()); | - | ||||||||||||||||||||||||
1098 | if (flags & QMetaType::PointerToQObject)
| 1-3 | ||||||||||||||||||||||||
1099 | dbg.nospace() << variant.value<QObject*>(); executed 1 time by 1 test: dbg.nospace() << variant.value<QObject*>(); Executed by:
| 1 | ||||||||||||||||||||||||
1100 | #else | - | ||||||||||||||||||||||||
1101 | Q_UNUSED(dbg); | - | ||||||||||||||||||||||||
1102 | Q_UNUSED(variant); | - | ||||||||||||||||||||||||
1103 | #endif | - | ||||||||||||||||||||||||
1104 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
1105 | #endif | - | ||||||||||||||||||||||||
1106 | - | |||||||||||||||||||||||||
1107 | const QVariant::Handler qt_custom_variant_handler = { | - | ||||||||||||||||||||||||
1108 | customConstruct, | - | ||||||||||||||||||||||||
1109 | customClear, | - | ||||||||||||||||||||||||
1110 | customIsNull, | - | ||||||||||||||||||||||||
1111 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1112 | 0, | - | ||||||||||||||||||||||||
1113 | 0, | - | ||||||||||||||||||||||||
1114 | #endif | - | ||||||||||||||||||||||||
1115 | customCompare, | - | ||||||||||||||||||||||||
1116 | customConvert, | - | ||||||||||||||||||||||||
1117 | 0, | - | ||||||||||||||||||||||||
1118 | #if !defined(QT_NO_DEBUG_STREAM) | - | ||||||||||||||||||||||||
1119 | customStreamDebug | - | ||||||||||||||||||||||||
1120 | #else | - | ||||||||||||||||||||||||
1121 | 0 | - | ||||||||||||||||||||||||
1122 | #endif | - | ||||||||||||||||||||||||
1123 | }; | - | ||||||||||||||||||||||||
1124 | - | |||||||||||||||||||||||||
1125 | } // annonymous used to hide QVariant handlers | - | ||||||||||||||||||||||||
1126 | - | |||||||||||||||||||||||||
1127 | static HandlersManager handlerManager; | - | ||||||||||||||||||||||||
1128 | Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0"); | - | ||||||||||||||||||||||||
1129 | const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount] | - | ||||||||||||||||||||||||
1130 | = { &qt_kernel_variant_handler, &qt_dummy_variant_handler, | - | ||||||||||||||||||||||||
1131 | &qt_dummy_variant_handler, &qt_custom_variant_handler }; | - | ||||||||||||||||||||||||
1132 | - | |||||||||||||||||||||||||
1133 | Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler() | - | ||||||||||||||||||||||||
1134 | { | - | ||||||||||||||||||||||||
1135 | return &qt_kernel_variant_handler; executed 238889 times by 60 tests: return &qt_kernel_variant_handler; Executed by:
| 238889 | ||||||||||||||||||||||||
1136 | } | - | ||||||||||||||||||||||||
1137 | - | |||||||||||||||||||||||||
1138 | Q_CORE_EXPORT void QVariantPrivate::registerHandler(const int /* Modules::Names */name, const QVariant::Handler *handler) | - | ||||||||||||||||||||||||
1139 | { | - | ||||||||||||||||||||||||
1140 | handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler); | - | ||||||||||||||||||||||||
1141 | } executed 250 times by 5 tests: end of block Executed by:
| 250 | ||||||||||||||||||||||||
1142 | - | |||||||||||||||||||||||||
1143 | /*! | - | ||||||||||||||||||||||||
1144 | \class QVariant | - | ||||||||||||||||||||||||
1145 | \inmodule QtCore | - | ||||||||||||||||||||||||
1146 | \brief The QVariant class acts like a union for the most common Qt data types. | - | ||||||||||||||||||||||||
1147 | - | |||||||||||||||||||||||||
1148 | \ingroup objectmodel | - | ||||||||||||||||||||||||
1149 | \ingroup shared | - | ||||||||||||||||||||||||
1150 | - | |||||||||||||||||||||||||
1151 | - | |||||||||||||||||||||||||
1152 | Because C++ forbids unions from including types that have | - | ||||||||||||||||||||||||
1153 | non-default constructors or destructors, most interesting Qt | - | ||||||||||||||||||||||||
1154 | classes cannot be used in unions. Without QVariant, this would be | - | ||||||||||||||||||||||||
1155 | a problem for QObject::property() and for database work, etc. | - | ||||||||||||||||||||||||
1156 | - | |||||||||||||||||||||||||
1157 | A QVariant object holds a single value of a single type() at a | - | ||||||||||||||||||||||||
1158 | time. (Some type()s are multi-valued, for example a string list.) | - | ||||||||||||||||||||||||
1159 | You can find out what type, T, the variant holds, convert it to a | - | ||||||||||||||||||||||||
1160 | different type using convert(), get its value using one of the | - | ||||||||||||||||||||||||
1161 | toT() functions (e.g., toSize()) and check whether the type can | - | ||||||||||||||||||||||||
1162 | be converted to a particular type using canConvert(). | - | ||||||||||||||||||||||||
1163 | - | |||||||||||||||||||||||||
1164 | The methods named toT() (e.g., toInt(), toString()) are const. If | - | ||||||||||||||||||||||||
1165 | you ask for the stored type, they return a copy of the stored | - | ||||||||||||||||||||||||
1166 | object. If you ask for a type that can be generated from the | - | ||||||||||||||||||||||||
1167 | stored type, toT() copies and converts and leaves the object | - | ||||||||||||||||||||||||
1168 | itself unchanged. If you ask for a type that cannot be generated | - | ||||||||||||||||||||||||
1169 | from the stored type, the result depends on the type; see the | - | ||||||||||||||||||||||||
1170 | function documentation for details. | - | ||||||||||||||||||||||||
1171 | - | |||||||||||||||||||||||||
1172 | Here is some example code to demonstrate the use of QVariant: | - | ||||||||||||||||||||||||
1173 | - | |||||||||||||||||||||||||
1174 | \snippet code/src_corelib_kernel_qvariant.cpp 0 | - | ||||||||||||||||||||||||
1175 | - | |||||||||||||||||||||||||
1176 | You can even store QList<QVariant> and QMap<QString, QVariant> | - | ||||||||||||||||||||||||
1177 | values in a variant, so you can easily construct arbitrarily | - | ||||||||||||||||||||||||
1178 | complex data structures of arbitrary types. This is very powerful | - | ||||||||||||||||||||||||
1179 | and versatile, but may prove less memory and speed efficient than | - | ||||||||||||||||||||||||
1180 | storing specific types in standard data structures. | - | ||||||||||||||||||||||||
1181 | - | |||||||||||||||||||||||||
1182 | QVariant also supports the notion of null values, where you can | - | ||||||||||||||||||||||||
1183 | have a defined type with no value set. However, note that QVariant | - | ||||||||||||||||||||||||
1184 | types can only be cast when they have had a value set. | - | ||||||||||||||||||||||||
1185 | - | |||||||||||||||||||||||||
1186 | \snippet code/src_corelib_kernel_qvariant.cpp 1 | - | ||||||||||||||||||||||||
1187 | - | |||||||||||||||||||||||||
1188 | QVariant can be extended to support other types than those | - | ||||||||||||||||||||||||
1189 | mentioned in the \l Type enum. See the \l QMetaType documentation | - | ||||||||||||||||||||||||
1190 | for details. | - | ||||||||||||||||||||||||
1191 | - | |||||||||||||||||||||||||
1192 | \section1 A Note on GUI Types | - | ||||||||||||||||||||||||
1193 | - | |||||||||||||||||||||||||
1194 | Because QVariant is part of the Qt Core module, it cannot provide | - | ||||||||||||||||||||||||
1195 | conversion functions to data types defined in Qt GUI, such as | - | ||||||||||||||||||||||||
1196 | QColor, QImage, and QPixmap. In other words, there is no \c | - | ||||||||||||||||||||||||
1197 | toColor() function. Instead, you can use the QVariant::value() or | - | ||||||||||||||||||||||||
1198 | the qvariant_cast() template function. For example: | - | ||||||||||||||||||||||||
1199 | - | |||||||||||||||||||||||||
1200 | \snippet code/src_corelib_kernel_qvariant.cpp 2 | - | ||||||||||||||||||||||||
1201 | - | |||||||||||||||||||||||||
1202 | The inverse conversion (e.g., from QColor to QVariant) is | - | ||||||||||||||||||||||||
1203 | automatic for all data types supported by QVariant, including | - | ||||||||||||||||||||||||
1204 | GUI-related types: | - | ||||||||||||||||||||||||
1205 | - | |||||||||||||||||||||||||
1206 | \snippet code/src_corelib_kernel_qvariant.cpp 3 | - | ||||||||||||||||||||||||
1207 | - | |||||||||||||||||||||||||
1208 | \section1 Using canConvert() and convert() Consecutively | - | ||||||||||||||||||||||||
1209 | - | |||||||||||||||||||||||||
1210 | When using canConvert() and convert() consecutively, it is possible for | - | ||||||||||||||||||||||||
1211 | canConvert() to return true, but convert() to return false. This | - | ||||||||||||||||||||||||
1212 | is typically because canConvert() only reports the general ability of | - | ||||||||||||||||||||||||
1213 | QVariant to convert between types given suitable data; it is still | - | ||||||||||||||||||||||||
1214 | possible to supply data which cannot actually be converted. | - | ||||||||||||||||||||||||
1215 | - | |||||||||||||||||||||||||
1216 | For example, canConvert(Int) would return true when called on a variant | - | ||||||||||||||||||||||||
1217 | containing a string because, in principle, QVariant is able to convert | - | ||||||||||||||||||||||||
1218 | strings of numbers to integers. | - | ||||||||||||||||||||||||
1219 | However, if the string contains non-numeric characters, it cannot be | - | ||||||||||||||||||||||||
1220 | converted to an integer, and any attempt to convert it will fail. | - | ||||||||||||||||||||||||
1221 | Hence, it is important to have both functions return true for a | - | ||||||||||||||||||||||||
1222 | successful conversion. | - | ||||||||||||||||||||||||
1223 | - | |||||||||||||||||||||||||
1224 | \sa QMetaType | - | ||||||||||||||||||||||||
1225 | */ | - | ||||||||||||||||||||||||
1226 | - | |||||||||||||||||||||||||
1227 | /*! | - | ||||||||||||||||||||||||
1228 | \obsolete Use QMetaType::Type instead | - | ||||||||||||||||||||||||
1229 | \enum QVariant::Type | - | ||||||||||||||||||||||||
1230 | - | |||||||||||||||||||||||||
1231 | This enum type defines the types of variable that a QVariant can | - | ||||||||||||||||||||||||
1232 | contain. | - | ||||||||||||||||||||||||
1233 | - | |||||||||||||||||||||||||
1234 | \value Invalid no type | - | ||||||||||||||||||||||||
1235 | \value BitArray a QBitArray | - | ||||||||||||||||||||||||
1236 | \value Bitmap a QBitmap | - | ||||||||||||||||||||||||
1237 | \value Bool a bool | - | ||||||||||||||||||||||||
1238 | \value Brush a QBrush | - | ||||||||||||||||||||||||
1239 | \value ByteArray a QByteArray | - | ||||||||||||||||||||||||
1240 | \value Char a QChar | - | ||||||||||||||||||||||||
1241 | \value Color a QColor | - | ||||||||||||||||||||||||
1242 | \value Cursor a QCursor | - | ||||||||||||||||||||||||
1243 | \value Date a QDate | - | ||||||||||||||||||||||||
1244 | \value DateTime a QDateTime | - | ||||||||||||||||||||||||
1245 | \value Double a double | - | ||||||||||||||||||||||||
1246 | \value EasingCurve a QEasingCurve | - | ||||||||||||||||||||||||
1247 | \value Uuid a QUuid | - | ||||||||||||||||||||||||
1248 | \value ModelIndex a QModelIndex | - | ||||||||||||||||||||||||
1249 | \value PersistentModelIndex a QPersistentModelIndex (since 5.5) | - | ||||||||||||||||||||||||
1250 | \value Font a QFont | - | ||||||||||||||||||||||||
1251 | \value Hash a QVariantHash | - | ||||||||||||||||||||||||
1252 | \value Icon a QIcon | - | ||||||||||||||||||||||||
1253 | \value Image a QImage | - | ||||||||||||||||||||||||
1254 | \value Int an int | - | ||||||||||||||||||||||||
1255 | \value KeySequence a QKeySequence | - | ||||||||||||||||||||||||
1256 | \value Line a QLine | - | ||||||||||||||||||||||||
1257 | \value LineF a QLineF | - | ||||||||||||||||||||||||
1258 | \value List a QVariantList | - | ||||||||||||||||||||||||
1259 | \value Locale a QLocale | - | ||||||||||||||||||||||||
1260 | \value LongLong a \l qlonglong | - | ||||||||||||||||||||||||
1261 | \value Map a QVariantMap | - | ||||||||||||||||||||||||
1262 | \value Matrix a QMatrix | - | ||||||||||||||||||||||||
1263 | \value Transform a QTransform | - | ||||||||||||||||||||||||
1264 | \value Matrix4x4 a QMatrix4x4 | - | ||||||||||||||||||||||||
1265 | \value Palette a QPalette | - | ||||||||||||||||||||||||
1266 | \value Pen a QPen | - | ||||||||||||||||||||||||
1267 | \value Pixmap a QPixmap | - | ||||||||||||||||||||||||
1268 | \value Point a QPoint | - | ||||||||||||||||||||||||
1269 | \value PointF a QPointF | - | ||||||||||||||||||||||||
1270 | \value Polygon a QPolygon | - | ||||||||||||||||||||||||
1271 | \value PolygonF a QPolygonF | - | ||||||||||||||||||||||||
1272 | \value Quaternion a QQuaternion | - | ||||||||||||||||||||||||
1273 | \value Rect a QRect | - | ||||||||||||||||||||||||
1274 | \value RectF a QRectF | - | ||||||||||||||||||||||||
1275 | \value RegExp a QRegExp | - | ||||||||||||||||||||||||
1276 | \value RegularExpression a QRegularExpression | - | ||||||||||||||||||||||||
1277 | \value Region a QRegion | - | ||||||||||||||||||||||||
1278 | \value Size a QSize | - | ||||||||||||||||||||||||
1279 | \value SizeF a QSizeF | - | ||||||||||||||||||||||||
1280 | \value SizePolicy a QSizePolicy | - | ||||||||||||||||||||||||
1281 | \value String a QString | - | ||||||||||||||||||||||||
1282 | \value StringList a QStringList | - | ||||||||||||||||||||||||
1283 | \value TextFormat a QTextFormat | - | ||||||||||||||||||||||||
1284 | \value TextLength a QTextLength | - | ||||||||||||||||||||||||
1285 | \value Time a QTime | - | ||||||||||||||||||||||||
1286 | \value UInt a \l uint | - | ||||||||||||||||||||||||
1287 | \value ULongLong a \l qulonglong | - | ||||||||||||||||||||||||
1288 | \value Url a QUrl | - | ||||||||||||||||||||||||
1289 | \value Vector2D a QVector2D | - | ||||||||||||||||||||||||
1290 | \value Vector3D a QVector3D | - | ||||||||||||||||||||||||
1291 | \value Vector4D a QVector4D | - | ||||||||||||||||||||||||
1292 | - | |||||||||||||||||||||||||
1293 | \value UserType Base value for user-defined types. | - | ||||||||||||||||||||||||
1294 | - | |||||||||||||||||||||||||
1295 | \omitvalue LastGuiType | - | ||||||||||||||||||||||||
1296 | \omitvalue LastCoreType | - | ||||||||||||||||||||||||
1297 | \omitvalue LastType | - | ||||||||||||||||||||||||
1298 | */ | - | ||||||||||||||||||||||||
1299 | - | |||||||||||||||||||||||||
1300 | /*! | - | ||||||||||||||||||||||||
1301 | \fn QVariant::QVariant(QVariant &&other) | - | ||||||||||||||||||||||||
1302 | - | |||||||||||||||||||||||||
1303 | Move-constructs a QVariant instance, making it point at the same | - | ||||||||||||||||||||||||
1304 | object that \a other was pointing to. | - | ||||||||||||||||||||||||
1305 | - | |||||||||||||||||||||||||
1306 | \since 5.2 | - | ||||||||||||||||||||||||
1307 | */ | - | ||||||||||||||||||||||||
1308 | - | |||||||||||||||||||||||||
1309 | /*! | - | ||||||||||||||||||||||||
1310 | \fn QVariant &QVariant::operator=(QVariant &&other) | - | ||||||||||||||||||||||||
1311 | - | |||||||||||||||||||||||||
1312 | Move-assigns \a other to this QVariant instance. | - | ||||||||||||||||||||||||
1313 | - | |||||||||||||||||||||||||
1314 | \since 5.2 | - | ||||||||||||||||||||||||
1315 | */ | - | ||||||||||||||||||||||||
1316 | - | |||||||||||||||||||||||||
1317 | /*! | - | ||||||||||||||||||||||||
1318 | \fn QVariant::QVariant() | - | ||||||||||||||||||||||||
1319 | - | |||||||||||||||||||||||||
1320 | Constructs an invalid variant. | - | ||||||||||||||||||||||||
1321 | */ | - | ||||||||||||||||||||||||
1322 | - | |||||||||||||||||||||||||
1323 | - | |||||||||||||||||||||||||
1324 | /*! | - | ||||||||||||||||||||||||
1325 | \fn QVariant::QVariant(int typeId, const void *copy) | - | ||||||||||||||||||||||||
1326 | - | |||||||||||||||||||||||||
1327 | Constructs variant of type \a typeId, and initializes with | - | ||||||||||||||||||||||||
1328 | \a copy if \a copy is not 0. | - | ||||||||||||||||||||||||
1329 | - | |||||||||||||||||||||||||
1330 | Note that you have to pass the address of the variable you want stored. | - | ||||||||||||||||||||||||
1331 | - | |||||||||||||||||||||||||
1332 | Usually, you never have to use this constructor, use QVariant::fromValue() | - | ||||||||||||||||||||||||
1333 | instead to construct variants from the pointer types represented by | - | ||||||||||||||||||||||||
1334 | \c QMetaType::VoidStar, and \c QMetaType::QObjectStar. | - | ||||||||||||||||||||||||
1335 | - | |||||||||||||||||||||||||
1336 | \sa QVariant::fromValue(), QMetaType::Type | - | ||||||||||||||||||||||||
1337 | */ | - | ||||||||||||||||||||||||
1338 | - | |||||||||||||||||||||||||
1339 | /*! | - | ||||||||||||||||||||||||
1340 | \fn QVariant::QVariant(Type type) | - | ||||||||||||||||||||||||
1341 | - | |||||||||||||||||||||||||
1342 | Constructs a null variant of type \a type. | - | ||||||||||||||||||||||||
1343 | */ | - | ||||||||||||||||||||||||
1344 | - | |||||||||||||||||||||||||
1345 | - | |||||||||||||||||||||||||
1346 | - | |||||||||||||||||||||||||
1347 | /*! | - | ||||||||||||||||||||||||
1348 | \fn QVariant::create(int type, const void *copy) | - | ||||||||||||||||||||||||
1349 | - | |||||||||||||||||||||||||
1350 | \internal | - | ||||||||||||||||||||||||
1351 | - | |||||||||||||||||||||||||
1352 | Constructs a variant private of type \a type, and initializes with \a copy if | - | ||||||||||||||||||||||||
1353 | \a copy is not 0. | - | ||||||||||||||||||||||||
1354 | */ | - | ||||||||||||||||||||||||
1355 | - | |||||||||||||||||||||||||
1356 | void QVariant::create(int type, const void *copy) | - | ||||||||||||||||||||||||
1357 | { | - | ||||||||||||||||||||||||
1358 | d.type = type; | - | ||||||||||||||||||||||||
1359 | handlerManager[type]->construct(&d, copy); | - | ||||||||||||||||||||||||
1360 | } executed 3555767 times by 249 tests: end of block Executed by:
| 3555767 | ||||||||||||||||||||||||
1361 | - | |||||||||||||||||||||||||
1362 | /*! | - | ||||||||||||||||||||||||
1363 | \fn QVariant::~QVariant() | - | ||||||||||||||||||||||||
1364 | - | |||||||||||||||||||||||||
1365 | Destroys the QVariant and the contained object. | - | ||||||||||||||||||||||||
1366 | - | |||||||||||||||||||||||||
1367 | Note that subclasses that reimplement clear() should reimplement | - | ||||||||||||||||||||||||
1368 | the destructor to call clear(). This destructor calls clear(), but | - | ||||||||||||||||||||||||
1369 | because it is the destructor, QVariant::clear() is called rather | - | ||||||||||||||||||||||||
1370 | than a subclass's clear(). | - | ||||||||||||||||||||||||
1371 | */ | - | ||||||||||||||||||||||||
1372 | - | |||||||||||||||||||||||||
1373 | QVariant::~QVariant() | - | ||||||||||||||||||||||||
1374 | { | - | ||||||||||||||||||||||||
1375 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
| 3439999-27355757 | ||||||||||||||||||||||||
1376 | handlerManager[d.type]->clear(&d); executed 15735039 times by 445 tests: handlerManager[d.type]->clear(&d); Executed by:
| 15735039 | ||||||||||||||||||||||||
1377 | } executed 34289747 times by 494 tests: end of block Executed by:
| 34289747 | ||||||||||||||||||||||||
1378 | - | |||||||||||||||||||||||||
1379 | /*! | - | ||||||||||||||||||||||||
1380 | \fn QVariant::QVariant(const QVariant &p) | - | ||||||||||||||||||||||||
1381 | - | |||||||||||||||||||||||||
1382 | Constructs a copy of the variant, \a p, passed as the argument to | - | ||||||||||||||||||||||||
1383 | this constructor. | - | ||||||||||||||||||||||||
1384 | */ | - | ||||||||||||||||||||||||
1385 | - | |||||||||||||||||||||||||
1386 | QVariant::QVariant(const QVariant &p) | - | ||||||||||||||||||||||||
1387 | : d(p.d) | - | ||||||||||||||||||||||||
1388 | { | - | ||||||||||||||||||||||||
1389 | if (d.is_shared) {
| 3492182-9311348 | ||||||||||||||||||||||||
1390 | d.data.shared->ref.ref(); | - | ||||||||||||||||||||||||
1391 | } else if (p.d.type > Char) { executed 3492182 times by 177 tests: end of block Executed by:
| 1237108-8074240 | ||||||||||||||||||||||||
1392 | handlerManager[d.type]->construct(&d, p.constData()); | - | ||||||||||||||||||||||||
1393 | d.is_null = p.d.is_null; | - | ||||||||||||||||||||||||
1394 | } executed 8074240 times by 391 tests: end of block Executed by:
| 8074240 | ||||||||||||||||||||||||
1395 | } executed 12803530 times by 411 tests: end of block Executed by:
| 12803530 | ||||||||||||||||||||||||
1396 | - | |||||||||||||||||||||||||
1397 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1398 | /*! | - | ||||||||||||||||||||||||
1399 | Reads the variant from the data stream, \a s. | - | ||||||||||||||||||||||||
1400 | */ | - | ||||||||||||||||||||||||
1401 | QVariant::QVariant(QDataStream &s) | - | ||||||||||||||||||||||||
1402 | { | - | ||||||||||||||||||||||||
1403 | d.is_null = true; | - | ||||||||||||||||||||||||
1404 | s >> *this; | - | ||||||||||||||||||||||||
1405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1406 | #endif //QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1407 | - | |||||||||||||||||||||||||
1408 | /*! | - | ||||||||||||||||||||||||
1409 | \fn QVariant::QVariant(const QString &val) | - | ||||||||||||||||||||||||
1410 | - | |||||||||||||||||||||||||
1411 | Constructs a new variant with a string value, \a val. | - | ||||||||||||||||||||||||
1412 | */ | - | ||||||||||||||||||||||||
1413 | - | |||||||||||||||||||||||||
1414 | /*! | - | ||||||||||||||||||||||||
1415 | \fn QVariant::QVariant(QLatin1String val) | - | ||||||||||||||||||||||||
1416 | - | |||||||||||||||||||||||||
1417 | Constructs a new variant with a string value, \a val. | - | ||||||||||||||||||||||||
1418 | */ | - | ||||||||||||||||||||||||
1419 | - | |||||||||||||||||||||||||
1420 | /*! | - | ||||||||||||||||||||||||
1421 | \fn QVariant::QVariant(const char *val) | - | ||||||||||||||||||||||||
1422 | - | |||||||||||||||||||||||||
1423 | Constructs a new variant with a string value of \a val. | - | ||||||||||||||||||||||||
1424 | The variant creates a deep copy of \a val into a QString assuming | - | ||||||||||||||||||||||||
1425 | UTF-8 encoding on the input \a val. | - | ||||||||||||||||||||||||
1426 | - | |||||||||||||||||||||||||
1427 | Note that \a val is converted to a QString for storing in the | - | ||||||||||||||||||||||||
1428 | variant and QVariant::userType() will return QMetaType::QString for | - | ||||||||||||||||||||||||
1429 | the variant. | - | ||||||||||||||||||||||||
1430 | - | |||||||||||||||||||||||||
1431 | You can disable this operator by defining \c | - | ||||||||||||||||||||||||
1432 | QT_NO_CAST_FROM_ASCII when you compile your applications. | - | ||||||||||||||||||||||||
1433 | */ | - | ||||||||||||||||||||||||
1434 | - | |||||||||||||||||||||||||
1435 | #ifndef QT_NO_CAST_FROM_ASCII | - | ||||||||||||||||||||||||
1436 | QVariant::QVariant(const char *val) | - | ||||||||||||||||||||||||
1437 | { | - | ||||||||||||||||||||||||
1438 | QString s = QString::fromUtf8(val); | - | ||||||||||||||||||||||||
1439 | create(String, &s); | - | ||||||||||||||||||||||||
1440 | } executed 10691 times by 46 tests: end of block Executed by:
| 10691 | ||||||||||||||||||||||||
1441 | #endif | - | ||||||||||||||||||||||||
1442 | - | |||||||||||||||||||||||||
1443 | /*! | - | ||||||||||||||||||||||||
1444 | \fn QVariant::QVariant(const QStringList &val) | - | ||||||||||||||||||||||||
1445 | - | |||||||||||||||||||||||||
1446 | Constructs a new variant with a string list value, \a val. | - | ||||||||||||||||||||||||
1447 | */ | - | ||||||||||||||||||||||||
1448 | - | |||||||||||||||||||||||||
1449 | /*! | - | ||||||||||||||||||||||||
1450 | \fn QVariant::QVariant(const QMap<QString, QVariant> &val) | - | ||||||||||||||||||||||||
1451 | - | |||||||||||||||||||||||||
1452 | Constructs a new variant with a map of \l {QVariant}s, \a val. | - | ||||||||||||||||||||||||
1453 | */ | - | ||||||||||||||||||||||||
1454 | - | |||||||||||||||||||||||||
1455 | /*! | - | ||||||||||||||||||||||||
1456 | \fn QVariant::QVariant(const QHash<QString, QVariant> &val) | - | ||||||||||||||||||||||||
1457 | - | |||||||||||||||||||||||||
1458 | Constructs a new variant with a hash of \l {QVariant}s, \a val. | - | ||||||||||||||||||||||||
1459 | */ | - | ||||||||||||||||||||||||
1460 | - | |||||||||||||||||||||||||
1461 | /*! | - | ||||||||||||||||||||||||
1462 | \fn QVariant::QVariant(const QDate &val) | - | ||||||||||||||||||||||||
1463 | - | |||||||||||||||||||||||||
1464 | Constructs a new variant with a date value, \a val. | - | ||||||||||||||||||||||||
1465 | */ | - | ||||||||||||||||||||||||
1466 | - | |||||||||||||||||||||||||
1467 | /*! | - | ||||||||||||||||||||||||
1468 | \fn QVariant::QVariant(const QTime &val) | - | ||||||||||||||||||||||||
1469 | - | |||||||||||||||||||||||||
1470 | Constructs a new variant with a time value, \a val. | - | ||||||||||||||||||||||||
1471 | */ | - | ||||||||||||||||||||||||
1472 | - | |||||||||||||||||||||||||
1473 | /*! | - | ||||||||||||||||||||||||
1474 | \fn QVariant::QVariant(const QDateTime &val) | - | ||||||||||||||||||||||||
1475 | - | |||||||||||||||||||||||||
1476 | Constructs a new variant with a date/time value, \a val. | - | ||||||||||||||||||||||||
1477 | */ | - | ||||||||||||||||||||||||
1478 | - | |||||||||||||||||||||||||
1479 | /*! | - | ||||||||||||||||||||||||
1480 | \since 4.7 | - | ||||||||||||||||||||||||
1481 | \fn QVariant::QVariant(const QEasingCurve &val) | - | ||||||||||||||||||||||||
1482 | - | |||||||||||||||||||||||||
1483 | Constructs a new variant with an easing curve value, \a val. | - | ||||||||||||||||||||||||
1484 | */ | - | ||||||||||||||||||||||||
1485 | - | |||||||||||||||||||||||||
1486 | /*! | - | ||||||||||||||||||||||||
1487 | \since 5.0 | - | ||||||||||||||||||||||||
1488 | \fn QVariant::QVariant(const QUuid &val) | - | ||||||||||||||||||||||||
1489 | - | |||||||||||||||||||||||||
1490 | Constructs a new variant with an uuid value, \a val. | - | ||||||||||||||||||||||||
1491 | */ | - | ||||||||||||||||||||||||
1492 | - | |||||||||||||||||||||||||
1493 | /*! | - | ||||||||||||||||||||||||
1494 | \since 5.0 | - | ||||||||||||||||||||||||
1495 | \fn QVariant::QVariant(const QModelIndex &val) | - | ||||||||||||||||||||||||
1496 | - | |||||||||||||||||||||||||
1497 | Constructs a new variant with a QModelIndex value, \a val. | - | ||||||||||||||||||||||||
1498 | */ | - | ||||||||||||||||||||||||
1499 | - | |||||||||||||||||||||||||
1500 | /*! | - | ||||||||||||||||||||||||
1501 | \since 5.5 | - | ||||||||||||||||||||||||
1502 | \fn QVariant::QVariant(const QPersistentModelIndex &val) | - | ||||||||||||||||||||||||
1503 | - | |||||||||||||||||||||||||
1504 | Constructs a new variant with a QPersistentModelIndex value, \a val. | - | ||||||||||||||||||||||||
1505 | */ | - | ||||||||||||||||||||||||
1506 | - | |||||||||||||||||||||||||
1507 | /*! | - | ||||||||||||||||||||||||
1508 | \since 5.0 | - | ||||||||||||||||||||||||
1509 | \fn QVariant::QVariant(const QJsonValue &val) | - | ||||||||||||||||||||||||
1510 | - | |||||||||||||||||||||||||
1511 | Constructs a new variant with a json value, \a val. | - | ||||||||||||||||||||||||
1512 | */ | - | ||||||||||||||||||||||||
1513 | - | |||||||||||||||||||||||||
1514 | /*! | - | ||||||||||||||||||||||||
1515 | \since 5.0 | - | ||||||||||||||||||||||||
1516 | \fn QVariant::QVariant(const QJsonObject &val) | - | ||||||||||||||||||||||||
1517 | - | |||||||||||||||||||||||||
1518 | Constructs a new variant with a json object value, \a val. | - | ||||||||||||||||||||||||
1519 | */ | - | ||||||||||||||||||||||||
1520 | - | |||||||||||||||||||||||||
1521 | /*! | - | ||||||||||||||||||||||||
1522 | \since 5.0 | - | ||||||||||||||||||||||||
1523 | \fn QVariant::QVariant(const QJsonArray &val) | - | ||||||||||||||||||||||||
1524 | - | |||||||||||||||||||||||||
1525 | Constructs a new variant with a json array value, \a val. | - | ||||||||||||||||||||||||
1526 | */ | - | ||||||||||||||||||||||||
1527 | - | |||||||||||||||||||||||||
1528 | /*! | - | ||||||||||||||||||||||||
1529 | \since 5.0 | - | ||||||||||||||||||||||||
1530 | \fn QVariant::QVariant(const QJsonDocument &val) | - | ||||||||||||||||||||||||
1531 | - | |||||||||||||||||||||||||
1532 | Constructs a new variant with a json document value, \a val. | - | ||||||||||||||||||||||||
1533 | */ | - | ||||||||||||||||||||||||
1534 | - | |||||||||||||||||||||||||
1535 | /*! | - | ||||||||||||||||||||||||
1536 | \fn QVariant::QVariant(const QByteArray &val) | - | ||||||||||||||||||||||||
1537 | - | |||||||||||||||||||||||||
1538 | Constructs a new variant with a bytearray value, \a val. | - | ||||||||||||||||||||||||
1539 | */ | - | ||||||||||||||||||||||||
1540 | - | |||||||||||||||||||||||||
1541 | /*! | - | ||||||||||||||||||||||||
1542 | \fn QVariant::QVariant(const QBitArray &val) | - | ||||||||||||||||||||||||
1543 | - | |||||||||||||||||||||||||
1544 | Constructs a new variant with a bitarray value, \a val. | - | ||||||||||||||||||||||||
1545 | */ | - | ||||||||||||||||||||||||
1546 | - | |||||||||||||||||||||||||
1547 | /*! | - | ||||||||||||||||||||||||
1548 | \fn QVariant::QVariant(const QPoint &val) | - | ||||||||||||||||||||||||
1549 | - | |||||||||||||||||||||||||
1550 | Constructs a new variant with a point value of \a val. | - | ||||||||||||||||||||||||
1551 | */ | - | ||||||||||||||||||||||||
1552 | - | |||||||||||||||||||||||||
1553 | /*! | - | ||||||||||||||||||||||||
1554 | \fn QVariant::QVariant(const QPointF &val) | - | ||||||||||||||||||||||||
1555 | - | |||||||||||||||||||||||||
1556 | Constructs a new variant with a point value of \a val. | - | ||||||||||||||||||||||||
1557 | */ | - | ||||||||||||||||||||||||
1558 | - | |||||||||||||||||||||||||
1559 | /*! | - | ||||||||||||||||||||||||
1560 | \fn QVariant::QVariant(const QRectF &val) | - | ||||||||||||||||||||||||
1561 | - | |||||||||||||||||||||||||
1562 | Constructs a new variant with a rect value of \a val. | - | ||||||||||||||||||||||||
1563 | */ | - | ||||||||||||||||||||||||
1564 | - | |||||||||||||||||||||||||
1565 | /*! | - | ||||||||||||||||||||||||
1566 | \fn QVariant::QVariant(const QLineF &val) | - | ||||||||||||||||||||||||
1567 | - | |||||||||||||||||||||||||
1568 | Constructs a new variant with a line value of \a val. | - | ||||||||||||||||||||||||
1569 | */ | - | ||||||||||||||||||||||||
1570 | - | |||||||||||||||||||||||||
1571 | /*! | - | ||||||||||||||||||||||||
1572 | \fn QVariant::QVariant(const QLine &val) | - | ||||||||||||||||||||||||
1573 | - | |||||||||||||||||||||||||
1574 | Constructs a new variant with a line value of \a val. | - | ||||||||||||||||||||||||
1575 | */ | - | ||||||||||||||||||||||||
1576 | - | |||||||||||||||||||||||||
1577 | /*! | - | ||||||||||||||||||||||||
1578 | \fn QVariant::QVariant(const QRect &val) | - | ||||||||||||||||||||||||
1579 | - | |||||||||||||||||||||||||
1580 | Constructs a new variant with a rect value of \a val. | - | ||||||||||||||||||||||||
1581 | */ | - | ||||||||||||||||||||||||
1582 | - | |||||||||||||||||||||||||
1583 | /*! | - | ||||||||||||||||||||||||
1584 | \fn QVariant::QVariant(const QSize &val) | - | ||||||||||||||||||||||||
1585 | - | |||||||||||||||||||||||||
1586 | Constructs a new variant with a size value of \a val. | - | ||||||||||||||||||||||||
1587 | */ | - | ||||||||||||||||||||||||
1588 | - | |||||||||||||||||||||||||
1589 | /*! | - | ||||||||||||||||||||||||
1590 | \fn QVariant::QVariant(const QSizeF &val) | - | ||||||||||||||||||||||||
1591 | - | |||||||||||||||||||||||||
1592 | Constructs a new variant with a size value of \a val. | - | ||||||||||||||||||||||||
1593 | */ | - | ||||||||||||||||||||||||
1594 | - | |||||||||||||||||||||||||
1595 | /*! | - | ||||||||||||||||||||||||
1596 | \fn QVariant::QVariant(const QUrl &val) | - | ||||||||||||||||||||||||
1597 | - | |||||||||||||||||||||||||
1598 | Constructs a new variant with a url value of \a val. | - | ||||||||||||||||||||||||
1599 | */ | - | ||||||||||||||||||||||||
1600 | - | |||||||||||||||||||||||||
1601 | /*! | - | ||||||||||||||||||||||||
1602 | \fn QVariant::QVariant(int val) | - | ||||||||||||||||||||||||
1603 | - | |||||||||||||||||||||||||
1604 | Constructs a new variant with an integer value, \a val. | - | ||||||||||||||||||||||||
1605 | */ | - | ||||||||||||||||||||||||
1606 | - | |||||||||||||||||||||||||
1607 | /*! | - | ||||||||||||||||||||||||
1608 | \fn QVariant::QVariant(uint val) | - | ||||||||||||||||||||||||
1609 | - | |||||||||||||||||||||||||
1610 | Constructs a new variant with an unsigned integer value, \a val. | - | ||||||||||||||||||||||||
1611 | */ | - | ||||||||||||||||||||||||
1612 | - | |||||||||||||||||||||||||
1613 | /*! | - | ||||||||||||||||||||||||
1614 | \fn QVariant::QVariant(qlonglong val) | - | ||||||||||||||||||||||||
1615 | - | |||||||||||||||||||||||||
1616 | Constructs a new variant with a long long integer value, \a val. | - | ||||||||||||||||||||||||
1617 | */ | - | ||||||||||||||||||||||||
1618 | - | |||||||||||||||||||||||||
1619 | /*! | - | ||||||||||||||||||||||||
1620 | \fn QVariant::QVariant(qulonglong val) | - | ||||||||||||||||||||||||
1621 | - | |||||||||||||||||||||||||
1622 | Constructs a new variant with an unsigned long long integer value, \a val. | - | ||||||||||||||||||||||||
1623 | */ | - | ||||||||||||||||||||||||
1624 | - | |||||||||||||||||||||||||
1625 | - | |||||||||||||||||||||||||
1626 | /*! | - | ||||||||||||||||||||||||
1627 | \fn QVariant::QVariant(bool val) | - | ||||||||||||||||||||||||
1628 | - | |||||||||||||||||||||||||
1629 | Constructs a new variant with a boolean value, \a val. | - | ||||||||||||||||||||||||
1630 | */ | - | ||||||||||||||||||||||||
1631 | - | |||||||||||||||||||||||||
1632 | /*! | - | ||||||||||||||||||||||||
1633 | \fn QVariant::QVariant(double val) | - | ||||||||||||||||||||||||
1634 | - | |||||||||||||||||||||||||
1635 | Constructs a new variant with a floating point value, \a val. | - | ||||||||||||||||||||||||
1636 | */ | - | ||||||||||||||||||||||||
1637 | - | |||||||||||||||||||||||||
1638 | /*! | - | ||||||||||||||||||||||||
1639 | \fn QVariant::QVariant(float val) | - | ||||||||||||||||||||||||
1640 | - | |||||||||||||||||||||||||
1641 | Constructs a new variant with a floating point value, \a val. | - | ||||||||||||||||||||||||
1642 | \since 4.6 | - | ||||||||||||||||||||||||
1643 | */ | - | ||||||||||||||||||||||||
1644 | - | |||||||||||||||||||||||||
1645 | /*! | - | ||||||||||||||||||||||||
1646 | \fn QVariant::QVariant(const QList<QVariant> &val) | - | ||||||||||||||||||||||||
1647 | - | |||||||||||||||||||||||||
1648 | Constructs a new variant with a list value, \a val. | - | ||||||||||||||||||||||||
1649 | */ | - | ||||||||||||||||||||||||
1650 | - | |||||||||||||||||||||||||
1651 | /*! | - | ||||||||||||||||||||||||
1652 | \fn QVariant::QVariant(QChar c) | - | ||||||||||||||||||||||||
1653 | - | |||||||||||||||||||||||||
1654 | Constructs a new variant with a char value, \a c. | - | ||||||||||||||||||||||||
1655 | */ | - | ||||||||||||||||||||||||
1656 | - | |||||||||||||||||||||||||
1657 | /*! | - | ||||||||||||||||||||||||
1658 | \fn QVariant::QVariant(const QLocale &l) | - | ||||||||||||||||||||||||
1659 | - | |||||||||||||||||||||||||
1660 | Constructs a new variant with a locale value, \a l. | - | ||||||||||||||||||||||||
1661 | */ | - | ||||||||||||||||||||||||
1662 | - | |||||||||||||||||||||||||
1663 | /*! | - | ||||||||||||||||||||||||
1664 | \fn QVariant::QVariant(const QRegExp ®Exp) | - | ||||||||||||||||||||||||
1665 | - | |||||||||||||||||||||||||
1666 | Constructs a new variant with the regexp value \a regExp. | - | ||||||||||||||||||||||||
1667 | */ | - | ||||||||||||||||||||||||
1668 | - | |||||||||||||||||||||||||
1669 | /*! | - | ||||||||||||||||||||||||
1670 | \fn QVariant::QVariant(const QRegularExpression &re) | - | ||||||||||||||||||||||||
1671 | - | |||||||||||||||||||||||||
1672 | \since 5.0 | - | ||||||||||||||||||||||||
1673 | - | |||||||||||||||||||||||||
1674 | Constructs a new variant with the regular expression value \a re. | - | ||||||||||||||||||||||||
1675 | */ | - | ||||||||||||||||||||||||
1676 | - | |||||||||||||||||||||||||
1677 | QVariant::QVariant(Type type) | - | ||||||||||||||||||||||||
1678 | { executed 8082 times by 17 tests: create(type, 0); }end of block Executed by:
executed 8082 times by 17 tests: end of block Executed by:
| 8082 | ||||||||||||||||||||||||
1679 | QVariant::QVariant(int typeId, const void *copy) | - | ||||||||||||||||||||||||
1680 | { executed 3501271 times by 228 tests: create(typeId, copy); d.is_null = false; }end of block Executed by:
executed 3501271 times by 228 tests: end of block Executed by:
| 3501271 | ||||||||||||||||||||||||
1681 | - | |||||||||||||||||||||||||
1682 | /*! | - | ||||||||||||||||||||||||
1683 | \internal | - | ||||||||||||||||||||||||
1684 | flags is true if it is a pointer type | - | ||||||||||||||||||||||||
1685 | */ | - | ||||||||||||||||||||||||
1686 | QVariant::QVariant(int typeId, const void *copy, uint flags) | - | ||||||||||||||||||||||||
1687 | { | - | ||||||||||||||||||||||||
1688 | if (flags) { //type is a pointer type
| 18638-42239 | ||||||||||||||||||||||||
1689 | d.type = typeId; | - | ||||||||||||||||||||||||
1690 | d.data.ptr = *reinterpret_cast<void *const*>(copy); | - | ||||||||||||||||||||||||
1691 | } else { executed 42239 times by 30 tests: end of block Executed by:
| 42239 | ||||||||||||||||||||||||
1692 | create(typeId, copy); | - | ||||||||||||||||||||||||
1693 | } executed 18638 times by 195 tests: end of block Executed by:
| 18638 | ||||||||||||||||||||||||
1694 | d.is_null = false; | - | ||||||||||||||||||||||||
1695 | } executed 60877 times by 199 tests: end of block Executed by:
| 60877 | ||||||||||||||||||||||||
1696 | - | |||||||||||||||||||||||||
1697 | QVariant::QVariant(int val) | - | ||||||||||||||||||||||||
1698 | : d(Int) | - | ||||||||||||||||||||||||
1699 | { executed 653435 times by 221 tests: d.data.i = val; }end of block Executed by:
executed 653435 times by 221 tests: end of block Executed by:
| 653435 | ||||||||||||||||||||||||
1700 | QVariant::QVariant(uint val) | - | ||||||||||||||||||||||||
1701 | : d(UInt) | - | ||||||||||||||||||||||||
1702 | { executed 3344 times by 53 tests: d.data.u = val; }end of block Executed by:
executed 3344 times by 53 tests: end of block Executed by:
| 3344 | ||||||||||||||||||||||||
1703 | QVariant::QVariant(qlonglong val) | - | ||||||||||||||||||||||||
1704 | : d(LongLong) | - | ||||||||||||||||||||||||
1705 | { executed 40329 times by 23 tests: d.data.ll = val; }end of block Executed by:
executed 40329 times by 23 tests: end of block Executed by:
| 40329 | ||||||||||||||||||||||||
1706 | QVariant::QVariant(qulonglong val) | - | ||||||||||||||||||||||||
1707 | : d(ULongLong) | - | ||||||||||||||||||||||||
1708 | { executed 87 times by 24 tests: d.data.ull = val; }end of block Executed by:
executed 87 times by 24 tests: end of block Executed by:
| 87 | ||||||||||||||||||||||||
1709 | QVariant::QVariant(bool val) | - | ||||||||||||||||||||||||
1710 | : d(Bool) | - | ||||||||||||||||||||||||
1711 | { executed 147247 times by 175 tests: d.data.b = val; }end of block Executed by:
executed 147247 times by 175 tests: end of block Executed by:
| 147247 | ||||||||||||||||||||||||
1712 | QVariant::QVariant(double val) | - | ||||||||||||||||||||||||
1713 | : d(Double) | - | ||||||||||||||||||||||||
1714 | { executed 73155 times by 75 tests: d.data.d = val; }end of block Executed by:
executed 73155 times by 75 tests: end of block Executed by:
| 73155 | ||||||||||||||||||||||||
1715 | QVariant::QVariant(float val) | - | ||||||||||||||||||||||||
1716 | : d(QMetaType::Float) | - | ||||||||||||||||||||||||
1717 | { executed 158 times by 16 tests: d.data.f = val; }end of block Executed by:
executed 158 times by 16 tests: end of block Executed by:
| 158 | ||||||||||||||||||||||||
1718 | - | |||||||||||||||||||||||||
1719 | QVariant::QVariant(const QByteArray &val) | - | ||||||||||||||||||||||||
1720 | : d(ByteArray) | - | ||||||||||||||||||||||||
1721 | { executed 894 times by 37 tests: v_construct<QByteArray>(&d, val); }end of block Executed by:
executed 894 times by 37 tests: end of block Executed by:
| 894 | ||||||||||||||||||||||||
1722 | QVariant::QVariant(const QBitArray &val) | - | ||||||||||||||||||||||||
1723 | : d(BitArray) | - | ||||||||||||||||||||||||
1724 | { executed 6 times by 1 test: v_construct<QBitArray>(&d, val); }end of block Executed by:
executed 6 times by 1 test: end of block Executed by:
| 6 | ||||||||||||||||||||||||
1725 | QVariant::QVariant(const QString &val) | - | ||||||||||||||||||||||||
1726 | : d(String) | - | ||||||||||||||||||||||||
1727 | { executed 3990181 times by 379 tests: v_construct<QString>(&d, val); }end of block Executed by:
executed 3990181 times by 379 tests: end of block Executed by:
| 3990181 | ||||||||||||||||||||||||
1728 | QVariant::QVariant(QChar val) | - | ||||||||||||||||||||||||
1729 | : d(Char) | - | ||||||||||||||||||||||||
1730 | { executed 5772 times by 66 tests: v_construct<QChar>(&d, val); }end of block Executed by:
executed 5772 times by 66 tests: end of block Executed by:
| 5772 | ||||||||||||||||||||||||
1731 | QVariant::QVariant(QLatin1String val) | - | ||||||||||||||||||||||||
1732 | : d(String) | - | ||||||||||||||||||||||||
1733 | { executed 882 times by 35 tests: v_construct<QString>(&d, val); }end of block Executed by:
executed 882 times by 35 tests: end of block Executed by:
| 882 | ||||||||||||||||||||||||
1734 | QVariant::QVariant(const QStringList &val) | - | ||||||||||||||||||||||||
1735 | : d(StringList) | - | ||||||||||||||||||||||||
1736 | { executed 919 times by 59 tests: v_construct<QStringList>(&d, val); }end of block Executed by:
executed 919 times by 59 tests: end of block Executed by:
| 919 | ||||||||||||||||||||||||
1737 | - | |||||||||||||||||||||||||
1738 | QVariant::QVariant(const QDate &val) | - | ||||||||||||||||||||||||
1739 | : d(Date) | - | ||||||||||||||||||||||||
1740 | { executed 166 times by 9 tests: v_construct<QDate>(&d, val); }end of block Executed by:
executed 166 times by 9 tests: end of block Executed by:
| 166 | ||||||||||||||||||||||||
1741 | QVariant::QVariant(const QTime &val) | - | ||||||||||||||||||||||||
1742 | : d(Time) | - | ||||||||||||||||||||||||
1743 | { executed 66 times by 7 tests: v_construct<QTime>(&d, val); }end of block Executed by:
executed 66 times by 7 tests: end of block Executed by:
| 66 | ||||||||||||||||||||||||
1744 | QVariant::QVariant(const QDateTime &val) | - | ||||||||||||||||||||||||
1745 | : d(DateTime) | - | ||||||||||||||||||||||||
1746 | { executed 25061 times by 21 tests: v_construct<QDateTime>(&d, val); }end of block Executed by:
executed 25061 times by 21 tests: end of block Executed by:
| 25061 | ||||||||||||||||||||||||
1747 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1748 | QVariant::QVariant(const QEasingCurve &val) | - | ||||||||||||||||||||||||
1749 | : d(EasingCurve) | - | ||||||||||||||||||||||||
1750 | { executed 3 times by 2 tests: v_construct<QEasingCurve>(&d, val); }end of block Executed by:
executed 3 times by 2 tests: end of block Executed by:
| 3 | ||||||||||||||||||||||||
1751 | #endif | - | ||||||||||||||||||||||||
1752 | QVariant::QVariant(const QList<QVariant> &list) | - | ||||||||||||||||||||||||
1753 | : d(List) | - | ||||||||||||||||||||||||
1754 | { executed 182 times by 19 tests: v_construct<QVariantList>(&d, list); }end of block Executed by:
executed 182 times by 19 tests: end of block Executed by:
| 182 | ||||||||||||||||||||||||
1755 | QVariant::QVariant(const QMap<QString, QVariant> &map) | - | ||||||||||||||||||||||||
1756 | : d(Map) | - | ||||||||||||||||||||||||
1757 | { executed 29 times by 4 tests: v_construct<QVariantMap>(&d, map); }end of block Executed by:
executed 29 times by 4 tests: end of block Executed by:
| 29 | ||||||||||||||||||||||||
1758 | QVariant::QVariant(const QHash<QString, QVariant> &hash) | - | ||||||||||||||||||||||||
1759 | : d(Hash) | - | ||||||||||||||||||||||||
1760 | { executed 14 times by 1 test: v_construct<QVariantHash>(&d, hash); }end of block Executed by:
executed 14 times by 1 test: end of block Executed by:
| 14 | ||||||||||||||||||||||||
1761 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
1762 | QVariant::QVariant(const QPoint &pt) | - | ||||||||||||||||||||||||
1763 | : d(Point) | - | ||||||||||||||||||||||||
1764 | { executed 50 times by 5 tests: v_construct<QPoint>(&d, pt); }end of block Executed by:
executed 50 times by 5 tests: end of block Executed by:
| 50 | ||||||||||||||||||||||||
1765 | QVariant::QVariant(const QPointF &pt) | - | ||||||||||||||||||||||||
1766 | : d(PointF) | - | ||||||||||||||||||||||||
1767 | { executed 67 times by 7 tests: v_construct<QPointF>(&d, pt); }end of block Executed by:
executed 67 times by 7 tests: end of block Executed by:
| 67 | ||||||||||||||||||||||||
1768 | QVariant::QVariant(const QRectF &r) | - | ||||||||||||||||||||||||
1769 | : d(RectF) | - | ||||||||||||||||||||||||
1770 | { executed 26 times by 7 tests: v_construct<QRectF>(&d, r); }end of block Executed by:
executed 26 times by 7 tests: end of block Executed by:
| 26 | ||||||||||||||||||||||||
1771 | QVariant::QVariant(const QLineF &l) | - | ||||||||||||||||||||||||
1772 | : d(LineF) | - | ||||||||||||||||||||||||
1773 | { executed 8 times by 3 tests: v_construct<QLineF>(&d, l); }end of block Executed by:
executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1774 | QVariant::QVariant(const QLine &l) | - | ||||||||||||||||||||||||
1775 | : d(Line) | - | ||||||||||||||||||||||||
1776 | { executed 8 times by 3 tests: v_construct<QLine>(&d, l); }end of block Executed by:
executed 8 times by 3 tests: end of block Executed by:
| 8 | ||||||||||||||||||||||||
1777 | QVariant::QVariant(const QRect &r) | - | ||||||||||||||||||||||||
1778 | : d(Rect) | - | ||||||||||||||||||||||||
1779 | { executed 5350 times by 23 tests: v_construct<QRect>(&d, r); }end of block Executed by:
executed 5350 times by 23 tests: end of block Executed by:
| 5350 | ||||||||||||||||||||||||
1780 | QVariant::QVariant(const QSize &s) | - | ||||||||||||||||||||||||
1781 | : d(Size) | - | ||||||||||||||||||||||||
1782 | { executed 1215 times by 16 tests: v_construct<QSize>(&d, s); }end of block Executed by:
executed 1215 times by 16 tests: end of block Executed by:
| 1215 | ||||||||||||||||||||||||
1783 | QVariant::QVariant(const QSizeF &s) | - | ||||||||||||||||||||||||
1784 | : d(SizeF) | - | ||||||||||||||||||||||||
1785 | { executed 38 times by 4 tests: v_construct<QSizeF>(&d, s); }end of block Executed by:
executed 38 times by 4 tests: end of block Executed by:
| 38 | ||||||||||||||||||||||||
1786 | #endif | - | ||||||||||||||||||||||||
1787 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1788 | QVariant::QVariant(const QUrl &u) | - | ||||||||||||||||||||||||
1789 | : d(Url) | - | ||||||||||||||||||||||||
1790 | { executed 5485 times by 10 tests: v_construct<QUrl>(&d, u); }end of block Executed by:
executed 5485 times by 10 tests: end of block Executed by:
| 5485 | ||||||||||||||||||||||||
1791 | #endif | - | ||||||||||||||||||||||||
1792 | QVariant::QVariant(const QLocale &l) | - | ||||||||||||||||||||||||
1793 | : d(Locale) | - | ||||||||||||||||||||||||
1794 | { executed 3 times by 2 tests: v_construct<QLocale>(&d, l); }end of block Executed by:
executed 3 times by 2 tests: end of block Executed by:
| 3 | ||||||||||||||||||||||||
1795 | #ifndef QT_NO_REGEXP | - | ||||||||||||||||||||||||
1796 | QVariant::QVariant(const QRegExp ®Exp) | - | ||||||||||||||||||||||||
1797 | : d(RegExp) | - | ||||||||||||||||||||||||
1798 | { executed 46 times by 2 tests: v_construct<QRegExp>(&d, regExp); }end of block Executed by:
executed 46 times by 2 tests: end of block Executed by:
| 46 | ||||||||||||||||||||||||
1799 | #endif // QT_NO_REGEXP | - | ||||||||||||||||||||||||
1800 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1801 | #ifndef QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
1802 | QVariant::QVariant(const QRegularExpression &re) | - | ||||||||||||||||||||||||
1803 | : d(RegularExpression) | - | ||||||||||||||||||||||||
1804 | { executed 104 times by 4 tests: v_construct<QRegularExpression>(&d, re); }end of block Executed by:
executed 104 times by 4 tests: end of block Executed by:
| 104 | ||||||||||||||||||||||||
1805 | #endif | - | ||||||||||||||||||||||||
1806 | QVariant::QVariant(const QUuid &uuid) | - | ||||||||||||||||||||||||
1807 | : d(Uuid) | - | ||||||||||||||||||||||||
1808 | { executed 5 times by 1 test: v_construct<QUuid>(&d, uuid); }end of block Executed by:
executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
1809 | QVariant::QVariant(const QModelIndex &modelIndex) | - | ||||||||||||||||||||||||
1810 | : d(ModelIndex) | - | ||||||||||||||||||||||||
1811 | { executed 2 times by 1 test: v_construct<QModelIndex>(&d, modelIndex); }end of block Executed by:
executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
1812 | QVariant::QVariant(const QPersistentModelIndex &modelIndex) | - | ||||||||||||||||||||||||
1813 | : d(PersistentModelIndex) | - | ||||||||||||||||||||||||
1814 | { executed 1 time by 1 test: v_construct<QPersistentModelIndex>(&d, modelIndex); }end of block Executed by:
executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1815 | QVariant::QVariant(const QJsonValue &jsonValue) | - | ||||||||||||||||||||||||
1816 | : d(QMetaType::QJsonValue) | - | ||||||||||||||||||||||||
1817 | { executed 17 times by 1 test: v_construct<QJsonValue>(&d, jsonValue); }end of block Executed by:
executed 17 times by 1 test: end of block Executed by:
| 17 | ||||||||||||||||||||||||
1818 | QVariant::QVariant(const QJsonObject &jsonObject) | - | ||||||||||||||||||||||||
1819 | : d(QMetaType::QJsonObject) | - | ||||||||||||||||||||||||
1820 | { executed 1 time by 1 test: v_construct<QJsonObject>(&d, jsonObject); }end of block Executed by:
executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1821 | QVariant::QVariant(const QJsonArray &jsonArray) | - | ||||||||||||||||||||||||
1822 | : d(QMetaType::QJsonArray) | - | ||||||||||||||||||||||||
1823 | { executed 1 time by 1 test: v_construct<QJsonArray>(&d, jsonArray); }end of block Executed by:
executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1824 | QVariant::QVariant(const QJsonDocument &jsonDocument) | - | ||||||||||||||||||||||||
1825 | : d(QMetaType::QJsonDocument) | - | ||||||||||||||||||||||||
1826 | { executed 1 time by 1 test: v_construct<QJsonDocument>(&d, jsonDocument); }end of block Executed by:
executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
1827 | #endif // QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
1828 | - | |||||||||||||||||||||||||
1829 | /*! | - | ||||||||||||||||||||||||
1830 | Returns the storage type of the value stored in the variant. | - | ||||||||||||||||||||||||
1831 | Although this function is declared as returning QVariant::Type, | - | ||||||||||||||||||||||||
1832 | the return value should be interpreted as QMetaType::Type. In | - | ||||||||||||||||||||||||
1833 | particular, QVariant::UserType is returned here only if the value | - | ||||||||||||||||||||||||
1834 | is equal or greater than QMetaType::User. | - | ||||||||||||||||||||||||
1835 | - | |||||||||||||||||||||||||
1836 | Note that return values in the ranges QVariant::Char through | - | ||||||||||||||||||||||||
1837 | QVariant::RegExp and QVariant::Font through QVariant::Transform | - | ||||||||||||||||||||||||
1838 | correspond to the values in the ranges QMetaType::QChar through | - | ||||||||||||||||||||||||
1839 | QMetaType::QRegExp and QMetaType::QFont through QMetaType::QQuaternion. | - | ||||||||||||||||||||||||
1840 | - | |||||||||||||||||||||||||
1841 | Pay particular attention when working with char and QChar | - | ||||||||||||||||||||||||
1842 | variants. Note that there is no QVariant constructor specifically | - | ||||||||||||||||||||||||
1843 | for type char, but there is one for QChar. For a variant of type | - | ||||||||||||||||||||||||
1844 | QChar, this function returns QVariant::Char, which is the same as | - | ||||||||||||||||||||||||
1845 | QMetaType::QChar, but for a variant of type \c char, this function | - | ||||||||||||||||||||||||
1846 | returns QMetaType::Char, which is \e not the same as | - | ||||||||||||||||||||||||
1847 | QVariant::Char. | - | ||||||||||||||||||||||||
1848 | - | |||||||||||||||||||||||||
1849 | Also note that the types \c void*, \c long, \c short, \c unsigned | - | ||||||||||||||||||||||||
1850 | \c long, \c unsigned \c short, \c unsigned \c char, \c float, \c | - | ||||||||||||||||||||||||
1851 | QObject*, and \c QWidget* are represented in QMetaType::Type but | - | ||||||||||||||||||||||||
1852 | not in QVariant::Type, and they can be returned by this function. | - | ||||||||||||||||||||||||
1853 | However, they are considered to be user defined types when tested | - | ||||||||||||||||||||||||
1854 | against QVariant::Type. | - | ||||||||||||||||||||||||
1855 | - | |||||||||||||||||||||||||
1856 | To test whether an instance of QVariant contains a data type that | - | ||||||||||||||||||||||||
1857 | is compatible with the data type you are interested in, use | - | ||||||||||||||||||||||||
1858 | canConvert(). | - | ||||||||||||||||||||||||
1859 | */ | - | ||||||||||||||||||||||||
1860 | - | |||||||||||||||||||||||||
1861 | QVariant::Type QVariant::type() const | - | ||||||||||||||||||||||||
1862 | { | - | ||||||||||||||||||||||||
1863 | return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type); executed 332149 times by 161 tests: return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type); Executed by:
| 138-332149 | ||||||||||||||||||||||||
1864 | } | - | ||||||||||||||||||||||||
1865 | - | |||||||||||||||||||||||||
1866 | /*! | - | ||||||||||||||||||||||||
1867 | Returns the storage type of the value stored in the variant. For | - | ||||||||||||||||||||||||
1868 | non-user types, this is the same as type(). | - | ||||||||||||||||||||||||
1869 | - | |||||||||||||||||||||||||
1870 | \sa type() | - | ||||||||||||||||||||||||
1871 | */ | - | ||||||||||||||||||||||||
1872 | - | |||||||||||||||||||||||||
1873 | int QVariant::userType() const | - | ||||||||||||||||||||||||
1874 | { | - | ||||||||||||||||||||||||
1875 | return d.type; executed 4474633 times by 232 tests: return d.type; Executed by:
| 4474633 | ||||||||||||||||||||||||
1876 | } | - | ||||||||||||||||||||||||
1877 | - | |||||||||||||||||||||||||
1878 | /*! | - | ||||||||||||||||||||||||
1879 | Assigns the value of the variant \a variant to this variant. | - | ||||||||||||||||||||||||
1880 | */ | - | ||||||||||||||||||||||||
1881 | QVariant& QVariant::operator=(const QVariant &variant) | - | ||||||||||||||||||||||||
1882 | { | - | ||||||||||||||||||||||||
1883 | if (this == &variant)
| 306-363636 | ||||||||||||||||||||||||
1884 | return *this; executed 306 times by 10 tests: return *this; Executed by:
| 306 | ||||||||||||||||||||||||
1885 | - | |||||||||||||||||||||||||
1886 | clear(); | - | ||||||||||||||||||||||||
1887 | if (variant.d.is_shared) {
| 1971-361665 | ||||||||||||||||||||||||
1888 | variant.d.data.shared->ref.ref(); | - | ||||||||||||||||||||||||
1889 | d = variant.d; | - | ||||||||||||||||||||||||
1890 | } else if (variant.d.type > Char) { executed 1971 times by 38 tests: end of block Executed by:
| 1971-191274 | ||||||||||||||||||||||||
1891 | d.type = variant.d.type; | - | ||||||||||||||||||||||||
1892 | handlerManager[d.type]->construct(&d, variant.constData()); | - | ||||||||||||||||||||||||
1893 | d.is_null = variant.d.is_null; | - | ||||||||||||||||||||||||
1894 | } else { executed 191274 times by 114 tests: end of block Executed by:
| 191274 | ||||||||||||||||||||||||
1895 | d = variant.d; | - | ||||||||||||||||||||||||
1896 | } executed 170391 times by 188 tests: end of block Executed by:
| 170391 | ||||||||||||||||||||||||
1897 | - | |||||||||||||||||||||||||
1898 | return *this; executed 363636 times by 211 tests: return *this; Executed by:
| 363636 | ||||||||||||||||||||||||
1899 | } | - | ||||||||||||||||||||||||
1900 | - | |||||||||||||||||||||||||
1901 | /*! | - | ||||||||||||||||||||||||
1902 | \fn void QVariant::swap(QVariant &other) | - | ||||||||||||||||||||||||
1903 | \since 4.8 | - | ||||||||||||||||||||||||
1904 | - | |||||||||||||||||||||||||
1905 | Swaps variant \a other with this variant. This operation is very | - | ||||||||||||||||||||||||
1906 | fast and never fails. | - | ||||||||||||||||||||||||
1907 | */ | - | ||||||||||||||||||||||||
1908 | - | |||||||||||||||||||||||||
1909 | /*! | - | ||||||||||||||||||||||||
1910 | \fn void QVariant::detach() | - | ||||||||||||||||||||||||
1911 | - | |||||||||||||||||||||||||
1912 | \internal | - | ||||||||||||||||||||||||
1913 | */ | - | ||||||||||||||||||||||||
1914 | - | |||||||||||||||||||||||||
1915 | void QVariant::detach() | - | ||||||||||||||||||||||||
1916 | { | - | ||||||||||||||||||||||||
1917 | if (!d.is_shared || d.data.shared->ref.load() == 1)
| 25-38330 | ||||||||||||||||||||||||
1918 | return; executed 43719 times by 164 tests: return; Executed by:
| 43719 | ||||||||||||||||||||||||
1919 | - | |||||||||||||||||||||||||
1920 | Private dd; | - | ||||||||||||||||||||||||
1921 | dd.type = d.type; | - | ||||||||||||||||||||||||
1922 | handlerManager[d.type]->construct(&dd, constData()); | - | ||||||||||||||||||||||||
1923 | if (!d.data.shared->ref.deref())
| 0-25 | ||||||||||||||||||||||||
1924 | handlerManager[d.type]->clear(&d); never executed: handlerManager[d.type]->clear(&d); | 0 | ||||||||||||||||||||||||
1925 | d.data.shared = dd.data.shared; | - | ||||||||||||||||||||||||
1926 | } executed 25 times by 7 tests: end of block Executed by:
| 25 | ||||||||||||||||||||||||
1927 | - | |||||||||||||||||||||||||
1928 | /*! | - | ||||||||||||||||||||||||
1929 | \fn bool QVariant::isDetached() const | - | ||||||||||||||||||||||||
1930 | - | |||||||||||||||||||||||||
1931 | \internal | - | ||||||||||||||||||||||||
1932 | */ | - | ||||||||||||||||||||||||
1933 | - | |||||||||||||||||||||||||
1934 | /*! | - | ||||||||||||||||||||||||
1935 | Returns the name of the type stored in the variant. The returned | - | ||||||||||||||||||||||||
1936 | strings describe the C++ datatype used to store the data: for | - | ||||||||||||||||||||||||
1937 | example, "QFont", "QString", or "QVariantList". An Invalid | - | ||||||||||||||||||||||||
1938 | variant returns 0. | - | ||||||||||||||||||||||||
1939 | */ | - | ||||||||||||||||||||||||
1940 | const char *QVariant::typeName() const | - | ||||||||||||||||||||||||
1941 | { | - | ||||||||||||||||||||||||
1942 | return QMetaType::typeName(d.type); executed 5751 times by 46 tests: return QMetaType::typeName(d.type); Executed by:
| 5751 | ||||||||||||||||||||||||
1943 | } | - | ||||||||||||||||||||||||
1944 | - | |||||||||||||||||||||||||
1945 | /*! | - | ||||||||||||||||||||||||
1946 | Convert this variant to type QMetaType::UnknownType and free up any resources | - | ||||||||||||||||||||||||
1947 | used. | - | ||||||||||||||||||||||||
1948 | */ | - | ||||||||||||||||||||||||
1949 | void QVariant::clear() | - | ||||||||||||||||||||||||
1950 | { | - | ||||||||||||||||||||||||
1951 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char))
| 48-391156 | ||||||||||||||||||||||||
1952 | handlerManager[d.type]->clear(&d); executed 132707 times by 86 tests: handlerManager[d.type]->clear(&d); Executed by:
| 132707 | ||||||||||||||||||||||||
1953 | d.type = Invalid; | - | ||||||||||||||||||||||||
1954 | d.is_null = true; | - | ||||||||||||||||||||||||
1955 | d.is_shared = false; | - | ||||||||||||||||||||||||
1956 | } executed 391331 times by 218 tests: end of block Executed by:
| 391331 | ||||||||||||||||||||||||
1957 | - | |||||||||||||||||||||||||
1958 | /*! | - | ||||||||||||||||||||||||
1959 | Converts the int representation of the storage type, \a typeId, to | - | ||||||||||||||||||||||||
1960 | its string representation. | - | ||||||||||||||||||||||||
1961 | - | |||||||||||||||||||||||||
1962 | Returns a null pointer if the type is QMetaType::UnknownType or doesn't exist. | - | ||||||||||||||||||||||||
1963 | */ | - | ||||||||||||||||||||||||
1964 | const char *QVariant::typeToName(int typeId) | - | ||||||||||||||||||||||||
1965 | { | - | ||||||||||||||||||||||||
1966 | return QMetaType::typeName(typeId); executed 408 times by 2 tests: return QMetaType::typeName(typeId); Executed by:
| 408 | ||||||||||||||||||||||||
1967 | } | - | ||||||||||||||||||||||||
1968 | - | |||||||||||||||||||||||||
1969 | - | |||||||||||||||||||||||||
1970 | /*! | - | ||||||||||||||||||||||||
1971 | Converts the string representation of the storage type given in \a | - | ||||||||||||||||||||||||
1972 | name, to its enum representation. | - | ||||||||||||||||||||||||
1973 | - | |||||||||||||||||||||||||
1974 | If the string representation cannot be converted to any enum | - | ||||||||||||||||||||||||
1975 | representation, the variant is set to \c Invalid. | - | ||||||||||||||||||||||||
1976 | */ | - | ||||||||||||||||||||||||
1977 | QVariant::Type QVariant::nameToType(const char *name) | - | ||||||||||||||||||||||||
1978 | { | - | ||||||||||||||||||||||||
1979 | int metaType = QMetaType::type(name); | - | ||||||||||||||||||||||||
1980 | return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType; executed 81 times by 1 test: return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType; Executed by:
| 0-81 | ||||||||||||||||||||||||
1981 | } | - | ||||||||||||||||||||||||
1982 | - | |||||||||||||||||||||||||
1983 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
1984 | enum { MapFromThreeCount = 36 }; | - | ||||||||||||||||||||||||
1985 | static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = | - | ||||||||||||||||||||||||
1986 | { | - | ||||||||||||||||||||||||
1987 | QVariant::Invalid, | - | ||||||||||||||||||||||||
1988 | QVariant::Map, | - | ||||||||||||||||||||||||
1989 | QVariant::List, | - | ||||||||||||||||||||||||
1990 | QVariant::String, | - | ||||||||||||||||||||||||
1991 | QVariant::StringList, | - | ||||||||||||||||||||||||
1992 | QVariant::Font, | - | ||||||||||||||||||||||||
1993 | QVariant::Pixmap, | - | ||||||||||||||||||||||||
1994 | QVariant::Brush, | - | ||||||||||||||||||||||||
1995 | QVariant::Rect, | - | ||||||||||||||||||||||||
1996 | QVariant::Size, | - | ||||||||||||||||||||||||
1997 | QVariant::Color, | - | ||||||||||||||||||||||||
1998 | QVariant::Palette, | - | ||||||||||||||||||||||||
1999 | 0, // ColorGroup | - | ||||||||||||||||||||||||
2000 | QVariant::Icon, | - | ||||||||||||||||||||||||
2001 | QVariant::Point, | - | ||||||||||||||||||||||||
2002 | QVariant::Image, | - | ||||||||||||||||||||||||
2003 | QVariant::Int, | - | ||||||||||||||||||||||||
2004 | QVariant::UInt, | - | ||||||||||||||||||||||||
2005 | QVariant::Bool, | - | ||||||||||||||||||||||||
2006 | QVariant::Double, | - | ||||||||||||||||||||||||
2007 | 0, // Buggy ByteArray, QByteArray never had id == 20 | - | ||||||||||||||||||||||||
2008 | QVariant::Polygon, | - | ||||||||||||||||||||||||
2009 | QVariant::Region, | - | ||||||||||||||||||||||||
2010 | QVariant::Bitmap, | - | ||||||||||||||||||||||||
2011 | QVariant::Cursor, | - | ||||||||||||||||||||||||
2012 | QVariant::SizePolicy, | - | ||||||||||||||||||||||||
2013 | QVariant::Date, | - | ||||||||||||||||||||||||
2014 | QVariant::Time, | - | ||||||||||||||||||||||||
2015 | QVariant::DateTime, | - | ||||||||||||||||||||||||
2016 | QVariant::ByteArray, | - | ||||||||||||||||||||||||
2017 | QVariant::BitArray, | - | ||||||||||||||||||||||||
2018 | QVariant::KeySequence, | - | ||||||||||||||||||||||||
2019 | QVariant::Pen, | - | ||||||||||||||||||||||||
2020 | QVariant::LongLong, | - | ||||||||||||||||||||||||
2021 | QVariant::ULongLong, | - | ||||||||||||||||||||||||
2022 | QVariant::EasingCurve | - | ||||||||||||||||||||||||
2023 | }; | - | ||||||||||||||||||||||||
2024 | - | |||||||||||||||||||||||||
2025 | /*! | - | ||||||||||||||||||||||||
2026 | Internal function for loading a variant from stream \a s. Use the | - | ||||||||||||||||||||||||
2027 | stream operators instead. | - | ||||||||||||||||||||||||
2028 | - | |||||||||||||||||||||||||
2029 | \internal | - | ||||||||||||||||||||||||
2030 | */ | - | ||||||||||||||||||||||||
2031 | void QVariant::load(QDataStream &s) | - | ||||||||||||||||||||||||
2032 | { | - | ||||||||||||||||||||||||
2033 | clear(); | - | ||||||||||||||||||||||||
2034 | - | |||||||||||||||||||||||||
2035 | quint32 typeId; | - | ||||||||||||||||||||||||
2036 | s >> typeId; | - | ||||||||||||||||||||||||
2037 | if (s.version() < QDataStream::Qt_4_0) {
| 1-16322 | ||||||||||||||||||||||||
2038 | if (typeId >= MapFromThreeCount)
| 0-1 | ||||||||||||||||||||||||
2039 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2040 | typeId = mapIdFromQt3ToCurrent[typeId]; | - | ||||||||||||||||||||||||
2041 | } else if (s.version() < QDataStream::Qt_5_0) { executed 1 time by 1 test: end of block Executed by:
| 1-15915 | ||||||||||||||||||||||||
2042 | if (typeId == 127 /* QVariant::UserType */) {
| 1-406 | ||||||||||||||||||||||||
2043 | typeId = QMetaType::User; | - | ||||||||||||||||||||||||
2044 | } else if (typeId >= 128 && typeId != QVariant::UserType) { executed 1 time by 1 test: end of block Executed by:
| 0-390 | ||||||||||||||||||||||||
2045 | // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes | - | ||||||||||||||||||||||||
2046 | // by moving all ids down by 97. | - | ||||||||||||||||||||||||
2047 | typeId -= 97; | - | ||||||||||||||||||||||||
2048 | } else if (typeId == 75 /* QSizePolicy */) { executed 16 times by 1 test: end of block Executed by:
| 0-390 | ||||||||||||||||||||||||
2049 | typeId = QMetaType::QSizePolicy; | - | ||||||||||||||||||||||||
2050 | } else if (typeId > 75 && typeId <= 86) { never executed: end of block
| 0-390 | ||||||||||||||||||||||||
2051 | // and as a result these types received lower ids too | - | ||||||||||||||||||||||||
2052 | // QKeySequence QPen QTextLength QTextFormat QMatrix QTransform QMatrix4x4 QVector2D QVector3D QVector4D QQuaternion | - | ||||||||||||||||||||||||
2053 | typeId -=1; | - | ||||||||||||||||||||||||
2054 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2055 | } executed 407 times by 3 tests: end of block Executed by:
| 407 | ||||||||||||||||||||||||
2056 | - | |||||||||||||||||||||||||
2057 | qint8 is_null = false; | - | ||||||||||||||||||||||||
2058 | if (s.version() >= QDataStream::Qt_4_2)
| 332-15991 | ||||||||||||||||||||||||
2059 | s >> is_null; executed 15991 times by 15 tests: s >> is_null; Executed by:
| 15991 | ||||||||||||||||||||||||
2060 | if (typeId == QVariant::UserType) {
| 4-16319 | ||||||||||||||||||||||||
2061 | QByteArray name; | - | ||||||||||||||||||||||||
2062 | s >> name; | - | ||||||||||||||||||||||||
2063 | typeId = QMetaType::type(name.constData()); | - | ||||||||||||||||||||||||
2064 | if (typeId == QMetaType::UnknownType) {
| 0-4 | ||||||||||||||||||||||||
2065 | s.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
2066 | return; never executed: return; | 0 | ||||||||||||||||||||||||
2067 | } | - | ||||||||||||||||||||||||
2068 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2069 | create(typeId, 0); | - | ||||||||||||||||||||||||
2070 | d.is_null = is_null; | - | ||||||||||||||||||||||||
2071 | - | |||||||||||||||||||||||||
2072 | if (!isValid()) {
| 13-16310 | ||||||||||||||||||||||||
2073 | if (s.version() < QDataStream::Qt_5_0) {
| 3-10 | ||||||||||||||||||||||||
2074 | // Since we wrote something, we should read something | - | ||||||||||||||||||||||||
2075 | QString x; | - | ||||||||||||||||||||||||
2076 | s >> x; | - | ||||||||||||||||||||||||
2077 | } executed 3 times by 1 test: end of block Executed by:
| 3 | ||||||||||||||||||||||||
2078 | d.is_null = true; | - | ||||||||||||||||||||||||
2079 | return; executed 13 times by 2 tests: return; Executed by:
| 13 | ||||||||||||||||||||||||
2080 | } | - | ||||||||||||||||||||||||
2081 | - | |||||||||||||||||||||||||
2082 | // const cast is safe since we operate on a newly constructed variant | - | ||||||||||||||||||||||||
2083 | if (!QMetaType::load(s, d.type, const_cast<void *>(constData()))) {
| 1-16309 | ||||||||||||||||||||||||
2084 | s.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||||||||||||||
2085 | qWarning("QVariant::load: unable to load type %d.", d.type); | - | ||||||||||||||||||||||||
2086 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
2087 | } executed 16310 times by 14 tests: end of block Executed by:
| 16310 | ||||||||||||||||||||||||
2088 | - | |||||||||||||||||||||||||
2089 | /*! | - | ||||||||||||||||||||||||
2090 | Internal function for saving a variant to the stream \a s. Use the | - | ||||||||||||||||||||||||
2091 | stream operators instead. | - | ||||||||||||||||||||||||
2092 | - | |||||||||||||||||||||||||
2093 | \internal | - | ||||||||||||||||||||||||
2094 | */ | - | ||||||||||||||||||||||||
2095 | void QVariant::save(QDataStream &s) const | - | ||||||||||||||||||||||||
2096 | { | - | ||||||||||||||||||||||||
2097 | quint32 typeId = type(); | - | ||||||||||||||||||||||||
2098 | bool fakeUserType = false; | - | ||||||||||||||||||||||||
2099 | if (s.version() < QDataStream::Qt_4_0) {
| 9-16343 | ||||||||||||||||||||||||
2100 | int i; | - | ||||||||||||||||||||||||
2101 | for (i = 0; i <= MapFromThreeCount - 1; ++i) {
| 1-76 | ||||||||||||||||||||||||
2102 | if (mapIdFromQt3ToCurrent[i] == typeId) {
| 8-68 | ||||||||||||||||||||||||
2103 | typeId = i; | - | ||||||||||||||||||||||||
2104 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||||||||||||||
2105 | } | - | ||||||||||||||||||||||||
2106 | } executed 68 times by 2 tests: end of block Executed by:
| 68 | ||||||||||||||||||||||||
2107 | if (i >= MapFromThreeCount) {
| 1-8 | ||||||||||||||||||||||||
2108 | s << QVariant(); | - | ||||||||||||||||||||||||
2109 | return; executed 1 time by 1 test: return; Executed by:
| 1 | ||||||||||||||||||||||||
2110 | } | - | ||||||||||||||||||||||||
2111 | } else if (s.version() < QDataStream::Qt_5_0) { executed 8 times by 2 tests: end of block Executed by:
| 8-15916 | ||||||||||||||||||||||||
2112 | if (typeId == QMetaType::User) {
| 0-427 | ||||||||||||||||||||||||
2113 | typeId = 127; // QVariant::UserType had this value in Qt4 | - | ||||||||||||||||||||||||
2114 | } else if (typeId >= 128 - 97 && typeId <= LastCoreType) { never executed: end of block
| 0-368 | ||||||||||||||||||||||||
2115 | // In Qt4 id == 128 was FirstExtCoreType. In Qt5 ExtCoreTypes set was merged to CoreTypes | - | ||||||||||||||||||||||||
2116 | // by moving all ids down by 97. | - | ||||||||||||||||||||||||
2117 | typeId += 97; | - | ||||||||||||||||||||||||
2118 | } else if (typeId == QMetaType::QSizePolicy) { executed 8 times by 1 test: end of block Executed by:
| 0-419 | ||||||||||||||||||||||||
2119 | typeId = 75; | - | ||||||||||||||||||||||||
2120 | } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { never executed: end of block
| 0-419 | ||||||||||||||||||||||||
2121 | // and as a result these types received lower ids too | - | ||||||||||||||||||||||||
2122 | typeId +=1; | - | ||||||||||||||||||||||||
2123 | } else if (typeId == QMetaType::QPolygonF) { never executed: end of block
| 0-419 | ||||||||||||||||||||||||
2124 | // This existed in Qt 4 only as a custom type | - | ||||||||||||||||||||||||
2125 | typeId = 127; | - | ||||||||||||||||||||||||
2126 | fakeUserType = true; | - | ||||||||||||||||||||||||
2127 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2128 | } executed 427 times by 2 tests: end of block Executed by:
| 427 | ||||||||||||||||||||||||
2129 | s << typeId; | - | ||||||||||||||||||||||||
2130 | if (s.version() >= QDataStream::Qt_4_2)
| 393-15958 | ||||||||||||||||||||||||
2131 | s << qint8(d.is_null); executed 15958 times by 16 tests: s << qint8(d.is_null); Executed by:
| 15958 | ||||||||||||||||||||||||
2132 | if (d.type >= QVariant::UserType || fakeUserType) {
| 0-16349 | ||||||||||||||||||||||||
2133 | s << QMetaType::typeName(userType()); | - | ||||||||||||||||||||||||
2134 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
2135 | - | |||||||||||||||||||||||||
2136 | if (!isValid()) {
| 18-16333 | ||||||||||||||||||||||||
2137 | if (s.version() < QDataStream::Qt_5_0)
| 5-13 | ||||||||||||||||||||||||
2138 | s << QString(); executed 13 times by 1 test: s << QString(); Executed by:
| 13 | ||||||||||||||||||||||||
2139 | return; executed 18 times by 2 tests: return; Executed by:
| 18 | ||||||||||||||||||||||||
2140 | } | - | ||||||||||||||||||||||||
2141 | - | |||||||||||||||||||||||||
2142 | if (!QMetaType::save(s, d.type, constData())) {
| 0-16333 | ||||||||||||||||||||||||
2143 | qWarning("QVariant::save: unable to save type '%s' (type id: %d).\n", QMetaType::typeName(d.type), d.type); | - | ||||||||||||||||||||||||
2144 | Q_ASSERT_X(false, "QVariant::save", "Invalid type to save"); | - | ||||||||||||||||||||||||
2145 | } never executed: end of block | 0 | ||||||||||||||||||||||||
2146 | } executed 16333 times by 15 tests: end of block Executed by:
| 16333 | ||||||||||||||||||||||||
2147 | - | |||||||||||||||||||||||||
2148 | /*! | - | ||||||||||||||||||||||||
2149 | \since 4.4 | - | ||||||||||||||||||||||||
2150 | - | |||||||||||||||||||||||||
2151 | Reads a variant \a p from the stream \a s. | - | ||||||||||||||||||||||||
2152 | - | |||||||||||||||||||||||||
2153 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||||||||
2154 | */ | - | ||||||||||||||||||||||||
2155 | QDataStream& operator>>(QDataStream &s, QVariant &p) | - | ||||||||||||||||||||||||
2156 | { | - | ||||||||||||||||||||||||
2157 | p.load(s); | - | ||||||||||||||||||||||||
2158 | return s; executed 16321 times by 15 tests: return s; Executed by:
| 16321 | ||||||||||||||||||||||||
2159 | } | - | ||||||||||||||||||||||||
2160 | - | |||||||||||||||||||||||||
2161 | /*! | - | ||||||||||||||||||||||||
2162 | Writes a variant \a p to the stream \a s. | - | ||||||||||||||||||||||||
2163 | - | |||||||||||||||||||||||||
2164 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||||||||||||||
2165 | */ | - | ||||||||||||||||||||||||
2166 | QDataStream& operator<<(QDataStream &s, const QVariant &p) | - | ||||||||||||||||||||||||
2167 | { | - | ||||||||||||||||||||||||
2168 | p.save(s); | - | ||||||||||||||||||||||||
2169 | return s; executed 16352 times by 16 tests: return s; Executed by:
| 16352 | ||||||||||||||||||||||||
2170 | } | - | ||||||||||||||||||||||||
2171 | - | |||||||||||||||||||||||||
2172 | /*! | - | ||||||||||||||||||||||||
2173 | Reads a variant type \a p in enum representation from the stream \a s. | - | ||||||||||||||||||||||||
2174 | */ | - | ||||||||||||||||||||||||
2175 | QDataStream& operator>>(QDataStream &s, QVariant::Type &p) | - | ||||||||||||||||||||||||
2176 | { | - | ||||||||||||||||||||||||
2177 | quint32 u; | - | ||||||||||||||||||||||||
2178 | s >> u; | - | ||||||||||||||||||||||||
2179 | p = (QVariant::Type)u; | - | ||||||||||||||||||||||||
2180 | - | |||||||||||||||||||||||||
2181 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
2182 | } | - | ||||||||||||||||||||||||
2183 | - | |||||||||||||||||||||||||
2184 | /*! | - | ||||||||||||||||||||||||
2185 | Writes a variant type \a p to the stream \a s. | - | ||||||||||||||||||||||||
2186 | */ | - | ||||||||||||||||||||||||
2187 | QDataStream& operator<<(QDataStream &s, const QVariant::Type p) | - | ||||||||||||||||||||||||
2188 | { | - | ||||||||||||||||||||||||
2189 | s << static_cast<quint32>(p); | - | ||||||||||||||||||||||||
2190 | - | |||||||||||||||||||||||||
2191 | return s; never executed: return s; | 0 | ||||||||||||||||||||||||
2192 | } | - | ||||||||||||||||||||||||
2193 | - | |||||||||||||||||||||||||
2194 | #endif //QT_NO_DATASTREAM | - | ||||||||||||||||||||||||
2195 | - | |||||||||||||||||||||||||
2196 | /*! | - | ||||||||||||||||||||||||
2197 | \fn bool QVariant::isValid() const | - | ||||||||||||||||||||||||
2198 | - | |||||||||||||||||||||||||
2199 | Returns \c true if the storage type of this variant is not | - | ||||||||||||||||||||||||
2200 | QMetaType::UnknownType; otherwise returns \c false. | - | ||||||||||||||||||||||||
2201 | */ | - | ||||||||||||||||||||||||
2202 | - | |||||||||||||||||||||||||
2203 | template <typename T> | - | ||||||||||||||||||||||||
2204 | inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager) | - | ||||||||||||||||||||||||
2205 | { | - | ||||||||||||||||||||||||
2206 | const uint targetType = qMetaTypeId<T>(); | - | ||||||||||||||||||||||||
2207 | if (d.type == targetType)
| 78418-627340 | ||||||||||||||||||||||||
2208 | return *v_cast<T>(&d); executed 627340 times by 261 tests: return *v_cast<T>(&d); Executed by:
| 627340 | ||||||||||||||||||||||||
2209 | - | |||||||||||||||||||||||||
2210 | T ret; | - | ||||||||||||||||||||||||
2211 | if (d.type >= QMetaType::User || targetType >= QMetaType::User) {
| 0-78249 | ||||||||||||||||||||||||
2212 | const void * const from = constData(d); | - | ||||||||||||||||||||||||
2213 | if (QMetaType::convert(from, d.type, &ret, targetType))
| 18-151 | ||||||||||||||||||||||||
2214 | return ret; executed 18 times by 2 tests: return ret; Executed by:
| 18 | ||||||||||||||||||||||||
2215 | } executed 151 times by 2 tests: end of block Executed by:
| 151 | ||||||||||||||||||||||||
2216 | - | |||||||||||||||||||||||||
2217 | handlerManager[d.type]->convert(&d, targetType, &ret, 0); | - | ||||||||||||||||||||||||
2218 | return ret; executed 78400 times by 84 tests: return ret; Executed by:
| 78400 | ||||||||||||||||||||||||
2219 | } | - | ||||||||||||||||||||||||
2220 | - | |||||||||||||||||||||||||
2221 | /*! | - | ||||||||||||||||||||||||
2222 | \fn QStringList QVariant::toStringList() const | - | ||||||||||||||||||||||||
2223 | - | |||||||||||||||||||||||||
2224 | Returns the variant as a QStringList if the variant has userType() | - | ||||||||||||||||||||||||
2225 | \l QMetaType::QStringList, \l QMetaType::QString, or | - | ||||||||||||||||||||||||
2226 | \l QMetaType::QVariantList of a type that can be converted to QString; | - | ||||||||||||||||||||||||
2227 | otherwise returns an empty list. | - | ||||||||||||||||||||||||
2228 | - | |||||||||||||||||||||||||
2229 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2230 | */ | - | ||||||||||||||||||||||||
2231 | QStringList QVariant::toStringList() const | - | ||||||||||||||||||||||||
2232 | { | - | ||||||||||||||||||||||||
2233 | return qVariantToHelper<QStringList>(d, handlerManager); executed 1046 times by 54 tests: return qVariantToHelper<QStringList>(d, handlerManager); Executed by:
| 1046 | ||||||||||||||||||||||||
2234 | } | - | ||||||||||||||||||||||||
2235 | - | |||||||||||||||||||||||||
2236 | /*! | - | ||||||||||||||||||||||||
2237 | Returns the variant as a QString if the variant has userType() \l | - | ||||||||||||||||||||||||
2238 | QMetaType::QString, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
2239 | \l QMetaType::QChar, \l QMetaType::QDate, \l QMetaType::QDateTime, | - | ||||||||||||||||||||||||
2240 | \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
2241 | \l QMetaType::QStringList, \l QMetaType::QTime, \l QMetaType::UInt, or | - | ||||||||||||||||||||||||
2242 | \l QMetaType::ULongLong; otherwise returns an empty string. | - | ||||||||||||||||||||||||
2243 | - | |||||||||||||||||||||||||
2244 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2245 | */ | - | ||||||||||||||||||||||||
2246 | QString QVariant::toString() const | - | ||||||||||||||||||||||||
2247 | { | - | ||||||||||||||||||||||||
2248 | return qVariantToHelper<QString>(d, handlerManager); executed 539304 times by 257 tests: return qVariantToHelper<QString>(d, handlerManager); Executed by:
| 539304 | ||||||||||||||||||||||||
2249 | } | - | ||||||||||||||||||||||||
2250 | - | |||||||||||||||||||||||||
2251 | /*! | - | ||||||||||||||||||||||||
2252 | Returns the variant as a QMap<QString, QVariant> if the variant | - | ||||||||||||||||||||||||
2253 | has type() \l QMetaType::QVariantMap; otherwise returns an empty map. | - | ||||||||||||||||||||||||
2254 | - | |||||||||||||||||||||||||
2255 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2256 | */ | - | ||||||||||||||||||||||||
2257 | QVariantMap QVariant::toMap() const | - | ||||||||||||||||||||||||
2258 | { | - | ||||||||||||||||||||||||
2259 | return qVariantToHelper<QVariantMap>(d, handlerManager); executed 7 times by 3 tests: return qVariantToHelper<QVariantMap>(d, handlerManager); Executed by:
| 7 | ||||||||||||||||||||||||
2260 | } | - | ||||||||||||||||||||||||
2261 | - | |||||||||||||||||||||||||
2262 | /*! | - | ||||||||||||||||||||||||
2263 | Returns the variant as a QHash<QString, QVariant> if the variant | - | ||||||||||||||||||||||||
2264 | has type() \l QMetaType::QVariantHash; otherwise returns an empty map. | - | ||||||||||||||||||||||||
2265 | - | |||||||||||||||||||||||||
2266 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2267 | */ | - | ||||||||||||||||||||||||
2268 | QVariantHash QVariant::toHash() const | - | ||||||||||||||||||||||||
2269 | { | - | ||||||||||||||||||||||||
2270 | return qVariantToHelper<QVariantHash>(d, handlerManager); executed 2 times by 1 test: return qVariantToHelper<QVariantHash>(d, handlerManager); Executed by:
| 2 | ||||||||||||||||||||||||
2271 | } | - | ||||||||||||||||||||||||
2272 | - | |||||||||||||||||||||||||
2273 | /*! | - | ||||||||||||||||||||||||
2274 | \fn QDate QVariant::toDate() const | - | ||||||||||||||||||||||||
2275 | - | |||||||||||||||||||||||||
2276 | Returns the variant as a QDate if the variant has userType() | - | ||||||||||||||||||||||||
2277 | \l QMetaType::QDate, \l QMetaType::QDateTime, or \l QMetaType::QString; | - | ||||||||||||||||||||||||
2278 | otherwise returns an invalid date. | - | ||||||||||||||||||||||||
2279 | - | |||||||||||||||||||||||||
2280 | If the type() is \l QMetaType::QString, an invalid date will be returned if | - | ||||||||||||||||||||||||
2281 | the string cannot be parsed as a Qt::ISODate format date. | - | ||||||||||||||||||||||||
2282 | - | |||||||||||||||||||||||||
2283 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2284 | */ | - | ||||||||||||||||||||||||
2285 | QDate QVariant::toDate() const | - | ||||||||||||||||||||||||
2286 | { | - | ||||||||||||||||||||||||
2287 | return qVariantToHelper<QDate>(d, handlerManager); executed 12853 times by 6 tests: return qVariantToHelper<QDate>(d, handlerManager); Executed by:
| 12853 | ||||||||||||||||||||||||
2288 | } | - | ||||||||||||||||||||||||
2289 | - | |||||||||||||||||||||||||
2290 | /*! | - | ||||||||||||||||||||||||
2291 | \fn QTime QVariant::toTime() const | - | ||||||||||||||||||||||||
2292 | - | |||||||||||||||||||||||||
2293 | Returns the variant as a QTime if the variant has userType() | - | ||||||||||||||||||||||||
2294 | \l QMetaType::QTime, \l QMetaType::QDateTime, or \l QMetaType::QString; | - | ||||||||||||||||||||||||
2295 | otherwise returns an invalid time. | - | ||||||||||||||||||||||||
2296 | - | |||||||||||||||||||||||||
2297 | If the type() is \l QMetaType::QString, an invalid time will be returned if | - | ||||||||||||||||||||||||
2298 | the string cannot be parsed as a Qt::ISODate format time. | - | ||||||||||||||||||||||||
2299 | - | |||||||||||||||||||||||||
2300 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2301 | */ | - | ||||||||||||||||||||||||
2302 | QTime QVariant::toTime() const | - | ||||||||||||||||||||||||
2303 | { | - | ||||||||||||||||||||||||
2304 | return qVariantToHelper<QTime>(d, handlerManager); executed 11023 times by 7 tests: return qVariantToHelper<QTime>(d, handlerManager); Executed by:
| 11023 | ||||||||||||||||||||||||
2305 | } | - | ||||||||||||||||||||||||
2306 | - | |||||||||||||||||||||||||
2307 | /*! | - | ||||||||||||||||||||||||
2308 | \fn QDateTime QVariant::toDateTime() const | - | ||||||||||||||||||||||||
2309 | - | |||||||||||||||||||||||||
2310 | Returns the variant as a QDateTime if the variant has userType() | - | ||||||||||||||||||||||||
2311 | \l QMetaType::QDateTime, \l QMetaType::QDate, or \l QMetaType::QString; | - | ||||||||||||||||||||||||
2312 | otherwise returns an invalid date/time. | - | ||||||||||||||||||||||||
2313 | - | |||||||||||||||||||||||||
2314 | If the type() is \l QMetaType::QString, an invalid date/time will be | - | ||||||||||||||||||||||||
2315 | returned if the string cannot be parsed as a Qt::ISODate format date/time. | - | ||||||||||||||||||||||||
2316 | - | |||||||||||||||||||||||||
2317 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2318 | */ | - | ||||||||||||||||||||||||
2319 | QDateTime QVariant::toDateTime() const | - | ||||||||||||||||||||||||
2320 | { | - | ||||||||||||||||||||||||
2321 | return qVariantToHelper<QDateTime>(d, handlerManager); executed 127841 times by 19 tests: return qVariantToHelper<QDateTime>(d, handlerManager); Executed by:
| 127841 | ||||||||||||||||||||||||
2322 | } | - | ||||||||||||||||||||||||
2323 | - | |||||||||||||||||||||||||
2324 | /*! | - | ||||||||||||||||||||||||
2325 | \since 4.7 | - | ||||||||||||||||||||||||
2326 | \fn QEasingCurve QVariant::toEasingCurve() const | - | ||||||||||||||||||||||||
2327 | - | |||||||||||||||||||||||||
2328 | Returns the variant as a QEasingCurve if the variant has userType() | - | ||||||||||||||||||||||||
2329 | \l QMetaType::QEasingCurve; otherwise returns a default easing curve. | - | ||||||||||||||||||||||||
2330 | - | |||||||||||||||||||||||||
2331 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2332 | */ | - | ||||||||||||||||||||||||
2333 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
2334 | QEasingCurve QVariant::toEasingCurve() const | - | ||||||||||||||||||||||||
2335 | { | - | ||||||||||||||||||||||||
2336 | return qVariantToHelper<QEasingCurve>(d, handlerManager); executed 3 times by 2 tests: return qVariantToHelper<QEasingCurve>(d, handlerManager); Executed by:
| 3 | ||||||||||||||||||||||||
2337 | } | - | ||||||||||||||||||||||||
2338 | #endif | - | ||||||||||||||||||||||||
2339 | - | |||||||||||||||||||||||||
2340 | /*! | - | ||||||||||||||||||||||||
2341 | \fn QByteArray QVariant::toByteArray() const | - | ||||||||||||||||||||||||
2342 | - | |||||||||||||||||||||||||
2343 | Returns the variant as a QByteArray if the variant has userType() | - | ||||||||||||||||||||||||
2344 | \l QMetaType::QByteArray or \l QMetaType::QString (converted using | - | ||||||||||||||||||||||||
2345 | QString::fromUtf8()); otherwise returns an empty byte array. | - | ||||||||||||||||||||||||
2346 | - | |||||||||||||||||||||||||
2347 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2348 | */ | - | ||||||||||||||||||||||||
2349 | QByteArray QVariant::toByteArray() const | - | ||||||||||||||||||||||||
2350 | { | - | ||||||||||||||||||||||||
2351 | return qVariantToHelper<QByteArray>(d, handlerManager); executed 1647 times by 53 tests: return qVariantToHelper<QByteArray>(d, handlerManager); Executed by:
| 1647 | ||||||||||||||||||||||||
2352 | } | - | ||||||||||||||||||||||||
2353 | - | |||||||||||||||||||||||||
2354 | #ifndef QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
2355 | /*! | - | ||||||||||||||||||||||||
2356 | \fn QPoint QVariant::toPoint() const | - | ||||||||||||||||||||||||
2357 | - | |||||||||||||||||||||||||
2358 | Returns the variant as a QPoint if the variant has userType() | - | ||||||||||||||||||||||||
2359 | \l QMetaType::QPointF or \l QMetaType::QPointF; otherwise returns a null | - | ||||||||||||||||||||||||
2360 | QPoint. | - | ||||||||||||||||||||||||
2361 | - | |||||||||||||||||||||||||
2362 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2363 | */ | - | ||||||||||||||||||||||||
2364 | QPoint QVariant::toPoint() const | - | ||||||||||||||||||||||||
2365 | { | - | ||||||||||||||||||||||||
2366 | return qVariantToHelper<QPoint>(d, handlerManager); executed 34 times by 5 tests: return qVariantToHelper<QPoint>(d, handlerManager); Executed by:
| 34 | ||||||||||||||||||||||||
2367 | } | - | ||||||||||||||||||||||||
2368 | - | |||||||||||||||||||||||||
2369 | /*! | - | ||||||||||||||||||||||||
2370 | \fn QRect QVariant::toRect() const | - | ||||||||||||||||||||||||
2371 | - | |||||||||||||||||||||||||
2372 | Returns the variant as a QRect if the variant has userType() | - | ||||||||||||||||||||||||
2373 | \l QMetaType::QRect; otherwise returns an invalid QRect. | - | ||||||||||||||||||||||||
2374 | - | |||||||||||||||||||||||||
2375 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2376 | */ | - | ||||||||||||||||||||||||
2377 | QRect QVariant::toRect() const | - | ||||||||||||||||||||||||
2378 | { | - | ||||||||||||||||||||||||
2379 | return qVariantToHelper<QRect>(d, handlerManager); executed 129 times by 10 tests: return qVariantToHelper<QRect>(d, handlerManager); Executed by:
| 129 | ||||||||||||||||||||||||
2380 | } | - | ||||||||||||||||||||||||
2381 | - | |||||||||||||||||||||||||
2382 | /*! | - | ||||||||||||||||||||||||
2383 | \fn QSize QVariant::toSize() const | - | ||||||||||||||||||||||||
2384 | - | |||||||||||||||||||||||||
2385 | Returns the variant as a QSize if the variant has userType() | - | ||||||||||||||||||||||||
2386 | \l QMetaType::QSize; otherwise returns an invalid QSize. | - | ||||||||||||||||||||||||
2387 | - | |||||||||||||||||||||||||
2388 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2389 | */ | - | ||||||||||||||||||||||||
2390 | QSize QVariant::toSize() const | - | ||||||||||||||||||||||||
2391 | { | - | ||||||||||||||||||||||||
2392 | return qVariantToHelper<QSize>(d, handlerManager); executed 166 times by 10 tests: return qVariantToHelper<QSize>(d, handlerManager); Executed by:
| 166 | ||||||||||||||||||||||||
2393 | } | - | ||||||||||||||||||||||||
2394 | - | |||||||||||||||||||||||||
2395 | /*! | - | ||||||||||||||||||||||||
2396 | \fn QSizeF QVariant::toSizeF() const | - | ||||||||||||||||||||||||
2397 | - | |||||||||||||||||||||||||
2398 | Returns the variant as a QSizeF if the variant has userType() \l | - | ||||||||||||||||||||||||
2399 | QMetaType::QSizeF; otherwise returns an invalid QSizeF. | - | ||||||||||||||||||||||||
2400 | - | |||||||||||||||||||||||||
2401 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2402 | */ | - | ||||||||||||||||||||||||
2403 | QSizeF QVariant::toSizeF() const | - | ||||||||||||||||||||||||
2404 | { | - | ||||||||||||||||||||||||
2405 | return qVariantToHelper<QSizeF>(d, handlerManager); executed 92 times by 3 tests: return qVariantToHelper<QSizeF>(d, handlerManager); Executed by:
| 92 | ||||||||||||||||||||||||
2406 | } | - | ||||||||||||||||||||||||
2407 | - | |||||||||||||||||||||||||
2408 | /*! | - | ||||||||||||||||||||||||
2409 | \fn QRectF QVariant::toRectF() const | - | ||||||||||||||||||||||||
2410 | - | |||||||||||||||||||||||||
2411 | Returns the variant as a QRectF if the variant has userType() | - | ||||||||||||||||||||||||
2412 | \l QMetaType::QRect or \l QMetaType::QRectF; otherwise returns an invalid | - | ||||||||||||||||||||||||
2413 | QRectF. | - | ||||||||||||||||||||||||
2414 | - | |||||||||||||||||||||||||
2415 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2416 | */ | - | ||||||||||||||||||||||||
2417 | QRectF QVariant::toRectF() const | - | ||||||||||||||||||||||||
2418 | { | - | ||||||||||||||||||||||||
2419 | return qVariantToHelper<QRectF>(d, handlerManager); executed 22 times by 7 tests: return qVariantToHelper<QRectF>(d, handlerManager); Executed by:
| 22 | ||||||||||||||||||||||||
2420 | } | - | ||||||||||||||||||||||||
2421 | - | |||||||||||||||||||||||||
2422 | /*! | - | ||||||||||||||||||||||||
2423 | \fn QLineF QVariant::toLineF() const | - | ||||||||||||||||||||||||
2424 | - | |||||||||||||||||||||||||
2425 | Returns the variant as a QLineF if the variant has userType() | - | ||||||||||||||||||||||||
2426 | \l QMetaType::QLineF; otherwise returns an invalid QLineF. | - | ||||||||||||||||||||||||
2427 | - | |||||||||||||||||||||||||
2428 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2429 | */ | - | ||||||||||||||||||||||||
2430 | QLineF QVariant::toLineF() const | - | ||||||||||||||||||||||||
2431 | { | - | ||||||||||||||||||||||||
2432 | return qVariantToHelper<QLineF>(d, handlerManager); executed 9 times by 2 tests: return qVariantToHelper<QLineF>(d, handlerManager); Executed by:
| 9 | ||||||||||||||||||||||||
2433 | } | - | ||||||||||||||||||||||||
2434 | - | |||||||||||||||||||||||||
2435 | /*! | - | ||||||||||||||||||||||||
2436 | \fn QLine QVariant::toLine() const | - | ||||||||||||||||||||||||
2437 | - | |||||||||||||||||||||||||
2438 | Returns the variant as a QLine if the variant has userType() | - | ||||||||||||||||||||||||
2439 | \l QMetaType::QLine; otherwise returns an invalid QLine. | - | ||||||||||||||||||||||||
2440 | - | |||||||||||||||||||||||||
2441 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2442 | */ | - | ||||||||||||||||||||||||
2443 | QLine QVariant::toLine() const | - | ||||||||||||||||||||||||
2444 | { | - | ||||||||||||||||||||||||
2445 | return qVariantToHelper<QLine>(d, handlerManager); executed 9 times by 2 tests: return qVariantToHelper<QLine>(d, handlerManager); Executed by:
| 9 | ||||||||||||||||||||||||
2446 | } | - | ||||||||||||||||||||||||
2447 | - | |||||||||||||||||||||||||
2448 | /*! | - | ||||||||||||||||||||||||
2449 | \fn QPointF QVariant::toPointF() const | - | ||||||||||||||||||||||||
2450 | - | |||||||||||||||||||||||||
2451 | Returns the variant as a QPointF if the variant has userType() \l | - | ||||||||||||||||||||||||
2452 | QMetaType::QPoint or \l QMetaType::QPointF; otherwise returns a null | - | ||||||||||||||||||||||||
2453 | QPointF. | - | ||||||||||||||||||||||||
2454 | - | |||||||||||||||||||||||||
2455 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2456 | */ | - | ||||||||||||||||||||||||
2457 | QPointF QVariant::toPointF() const | - | ||||||||||||||||||||||||
2458 | { | - | ||||||||||||||||||||||||
2459 | return qVariantToHelper<QPointF>(d, handlerManager); executed 1641 times by 16 tests: return qVariantToHelper<QPointF>(d, handlerManager); Executed by:
| 1641 | ||||||||||||||||||||||||
2460 | } | - | ||||||||||||||||||||||||
2461 | - | |||||||||||||||||||||||||
2462 | #endif // QT_NO_GEOM_VARIANT | - | ||||||||||||||||||||||||
2463 | - | |||||||||||||||||||||||||
2464 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
2465 | /*! | - | ||||||||||||||||||||||||
2466 | \fn QUrl QVariant::toUrl() const | - | ||||||||||||||||||||||||
2467 | - | |||||||||||||||||||||||||
2468 | Returns the variant as a QUrl if the variant has userType() | - | ||||||||||||||||||||||||
2469 | \l QMetaType::QUrl; otherwise returns an invalid QUrl. | - | ||||||||||||||||||||||||
2470 | - | |||||||||||||||||||||||||
2471 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2472 | */ | - | ||||||||||||||||||||||||
2473 | QUrl QVariant::toUrl() const | - | ||||||||||||||||||||||||
2474 | { | - | ||||||||||||||||||||||||
2475 | return qVariantToHelper<QUrl>(d, handlerManager); executed 7216 times by 10 tests: return qVariantToHelper<QUrl>(d, handlerManager); Executed by:
| 7216 | ||||||||||||||||||||||||
2476 | } | - | ||||||||||||||||||||||||
2477 | #endif | - | ||||||||||||||||||||||||
2478 | - | |||||||||||||||||||||||||
2479 | /*! | - | ||||||||||||||||||||||||
2480 | \fn QLocale QVariant::toLocale() const | - | ||||||||||||||||||||||||
2481 | - | |||||||||||||||||||||||||
2482 | Returns the variant as a QLocale if the variant has userType() | - | ||||||||||||||||||||||||
2483 | \l QMetaType::QLocale; otherwise returns an invalid QLocale. | - | ||||||||||||||||||||||||
2484 | - | |||||||||||||||||||||||||
2485 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2486 | */ | - | ||||||||||||||||||||||||
2487 | QLocale QVariant::toLocale() const | - | ||||||||||||||||||||||||
2488 | { | - | ||||||||||||||||||||||||
2489 | return qVariantToHelper<QLocale>(d, handlerManager); executed 3 times by 1 test: return qVariantToHelper<QLocale>(d, handlerManager); Executed by:
| 3 | ||||||||||||||||||||||||
2490 | } | - | ||||||||||||||||||||||||
2491 | - | |||||||||||||||||||||||||
2492 | /*! | - | ||||||||||||||||||||||||
2493 | \fn QRegExp QVariant::toRegExp() const | - | ||||||||||||||||||||||||
2494 | \since 4.1 | - | ||||||||||||||||||||||||
2495 | - | |||||||||||||||||||||||||
2496 | Returns the variant as a QRegExp if the variant has userType() | - | ||||||||||||||||||||||||
2497 | \l QMetaType::QRegExp; otherwise returns an empty QRegExp. | - | ||||||||||||||||||||||||
2498 | - | |||||||||||||||||||||||||
2499 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2500 | */ | - | ||||||||||||||||||||||||
2501 | #ifndef QT_NO_REGEXP | - | ||||||||||||||||||||||||
2502 | QRegExp QVariant::toRegExp() const | - | ||||||||||||||||||||||||
2503 | { | - | ||||||||||||||||||||||||
2504 | return qVariantToHelper<QRegExp>(d, handlerManager); executed 45 times by 2 tests: return qVariantToHelper<QRegExp>(d, handlerManager); Executed by:
| 45 | ||||||||||||||||||||||||
2505 | } | - | ||||||||||||||||||||||||
2506 | #endif | - | ||||||||||||||||||||||||
2507 | - | |||||||||||||||||||||||||
2508 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
2509 | /*! | - | ||||||||||||||||||||||||
2510 | \fn QRegularExpression QVariant::toRegularExpression() const | - | ||||||||||||||||||||||||
2511 | \since 5.0 | - | ||||||||||||||||||||||||
2512 | - | |||||||||||||||||||||||||
2513 | Returns the variant as a QRegularExpression if the variant has userType() \l | - | ||||||||||||||||||||||||
2514 | QRegularExpression; otherwise returns an empty QRegularExpression. | - | ||||||||||||||||||||||||
2515 | - | |||||||||||||||||||||||||
2516 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2517 | */ | - | ||||||||||||||||||||||||
2518 | #ifndef QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
2519 | QRegularExpression QVariant::toRegularExpression() const | - | ||||||||||||||||||||||||
2520 | { | - | ||||||||||||||||||||||||
2521 | return qVariantToHelper<QRegularExpression>(d, handlerManager); executed 103 times by 4 tests: return qVariantToHelper<QRegularExpression>(d, handlerManager); Executed by:
| 103 | ||||||||||||||||||||||||
2522 | } | - | ||||||||||||||||||||||||
2523 | #endif // QT_NO_REGULAREXPRESSION | - | ||||||||||||||||||||||||
2524 | - | |||||||||||||||||||||||||
2525 | /*! | - | ||||||||||||||||||||||||
2526 | \since 5.0 | - | ||||||||||||||||||||||||
2527 | - | |||||||||||||||||||||||||
2528 | Returns the variant as a QUuid if the variant has type() | - | ||||||||||||||||||||||||
2529 | \l QMetaType::QUuid or \l QMetaType::QString; | - | ||||||||||||||||||||||||
2530 | otherwise returns a default-constructed QUuid. | - | ||||||||||||||||||||||||
2531 | - | |||||||||||||||||||||||||
2532 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2533 | */ | - | ||||||||||||||||||||||||
2534 | QUuid QVariant::toUuid() const | - | ||||||||||||||||||||||||
2535 | { | - | ||||||||||||||||||||||||
2536 | return qVariantToHelper<QUuid>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QUuid>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2537 | } | - | ||||||||||||||||||||||||
2538 | - | |||||||||||||||||||||||||
2539 | /*! | - | ||||||||||||||||||||||||
2540 | \since 5.0 | - | ||||||||||||||||||||||||
2541 | - | |||||||||||||||||||||||||
2542 | Returns the variant as a QModelIndex if the variant has userType() \l | - | ||||||||||||||||||||||||
2543 | QModelIndex; otherwise returns a default constructed QModelIndex. | - | ||||||||||||||||||||||||
2544 | - | |||||||||||||||||||||||||
2545 | \sa canConvert(), convert(), toPersistentModelIndex() | - | ||||||||||||||||||||||||
2546 | */ | - | ||||||||||||||||||||||||
2547 | QModelIndex QVariant::toModelIndex() const | - | ||||||||||||||||||||||||
2548 | { | - | ||||||||||||||||||||||||
2549 | return qVariantToHelper<QModelIndex>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QModelIndex>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2550 | } | - | ||||||||||||||||||||||||
2551 | - | |||||||||||||||||||||||||
2552 | /*! | - | ||||||||||||||||||||||||
2553 | \since 5.5 | - | ||||||||||||||||||||||||
2554 | - | |||||||||||||||||||||||||
2555 | Returns the variant as a QPersistentModelIndex if the variant has userType() \l | - | ||||||||||||||||||||||||
2556 | QPersistentModelIndex; otherwise returns a default constructed QPersistentModelIndex. | - | ||||||||||||||||||||||||
2557 | - | |||||||||||||||||||||||||
2558 | \sa canConvert(), convert(), toModelIndex() | - | ||||||||||||||||||||||||
2559 | */ | - | ||||||||||||||||||||||||
2560 | QPersistentModelIndex QVariant::toPersistentModelIndex() const | - | ||||||||||||||||||||||||
2561 | { | - | ||||||||||||||||||||||||
2562 | return qVariantToHelper<QPersistentModelIndex>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QPersistentModelIndex>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2563 | } | - | ||||||||||||||||||||||||
2564 | - | |||||||||||||||||||||||||
2565 | /*! | - | ||||||||||||||||||||||||
2566 | \since 5.0 | - | ||||||||||||||||||||||||
2567 | - | |||||||||||||||||||||||||
2568 | Returns the variant as a QJsonValue if the variant has userType() \l | - | ||||||||||||||||||||||||
2569 | QJsonValue; otherwise returns a default constructed QJsonValue. | - | ||||||||||||||||||||||||
2570 | - | |||||||||||||||||||||||||
2571 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2572 | */ | - | ||||||||||||||||||||||||
2573 | QJsonValue QVariant::toJsonValue() const | - | ||||||||||||||||||||||||
2574 | { | - | ||||||||||||||||||||||||
2575 | return qVariantToHelper<QJsonValue>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonValue>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2576 | } | - | ||||||||||||||||||||||||
2577 | - | |||||||||||||||||||||||||
2578 | /*! | - | ||||||||||||||||||||||||
2579 | \since 5.0 | - | ||||||||||||||||||||||||
2580 | - | |||||||||||||||||||||||||
2581 | Returns the variant as a QJsonObject if the variant has userType() \l | - | ||||||||||||||||||||||||
2582 | QJsonObject; otherwise returns a default constructed QJsonObject. | - | ||||||||||||||||||||||||
2583 | - | |||||||||||||||||||||||||
2584 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2585 | */ | - | ||||||||||||||||||||||||
2586 | QJsonObject QVariant::toJsonObject() const | - | ||||||||||||||||||||||||
2587 | { | - | ||||||||||||||||||||||||
2588 | return qVariantToHelper<QJsonObject>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonObject>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2589 | } | - | ||||||||||||||||||||||||
2590 | - | |||||||||||||||||||||||||
2591 | /*! | - | ||||||||||||||||||||||||
2592 | \since 5.0 | - | ||||||||||||||||||||||||
2593 | - | |||||||||||||||||||||||||
2594 | Returns the variant as a QJsonArray if the variant has userType() \l | - | ||||||||||||||||||||||||
2595 | QJsonArray; otherwise returns a default constructed QJsonArray. | - | ||||||||||||||||||||||||
2596 | - | |||||||||||||||||||||||||
2597 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2598 | */ | - | ||||||||||||||||||||||||
2599 | QJsonArray QVariant::toJsonArray() const | - | ||||||||||||||||||||||||
2600 | { | - | ||||||||||||||||||||||||
2601 | return qVariantToHelper<QJsonArray>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonArray>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2602 | } | - | ||||||||||||||||||||||||
2603 | - | |||||||||||||||||||||||||
2604 | /*! | - | ||||||||||||||||||||||||
2605 | \since 5.0 | - | ||||||||||||||||||||||||
2606 | - | |||||||||||||||||||||||||
2607 | Returns the variant as a QJsonDocument if the variant has userType() \l | - | ||||||||||||||||||||||||
2608 | QJsonDocument; otherwise returns a default constructed QJsonDocument. | - | ||||||||||||||||||||||||
2609 | - | |||||||||||||||||||||||||
2610 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2611 | */ | - | ||||||||||||||||||||||||
2612 | QJsonDocument QVariant::toJsonDocument() const | - | ||||||||||||||||||||||||
2613 | { | - | ||||||||||||||||||||||||
2614 | return qVariantToHelper<QJsonDocument>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QJsonDocument>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2615 | } | - | ||||||||||||||||||||||||
2616 | #endif | - | ||||||||||||||||||||||||
2617 | - | |||||||||||||||||||||||||
2618 | /*! | - | ||||||||||||||||||||||||
2619 | \fn QChar QVariant::toChar() const | - | ||||||||||||||||||||||||
2620 | - | |||||||||||||||||||||||||
2621 | Returns the variant as a QChar if the variant has userType() | - | ||||||||||||||||||||||||
2622 | \l QMetaType::QChar, \l QMetaType::Int, or \l QMetaType::UInt; otherwise | - | ||||||||||||||||||||||||
2623 | returns an invalid QChar. | - | ||||||||||||||||||||||||
2624 | - | |||||||||||||||||||||||||
2625 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2626 | */ | - | ||||||||||||||||||||||||
2627 | QChar QVariant::toChar() const | - | ||||||||||||||||||||||||
2628 | { | - | ||||||||||||||||||||||||
2629 | return qVariantToHelper<QChar>(d, handlerManager); executed 1860 times by 56 tests: return qVariantToHelper<QChar>(d, handlerManager); Executed by:
| 1860 | ||||||||||||||||||||||||
2630 | } | - | ||||||||||||||||||||||||
2631 | - | |||||||||||||||||||||||||
2632 | /*! | - | ||||||||||||||||||||||||
2633 | Returns the variant as a QBitArray if the variant has userType() | - | ||||||||||||||||||||||||
2634 | \l QMetaType::QBitArray; otherwise returns an empty bit array. | - | ||||||||||||||||||||||||
2635 | - | |||||||||||||||||||||||||
2636 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2637 | */ | - | ||||||||||||||||||||||||
2638 | QBitArray QVariant::toBitArray() const | - | ||||||||||||||||||||||||
2639 | { | - | ||||||||||||||||||||||||
2640 | return qVariantToHelper<QBitArray>(d, handlerManager); executed 1 time by 1 test: return qVariantToHelper<QBitArray>(d, handlerManager); Executed by:
| 1 | ||||||||||||||||||||||||
2641 | } | - | ||||||||||||||||||||||||
2642 | - | |||||||||||||||||||||||||
2643 | template <typename T> | - | ||||||||||||||||||||||||
2644 | inline T qNumVariantToHelper(const QVariant::Private &d, | - | ||||||||||||||||||||||||
2645 | const HandlersManager &handlerManager, bool *ok, const T& val) | - | ||||||||||||||||||||||||
2646 | { | - | ||||||||||||||||||||||||
2647 | const uint t = qMetaTypeId<T>(); | - | ||||||||||||||||||||||||
2648 | if (ok)
| 6171-790540 | ||||||||||||||||||||||||
2649 | *ok = true; executed 6171 times by 32 tests: *ok = true; Executed by:
| 6171 | ||||||||||||||||||||||||
2650 | - | |||||||||||||||||||||||||
2651 | if (d.type == t)
| 27414-769297 | ||||||||||||||||||||||||
2652 | return val; executed 769297 times by 215 tests: return val; Executed by:
| 769297 | ||||||||||||||||||||||||
2653 | - | |||||||||||||||||||||||||
2654 | T ret = 0; | - | ||||||||||||||||||||||||
2655 | if ((d.type >= QMetaType::User || t >= QMetaType::User)
| 0-27284 | ||||||||||||||||||||||||
2656 | && QMetaType::convert(constData(d), d.type, &ret, t))
| 8-122 | ||||||||||||||||||||||||
2657 | return ret; executed 8 times by 2 tests: return ret; Executed by:
| 8 | ||||||||||||||||||||||||
2658 | - | |||||||||||||||||||||||||
2659 | if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok)
| 20-26402 | ||||||||||||||||||||||||
2660 | *ok = false; executed 20 times by 2 tests: *ok = false; Executed by:
| 20 | ||||||||||||||||||||||||
2661 | return ret; executed 27406 times by 86 tests: return ret; Executed by:
| 27406 | ||||||||||||||||||||||||
2662 | } | - | ||||||||||||||||||||||||
2663 | - | |||||||||||||||||||||||||
2664 | /*! | - | ||||||||||||||||||||||||
2665 | Returns the variant as an int if the variant has userType() | - | ||||||||||||||||||||||||
2666 | \l QMetaType::Int, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
2667 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
2668 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
2669 | otherwise returns 0. | - | ||||||||||||||||||||||||
2670 | - | |||||||||||||||||||||||||
2671 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2672 | converted to an int; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2673 | - | |||||||||||||||||||||||||
2674 | \b{Warning:} If the value is convertible to a \l QMetaType::LongLong but is | - | ||||||||||||||||||||||||
2675 | too large to be represented in an int, the resulting arithmetic overflow | - | ||||||||||||||||||||||||
2676 | will not be reflected in \a ok. A simple workaround is to use | - | ||||||||||||||||||||||||
2677 | QString::toInt(). | - | ||||||||||||||||||||||||
2678 | - | |||||||||||||||||||||||||
2679 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2680 | */ | - | ||||||||||||||||||||||||
2681 | int QVariant::toInt(bool *ok) const | - | ||||||||||||||||||||||||
2682 | { | - | ||||||||||||||||||||||||
2683 | return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i); executed 726428 times by 207 tests: return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i); Executed by:
| 726428 | ||||||||||||||||||||||||
2684 | } | - | ||||||||||||||||||||||||
2685 | - | |||||||||||||||||||||||||
2686 | /*! | - | ||||||||||||||||||||||||
2687 | Returns the variant as an unsigned int if the variant has userType() | - | ||||||||||||||||||||||||
2688 | \l QMetaType::UInt, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
2689 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
2690 | \l QMetaType::LongLong, \l QMetaType::QString, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
2691 | otherwise returns 0. | - | ||||||||||||||||||||||||
2692 | - | |||||||||||||||||||||||||
2693 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2694 | converted to an unsigned int; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2695 | - | |||||||||||||||||||||||||
2696 | \b{Warning:} If the value is convertible to a \l QMetaType::ULongLong but is | - | ||||||||||||||||||||||||
2697 | too large to be represented in an unsigned int, the resulting arithmetic | - | ||||||||||||||||||||||||
2698 | overflow will not be reflected in \a ok. A simple workaround is to use | - | ||||||||||||||||||||||||
2699 | QString::toUInt(). | - | ||||||||||||||||||||||||
2700 | - | |||||||||||||||||||||||||
2701 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2702 | */ | - | ||||||||||||||||||||||||
2703 | uint QVariant::toUInt(bool *ok) const | - | ||||||||||||||||||||||||
2704 | { | - | ||||||||||||||||||||||||
2705 | return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u); executed 1493 times by 56 tests: return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u); Executed by:
| 1493 | ||||||||||||||||||||||||
2706 | } | - | ||||||||||||||||||||||||
2707 | - | |||||||||||||||||||||||||
2708 | /*! | - | ||||||||||||||||||||||||
2709 | Returns the variant as a long long int if the variant has userType() | - | ||||||||||||||||||||||||
2710 | \l QMetaType::LongLong, \l QMetaType::Bool, \l QMetaType::QByteArray, | - | ||||||||||||||||||||||||
2711 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
2712 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
2713 | otherwise returns 0. | - | ||||||||||||||||||||||||
2714 | - | |||||||||||||||||||||||||
2715 | If \a ok is non-null: \c{*}\c{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2716 | converted to an int; otherwise \c{*}\c{ok} is set to false. | - | ||||||||||||||||||||||||
2717 | - | |||||||||||||||||||||||||
2718 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2719 | */ | - | ||||||||||||||||||||||||
2720 | qlonglong QVariant::toLongLong(bool *ok) const | - | ||||||||||||||||||||||||
2721 | { | - | ||||||||||||||||||||||||
2722 | return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll); executed 11710 times by 23 tests: return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll); Executed by:
| 11710 | ||||||||||||||||||||||||
2723 | } | - | ||||||||||||||||||||||||
2724 | - | |||||||||||||||||||||||||
2725 | /*! | - | ||||||||||||||||||||||||
2726 | Returns the variant as an unsigned long long int if the | - | ||||||||||||||||||||||||
2727 | variant has type() \l QMetaType::ULongLong, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2728 | \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, | - | ||||||||||||||||||||||||
2729 | \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, or | - | ||||||||||||||||||||||||
2730 | \l QMetaType::UInt; otherwise returns 0. | - | ||||||||||||||||||||||||
2731 | - | |||||||||||||||||||||||||
2732 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2733 | converted to an int; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2734 | - | |||||||||||||||||||||||||
2735 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2736 | */ | - | ||||||||||||||||||||||||
2737 | qulonglong QVariant::toULongLong(bool *ok) const | - | ||||||||||||||||||||||||
2738 | { | - | ||||||||||||||||||||||||
2739 | return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull); executed 104 times by 5 tests: return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull); Executed by:
| 104 | ||||||||||||||||||||||||
2740 | } | - | ||||||||||||||||||||||||
2741 | - | |||||||||||||||||||||||||
2742 | /*! | - | ||||||||||||||||||||||||
2743 | Returns the variant as a bool if the variant has userType() Bool. | - | ||||||||||||||||||||||||
2744 | - | |||||||||||||||||||||||||
2745 | Returns \c true if the variant has userType() \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2746 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
2747 | \l QMetaType::LongLong, \l QMetaType::UInt, or \l QMetaType::ULongLong and | - | ||||||||||||||||||||||||
2748 | the value is non-zero, or if the variant has type \l QMetaType::QString or | - | ||||||||||||||||||||||||
2749 | \l QMetaType::QByteArray and its lower-case content is not one of the | - | ||||||||||||||||||||||||
2750 | following: empty, "0" or "false"; otherwise returns \c false. | - | ||||||||||||||||||||||||
2751 | - | |||||||||||||||||||||||||
2752 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2753 | */ | - | ||||||||||||||||||||||||
2754 | bool QVariant::toBool() const | - | ||||||||||||||||||||||||
2755 | { | - | ||||||||||||||||||||||||
2756 | if (d.type == Bool)
| 41407-80407 | ||||||||||||||||||||||||
2757 | return d.data.b; executed 80407 times by 161 tests: return d.data.b; Executed by:
| 80407 | ||||||||||||||||||||||||
2758 | - | |||||||||||||||||||||||||
2759 | bool res = false; | - | ||||||||||||||||||||||||
2760 | handlerManager[d.type]->convert(&d, Bool, &res, 0); | - | ||||||||||||||||||||||||
2761 | - | |||||||||||||||||||||||||
2762 | return res; executed 41407 times by 115 tests: return res; Executed by:
| 41407 | ||||||||||||||||||||||||
2763 | } | - | ||||||||||||||||||||||||
2764 | - | |||||||||||||||||||||||||
2765 | /*! | - | ||||||||||||||||||||||||
2766 | Returns the variant as a double if the variant has userType() | - | ||||||||||||||||||||||||
2767 | \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2768 | \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
2769 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
2770 | otherwise returns 0.0. | - | ||||||||||||||||||||||||
2771 | - | |||||||||||||||||||||||||
2772 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2773 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2774 | - | |||||||||||||||||||||||||
2775 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2776 | */ | - | ||||||||||||||||||||||||
2777 | double QVariant::toDouble(bool *ok) const | - | ||||||||||||||||||||||||
2778 | { | - | ||||||||||||||||||||||||
2779 | return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d); executed 40261 times by 58 tests: return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d); Executed by:
| 40261 | ||||||||||||||||||||||||
2780 | } | - | ||||||||||||||||||||||||
2781 | - | |||||||||||||||||||||||||
2782 | /*! | - | ||||||||||||||||||||||||
2783 | Returns the variant as a float if the variant has userType() | - | ||||||||||||||||||||||||
2784 | \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2785 | \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
2786 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
2787 | otherwise returns 0.0. | - | ||||||||||||||||||||||||
2788 | - | |||||||||||||||||||||||||
2789 | \since 4.6 | - | ||||||||||||||||||||||||
2790 | - | |||||||||||||||||||||||||
2791 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2792 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2793 | - | |||||||||||||||||||||||||
2794 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2795 | */ | - | ||||||||||||||||||||||||
2796 | float QVariant::toFloat(bool *ok) const | - | ||||||||||||||||||||||||
2797 | { | - | ||||||||||||||||||||||||
2798 | return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f); executed 154 times by 16 tests: return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f); Executed by:
| 154 | ||||||||||||||||||||||||
2799 | } | - | ||||||||||||||||||||||||
2800 | - | |||||||||||||||||||||||||
2801 | /*! | - | ||||||||||||||||||||||||
2802 | Returns the variant as a qreal if the variant has userType() | - | ||||||||||||||||||||||||
2803 | \l QMetaType::Double, \l QMetaType::Float, \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2804 | \l QMetaType::QByteArray, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
2805 | \l QMetaType::QString, \l QMetaType::UInt, or \l QMetaType::ULongLong; | - | ||||||||||||||||||||||||
2806 | otherwise returns 0.0. | - | ||||||||||||||||||||||||
2807 | - | |||||||||||||||||||||||||
2808 | \since 4.6 | - | ||||||||||||||||||||||||
2809 | - | |||||||||||||||||||||||||
2810 | If \a ok is non-null: \c{*}\a{ok} is set to true if the value could be | - | ||||||||||||||||||||||||
2811 | converted to a double; otherwise \c{*}\a{ok} is set to false. | - | ||||||||||||||||||||||||
2812 | - | |||||||||||||||||||||||||
2813 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2814 | */ | - | ||||||||||||||||||||||||
2815 | qreal QVariant::toReal(bool *ok) const | - | ||||||||||||||||||||||||
2816 | { | - | ||||||||||||||||||||||||
2817 | return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real); executed 16561 times by 29 tests: return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real); Executed by:
| 16561 | ||||||||||||||||||||||||
2818 | } | - | ||||||||||||||||||||||||
2819 | - | |||||||||||||||||||||||||
2820 | /*! | - | ||||||||||||||||||||||||
2821 | Returns the variant as a QVariantList if the variant has userType() | - | ||||||||||||||||||||||||
2822 | \l QMetaType::QVariantList or \l QMetaType::QStringList; otherwise returns | - | ||||||||||||||||||||||||
2823 | an empty list. | - | ||||||||||||||||||||||||
2824 | - | |||||||||||||||||||||||||
2825 | \sa canConvert(), convert() | - | ||||||||||||||||||||||||
2826 | */ | - | ||||||||||||||||||||||||
2827 | QVariantList QVariant::toList() const | - | ||||||||||||||||||||||||
2828 | { | - | ||||||||||||||||||||||||
2829 | return qVariantToHelper<QVariantList>(d, handlerManager); executed 695 times by 17 tests: return qVariantToHelper<QVariantList>(d, handlerManager); Executed by:
| 695 | ||||||||||||||||||||||||
2830 | } | - | ||||||||||||||||||||||||
2831 | - | |||||||||||||||||||||||||
2832 | - | |||||||||||||||||||||||||
2833 | static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = | - | ||||||||||||||||||||||||
2834 | { | - | ||||||||||||||||||||||||
2835 | /*Invalid*/ 0, | - | ||||||||||||||||||||||||
2836 | - | |||||||||||||||||||||||||
2837 | /*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt | - | ||||||||||||||||||||||||
2838 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray | - | ||||||||||||||||||||||||
2839 | | 1 << QVariant::String | 1 << QVariant::Char, | - | ||||||||||||||||||||||||
2840 | - | |||||||||||||||||||||||||
2841 | /*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
2842 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
2843 | | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, | - | ||||||||||||||||||||||||
2844 | - | |||||||||||||||||||||||||
2845 | /*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
2846 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
2847 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
2848 | - | |||||||||||||||||||||||||
2849 | /*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
2850 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
2851 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
2852 | - | |||||||||||||||||||||||||
2853 | /*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||||||||||||||
2854 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||||||||||||||
2855 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
2856 | - | |||||||||||||||||||||||||
2857 | /*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong | - | ||||||||||||||||||||||||
2858 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||||||||||||||
2859 | | 1 << QVariant::ByteArray, | - | ||||||||||||||||||||||||
2860 | - | |||||||||||||||||||||||||
2861 | /*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||||||||||||||
2862 | | 1 << QVariant::ULongLong, | - | ||||||||||||||||||||||||
2863 | - | |||||||||||||||||||||||||
2864 | /*QMap*/ 0, | - | ||||||||||||||||||||||||
2865 | - | |||||||||||||||||||||||||
2866 | /*QList*/ 1 << QVariant::StringList, | - | ||||||||||||||||||||||||
2867 | - | |||||||||||||||||||||||||
2868 | /*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int | - | ||||||||||||||||||||||||
2869 | | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double | - | ||||||||||||||||||||||||
2870 | | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime | - | ||||||||||||||||||||||||
2871 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char | - | ||||||||||||||||||||||||
2872 | | 1 << QVariant::Url | 1 << QVariant::Uuid, | - | ||||||||||||||||||||||||
2873 | - | |||||||||||||||||||||||||
2874 | /*QStringList*/ 1 << QVariant::List | 1 << QVariant::String, | - | ||||||||||||||||||||||||
2875 | - | |||||||||||||||||||||||||
2876 | /*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool | - | ||||||||||||||||||||||||
2877 | | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, | - | ||||||||||||||||||||||||
2878 | - | |||||||||||||||||||||||||
2879 | /*QBitArray*/ 0, | - | ||||||||||||||||||||||||
2880 | - | |||||||||||||||||||||||||
2881 | /*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime, | - | ||||||||||||||||||||||||
2882 | - | |||||||||||||||||||||||||
2883 | /*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime, | - | ||||||||||||||||||||||||
2884 | - | |||||||||||||||||||||||||
2885 | /*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date, | - | ||||||||||||||||||||||||
2886 | - | |||||||||||||||||||||||||
2887 | /*QUrl*/ 1 << QVariant::String, | - | ||||||||||||||||||||||||
2888 | - | |||||||||||||||||||||||||
2889 | /*QLocale*/ 0, | - | ||||||||||||||||||||||||
2890 | - | |||||||||||||||||||||||||
2891 | /*QRect*/ 1 << QVariant::RectF, | - | ||||||||||||||||||||||||
2892 | - | |||||||||||||||||||||||||
2893 | /*QRectF*/ 1 << QVariant::Rect, | - | ||||||||||||||||||||||||
2894 | - | |||||||||||||||||||||||||
2895 | /*QSize*/ 1 << QVariant::SizeF, | - | ||||||||||||||||||||||||
2896 | - | |||||||||||||||||||||||||
2897 | /*QSizeF*/ 1 << QVariant::Size, | - | ||||||||||||||||||||||||
2898 | - | |||||||||||||||||||||||||
2899 | /*QLine*/ 1 << QVariant::LineF, | - | ||||||||||||||||||||||||
2900 | - | |||||||||||||||||||||||||
2901 | /*QLineF*/ 1 << QVariant::Line, | - | ||||||||||||||||||||||||
2902 | - | |||||||||||||||||||||||||
2903 | /*QPoint*/ 1 << QVariant::PointF, | - | ||||||||||||||||||||||||
2904 | - | |||||||||||||||||||||||||
2905 | /*QPointF*/ 1 << QVariant::Point, | - | ||||||||||||||||||||||||
2906 | - | |||||||||||||||||||||||||
2907 | /*QRegExp*/ 0, | - | ||||||||||||||||||||||||
2908 | - | |||||||||||||||||||||||||
2909 | /*QHash*/ 0, | - | ||||||||||||||||||||||||
2910 | - | |||||||||||||||||||||||||
2911 | /*QEasingCurve*/ 0, | - | ||||||||||||||||||||||||
2912 | - | |||||||||||||||||||||||||
2913 | /*QUuid*/ 1 << QVariant::String | - | ||||||||||||||||||||||||
2914 | }; | - | ||||||||||||||||||||||||
2915 | static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); | - | ||||||||||||||||||||||||
2916 | - | |||||||||||||||||||||||||
2917 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
2918 | /*! | - | ||||||||||||||||||||||||
2919 | Returns \c true if from inherits to. | - | ||||||||||||||||||||||||
2920 | */ | - | ||||||||||||||||||||||||
2921 | static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to) | - | ||||||||||||||||||||||||
2922 | { | - | ||||||||||||||||||||||||
2923 | if (from && to == &QObject::staticMetaObject)
| 0-19 | ||||||||||||||||||||||||
2924 | return true; executed 12 times by 2 tests: return true; Executed by:
| 12 | ||||||||||||||||||||||||
2925 | - | |||||||||||||||||||||||||
2926 | while (from) {
| 0-11 | ||||||||||||||||||||||||
2927 | if (from == to)
| 4-7 | ||||||||||||||||||||||||
2928 | return true; executed 7 times by 2 tests: return true; Executed by:
| 7 | ||||||||||||||||||||||||
2929 | from = from->superClass(); | - | ||||||||||||||||||||||||
2930 | } executed 4 times by 2 tests: end of block Executed by:
| 4 | ||||||||||||||||||||||||
2931 | - | |||||||||||||||||||||||||
2932 | return false; never executed: return false; | 0 | ||||||||||||||||||||||||
2933 | } | - | ||||||||||||||||||||||||
2934 | #endif | - | ||||||||||||||||||||||||
2935 | - | |||||||||||||||||||||||||
2936 | static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) | - | ||||||||||||||||||||||||
2937 | { | - | ||||||||||||||||||||||||
2938 | #ifndef QT_BOOTSTRAPPED | - | ||||||||||||||||||||||||
2939 | QMetaType toType(toId); | - | ||||||||||||||||||||||||
2940 | if ((QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) { | - | ||||||||||||||||||||||||
2941 | if (!fromObject)
| 4-19 | ||||||||||||||||||||||||
2942 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
2943 | return canConvertMetaObject(fromObject->metaObject(), toType.metaObject()); executed 19 times by 3 tests: return canConvertMetaObject(fromObject->metaObject(), toType.metaObject()); Executed by:
| 19 | ||||||||||||||||||||||||
2944 | } | - | ||||||||||||||||||||||||
2945 | #else | - | ||||||||||||||||||||||||
2946 | Q_UNUSED(fromId); | - | ||||||||||||||||||||||||
2947 | Q_UNUSED(toId); | - | ||||||||||||||||||||||||
2948 | Q_UNUSED(fromObject); | - | ||||||||||||||||||||||||
2949 | #endif | - | ||||||||||||||||||||||||
2950 | return false; executed 89 times by 5 tests: return false; Executed by:
| 89 | ||||||||||||||||||||||||
2951 | } | - | ||||||||||||||||||||||||
2952 | - | |||||||||||||||||||||||||
2953 | - | |||||||||||||||||||||||||
2954 | /*! | - | ||||||||||||||||||||||||
2955 | Returns \c true if the variant's type can be cast to the requested | - | ||||||||||||||||||||||||
2956 | type, \a targetTypeId. Such casting is done automatically when calling the | - | ||||||||||||||||||||||||
2957 | toInt(), toBool(), ... methods. | - | ||||||||||||||||||||||||
2958 | - | |||||||||||||||||||||||||
2959 | The following casts are done automatically: | - | ||||||||||||||||||||||||
2960 | - | |||||||||||||||||||||||||
2961 | \table | - | ||||||||||||||||||||||||
2962 | \header \li Type \li Automatically Cast To | - | ||||||||||||||||||||||||
2963 | \row \li \l QMetaType::Bool \li \l QMetaType::QChar, \l QMetaType::Double, | - | ||||||||||||||||||||||||
2964 | \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, | - | ||||||||||||||||||||||||
2965 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
2966 | \row \li \l QMetaType::QByteArray \li \l QMetaType::Double, | - | ||||||||||||||||||||||||
2967 | \l QMetaType::Int, \l QMetaType::LongLong, \l QMetaType::QString, | - | ||||||||||||||||||||||||
2968 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
2969 | \row \li \l QMetaType::QChar \li \l QMetaType::Bool, \l QMetaType::Int, | - | ||||||||||||||||||||||||
2970 | \l QMetaType::UInt, \l QMetaType::LongLong, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
2971 | \row \li \l QMetaType::QColor \li \l QMetaType::QString | - | ||||||||||||||||||||||||
2972 | \row \li \l QMetaType::QDate \li \l QMetaType::QDateTime, | - | ||||||||||||||||||||||||
2973 | \l QMetaType::QString | - | ||||||||||||||||||||||||
2974 | \row \li \l QMetaType::QDateTime \li \l QMetaType::QDate, | - | ||||||||||||||||||||||||
2975 | \l QMetaType::QString, \l QMetaType::QTime | - | ||||||||||||||||||||||||
2976 | \row \li \l QMetaType::Double \li \l QMetaType::Bool, \l QMetaType::Int, | - | ||||||||||||||||||||||||
2977 | \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt, | - | ||||||||||||||||||||||||
2978 | \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
2979 | \row \li \l QMetaType::QFont \li \l QMetaType::QString | - | ||||||||||||||||||||||||
2980 | \row \li \l QMetaType::Int \li \l QMetaType::Bool, \l QMetaType::QChar, | - | ||||||||||||||||||||||||
2981 | \l QMetaType::Double, \l QMetaType::LongLong, \l QMetaType::QString, | - | ||||||||||||||||||||||||
2982 | \l QMetaType::UInt, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
2983 | \row \li \l QMetaType::QKeySequence \li \l QMetaType::Int, | - | ||||||||||||||||||||||||
2984 | \l QMetaType::QString | - | ||||||||||||||||||||||||
2985 | \row \li \l QMetaType::QVariantList \li \l QMetaType::QStringList (if the | - | ||||||||||||||||||||||||
2986 | list's items can be converted to QStrings) | - | ||||||||||||||||||||||||
2987 | \row \li \l QMetaType::LongLong \li \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2988 | \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::Double, | - | ||||||||||||||||||||||||
2989 | \l QMetaType::Int, \l QMetaType::QString, \l QMetaType::UInt, | - | ||||||||||||||||||||||||
2990 | \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
2991 | \row \li \l QMetaType::QPoint \li QMetaType::QPointF | - | ||||||||||||||||||||||||
2992 | \row \li \l QMetaType::QRect \li QMetaType::QRectF | - | ||||||||||||||||||||||||
2993 | \row \li \l QMetaType::QString \li \l QMetaType::Bool, | - | ||||||||||||||||||||||||
2994 | \l QMetaType::QByteArray, \l QMetaType::QChar, \l QMetaType::QColor, | - | ||||||||||||||||||||||||
2995 | \l QMetaType::QDate, \l QMetaType::QDateTime, \l QMetaType::Double, | - | ||||||||||||||||||||||||
2996 | \l QMetaType::QFont, \l QMetaType::Int, \l QMetaType::QKeySequence, | - | ||||||||||||||||||||||||
2997 | \l QMetaType::LongLong, \l QMetaType::QStringList, \l QMetaType::QTime, | - | ||||||||||||||||||||||||
2998 | \l QMetaType::UInt, \l QMetaType::ULongLong, \l QMetaType::QUuid | - | ||||||||||||||||||||||||
2999 | \row \li \l QMetaType::QStringList \li \l QMetaType::QVariantList, | - | ||||||||||||||||||||||||
3000 | \l QMetaType::QString (if the list contains exactly one item) | - | ||||||||||||||||||||||||
3001 | \row \li \l QMetaType::QTime \li \l QMetaType::QString | - | ||||||||||||||||||||||||
3002 | \row \li \l QMetaType::UInt \li \l QMetaType::Bool, \l QMetaType::QChar, | - | ||||||||||||||||||||||||
3003 | \l QMetaType::Double, \l QMetaType::Int, \l QMetaType::LongLong, | - | ||||||||||||||||||||||||
3004 | \l QMetaType::QString, \l QMetaType::ULongLong | - | ||||||||||||||||||||||||
3005 | \row \li \l QMetaType::ULongLong \li \l QMetaType::Bool, | - | ||||||||||||||||||||||||
3006 | \l QMetaType::QChar, \l QMetaType::Double, \l QMetaType::Int, | - | ||||||||||||||||||||||||
3007 | \l QMetaType::LongLong, \l QMetaType::QString, \l QMetaType::UInt | - | ||||||||||||||||||||||||
3008 | \row \li \l QMetaType::QUuid \li \l QMetaType::QString | - | ||||||||||||||||||||||||
3009 | \endtable | - | ||||||||||||||||||||||||
3010 | - | |||||||||||||||||||||||||
3011 | A QVariant containing a pointer to a type derived from QObject will also return true for this | - | ||||||||||||||||||||||||
3012 | function if a qobject_cast to the type described by \a targetTypeId would succeed. Note that | - | ||||||||||||||||||||||||
3013 | this only works for QObject subclasses which use the Q_OBJECT macro. | - | ||||||||||||||||||||||||
3014 | - | |||||||||||||||||||||||||
3015 | A QVariant containing a sequential container will also return true for this | - | ||||||||||||||||||||||||
3016 | function if the \a targetTypeId is QVariantList. It is possible to iterate over | - | ||||||||||||||||||||||||
3017 | the contents of the container without extracting it as a (copied) QVariantList: | - | ||||||||||||||||||||||||
3018 | - | |||||||||||||||||||||||||
3019 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
3020 | - | |||||||||||||||||||||||||
3021 | This requires that the value_type of the container is itself a metatype. | - | ||||||||||||||||||||||||
3022 | - | |||||||||||||||||||||||||
3023 | Similarly, a QVariant containing a sequential container will also return true for this | - | ||||||||||||||||||||||||
3024 | function the \a targetTypeId is QVariantHash or QVariantMap. It is possible to iterate over | - | ||||||||||||||||||||||||
3025 | the contents of the container without extracting it as a (copied) QVariantHash or QVariantMap: | - | ||||||||||||||||||||||||
3026 | - | |||||||||||||||||||||||||
3027 | \snippet code/src_corelib_kernel_qvariant.cpp 10 | - | ||||||||||||||||||||||||
3028 | - | |||||||||||||||||||||||||
3029 | \sa convert(), QSequentialIterable, Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(), QAssociativeIterable, | - | ||||||||||||||||||||||||
3030 | Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE() | - | ||||||||||||||||||||||||
3031 | */ | - | ||||||||||||||||||||||||
3032 | bool QVariant::canConvert(int targetTypeId) const | - | ||||||||||||||||||||||||
3033 | { | - | ||||||||||||||||||||||||
3034 | if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex)
| 0-225149 | ||||||||||||||||||||||||
3035 | || (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex))
| 0-225147 | ||||||||||||||||||||||||
3036 | return true; executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||||||||||||||
3037 | - | |||||||||||||||||||||||||
3038 | if (targetTypeId == QMetaType::QVariantList
| 63-225084 | ||||||||||||||||||||||||
3039 | && (d.type == QMetaType::QVariantList
| 2-61 | ||||||||||||||||||||||||
3040 | || d.type == QMetaType::QStringList
| 2-59 | ||||||||||||||||||||||||
3041 | || d.type == QMetaType::QByteArrayList
| 2-57 | ||||||||||||||||||||||||
3042 | || QMetaType::hasRegisteredConverterFunction(d.type,
| 20-37 | ||||||||||||||||||||||||
3043 | qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>()))) {
| 20-37 | ||||||||||||||||||||||||
3044 | return true; executed 26 times by 1 test: return true; Executed by:
| 26 | ||||||||||||||||||||||||
3045 | } | - | ||||||||||||||||||||||||
3046 | - | |||||||||||||||||||||||||
3047 | if ((targetTypeId == QMetaType::QVariantHash || targetTypeId == QMetaType::QVariantMap)
| 21-225100 | ||||||||||||||||||||||||
3048 | && (d.type == QMetaType::QVariantMap
| 1-59 | ||||||||||||||||||||||||
3049 | || d.type == QMetaType::QVariantHash
| 0-59 | ||||||||||||||||||||||||
3050 | || QMetaType::hasRegisteredConverterFunction(d.type,
| 0-59 | ||||||||||||||||||||||||
3051 | qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>()))) {
| 0-59 | ||||||||||||||||||||||||
3052 | return true; executed 1 time by 1 test: return true; Executed by:
| 1 | ||||||||||||||||||||||||
3053 | } | - | ||||||||||||||||||||||||
3054 | - | |||||||||||||||||||||||||
3055 | if (targetTypeId == qMetaTypeId<QPair<QVariant, QVariant> >() &&
| 10-225110 | ||||||||||||||||||||||||
3056 | QMetaType::hasRegisteredConverterFunction(d.type,
| 0-10 | ||||||||||||||||||||||||
3057 | qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) {
| 0-10 | ||||||||||||||||||||||||
3058 | return true; executed 10 times by 1 test: return true; Executed by:
| 10 | ||||||||||||||||||||||||
3059 | } | - | ||||||||||||||||||||||||
3060 | - | |||||||||||||||||||||||||
3061 | if ((d.type >= QMetaType::User || targetTypeId >= QMetaType::User)
| 129-224649 | ||||||||||||||||||||||||
3062 | && QMetaType::hasRegisteredConverterFunction(d.type, targetTypeId)) {
| 16-574 | ||||||||||||||||||||||||
3063 | return true; executed 16 times by 3 tests: return true; Executed by:
| 16 | ||||||||||||||||||||||||
3064 | } | - | ||||||||||||||||||||||||
3065 | - | |||||||||||||||||||||||||
3066 | // TODO Reimplement this function, currently it works but it is a historical mess. | - | ||||||||||||||||||||||||
3067 | uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type);
| 84-225010 | ||||||||||||||||||||||||
3068 | if (currentType == QMetaType::SChar || currentType == QMetaType::Char)
| 63-225030 | ||||||||||||||||||||||||
3069 | currentType = QMetaType::UInt; executed 127 times by 1 test: currentType = QMetaType::UInt; Executed by:
| 127 | ||||||||||||||||||||||||
3070 | if (targetTypeId == QMetaType::SChar || currentType == QMetaType::Char)
| 0-225093 | ||||||||||||||||||||||||
3071 | targetTypeId = QMetaType::UInt; executed 1 time by 1 test: targetTypeId = QMetaType::UInt; Executed by:
| 1 | ||||||||||||||||||||||||
3072 | if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double; executed 51 times by 5 tests: targetTypeId = QVariant::Double; Executed by:
| 51-225043 | ||||||||||||||||||||||||
3073 | - | |||||||||||||||||||||||||
3074 | - | |||||||||||||||||||||||||
3075 | if (currentType == uint(targetTypeId))
| 537-224557 | ||||||||||||||||||||||||
3076 | return true; executed 537 times by 26 tests: return true; Executed by:
| 537 | ||||||||||||||||||||||||
3077 | - | |||||||||||||||||||||||||
3078 | if (targetTypeId < 0)
| 75-224482 | ||||||||||||||||||||||||
3079 | return false; executed 75 times by 1 test: return false; Executed by:
| 75 | ||||||||||||||||||||||||
3080 | if (targetTypeId >= QMetaType::User) {
| 129-224353 | ||||||||||||||||||||||||
3081 | if (QMetaType::typeFlags(targetTypeId) & QMetaType::IsEnumeration) {
| 57-72 | ||||||||||||||||||||||||
3082 | targetTypeId = QMetaType::Int; | - | ||||||||||||||||||||||||
3083 | } else { executed 57 times by 1 test: end of block Executed by:
| 57 | ||||||||||||||||||||||||
3084 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); executed 72 times by 6 tests: return canConvertMetaObject(currentType, targetTypeId, d.data.o); Executed by:
| 72 | ||||||||||||||||||||||||
3085 | } | - | ||||||||||||||||||||||||
3086 | } | - | ||||||||||||||||||||||||
3087 | - | |||||||||||||||||||||||||
3088 | if (currentType == QMetaType::QJsonValue) {
| 48-224362 | ||||||||||||||||||||||||
3089 | switch (targetTypeId) { | - | ||||||||||||||||||||||||
3090 | case QMetaType::QString: executed 3 times by 1 test: case QMetaType::QString: Executed by:
| 3 | ||||||||||||||||||||||||
3091 | case QMetaType::Bool: executed 3 times by 1 test: case QMetaType::Bool: Executed by:
| 3 | ||||||||||||||||||||||||
3092 | case QMetaType::Int: executed 3 times by 1 test: case QMetaType::Int: Executed by:
| 3 | ||||||||||||||||||||||||
3093 | case QMetaType::UInt: executed 3 times by 1 test: case QMetaType::UInt: Executed by:
| 3 | ||||||||||||||||||||||||
3094 | case QMetaType::Double: executed 6 times by 1 test: case QMetaType::Double: Executed by:
| 6 | ||||||||||||||||||||||||
3095 | case QMetaType::Float: never executed: case QMetaType::Float: | 0 | ||||||||||||||||||||||||
3096 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
3097 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
3098 | case QMetaType::LongLong: executed 3 times by 1 test: case QMetaType::LongLong: Executed by:
| 3 | ||||||||||||||||||||||||
3099 | case QMetaType::ULongLong: executed 3 times by 1 test: case QMetaType::ULongLong: Executed by:
| 3 | ||||||||||||||||||||||||
3100 | case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||||||||||||||
3101 | case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||||||||||||||
3102 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
3103 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
3104 | case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||||||||||||||
3105 | case QMetaType::QVariantList: executed 1 time by 1 test: case QMetaType::QVariantList: Executed by:
| 1 | ||||||||||||||||||||||||
3106 | case QMetaType::QVariantMap: executed 1 time by 1 test: case QMetaType::QVariantMap: Executed by:
| 1 | ||||||||||||||||||||||||
3107 | case QMetaType::QVariantHash: never executed: case QMetaType::QVariantHash: | 0 | ||||||||||||||||||||||||
3108 | return true; executed 26 times by 1 test: return true; Executed by:
| 26 | ||||||||||||||||||||||||
3109 | default: executed 22 times by 1 test: default: Executed by:
| 22 | ||||||||||||||||||||||||
3110 | return false; executed 22 times by 1 test: return false; Executed by:
| 22 | ||||||||||||||||||||||||
3111 | } | - | ||||||||||||||||||||||||
3112 | } | - | ||||||||||||||||||||||||
3113 | if (currentType == QMetaType::QJsonArray)
| 32-224330 | ||||||||||||||||||||||||
3114 | return targetTypeId == QMetaType::QVariantList; executed 32 times by 1 test: return targetTypeId == QMetaType::QVariantList; Executed by:
| 32 | ||||||||||||||||||||||||
3115 | if (currentType == QMetaType::QJsonObject)
| 32-224298 | ||||||||||||||||||||||||
3116 | return targetTypeId == QMetaType::QVariantMap || targetTypeId == QMetaType::QVariantHash; executed 32 times by 1 test: return targetTypeId == QMetaType::QVariantMap || targetTypeId == QMetaType::QVariantHash; Executed by:
| 0-32 | ||||||||||||||||||||||||
3117 | - | |||||||||||||||||||||||||
3118 | // FIXME It should be LastCoreType intead of Uuid | - | ||||||||||||||||||||||||
3119 | if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) {
| 12745-163813 | ||||||||||||||||||||||||
3120 | switch (uint(targetTypeId)) { | - | ||||||||||||||||||||||||
3121 | case QVariant::Int: executed 71 times by 4 tests: case QVariant::Int: Executed by:
| 71 | ||||||||||||||||||||||||
3122 | if (currentType == QVariant::KeySequence)
| 2-69 | ||||||||||||||||||||||||
3123 | return true; executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||||||||||||||
3124 | // fall through | - | ||||||||||||||||||||||||
3125 | case QVariant::UInt: code before this statement executed 69 times by 4 tests: case QVariant::UInt: Executed by:
executed 37 times by 3 tests: case QVariant::UInt: Executed by:
| 37-69 | ||||||||||||||||||||||||
3126 | case QVariant::LongLong: executed 40 times by 3 tests: case QVariant::LongLong: Executed by:
| 40 | ||||||||||||||||||||||||
3127 | case QVariant::ULongLong: executed 40 times by 3 tests: case QVariant::ULongLong: Executed by:
| 40 | ||||||||||||||||||||||||
3128 | return currentType == QMetaType::ULong executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 3-186 | ||||||||||||||||||||||||
3129 | || currentType == QMetaType::Long executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 6-186 | ||||||||||||||||||||||||
3130 | || currentType == QMetaType::UShort executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 2-186 | ||||||||||||||||||||||||
3131 | || currentType == QMetaType::UChar executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 2-186 | ||||||||||||||||||||||||
3132 | || currentType == QMetaType::Char executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 0-186 | ||||||||||||||||||||||||
3133 | || currentType == QMetaType::SChar executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 0-186 | ||||||||||||||||||||||||
3134 | || currentType == QMetaType::Short executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 2-186 | ||||||||||||||||||||||||
3135 | || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; executed 186 times by 4 tests: return currentType == QMetaType::ULong || currentType == QMetaType::Long || currentType == QMetaType::UShort || currentType == QMetaType::UChar || currentType == QMetaType::Char || currentType == QMetaType::SChar || currentType == QMetaType::Short || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 186 | ||||||||||||||||||||||||
3136 | case QVariant::Image: executed 35 times by 3 tests: case QVariant::Image: Executed by:
| 35 | ||||||||||||||||||||||||
3137 | return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap; executed 35 times by 3 tests: return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap; Executed by:
| 1-35 | ||||||||||||||||||||||||
3138 | case QVariant::Pixmap: executed 36 times by 3 tests: case QVariant::Pixmap: Executed by:
| 36 | ||||||||||||||||||||||||
3139 | return currentType == QVariant::Image || currentType == QVariant::Bitmap executed 36 times by 3 tests: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush; Executed by:
| 1-36 | ||||||||||||||||||||||||
3140 | || currentType == QVariant::Brush; executed 36 times by 3 tests: return currentType == QVariant::Image || currentType == QVariant::Bitmap || currentType == QVariant::Brush; Executed by:
| 1-36 | ||||||||||||||||||||||||
3141 | case QVariant::Bitmap: executed 35 times by 3 tests: case QVariant::Bitmap: Executed by:
| 35 | ||||||||||||||||||||||||
3142 | return currentType == QVariant::Pixmap || currentType == QVariant::Image; executed 35 times by 3 tests: return currentType == QVariant::Pixmap || currentType == QVariant::Image; Executed by:
| 1-35 | ||||||||||||||||||||||||
3143 | case QVariant::ByteArray: executed 24 times by 3 tests: case QVariant::ByteArray: Executed by:
| 24 | ||||||||||||||||||||||||
3144 | return currentType == QVariant::Color executed 24 times by 3 tests: return currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); Executed by:
| 1-24 | ||||||||||||||||||||||||
3145 | || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); executed 24 times by 3 tests: return currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); Executed by:
| 0-24 | ||||||||||||||||||||||||
3146 | case QVariant::String: executed 398 times by 11 tests: case QVariant::String: Executed by:
| 398 | ||||||||||||||||||||||||
3147 | return currentType == QVariant::KeySequence || currentType == QVariant::Font executed 398 times by 11 tests: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); Executed by:
| 4-398 | ||||||||||||||||||||||||
3148 | || currentType == QVariant::Color executed 398 times by 11 tests: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); Executed by:
| 5-398 | ||||||||||||||||||||||||
3149 | || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); executed 398 times by 11 tests: return currentType == QVariant::KeySequence || currentType == QVariant::Font || currentType == QVariant::Color || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); Executed by:
| 0-398 | ||||||||||||||||||||||||
3150 | case QVariant::KeySequence: executed 37 times by 3 tests: case QVariant::KeySequence: Executed by:
| 37 | ||||||||||||||||||||||||
3151 | return currentType == QVariant::String || currentType == QVariant::Int; executed 37 times by 3 tests: return currentType == QVariant::String || currentType == QVariant::Int; Executed by:
| 2-37 | ||||||||||||||||||||||||
3152 | case QVariant::Font: executed 71 times by 4 tests: case QVariant::Font: Executed by:
| 71 | ||||||||||||||||||||||||
3153 | return currentType == QVariant::String; executed 71 times by 4 tests: return currentType == QVariant::String; Executed by:
| 71 | ||||||||||||||||||||||||
3154 | case QVariant::Color: executed 289 times by 13 tests: case QVariant::Color: Executed by:
| 289 | ||||||||||||||||||||||||
3155 | return currentType == QVariant::String || currentType == QVariant::ByteArray executed 289 times by 13 tests: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush; Executed by:
| 7-289 | ||||||||||||||||||||||||
3156 | || currentType == QVariant::Brush; executed 289 times by 13 tests: return currentType == QVariant::String || currentType == QVariant::ByteArray || currentType == QVariant::Brush; Executed by:
| 3-289 | ||||||||||||||||||||||||
3157 | case QVariant::Brush: executed 209792 times by 32 tests: case QVariant::Brush: Executed by:
| 209792 | ||||||||||||||||||||||||
3158 | return currentType == QVariant::Color || currentType == QVariant::Pixmap; executed 209792 times by 32 tests: return currentType == QVariant::Color || currentType == QVariant::Pixmap; Executed by:
| 2-209792 | ||||||||||||||||||||||||
3159 | case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||||||||||||||
3160 | case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||||||||||||||
3161 | case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||||||||||||||
3162 | case QMetaType::UChar: executed 1 time by 1 test: case QMetaType::UChar: Executed by:
| 1 | ||||||||||||||||||||||||
3163 | case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||||||||||||||
3164 | case QMetaType::Short: executed 24 times by 1 test: case QMetaType::Short: Executed by:
| 24 | ||||||||||||||||||||||||
3165 | case QMetaType::UShort: executed 24 times by 1 test: case QMetaType::UShort: Executed by:
| 24 | ||||||||||||||||||||||||
3166 | return currentType == QVariant::Int executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 3-49 | ||||||||||||||||||||||||
3167 | || (currentType < qCanConvertMatrixMaximumTargetType executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 0-49 | ||||||||||||||||||||||||
3168 | && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 0-49 | ||||||||||||||||||||||||
3169 | || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; executed 49 times by 1 test: return currentType == QVariant::Int || (currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; Executed by:
| 49 | ||||||||||||||||||||||||
3170 | case QMetaType::QObjectStar: executed 40 times by 2 tests: case QMetaType::QObjectStar: Executed by:
| 40 | ||||||||||||||||||||||||
3171 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); executed 40 times by 2 tests: return canConvertMetaObject(currentType, targetTypeId, d.data.o); Executed by:
| 40 | ||||||||||||||||||||||||
3172 | default: executed 559 times by 6 tests: default: Executed by:
| 559 | ||||||||||||||||||||||||
3173 | return false; executed 559 times by 6 tests: return false; Executed by:
| 559 | ||||||||||||||||||||||||
3174 | } | - | ||||||||||||||||||||||||
3175 | } | - | ||||||||||||||||||||||||
3176 | - | |||||||||||||||||||||||||
3177 | if (targetTypeId == String && currentType == StringList)
| 18-7622 | ||||||||||||||||||||||||
3178 | return v_cast<QStringList>(&d)->count() == 1; executed 18 times by 3 tests: return v_cast<QStringList>(&d)->count() == 1; Executed by:
| 18 | ||||||||||||||||||||||||
3179 | return currentType < qCanConvertMatrixMaximumTargetType executed 12727 times by 65 tests: return currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[targetTypeId] & (1U << currentType); Executed by:
| 0-12727 | ||||||||||||||||||||||||
3180 | && qCanConvertMatrix[targetTypeId] & (1U << currentType); executed 12727 times by 65 tests: return currentType < qCanConvertMatrixMaximumTargetType && qCanConvertMatrix[targetTypeId] & (1U << currentType); Executed by:
| 1771-12727 | ||||||||||||||||||||||||
3181 | } | - | ||||||||||||||||||||||||
3182 | - | |||||||||||||||||||||||||
3183 | /*! | - | ||||||||||||||||||||||||
3184 | Casts the variant to the requested type, \a targetTypeId. If the cast cannot be | - | ||||||||||||||||||||||||
3185 | done, the variant is cleared. Returns \c true if the current type of | - | ||||||||||||||||||||||||
3186 | the variant was successfully cast; otherwise returns \c false. | - | ||||||||||||||||||||||||
3187 | - | |||||||||||||||||||||||||
3188 | A QVariant containing a pointer to a type derived from QObject will also convert | - | ||||||||||||||||||||||||
3189 | and return true for this function if a qobject_cast to the type described | - | ||||||||||||||||||||||||
3190 | by \a targetTypeId would succeed. Note that this only works for QObject subclasses | - | ||||||||||||||||||||||||
3191 | which use the Q_OBJECT macro. | - | ||||||||||||||||||||||||
3192 | - | |||||||||||||||||||||||||
3193 | \warning For historical reasons, converting a null QVariant results | - | ||||||||||||||||||||||||
3194 | in a null value of the desired type (e.g., an empty string for | - | ||||||||||||||||||||||||
3195 | QString) and a result of false. | - | ||||||||||||||||||||||||
3196 | - | |||||||||||||||||||||||||
3197 | \sa canConvert(), clear() | - | ||||||||||||||||||||||||
3198 | */ | - | ||||||||||||||||||||||||
3199 | - | |||||||||||||||||||||||||
3200 | bool QVariant::convert(int targetTypeId) | - | ||||||||||||||||||||||||
3201 | { | - | ||||||||||||||||||||||||
3202 | if (d.type == uint(targetTypeId))
| 1355-6205 | ||||||||||||||||||||||||
3203 | return true; executed 1355 times by 27 tests: return true; Executed by:
| 1355 | ||||||||||||||||||||||||
3204 | - | |||||||||||||||||||||||||
3205 | QVariant oldValue = *this; | - | ||||||||||||||||||||||||
3206 | - | |||||||||||||||||||||||||
3207 | clear(); | - | ||||||||||||||||||||||||
3208 | if (!oldValue.canConvert(targetTypeId))
| 755-5450 | ||||||||||||||||||||||||
3209 | return false; executed 5450 times by 34 tests: return false; Executed by:
| 5450 | ||||||||||||||||||||||||
3210 | - | |||||||||||||||||||||||||
3211 | create(targetTypeId, 0); | - | ||||||||||||||||||||||||
3212 | if (oldValue.isNull())
| 20-735 | ||||||||||||||||||||||||
3213 | return false; executed 20 times by 2 tests: return false; Executed by:
| 20 | ||||||||||||||||||||||||
3214 | - | |||||||||||||||||||||||||
3215 | if ((QMetaType::typeFlags(oldValue.userType()) & QMetaType::PointerToQObject) && (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject)) { | - | ||||||||||||||||||||||||
3216 | create(targetTypeId, &oldValue.d.data.o); | - | ||||||||||||||||||||||||
3217 | return true; executed 7 times by 3 tests: return true; Executed by:
| 7 | ||||||||||||||||||||||||
3218 | } | - | ||||||||||||||||||||||||
3219 | - | |||||||||||||||||||||||||
3220 | bool isOk = true; | - | ||||||||||||||||||||||||
3221 | int converterType = std::max(oldValue.userType(), targetTypeId); | - | ||||||||||||||||||||||||
3222 | if (!handlerManager[converterType]->convert(&oldValue.d, targetTypeId, data(), &isOk))
| 60-668 | ||||||||||||||||||||||||
3223 | isOk = false; executed 60 times by 7 tests: isOk = false; Executed by:
| 60 | ||||||||||||||||||||||||
3224 | d.is_null = !isOk; | - | ||||||||||||||||||||||||
3225 | return isOk; executed 728 times by 29 tests: return isOk; Executed by:
| 728 | ||||||||||||||||||||||||
3226 | } | - | ||||||||||||||||||||||||
3227 | - | |||||||||||||||||||||||||
3228 | /*! | - | ||||||||||||||||||||||||
3229 | \fn bool QVariant::convert(const int type, void *ptr) const | - | ||||||||||||||||||||||||
3230 | \internal | - | ||||||||||||||||||||||||
3231 | Created for qvariant_cast() usage | - | ||||||||||||||||||||||||
3232 | */ | - | ||||||||||||||||||||||||
3233 | bool QVariant::convert(const int type, void *ptr) const | - | ||||||||||||||||||||||||
3234 | { | - | ||||||||||||||||||||||||
3235 | return handlerManager[type]->convert(&d, type, ptr, 0); executed 368846 times by 118 tests: return handlerManager[type]->convert(&d, type, ptr, 0); Executed by:
| 368846 | ||||||||||||||||||||||||
3236 | } | - | ||||||||||||||||||||||||
3237 | - | |||||||||||||||||||||||||
3238 | - | |||||||||||||||||||||||||
3239 | /*! | - | ||||||||||||||||||||||||
3240 | \fn bool operator==(const QVariant &v1, const QVariant &v2) | - | ||||||||||||||||||||||||
3241 | - | |||||||||||||||||||||||||
3242 | \relates QVariant | - | ||||||||||||||||||||||||
3243 | - | |||||||||||||||||||||||||
3244 | Returns \c true if \a v1 and \a v2 are equal; otherwise returns \c false. | - | ||||||||||||||||||||||||
3245 | - | |||||||||||||||||||||||||
3246 | If \a v1 and \a v2 have the same \l{QVariant::}{type()}, the | - | ||||||||||||||||||||||||
3247 | type's equality operator is used for comparison. If not, it is | - | ||||||||||||||||||||||||
3248 | attempted to \l{QVariant::}{convert()} \a v2 to the same type as | - | ||||||||||||||||||||||||
3249 | \a v1. See \l{QVariant::}{canConvert()} for a list of possible | - | ||||||||||||||||||||||||
3250 | conversions. | - | ||||||||||||||||||||||||
3251 | - | |||||||||||||||||||||||||
3252 | The result of the function is not affected by the result of QVariant::isNull, | - | ||||||||||||||||||||||||
3253 | which means that two values can be equal even if one of them is null and | - | ||||||||||||||||||||||||
3254 | another is not. | - | ||||||||||||||||||||||||
3255 | - | |||||||||||||||||||||||||
3256 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3257 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3258 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3259 | */ | - | ||||||||||||||||||||||||
3260 | /*! | - | ||||||||||||||||||||||||
3261 | \fn bool operator!=(const QVariant &v1, const QVariant &v2) | - | ||||||||||||||||||||||||
3262 | - | |||||||||||||||||||||||||
3263 | \relates QVariant | - | ||||||||||||||||||||||||
3264 | - | |||||||||||||||||||||||||
3265 | Returns \c false if \a v1 and \a v2 are equal; otherwise returns \c true. | - | ||||||||||||||||||||||||
3266 | - | |||||||||||||||||||||||||
3267 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3268 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3269 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3270 | */ | - | ||||||||||||||||||||||||
3271 | - | |||||||||||||||||||||||||
3272 | /*! \fn bool QVariant::operator==(const QVariant &v) const | - | ||||||||||||||||||||||||
3273 | - | |||||||||||||||||||||||||
3274 | Compares this QVariant with \a v and returns \c true if they are | - | ||||||||||||||||||||||||
3275 | equal; otherwise returns \c false. | - | ||||||||||||||||||||||||
3276 | - | |||||||||||||||||||||||||
3277 | QVariant uses the equality operator of the type() it contains to | - | ||||||||||||||||||||||||
3278 | check for equality. QVariant will try to convert() \a v if its | - | ||||||||||||||||||||||||
3279 | type is not the same as this variant's type. See canConvert() for | - | ||||||||||||||||||||||||
3280 | a list of possible conversions. | - | ||||||||||||||||||||||||
3281 | - | |||||||||||||||||||||||||
3282 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3283 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3284 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3285 | */ | - | ||||||||||||||||||||||||
3286 | - | |||||||||||||||||||||||||
3287 | /*! | - | ||||||||||||||||||||||||
3288 | \fn bool QVariant::operator!=(const QVariant &v) const | - | ||||||||||||||||||||||||
3289 | - | |||||||||||||||||||||||||
3290 | Compares this QVariant with \a v and returns \c true if they are not | - | ||||||||||||||||||||||||
3291 | equal; otherwise returns \c false. | - | ||||||||||||||||||||||||
3292 | - | |||||||||||||||||||||||||
3293 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3294 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3295 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3296 | */ | - | ||||||||||||||||||||||||
3297 | - | |||||||||||||||||||||||||
3298 | /*! | - | ||||||||||||||||||||||||
3299 | \fn bool QVariant::operator<(const QVariant &v) const | - | ||||||||||||||||||||||||
3300 | - | |||||||||||||||||||||||||
3301 | Compares this QVariant with \a v and returns \c true if this is less than \a v. | - | ||||||||||||||||||||||||
3302 | - | |||||||||||||||||||||||||
3303 | \note Comparability might not be availabe for the type stored in this QVariant | - | ||||||||||||||||||||||||
3304 | or in \a v. | - | ||||||||||||||||||||||||
3305 | - | |||||||||||||||||||||||||
3306 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3307 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3308 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3309 | */ | - | ||||||||||||||||||||||||
3310 | - | |||||||||||||||||||||||||
3311 | /*! | - | ||||||||||||||||||||||||
3312 | \fn bool QVariant::operator<=(const QVariant &v) const | - | ||||||||||||||||||||||||
3313 | - | |||||||||||||||||||||||||
3314 | Compares this QVariant with \a v and returns \c true if this is less or equal than \a v. | - | ||||||||||||||||||||||||
3315 | - | |||||||||||||||||||||||||
3316 | \note Comparability might not be available for the type stored in this QVariant | - | ||||||||||||||||||||||||
3317 | or in \a v. | - | ||||||||||||||||||||||||
3318 | - | |||||||||||||||||||||||||
3319 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3320 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3321 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3322 | */ | - | ||||||||||||||||||||||||
3323 | - | |||||||||||||||||||||||||
3324 | /*! | - | ||||||||||||||||||||||||
3325 | \fn bool QVariant::operator>(const QVariant &v) const | - | ||||||||||||||||||||||||
3326 | - | |||||||||||||||||||||||||
3327 | Compares this QVariant with \a v and returns \c true if this is larger than \a v. | - | ||||||||||||||||||||||||
3328 | - | |||||||||||||||||||||||||
3329 | \note Comparability might not be available for the type stored in this QVariant | - | ||||||||||||||||||||||||
3330 | or in \a v. | - | ||||||||||||||||||||||||
3331 | - | |||||||||||||||||||||||||
3332 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3333 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3334 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3335 | */ | - | ||||||||||||||||||||||||
3336 | - | |||||||||||||||||||||||||
3337 | /*! | - | ||||||||||||||||||||||||
3338 | \fn bool QVariant::operator>=(const QVariant &v) const | - | ||||||||||||||||||||||||
3339 | - | |||||||||||||||||||||||||
3340 | Compares this QVariant with \a v and returns \c true if this is larger or equal than \a v. | - | ||||||||||||||||||||||||
3341 | - | |||||||||||||||||||||||||
3342 | \note Comparability might not be available for the type stored in this QVariant | - | ||||||||||||||||||||||||
3343 | or in \a v. | - | ||||||||||||||||||||||||
3344 | - | |||||||||||||||||||||||||
3345 | \warning To make this function work with a custom type registered with | - | ||||||||||||||||||||||||
3346 | qRegisterMetaType(), its comparison operator must be registered using | - | ||||||||||||||||||||||||
3347 | QMetaType::registerComparators(). | - | ||||||||||||||||||||||||
3348 | */ | - | ||||||||||||||||||||||||
3349 | - | |||||||||||||||||||||||||
3350 | static bool qIsNumericType(uint tp) | - | ||||||||||||||||||||||||
3351 | { | - | ||||||||||||||||||||||||
3352 | static const qulonglong numericTypeBits = | - | ||||||||||||||||||||||||
3353 | Q_UINT64_C(1) << QMetaType::Bool | | - | ||||||||||||||||||||||||
3354 | Q_UINT64_C(1) << QMetaType::Double | | - | ||||||||||||||||||||||||
3355 | Q_UINT64_C(1) << QMetaType::Float | | - | ||||||||||||||||||||||||
3356 | Q_UINT64_C(1) << QMetaType::Char | | - | ||||||||||||||||||||||||
3357 | Q_UINT64_C(1) << QMetaType::SChar | | - | ||||||||||||||||||||||||
3358 | Q_UINT64_C(1) << QMetaType::UChar | | - | ||||||||||||||||||||||||
3359 | Q_UINT64_C(1) << QMetaType::Short | | - | ||||||||||||||||||||||||
3360 | Q_UINT64_C(1) << QMetaType::UShort | | - | ||||||||||||||||||||||||
3361 | Q_UINT64_C(1) << QMetaType::Int | | - | ||||||||||||||||||||||||
3362 | Q_UINT64_C(1) << QMetaType::UInt | | - | ||||||||||||||||||||||||
3363 | Q_UINT64_C(1) << QMetaType::Long | | - | ||||||||||||||||||||||||
3364 | Q_UINT64_C(1) << QMetaType::ULong | | - | ||||||||||||||||||||||||
3365 | Q_UINT64_C(1) << QMetaType::LongLong | | - | ||||||||||||||||||||||||
3366 | Q_UINT64_C(1) << QMetaType::ULongLong; | - | ||||||||||||||||||||||||
3367 | return tp < (CHAR_BIT * sizeof numericTypeBits) ? numericTypeBits & (Q_UINT64_C(1) << tp) : false; executed 968818 times by 117 tests: return tp < (8 * sizeof numericTypeBits) ? numericTypeBits & (static_cast<unsigned long long>(1ULL) << tp) : false; Executed by:
| 2022-968818 | ||||||||||||||||||||||||
3368 | } | - | ||||||||||||||||||||||||
3369 | - | |||||||||||||||||||||||||
3370 | static bool qIsFloatingPoint(uint tp) | - | ||||||||||||||||||||||||
3371 | { | - | ||||||||||||||||||||||||
3372 | return tp == QVariant::Double || tp == QMetaType::Float; executed 429632 times by 84 tests: return tp == QVariant::Double || tp == QMetaType::Float; Executed by:
| 191-429632 | ||||||||||||||||||||||||
3373 | } | - | ||||||||||||||||||||||||
3374 | - | |||||||||||||||||||||||||
3375 | static int normalizeLowerRanks(uint tp) | - | ||||||||||||||||||||||||
3376 | { | - | ||||||||||||||||||||||||
3377 | static const qulonglong numericTypeBits = | - | ||||||||||||||||||||||||
3378 | Q_UINT64_C(1) << QMetaType::Bool | | - | ||||||||||||||||||||||||
3379 | Q_UINT64_C(1) << QMetaType::Char | | - | ||||||||||||||||||||||||
3380 | Q_UINT64_C(1) << QMetaType::SChar | | - | ||||||||||||||||||||||||
3381 | Q_UINT64_C(1) << QMetaType::UChar | | - | ||||||||||||||||||||||||
3382 | Q_UINT64_C(1) << QMetaType::Short | | - | ||||||||||||||||||||||||
3383 | Q_UINT64_C(1) << QMetaType::UShort; | - | ||||||||||||||||||||||||
3384 | return numericTypeBits & (Q_UINT64_C(1) << tp) ? QVariant::Int : tp; executed 423818 times by 83 tests: return numericTypeBits & (static_cast<unsigned long long>(1ULL) << tp) ? QVariant::Int : tp; Executed by:
| 1312-423818 | ||||||||||||||||||||||||
3385 | } | - | ||||||||||||||||||||||||
3386 | - | |||||||||||||||||||||||||
3387 | static int normalizeLong(uint tp) | - | ||||||||||||||||||||||||
3388 | { | - | ||||||||||||||||||||||||
3389 | const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong;
| 0-423818 | ||||||||||||||||||||||||
3390 | const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong;
| 0-423818 | ||||||||||||||||||||||||
3391 | return tp == QMetaType::Long ? IntType : executed 423818 times by 83 tests: return tp == QMetaType::Long ? IntType : tp == QMetaType::ULong ? UIntType : tp; Executed by:
| 102-423818 | ||||||||||||||||||||||||
3392 | tp == QMetaType::ULong ? UIntType : tp; executed 423818 times by 83 tests: return tp == QMetaType::Long ? IntType : tp == QMetaType::ULong ? UIntType : tp; Executed by:
| 84-423818 | ||||||||||||||||||||||||
3393 | } | - | ||||||||||||||||||||||||
3394 | - | |||||||||||||||||||||||||
3395 | static int numericTypePromotion(uint t1, uint t2) | - | ||||||||||||||||||||||||
3396 | { | - | ||||||||||||||||||||||||
3397 | Q_ASSERT(qIsNumericType(t1)); | - | ||||||||||||||||||||||||
3398 | Q_ASSERT(qIsNumericType(t2)); | - | ||||||||||||||||||||||||
3399 | - | |||||||||||||||||||||||||
3400 | // C++ integral ranks: (4.13 Integer conversion rank [conv.rank]) | - | ||||||||||||||||||||||||
3401 | // bool < signed char < short < int < long < long long | - | ||||||||||||||||||||||||
3402 | // unsigneds have the same rank as their signed counterparts | - | ||||||||||||||||||||||||
3403 | // C++ integral promotion rules (4.5 Integral Promotions [conv.prom]) | - | ||||||||||||||||||||||||
3404 | // - any type with rank less than int can be converted to int or unsigned int | - | ||||||||||||||||||||||||
3405 | // 5 Expressions [expr] paragraph 9: | - | ||||||||||||||||||||||||
3406 | // - if either operand is double, the other shall be converted to double | - | ||||||||||||||||||||||||
3407 | // - " " float, " " " float | - | ||||||||||||||||||||||||
3408 | // - if both operands have the same type, no further conversion is needed. | - | ||||||||||||||||||||||||
3409 | // - if both are signed or if both are unsigned, convert to the one with highest rank | - | ||||||||||||||||||||||||
3410 | // - if the unsigned has higher or same rank, convert the signed to the unsigned one | - | ||||||||||||||||||||||||
3411 | // - if the signed can represent all values of the unsigned, convert to the signed | - | ||||||||||||||||||||||||
3412 | // - otherwise, convert to the unsigned corresponding to the rank of the signed | - | ||||||||||||||||||||||||
3413 | - | |||||||||||||||||||||||||
3414 | // floating point: we deviate from the C++ standard by always using qreal | - | ||||||||||||||||||||||||
3415 | if (qIsFloatingPoint(t1) || qIsFloatingPoint(t2))
| 85-211994 | ||||||||||||||||||||||||
3416 | return QMetaType::QReal; executed 5729 times by 32 tests: return QMetaType::QReal; Executed by:
| 5729 | ||||||||||||||||||||||||
3417 | - | |||||||||||||||||||||||||
3418 | // integral rules: | - | ||||||||||||||||||||||||
3419 | // for all platforms we support, int can always hold the values of lower-ranked types | - | ||||||||||||||||||||||||
3420 | t1 = normalizeLowerRanks(t1); | - | ||||||||||||||||||||||||
3421 | t2 = normalizeLowerRanks(t2); | - | ||||||||||||||||||||||||
3422 | - | |||||||||||||||||||||||||
3423 | // normalize long / ulong: in all platforms we run, they're either the same as int or as long long | - | ||||||||||||||||||||||||
3424 | t1 = normalizeLong(t1); | - | ||||||||||||||||||||||||
3425 | t2 = normalizeLong(t2); | - | ||||||||||||||||||||||||
3426 | - | |||||||||||||||||||||||||
3427 | // implement the other rules | - | ||||||||||||||||||||||||
3428 | // the four possibilities are Int, UInt, LongLong and ULongLong | - | ||||||||||||||||||||||||
3429 | // if any of the two is ULongLong, then it wins (highest rank, unsigned) | - | ||||||||||||||||||||||||
3430 | // otherwise, if one of the two is LongLong, then the other is either LongLong too or lower-ranked | - | ||||||||||||||||||||||||
3431 | // otherwise, if one of the two is UInt, then the other is either UInt too or Int | - | ||||||||||||||||||||||||
3432 | if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong)
| 105-211708 | ||||||||||||||||||||||||
3433 | return QVariant::ULongLong; executed 306 times by 3 tests: return QVariant::ULongLong; Executed by:
| 306 | ||||||||||||||||||||||||
3434 | if (t1 == QVariant::LongLong || t2 == QVariant::LongLong)
| 102-209614 | ||||||||||||||||||||||||
3435 | return QVariant::LongLong; executed 2091 times by 14 tests: return QVariant::LongLong; Executed by:
| 2091 | ||||||||||||||||||||||||
3436 | if (t1 == QVariant::UInt || t2 == QVariant::UInt)
| 235-209202 | ||||||||||||||||||||||||
3437 | return QVariant::UInt; executed 545 times by 10 tests: return QVariant::UInt; Executed by:
| 545 | ||||||||||||||||||||||||
3438 | return QVariant::Int; executed 208967 times by 77 tests: return QVariant::Int; Executed by:
| 208967 | ||||||||||||||||||||||||
3439 | } | - | ||||||||||||||||||||||||
3440 | - | |||||||||||||||||||||||||
3441 | static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2) | - | ||||||||||||||||||||||||
3442 | { | - | ||||||||||||||||||||||||
3443 | // use toLongLong to retrieve the data, it gets us all the bits | - | ||||||||||||||||||||||||
3444 | bool ok; | - | ||||||||||||||||||||||||
3445 | qlonglong l1 = qConvertToNumber(d1, &ok); | - | ||||||||||||||||||||||||
3446 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
3447 | - | |||||||||||||||||||||||||
3448 | qlonglong l2 = qConvertToNumber(d2, &ok); | - | ||||||||||||||||||||||||
3449 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
3450 | - | |||||||||||||||||||||||||
3451 | if (promotedType == QVariant::Int)
| 2942-208967 | ||||||||||||||||||||||||
3452 | return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1; executed 208967 times by 77 tests: return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1; Executed by:
| 1197-208967 | ||||||||||||||||||||||||
3453 | if (promotedType == QVariant::UInt)
| 545-2397 | ||||||||||||||||||||||||
3454 | return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1; executed 545 times by 10 tests: return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1; Executed by:
| 156-545 | ||||||||||||||||||||||||
3455 | if (promotedType == QVariant::LongLong)
| 306-2091 | ||||||||||||||||||||||||
3456 | return l1 < l2 ? -1 : l1 == l2 ? 0 : 1; executed 2091 times by 14 tests: return l1 < l2 ? -1 : l1 == l2 ? 0 : 1; Executed by:
| 125-2091 | ||||||||||||||||||||||||
3457 | if (promotedType == QVariant::ULongLong)
| 0-306 | ||||||||||||||||||||||||
3458 | return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1; executed 306 times by 3 tests: return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1; Executed by:
| 90-306 | ||||||||||||||||||||||||
3459 | - | |||||||||||||||||||||||||
3460 | Q_UNREACHABLE(); | - | ||||||||||||||||||||||||
3461 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
3462 | } | - | ||||||||||||||||||||||||
3463 | - | |||||||||||||||||||||||||
3464 | static int numericCompare(const QVariant::Private *d1, const QVariant::Private *d2) | - | ||||||||||||||||||||||||
3465 | { | - | ||||||||||||||||||||||||
3466 | uint promotedType = numericTypePromotion(d1->type, d2->type); | - | ||||||||||||||||||||||||
3467 | if (promotedType != QMetaType::QReal)
| 5729-211909 | ||||||||||||||||||||||||
3468 | return integralCompare(promotedType, d1, d2); executed 211909 times by 83 tests: return integralCompare(promotedType, d1, d2); Executed by:
| 211909 | ||||||||||||||||||||||||
3469 | - | |||||||||||||||||||||||||
3470 | // qreal comparisons | - | ||||||||||||||||||||||||
3471 | bool ok; | - | ||||||||||||||||||||||||
3472 | qreal r1 = qConvertToRealNumber(d1, &ok); | - | ||||||||||||||||||||||||
3473 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
3474 | qreal r2 = qConvertToRealNumber(d2, &ok); | - | ||||||||||||||||||||||||
3475 | Q_ASSERT(ok); | - | ||||||||||||||||||||||||
3476 | if (r1 == r2 || qFuzzyCompare(r1, r2))
| 10-2998 | ||||||||||||||||||||||||
3477 | return 0; executed 3008 times by 32 tests: return 0; Executed by:
| 3008 | ||||||||||||||||||||||||
3478 | return r1 < r2 ? -1 : 1; executed 2721 times by 8 tests: return r1 < r2 ? -1 : 1; Executed by:
| 723-2721 | ||||||||||||||||||||||||
3479 | } | - | ||||||||||||||||||||||||
3480 | - | |||||||||||||||||||||||||
3481 | /*! | - | ||||||||||||||||||||||||
3482 | \internal | - | ||||||||||||||||||||||||
3483 | */ | - | ||||||||||||||||||||||||
3484 | bool QVariant::cmp(const QVariant &v) const | - | ||||||||||||||||||||||||
3485 | { | - | ||||||||||||||||||||||||
3486 | // try numerics first, with C++ type promotion rules (no conversion) | - | ||||||||||||||||||||||||
3487 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type))
| 137-216030 | ||||||||||||||||||||||||
3488 | return numericCompare(&d, &v.d) == 0; executed 215893 times by 84 tests: return numericCompare(&d, &v.d) == 0; Executed by:
| 215893 | ||||||||||||||||||||||||
3489 | - | |||||||||||||||||||||||||
3490 | QVariant v1 = *this; | - | ||||||||||||||||||||||||
3491 | QVariant v2 = v; | - | ||||||||||||||||||||||||
3492 | if (d.type != v2.d.type) {
| 1583-96322 | ||||||||||||||||||||||||
3493 | if (v2.canConvert(v1.d.type)) {
| 125-1458 | ||||||||||||||||||||||||
3494 | if (!v2.convert(v1.d.type))
| 53-72 | ||||||||||||||||||||||||
3495 | return false; executed 72 times by 6 tests: return false; Executed by:
| 72 | ||||||||||||||||||||||||
3496 | } else { executed 53 times by 6 tests: end of block Executed by:
| 53 | ||||||||||||||||||||||||
3497 | // try the opposite conversion, it might work | - | ||||||||||||||||||||||||
3498 | qSwap(v1, v2); | - | ||||||||||||||||||||||||
3499 | if (!v2.convert(v1.d.type))
| 5-1453 | ||||||||||||||||||||||||
3500 | return false; executed 1453 times by 11 tests: return false; Executed by:
| 1453 | ||||||||||||||||||||||||
3501 | } executed 5 times by 2 tests: end of block Executed by:
| 5 | ||||||||||||||||||||||||
3502 | } | - | ||||||||||||||||||||||||
3503 | if (v1.d.type >= QMetaType::User) {
| 362-96018 | ||||||||||||||||||||||||
3504 | int result; | - | ||||||||||||||||||||||||
3505 | if (QMetaType::equals(QT_PREPEND_NAMESPACE(constData(v1.d)), QT_PREPEND_NAMESPACE(constData(v2.d)), v1.d.type, &result))
| 17-345 | ||||||||||||||||||||||||
3506 | return result == 0; executed 17 times by 1 test: return result == 0; Executed by:
| 17 | ||||||||||||||||||||||||
3507 | } executed 345 times by 23 tests: end of block Executed by:
| 345 | ||||||||||||||||||||||||
3508 | return handlerManager[v1.d.type]->compare(&v1.d, &v2.d); executed 96363 times by 92 tests: return handlerManager[v1.d.type]->compare(&v1.d, &v2.d); Executed by:
| 96363 | ||||||||||||||||||||||||
3509 | } | - | ||||||||||||||||||||||||
3510 | - | |||||||||||||||||||||||||
3511 | /*! | - | ||||||||||||||||||||||||
3512 | \internal | - | ||||||||||||||||||||||||
3513 | */ | - | ||||||||||||||||||||||||
3514 | int QVariant::compare(const QVariant &v) const | - | ||||||||||||||||||||||||
3515 | { | - | ||||||||||||||||||||||||
3516 | // try numerics first, with C++ type promotion rules (no conversion) | - | ||||||||||||||||||||||||
3517 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type))
| 9-1754 | ||||||||||||||||||||||||
3518 | return numericCompare(&d, &v.d); executed 1745 times by 2 tests: return numericCompare(&d, &v.d); Executed by:
| 1745 | ||||||||||||||||||||||||
3519 | - | |||||||||||||||||||||||||
3520 | // check for equality next, as more types implement operator== than operator< | - | ||||||||||||||||||||||||
3521 | if (cmp(v))
| 37-170 | ||||||||||||||||||||||||
3522 | return 0; executed 37 times by 2 tests: return 0; Executed by:
| 37 | ||||||||||||||||||||||||
3523 | - | |||||||||||||||||||||||||
3524 | QVariant v1 = *this; | - | ||||||||||||||||||||||||
3525 | QVariant v2 = v; | - | ||||||||||||||||||||||||
3526 | - | |||||||||||||||||||||||||
3527 | if (v1.d.type != v2.d.type) {
| 12-158 | ||||||||||||||||||||||||
3528 | // if both types differ, try to convert | - | ||||||||||||||||||||||||
3529 | if (v2.canConvert(v1.d.type)) {
| 5-7 | ||||||||||||||||||||||||
3530 | QVariant temp = v2; | - | ||||||||||||||||||||||||
3531 | if (temp.convert(v1.d.type))
| 2-3 | ||||||||||||||||||||||||
3532 | v2 = temp; executed 2 times by 1 test: v2 = temp; Executed by:
| 2 | ||||||||||||||||||||||||
3533 | } executed 5 times by 2 tests: end of block Executed by:
| 5 | ||||||||||||||||||||||||
3534 | if (v1.d.type != v2.d.type && v1.canConvert(v2.d.type)) {
| 2-10 | ||||||||||||||||||||||||
3535 | QVariant temp = v1; | - | ||||||||||||||||||||||||
3536 | if (temp.convert(v2.d.type))
| 0-5 | ||||||||||||||||||||||||
3537 | v1 = temp; executed 5 times by 2 tests: v1 = temp; Executed by:
| 5 | ||||||||||||||||||||||||
3538 | } executed 5 times by 2 tests: end of block Executed by:
| 5 | ||||||||||||||||||||||||
3539 | if (v1.d.type != v2.d.type) {
| 5-7 | ||||||||||||||||||||||||
3540 | // if conversion fails, default to toString | - | ||||||||||||||||||||||||
3541 | int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); | - | ||||||||||||||||||||||||
3542 | if (r == 0) {
| 2-3 | ||||||||||||||||||||||||
3543 | // cmp(v) returned false, so we should try to agree with it. | - | ||||||||||||||||||||||||
3544 | return (v1.d.type < v2.d.type) ? -1 : 1; executed 2 times by 1 test: return (v1.d.type < v2.d.type) ? -1 : 1; Executed by:
| 0-2 | ||||||||||||||||||||||||
3545 | } | - | ||||||||||||||||||||||||
3546 | return r; executed 3 times by 2 tests: return r; Executed by:
| 3 | ||||||||||||||||||||||||
3547 | } | - | ||||||||||||||||||||||||
3548 | - | |||||||||||||||||||||||||
3549 | // did we end up with two numerics? If so, restart | - | ||||||||||||||||||||||||
3550 | if (qIsNumericType(v1.d.type) && qIsNumericType(v2.d.type))
| 0-6 | ||||||||||||||||||||||||
3551 | return v1.compare(v2); executed 1 time by 1 test: return v1.compare(v2); Executed by:
| 1 | ||||||||||||||||||||||||
3552 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
3553 | if (v1.d.type >= QMetaType::User) {
| 7-157 | ||||||||||||||||||||||||
3554 | int result; | - | ||||||||||||||||||||||||
3555 | if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2.d)), d.type, &result))
| 2-5 | ||||||||||||||||||||||||
3556 | return result; executed 5 times by 1 test: return result; Executed by:
| 5 | ||||||||||||||||||||||||
3557 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3558 | switch (v1.d.type) { | - | ||||||||||||||||||||||||
3559 | case QVariant::Date: executed 16 times by 2 tests: case QVariant::Date: Executed by:
| 16 | ||||||||||||||||||||||||
3560 | return v1.toDate() < v2.toDate() ? -1 : 1; executed 16 times by 2 tests: return v1.toDate() < v2.toDate() ? -1 : 1; Executed by:
| 8-16 | ||||||||||||||||||||||||
3561 | case QVariant::Time: executed 15 times by 2 tests: case QVariant::Time: Executed by:
| 15 | ||||||||||||||||||||||||
3562 | return v1.toTime() < v2.toTime() ? -1 : 1; executed 15 times by 2 tests: return v1.toTime() < v2.toTime() ? -1 : 1; Executed by:
| 7-15 | ||||||||||||||||||||||||
3563 | case QVariant::DateTime: executed 8 times by 1 test: case QVariant::DateTime: Executed by:
| 8 | ||||||||||||||||||||||||
3564 | return v1.toDateTime() < v2.toDateTime() ? -1 : 1; executed 8 times by 1 test: return v1.toDateTime() < v2.toDateTime() ? -1 : 1; Executed by:
| 4-8 | ||||||||||||||||||||||||
3565 | case QVariant::StringList: executed 56 times by 1 test: case QVariant::StringList: Executed by:
| 56 | ||||||||||||||||||||||||
3566 | return v1.toStringList() < v2.toStringList() ? -1 : 1; executed 56 times by 1 test: return v1.toStringList() < v2.toStringList() ? -1 : 1; Executed by:
| 28-56 | ||||||||||||||||||||||||
3567 | } | - | ||||||||||||||||||||||||
3568 | int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); | - | ||||||||||||||||||||||||
3569 | if (r == 0) {
| 2-62 | ||||||||||||||||||||||||
3570 | // cmp(v) returned false, so we should try to agree with it. | - | ||||||||||||||||||||||||
3571 | return (d.type < v.d.type) ? -1 : 1; executed 2 times by 1 test: return (d.type < v.d.type) ? -1 : 1; Executed by:
| 0-2 | ||||||||||||||||||||||||
3572 | } | - | ||||||||||||||||||||||||
3573 | return r; executed 62 times by 2 tests: return r; Executed by:
| 62 | ||||||||||||||||||||||||
3574 | } | - | ||||||||||||||||||||||||
3575 | - | |||||||||||||||||||||||||
3576 | /*! | - | ||||||||||||||||||||||||
3577 | \internal | - | ||||||||||||||||||||||||
3578 | */ | - | ||||||||||||||||||||||||
3579 | - | |||||||||||||||||||||||||
3580 | const void *QVariant::constData() const | - | ||||||||||||||||||||||||
3581 | { | - | ||||||||||||||||||||||||
3582 | return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr); executed 8562213 times by 404 tests: return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr); Executed by:
| 25883-8562213 | ||||||||||||||||||||||||
3583 | } | - | ||||||||||||||||||||||||
3584 | - | |||||||||||||||||||||||||
3585 | /*! | - | ||||||||||||||||||||||||
3586 | \fn const void* QVariant::data() const | - | ||||||||||||||||||||||||
3587 | - | |||||||||||||||||||||||||
3588 | \internal | - | ||||||||||||||||||||||||
3589 | */ | - | ||||||||||||||||||||||||
3590 | - | |||||||||||||||||||||||||
3591 | /*! | - | ||||||||||||||||||||||||
3592 | \internal | - | ||||||||||||||||||||||||
3593 | */ | - | ||||||||||||||||||||||||
3594 | void* QVariant::data() | - | ||||||||||||||||||||||||
3595 | { | - | ||||||||||||||||||||||||
3596 | detach(); | - | ||||||||||||||||||||||||
3597 | return const_cast<void *>(constData()); executed 43743 times by 164 tests: return const_cast<void *>(constData()); Executed by:
| 43743 | ||||||||||||||||||||||||
3598 | } | - | ||||||||||||||||||||||||
3599 | - | |||||||||||||||||||||||||
3600 | - | |||||||||||||||||||||||||
3601 | /*! | - | ||||||||||||||||||||||||
3602 | Returns \c true if this is a null variant, false otherwise. A variant is | - | ||||||||||||||||||||||||
3603 | considered null if it contains a default constructed value or a built-in | - | ||||||||||||||||||||||||
3604 | type instance that has an isNull method, in which case the result | - | ||||||||||||||||||||||||
3605 | would be the same as calling isNull on the wrapped object. | - | ||||||||||||||||||||||||
3606 | - | |||||||||||||||||||||||||
3607 | \warning The result of the function doesn't affect == operator, which means | - | ||||||||||||||||||||||||
3608 | that two values can be equal even if one of them is null and another is not. | - | ||||||||||||||||||||||||
3609 | */ | - | ||||||||||||||||||||||||
3610 | bool QVariant::isNull() const | - | ||||||||||||||||||||||||
3611 | { | - | ||||||||||||||||||||||||
3612 | return handlerManager[d.type]->isNull(&d); executed 418643 times by 135 tests: return handlerManager[d.type]->isNull(&d); Executed by:
| 418643 | ||||||||||||||||||||||||
3613 | } | - | ||||||||||||||||||||||||
3614 | - | |||||||||||||||||||||||||
3615 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||||||||||||||
3616 | QDebug operator<<(QDebug dbg, const QVariant &v) | - | ||||||||||||||||||||||||
3617 | { | - | ||||||||||||||||||||||||
3618 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||
3619 | const uint typeId = v.d.type; | - | ||||||||||||||||||||||||
3620 | dbg.nospace() << "QVariant("; | - | ||||||||||||||||||||||||
3621 | if (typeId != QMetaType::UnknownType) {
| 2-81 | ||||||||||||||||||||||||
3622 | dbg << QMetaType::typeName(typeId) << ", "; | - | ||||||||||||||||||||||||
3623 | bool userStream = false; | - | ||||||||||||||||||||||||
3624 | bool canConvertToString = false; | - | ||||||||||||||||||||||||
3625 | if (typeId >= QMetaType::User) {
| 6-75 | ||||||||||||||||||||||||
3626 | userStream = QMetaType::debugStream(dbg, constData(v.d), typeId); | - | ||||||||||||||||||||||||
3627 | canConvertToString = v.canConvert<QString>(); | - | ||||||||||||||||||||||||
3628 | } executed 6 times by 2 tests: end of block Executed by:
| 6 | ||||||||||||||||||||||||
3629 | if (!userStream && canConvertToString)
| 1-80 | ||||||||||||||||||||||||
3630 | dbg << v.toString(); executed 1 time by 1 test: dbg << v.toString(); Executed by:
| 1 | ||||||||||||||||||||||||
3631 | else if (!userStream)
| 1-79 | ||||||||||||||||||||||||
3632 | handlerManager[typeId]->debugStream(dbg, v); executed 79 times by 5 tests: handlerManager[typeId]->debugStream(dbg, v); Executed by:
| 79 | ||||||||||||||||||||||||
3633 | } else { executed 81 times by 5 tests: end of block Executed by:
| 81 | ||||||||||||||||||||||||
3634 | dbg << "Invalid"; | - | ||||||||||||||||||||||||
3635 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||
3636 | dbg << ')'; | - | ||||||||||||||||||||||||
3637 | return dbg; executed 83 times by 5 tests: return dbg; Executed by:
| 83 | ||||||||||||||||||||||||
3638 | } | - | ||||||||||||||||||||||||
3639 | - | |||||||||||||||||||||||||
3640 | QDebug operator<<(QDebug dbg, const QVariant::Type p) | - | ||||||||||||||||||||||||
3641 | { | - | ||||||||||||||||||||||||
3642 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||
3643 | dbg.nospace() << "QVariant::" | - | ||||||||||||||||||||||||
3644 | << (int(p) != int(QMetaType::UnknownType) | - | ||||||||||||||||||||||||
3645 | ? QMetaType::typeName(p) | - | ||||||||||||||||||||||||
3646 | : "Invalid"); | - | ||||||||||||||||||||||||
3647 | return dbg; executed 54 times by 1 test: return dbg; Executed by:
| 54 | ||||||||||||||||||||||||
3648 | } | - | ||||||||||||||||||||||||
3649 | #endif | - | ||||||||||||||||||||||||
3650 | - | |||||||||||||||||||||||||
3651 | - | |||||||||||||||||||||||||
3652 | /*! \fn void QVariant::setValue(const T &value) | - | ||||||||||||||||||||||||
3653 | - | |||||||||||||||||||||||||
3654 | Stores a copy of \a value. If \c{T} is a type that QVariant | - | ||||||||||||||||||||||||
3655 | doesn't support, QMetaType is used to store the value. A compile | - | ||||||||||||||||||||||||
3656 | error will occur if QMetaType doesn't handle the type. | - | ||||||||||||||||||||||||
3657 | - | |||||||||||||||||||||||||
3658 | Example: | - | ||||||||||||||||||||||||
3659 | - | |||||||||||||||||||||||||
3660 | \snippet code/src_corelib_kernel_qvariant.cpp 4 | - | ||||||||||||||||||||||||
3661 | - | |||||||||||||||||||||||||
3662 | \sa value(), fromValue(), canConvert() | - | ||||||||||||||||||||||||
3663 | */ | - | ||||||||||||||||||||||||
3664 | - | |||||||||||||||||||||||||
3665 | /*! \fn T QVariant::value() const | - | ||||||||||||||||||||||||
3666 | - | |||||||||||||||||||||||||
3667 | Returns the stored value converted to the template type \c{T}. | - | ||||||||||||||||||||||||
3668 | Call canConvert() to find out whether a type can be converted. | - | ||||||||||||||||||||||||
3669 | If the value cannot be converted, a \l{default-constructed value} | - | ||||||||||||||||||||||||
3670 | will be returned. | - | ||||||||||||||||||||||||
3671 | - | |||||||||||||||||||||||||
3672 | If the type \c{T} is supported by QVariant, this function behaves | - | ||||||||||||||||||||||||
3673 | exactly as toString(), toInt() etc. | - | ||||||||||||||||||||||||
3674 | - | |||||||||||||||||||||||||
3675 | Example: | - | ||||||||||||||||||||||||
3676 | - | |||||||||||||||||||||||||
3677 | \snippet code/src_corelib_kernel_qvariant.cpp 5 | - | ||||||||||||||||||||||||
3678 | - | |||||||||||||||||||||||||
3679 | If the QVariant contains a pointer to a type derived from QObject then | - | ||||||||||||||||||||||||
3680 | \c{T} may be any QObject type. If the pointer stored in the QVariant can be | - | ||||||||||||||||||||||||
3681 | qobject_cast to T, then that result is returned. Otherwise a null pointer is | - | ||||||||||||||||||||||||
3682 | returned. Note that this only works for QObject subclasses which use the | - | ||||||||||||||||||||||||
3683 | Q_OBJECT macro. | - | ||||||||||||||||||||||||
3684 | - | |||||||||||||||||||||||||
3685 | If the QVariant contains a sequential container and \c{T} is QVariantList, the | - | ||||||||||||||||||||||||
3686 | elements of the container will be converted into \l {QVariant}s and returned as a QVariantList. | - | ||||||||||||||||||||||||
3687 | - | |||||||||||||||||||||||||
3688 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
3689 | - | |||||||||||||||||||||||||
3690 | \sa setValue(), fromValue(), canConvert(), Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE() | - | ||||||||||||||||||||||||
3691 | */ | - | ||||||||||||||||||||||||
3692 | - | |||||||||||||||||||||||||
3693 | /*! \fn bool QVariant::canConvert() const | - | ||||||||||||||||||||||||
3694 | - | |||||||||||||||||||||||||
3695 | Returns \c true if the variant can be converted to the template type \c{T}, | - | ||||||||||||||||||||||||
3696 | otherwise false. | - | ||||||||||||||||||||||||
3697 | - | |||||||||||||||||||||||||
3698 | Example: | - | ||||||||||||||||||||||||
3699 | - | |||||||||||||||||||||||||
3700 | \snippet code/src_corelib_kernel_qvariant.cpp 6 | - | ||||||||||||||||||||||||
3701 | - | |||||||||||||||||||||||||
3702 | A QVariant containing a pointer to a type derived from QObject will also return true for this | - | ||||||||||||||||||||||||
3703 | function if a qobject_cast to the template type \c{T} would succeed. Note that this only works | - | ||||||||||||||||||||||||
3704 | for QObject subclasses which use the Q_OBJECT macro. | - | ||||||||||||||||||||||||
3705 | - | |||||||||||||||||||||||||
3706 | \sa convert() | - | ||||||||||||||||||||||||
3707 | */ | - | ||||||||||||||||||||||||
3708 | - | |||||||||||||||||||||||||
3709 | /*! \fn static QVariant QVariant::fromValue(const T &value) | - | ||||||||||||||||||||||||
3710 | - | |||||||||||||||||||||||||
3711 | Returns a QVariant containing a copy of \a value. Behaves | - | ||||||||||||||||||||||||
3712 | exactly like setValue() otherwise. | - | ||||||||||||||||||||||||
3713 | - | |||||||||||||||||||||||||
3714 | Example: | - | ||||||||||||||||||||||||
3715 | - | |||||||||||||||||||||||||
3716 | \snippet code/src_corelib_kernel_qvariant.cpp 7 | - | ||||||||||||||||||||||||
3717 | - | |||||||||||||||||||||||||
3718 | \note If you are working with custom types, you should use | - | ||||||||||||||||||||||||
3719 | the Q_DECLARE_METATYPE() macro to register your custom type. | - | ||||||||||||||||||||||||
3720 | - | |||||||||||||||||||||||||
3721 | \sa setValue(), value() | - | ||||||||||||||||||||||||
3722 | */ | - | ||||||||||||||||||||||||
3723 | - | |||||||||||||||||||||||||
3724 | /*! | - | ||||||||||||||||||||||||
3725 | \fn QVariant qVariantFromValue(const T &value) | - | ||||||||||||||||||||||||
3726 | \relates QVariant | - | ||||||||||||||||||||||||
3727 | \obsolete | - | ||||||||||||||||||||||||
3728 | - | |||||||||||||||||||||||||
3729 | Returns a variant containing a copy of the given \a value | - | ||||||||||||||||||||||||
3730 | with template type \c{T}. | - | ||||||||||||||||||||||||
3731 | - | |||||||||||||||||||||||||
3732 | This function is equivalent to QVariant::fromValue(\a value). | - | ||||||||||||||||||||||||
3733 | - | |||||||||||||||||||||||||
3734 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
3735 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
3736 | to use the other form in new code. | - | ||||||||||||||||||||||||
3737 | - | |||||||||||||||||||||||||
3738 | For example, a QObject pointer can be stored in a variant with the | - | ||||||||||||||||||||||||
3739 | following code: | - | ||||||||||||||||||||||||
3740 | - | |||||||||||||||||||||||||
3741 | \snippet code/src_corelib_kernel_qvariant.cpp 8 | - | ||||||||||||||||||||||||
3742 | - | |||||||||||||||||||||||||
3743 | \sa QVariant::fromValue() | - | ||||||||||||||||||||||||
3744 | */ | - | ||||||||||||||||||||||||
3745 | - | |||||||||||||||||||||||||
3746 | /*! \fn void qVariantSetValue(QVariant &variant, const T &value) | - | ||||||||||||||||||||||||
3747 | \relates QVariant | - | ||||||||||||||||||||||||
3748 | \obsolete | - | ||||||||||||||||||||||||
3749 | - | |||||||||||||||||||||||||
3750 | Sets the contents of the given \a variant to a copy of the | - | ||||||||||||||||||||||||
3751 | \a value with the specified template type \c{T}. | - | ||||||||||||||||||||||||
3752 | - | |||||||||||||||||||||||||
3753 | This function is equivalent to QVariant::setValue(\a value). | - | ||||||||||||||||||||||||
3754 | - | |||||||||||||||||||||||||
3755 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
3756 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
3757 | to use the other form in new code. | - | ||||||||||||||||||||||||
3758 | - | |||||||||||||||||||||||||
3759 | \sa QVariant::setValue() | - | ||||||||||||||||||||||||
3760 | */ | - | ||||||||||||||||||||||||
3761 | - | |||||||||||||||||||||||||
3762 | /*! | - | ||||||||||||||||||||||||
3763 | \fn T qvariant_cast(const QVariant &value) | - | ||||||||||||||||||||||||
3764 | \relates QVariant | - | ||||||||||||||||||||||||
3765 | - | |||||||||||||||||||||||||
3766 | Returns the given \a value converted to the template type \c{T}. | - | ||||||||||||||||||||||||
3767 | - | |||||||||||||||||||||||||
3768 | This function is equivalent to QVariant::value(). | - | ||||||||||||||||||||||||
3769 | - | |||||||||||||||||||||||||
3770 | \sa QVariant::value() | - | ||||||||||||||||||||||||
3771 | */ | - | ||||||||||||||||||||||||
3772 | - | |||||||||||||||||||||||||
3773 | /*! \fn T qVariantValue(const QVariant &value) | - | ||||||||||||||||||||||||
3774 | \relates QVariant | - | ||||||||||||||||||||||||
3775 | \obsolete | - | ||||||||||||||||||||||||
3776 | - | |||||||||||||||||||||||||
3777 | Returns the given \a value converted to the template type \c{T}. | - | ||||||||||||||||||||||||
3778 | - | |||||||||||||||||||||||||
3779 | This function is equivalent to | - | ||||||||||||||||||||||||
3780 | \l{QVariant::value()}{QVariant::value}<T>(\a value). | - | ||||||||||||||||||||||||
3781 | - | |||||||||||||||||||||||||
3782 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
3783 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
3784 | to use the other form in new code. | - | ||||||||||||||||||||||||
3785 | - | |||||||||||||||||||||||||
3786 | \sa QVariant::value(), qvariant_cast() | - | ||||||||||||||||||||||||
3787 | */ | - | ||||||||||||||||||||||||
3788 | - | |||||||||||||||||||||||||
3789 | /*! \fn bool qVariantCanConvert(const QVariant &value) | - | ||||||||||||||||||||||||
3790 | \relates QVariant | - | ||||||||||||||||||||||||
3791 | \obsolete | - | ||||||||||||||||||||||||
3792 | - | |||||||||||||||||||||||||
3793 | Returns \c true if the given \a value can be converted to the | - | ||||||||||||||||||||||||
3794 | template type specified; otherwise returns \c false. | - | ||||||||||||||||||||||||
3795 | - | |||||||||||||||||||||||||
3796 | This function is equivalent to QVariant::canConvert(\a value). | - | ||||||||||||||||||||||||
3797 | - | |||||||||||||||||||||||||
3798 | \note This function was provided as a workaround for MSVC 6 | - | ||||||||||||||||||||||||
3799 | which did not support member template functions. It is advised | - | ||||||||||||||||||||||||
3800 | to use the other form in new code. | - | ||||||||||||||||||||||||
3801 | - | |||||||||||||||||||||||||
3802 | \sa QVariant::canConvert() | - | ||||||||||||||||||||||||
3803 | */ | - | ||||||||||||||||||||||||
3804 | - | |||||||||||||||||||||||||
3805 | /*! | - | ||||||||||||||||||||||||
3806 | \typedef QVariantList | - | ||||||||||||||||||||||||
3807 | \relates QVariant | - | ||||||||||||||||||||||||
3808 | - | |||||||||||||||||||||||||
3809 | Synonym for QList<QVariant>. | - | ||||||||||||||||||||||||
3810 | */ | - | ||||||||||||||||||||||||
3811 | - | |||||||||||||||||||||||||
3812 | /*! | - | ||||||||||||||||||||||||
3813 | \typedef QVariantMap | - | ||||||||||||||||||||||||
3814 | \relates QVariant | - | ||||||||||||||||||||||||
3815 | - | |||||||||||||||||||||||||
3816 | Synonym for QMap<QString, QVariant>. | - | ||||||||||||||||||||||||
3817 | */ | - | ||||||||||||||||||||||||
3818 | - | |||||||||||||||||||||||||
3819 | /*! | - | ||||||||||||||||||||||||
3820 | \typedef QVariantHash | - | ||||||||||||||||||||||||
3821 | \relates QVariant | - | ||||||||||||||||||||||||
3822 | \since 4.5 | - | ||||||||||||||||||||||||
3823 | - | |||||||||||||||||||||||||
3824 | Synonym for QHash<QString, QVariant>. | - | ||||||||||||||||||||||||
3825 | */ | - | ||||||||||||||||||||||||
3826 | - | |||||||||||||||||||||||||
3827 | /*! | - | ||||||||||||||||||||||||
3828 | \typedef QVariant::DataPtr | - | ||||||||||||||||||||||||
3829 | \internal | - | ||||||||||||||||||||||||
3830 | */ | - | ||||||||||||||||||||||||
3831 | - | |||||||||||||||||||||||||
3832 | /*! | - | ||||||||||||||||||||||||
3833 | \fn DataPtr &QVariant::data_ptr() | - | ||||||||||||||||||||||||
3834 | \internal | - | ||||||||||||||||||||||||
3835 | */ | - | ||||||||||||||||||||||||
3836 | - | |||||||||||||||||||||||||
3837 | /*! | - | ||||||||||||||||||||||||
3838 | \fn const DataPtr &QVariant::data_ptr() const | - | ||||||||||||||||||||||||
3839 | \internal | - | ||||||||||||||||||||||||
3840 | */ | - | ||||||||||||||||||||||||
3841 | - | |||||||||||||||||||||||||
3842 | /*! | - | ||||||||||||||||||||||||
3843 | \class QSequentialIterable | - | ||||||||||||||||||||||||
3844 | \since 5.2 | - | ||||||||||||||||||||||||
3845 | \inmodule QtCore | - | ||||||||||||||||||||||||
3846 | \brief The QSequentialIterable class is an iterable interface for a container in a QVariant. | - | ||||||||||||||||||||||||
3847 | - | |||||||||||||||||||||||||
3848 | This class allows several methods of accessing the elements of a container held within | - | ||||||||||||||||||||||||
3849 | a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can | - | ||||||||||||||||||||||||
3850 | be converted to a QVariantList. | - | ||||||||||||||||||||||||
3851 | - | |||||||||||||||||||||||||
3852 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
3853 | - | |||||||||||||||||||||||||
3854 | The container itself is not copied before iterating over it. | - | ||||||||||||||||||||||||
3855 | - | |||||||||||||||||||||||||
3856 | \sa QVariant | - | ||||||||||||||||||||||||
3857 | */ | - | ||||||||||||||||||||||||
3858 | - | |||||||||||||||||||||||||
3859 | /*! | - | ||||||||||||||||||||||||
3860 | \internal | - | ||||||||||||||||||||||||
3861 | */ | - | ||||||||||||||||||||||||
3862 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | - | ||||||||||||||||||||||||
3863 | QSequentialIterable::QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl impl) | - | ||||||||||||||||||||||||
3864 | #else | - | ||||||||||||||||||||||||
3865 | QSequentialIterable::QSequentialIterable(const QtMetaTypePrivate::QSequentialIterableImpl &impl) | - | ||||||||||||||||||||||||
3866 | #endif | - | ||||||||||||||||||||||||
3867 | : m_impl(impl) | - | ||||||||||||||||||||||||
3868 | { | - | ||||||||||||||||||||||||
3869 | } executed 50 times by 1 test: end of block Executed by:
| 50 | ||||||||||||||||||||||||
3870 | - | |||||||||||||||||||||||||
3871 | QSequentialIterable::const_iterator::const_iterator(const QSequentialIterable &iter, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
3872 | : m_impl(iter.m_impl), ref(ref_) | - | ||||||||||||||||||||||||
3873 | { | - | ||||||||||||||||||||||||
3874 | ref->ref(); | - | ||||||||||||||||||||||||
3875 | } executed 149 times by 1 test: end of block Executed by:
| 149 | ||||||||||||||||||||||||
3876 | - | |||||||||||||||||||||||||
3877 | QSequentialIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QSequentialIterableImpl &impl, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
3878 | : m_impl(impl), ref(ref_) | - | ||||||||||||||||||||||||
3879 | { | - | ||||||||||||||||||||||||
3880 | ref->ref(); | - | ||||||||||||||||||||||||
3881 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
3882 | - | |||||||||||||||||||||||||
3883 | void QSequentialIterable::const_iterator::begin() | - | ||||||||||||||||||||||||
3884 | { | - | ||||||||||||||||||||||||
3885 | m_impl.moveToBegin(); | - | ||||||||||||||||||||||||
3886 | } executed 75 times by 1 test: end of block Executed by:
| 75 | ||||||||||||||||||||||||
3887 | - | |||||||||||||||||||||||||
3888 | void QSequentialIterable::const_iterator::end() | - | ||||||||||||||||||||||||
3889 | { | - | ||||||||||||||||||||||||
3890 | m_impl.moveToEnd(); | - | ||||||||||||||||||||||||
3891 | } executed 74 times by 1 test: end of block Executed by:
| 74 | ||||||||||||||||||||||||
3892 | - | |||||||||||||||||||||||||
3893 | /*! \fn QSequentialIterable::const_iterator QSequentialIterable::begin() const | - | ||||||||||||||||||||||||
3894 | - | |||||||||||||||||||||||||
3895 | Returns a QSequentialIterable::const_iterator for the beginning of the container. This | - | ||||||||||||||||||||||||
3896 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
3897 | - | |||||||||||||||||||||||||
3898 | \sa end() | - | ||||||||||||||||||||||||
3899 | */ | - | ||||||||||||||||||||||||
3900 | QSequentialIterable::const_iterator QSequentialIterable::begin() const | - | ||||||||||||||||||||||||
3901 | { | - | ||||||||||||||||||||||||
3902 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
3903 | it.begin(); | - | ||||||||||||||||||||||||
3904 | return it; executed 75 times by 1 test: return it; Executed by:
| 75 | ||||||||||||||||||||||||
3905 | } | - | ||||||||||||||||||||||||
3906 | - | |||||||||||||||||||||||||
3907 | /*! | - | ||||||||||||||||||||||||
3908 | Returns a QSequentialIterable::const_iterator for the end of the container. This | - | ||||||||||||||||||||||||
3909 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
3910 | - | |||||||||||||||||||||||||
3911 | \sa begin() | - | ||||||||||||||||||||||||
3912 | */ | - | ||||||||||||||||||||||||
3913 | QSequentialIterable::const_iterator QSequentialIterable::end() const | - | ||||||||||||||||||||||||
3914 | { | - | ||||||||||||||||||||||||
3915 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
3916 | it.end(); | - | ||||||||||||||||||||||||
3917 | return it; executed 74 times by 1 test: return it; Executed by:
| 74 | ||||||||||||||||||||||||
3918 | } | - | ||||||||||||||||||||||||
3919 | - | |||||||||||||||||||||||||
3920 | /*! | - | ||||||||||||||||||||||||
3921 | Returns the element at position \a idx in the container. | - | ||||||||||||||||||||||||
3922 | */ | - | ||||||||||||||||||||||||
3923 | QVariant QSequentialIterable::at(int idx) const | - | ||||||||||||||||||||||||
3924 | { | - | ||||||||||||||||||||||||
3925 | const QtMetaTypePrivate::VariantData d = m_impl.at(idx); | - | ||||||||||||||||||||||||
3926 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 42-102 | ||||||||||||||||||||||||
3927 | return *reinterpret_cast<const QVariant*>(d.data); executed 42 times by 1 test: return *reinterpret_cast<const QVariant*>(d.data); Executed by:
| 42 | ||||||||||||||||||||||||
3928 | return QVariant(d.metaTypeId, d.data, d.flags); executed 102 times by 1 test: return QVariant(d.metaTypeId, d.data, d.flags); Executed by:
| 102 | ||||||||||||||||||||||||
3929 | } | - | ||||||||||||||||||||||||
3930 | - | |||||||||||||||||||||||||
3931 | /*! | - | ||||||||||||||||||||||||
3932 | Returns the number of elements in the container. | - | ||||||||||||||||||||||||
3933 | */ | - | ||||||||||||||||||||||||
3934 | int QSequentialIterable::size() const | - | ||||||||||||||||||||||||
3935 | { | - | ||||||||||||||||||||||||
3936 | return m_impl.size(); executed 145 times by 1 test: return m_impl.size(); Executed by:
| 145 | ||||||||||||||||||||||||
3937 | } | - | ||||||||||||||||||||||||
3938 | - | |||||||||||||||||||||||||
3939 | /*! | - | ||||||||||||||||||||||||
3940 | Returns whether it is possible to iterate over the container in reverse. This | - | ||||||||||||||||||||||||
3941 | corresponds to the std::bidirectional_iterator_tag iterator trait of the | - | ||||||||||||||||||||||||
3942 | const_iterator of the container. | - | ||||||||||||||||||||||||
3943 | */ | - | ||||||||||||||||||||||||
3944 | bool QSequentialIterable::canReverseIterate() const | - | ||||||||||||||||||||||||
3945 | { | - | ||||||||||||||||||||||||
3946 | return m_impl._iteratorCapabilities & QtMetaTypePrivate::BiDirectionalCapability; never executed: return m_impl._iteratorCapabilities & QtMetaTypePrivate::BiDirectionalCapability; | 0 | ||||||||||||||||||||||||
3947 | } | - | ||||||||||||||||||||||||
3948 | - | |||||||||||||||||||||||||
3949 | /*! | - | ||||||||||||||||||||||||
3950 | \class QSequentialIterable::const_iterator | - | ||||||||||||||||||||||||
3951 | \since 5.2 | - | ||||||||||||||||||||||||
3952 | \inmodule QtCore | - | ||||||||||||||||||||||||
3953 | \brief The QSequentialIterable::const_iterator allows iteration over a container in a QVariant. | - | ||||||||||||||||||||||||
3954 | - | |||||||||||||||||||||||||
3955 | A QSequentialIterable::const_iterator can only be created by a QSequentialIterable instance, | - | ||||||||||||||||||||||||
3956 | and can be used in a way similar to other stl-style iterators. | - | ||||||||||||||||||||||||
3957 | - | |||||||||||||||||||||||||
3958 | \snippet code/src_corelib_kernel_qvariant.cpp 9 | - | ||||||||||||||||||||||||
3959 | - | |||||||||||||||||||||||||
3960 | \sa QSequentialIterable | - | ||||||||||||||||||||||||
3961 | */ | - | ||||||||||||||||||||||||
3962 | - | |||||||||||||||||||||||||
3963 | - | |||||||||||||||||||||||||
3964 | /*! | - | ||||||||||||||||||||||||
3965 | Destroys the QSequentialIterable::const_iterator. | - | ||||||||||||||||||||||||
3966 | */ | - | ||||||||||||||||||||||||
3967 | QSequentialIterable::const_iterator::~const_iterator() { | - | ||||||||||||||||||||||||
3968 | if (!ref->deref()) {
| 1-152 | ||||||||||||||||||||||||
3969 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
3970 | delete ref; | - | ||||||||||||||||||||||||
3971 | } executed 152 times by 1 test: end of block Executed by:
| 152 | ||||||||||||||||||||||||
3972 | } executed 153 times by 1 test: end of block Executed by:
| 153 | ||||||||||||||||||||||||
3973 | - | |||||||||||||||||||||||||
3974 | /*! | - | ||||||||||||||||||||||||
3975 | Creates a copy of \a other. | - | ||||||||||||||||||||||||
3976 | */ | - | ||||||||||||||||||||||||
3977 | QSequentialIterable::const_iterator::const_iterator(const const_iterator &other) | - | ||||||||||||||||||||||||
3978 | : m_impl(other.m_impl), ref(other.ref) | - | ||||||||||||||||||||||||
3979 | { | - | ||||||||||||||||||||||||
3980 | ref->ref(); | - | ||||||||||||||||||||||||
3981 | } never executed: end of block | 0 | ||||||||||||||||||||||||
3982 | - | |||||||||||||||||||||||||
3983 | /*! | - | ||||||||||||||||||||||||
3984 | Assigns \a other to this. | - | ||||||||||||||||||||||||
3985 | */ | - | ||||||||||||||||||||||||
3986 | QSequentialIterable::const_iterator& | - | ||||||||||||||||||||||||
3987 | QSequentialIterable::const_iterator::operator=(const const_iterator &other) | - | ||||||||||||||||||||||||
3988 | { | - | ||||||||||||||||||||||||
3989 | other.ref->ref(); | - | ||||||||||||||||||||||||
3990 | if (!ref->deref()) {
| 0-1 | ||||||||||||||||||||||||
3991 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
3992 | delete ref; | - | ||||||||||||||||||||||||
3993 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
3994 | m_impl = other.m_impl; | - | ||||||||||||||||||||||||
3995 | ref = other.ref; | - | ||||||||||||||||||||||||
3996 | return *this; executed 1 time by 1 test: return *this; Executed by:
| 1 | ||||||||||||||||||||||||
3997 | } | - | ||||||||||||||||||||||||
3998 | - | |||||||||||||||||||||||||
3999 | /*! | - | ||||||||||||||||||||||||
4000 | Returns the current item, converted to a QVariant. | - | ||||||||||||||||||||||||
4001 | */ | - | ||||||||||||||||||||||||
4002 | const QVariant QSequentialIterable::const_iterator::operator*() const | - | ||||||||||||||||||||||||
4003 | { | - | ||||||||||||||||||||||||
4004 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrent(); | - | ||||||||||||||||||||||||
4005 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 67-155 | ||||||||||||||||||||||||
4006 | return *reinterpret_cast<const QVariant*>(d.data); executed 67 times by 1 test: return *reinterpret_cast<const QVariant*>(d.data); Executed by:
| 67 | ||||||||||||||||||||||||
4007 | return QVariant(d.metaTypeId, d.data, d.flags); executed 155 times by 1 test: return QVariant(d.metaTypeId, d.data, d.flags); Executed by:
| 155 | ||||||||||||||||||||||||
4008 | } | - | ||||||||||||||||||||||||
4009 | - | |||||||||||||||||||||||||
4010 | /*! | - | ||||||||||||||||||||||||
4011 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||||||||
4012 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
4013 | - | |||||||||||||||||||||||||
4014 | \sa operator!=() | - | ||||||||||||||||||||||||
4015 | */ | - | ||||||||||||||||||||||||
4016 | bool QSequentialIterable::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||||||||||||||
4017 | { | - | ||||||||||||||||||||||||
4018 | return m_impl.equal(other.m_impl); never executed: return m_impl.equal(other.m_impl); | 0 | ||||||||||||||||||||||||
4019 | } | - | ||||||||||||||||||||||||
4020 | - | |||||||||||||||||||||||||
4021 | /*! | - | ||||||||||||||||||||||||
4022 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||||||||
4023 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
4024 | - | |||||||||||||||||||||||||
4025 | \sa operator==() | - | ||||||||||||||||||||||||
4026 | */ | - | ||||||||||||||||||||||||
4027 | bool QSequentialIterable::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||||||||||||||
4028 | { | - | ||||||||||||||||||||||||
4029 | return !m_impl.equal(other.m_impl); executed 292 times by 1 test: return !m_impl.equal(other.m_impl); Executed by:
| 292 | ||||||||||||||||||||||||
4030 | } | - | ||||||||||||||||||||||||
4031 | - | |||||||||||||||||||||||||
4032 | /*! | - | ||||||||||||||||||||||||
4033 | The prefix ++ operator (\c{++it}) advances the iterator to the | - | ||||||||||||||||||||||||
4034 | next item in the container and returns an iterator to the new current | - | ||||||||||||||||||||||||
4035 | item. | - | ||||||||||||||||||||||||
4036 | - | |||||||||||||||||||||||||
4037 | Calling this function on QSequentialIterable::end() leads to undefined results. | - | ||||||||||||||||||||||||
4038 | - | |||||||||||||||||||||||||
4039 | \sa operator--() | - | ||||||||||||||||||||||||
4040 | */ | - | ||||||||||||||||||||||||
4041 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator++() | - | ||||||||||||||||||||||||
4042 | { | - | ||||||||||||||||||||||||
4043 | m_impl.advance(1); | - | ||||||||||||||||||||||||
4044 | return *this; executed 218 times by 1 test: return *this; Executed by:
| 218 | ||||||||||||||||||||||||
4045 | } | - | ||||||||||||||||||||||||
4046 | - | |||||||||||||||||||||||||
4047 | /*! | - | ||||||||||||||||||||||||
4048 | \overload | - | ||||||||||||||||||||||||
4049 | - | |||||||||||||||||||||||||
4050 | The postfix ++ operator (\c{it++}) advances the iterator to the | - | ||||||||||||||||||||||||
4051 | next item in the container and returns an iterator to the previously | - | ||||||||||||||||||||||||
4052 | current item. | - | ||||||||||||||||||||||||
4053 | */ | - | ||||||||||||||||||||||||
4054 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator++(int) | - | ||||||||||||||||||||||||
4055 | { | - | ||||||||||||||||||||||||
4056 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
4057 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4058 | m_impl.advance(1); | - | ||||||||||||||||||||||||
4059 | return const_iterator(impl, new QAtomicInt(0)); executed 3 times by 1 test: return const_iterator(impl, new QAtomicInt(0)); Executed by:
| 3 | ||||||||||||||||||||||||
4060 | } | - | ||||||||||||||||||||||||
4061 | - | |||||||||||||||||||||||||
4062 | /*! | - | ||||||||||||||||||||||||
4063 | The prefix -- operator (\c{--it}) makes the preceding item | - | ||||||||||||||||||||||||
4064 | current and returns an iterator to the new current item. | - | ||||||||||||||||||||||||
4065 | - | |||||||||||||||||||||||||
4066 | Calling this function on QSequentialIterable::begin() leads to undefined results. | - | ||||||||||||||||||||||||
4067 | - | |||||||||||||||||||||||||
4068 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
4069 | leads to undefined results. | - | ||||||||||||||||||||||||
4070 | - | |||||||||||||||||||||||||
4071 | \sa operator++(), canReverseIterate() | - | ||||||||||||||||||||||||
4072 | */ | - | ||||||||||||||||||||||||
4073 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator--() | - | ||||||||||||||||||||||||
4074 | { | - | ||||||||||||||||||||||||
4075 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
4076 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
4077 | } | - | ||||||||||||||||||||||||
4078 | - | |||||||||||||||||||||||||
4079 | /*! | - | ||||||||||||||||||||||||
4080 | \overload | - | ||||||||||||||||||||||||
4081 | - | |||||||||||||||||||||||||
4082 | The postfix -- operator (\c{it--}) makes the preceding item | - | ||||||||||||||||||||||||
4083 | current and returns an iterator to the previously current item. | - | ||||||||||||||||||||||||
4084 | - | |||||||||||||||||||||||||
4085 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
4086 | leads to undefined results. | - | ||||||||||||||||||||||||
4087 | - | |||||||||||||||||||||||||
4088 | \sa canReverseIterate() | - | ||||||||||||||||||||||||
4089 | */ | - | ||||||||||||||||||||||||
4090 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator--(int) | - | ||||||||||||||||||||||||
4091 | { | - | ||||||||||||||||||||||||
4092 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
4093 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4094 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
4095 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
4096 | } | - | ||||||||||||||||||||||||
4097 | - | |||||||||||||||||||||||||
4098 | /*! | - | ||||||||||||||||||||||||
4099 | Advances the iterator by \a j items. | - | ||||||||||||||||||||||||
4100 | - | |||||||||||||||||||||||||
4101 | \sa operator-=(), operator+() | - | ||||||||||||||||||||||||
4102 | */ | - | ||||||||||||||||||||||||
4103 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator+=(int j) | - | ||||||||||||||||||||||||
4104 | { | - | ||||||||||||||||||||||||
4105 | m_impl.advance(j); | - | ||||||||||||||||||||||||
4106 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
4107 | } | - | ||||||||||||||||||||||||
4108 | - | |||||||||||||||||||||||||
4109 | /*! | - | ||||||||||||||||||||||||
4110 | Makes the iterator go back by \a j items. | - | ||||||||||||||||||||||||
4111 | - | |||||||||||||||||||||||||
4112 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
4113 | leads to undefined results. | - | ||||||||||||||||||||||||
4114 | - | |||||||||||||||||||||||||
4115 | \sa operator+=(), operator-(), canReverseIterate() | - | ||||||||||||||||||||||||
4116 | */ | - | ||||||||||||||||||||||||
4117 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator-=(int j) | - | ||||||||||||||||||||||||
4118 | { | - | ||||||||||||||||||||||||
4119 | m_impl.advance(-j); | - | ||||||||||||||||||||||||
4120 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
4121 | } | - | ||||||||||||||||||||||||
4122 | - | |||||||||||||||||||||||||
4123 | /*! | - | ||||||||||||||||||||||||
4124 | Returns an iterator to the item at \a j positions forward from | - | ||||||||||||||||||||||||
4125 | this iterator. | - | ||||||||||||||||||||||||
4126 | - | |||||||||||||||||||||||||
4127 | \sa operator-(), operator+=() | - | ||||||||||||||||||||||||
4128 | */ | - | ||||||||||||||||||||||||
4129 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator+(int j) const | - | ||||||||||||||||||||||||
4130 | { | - | ||||||||||||||||||||||||
4131 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
4132 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4133 | impl.advance(j); | - | ||||||||||||||||||||||||
4134 | return const_iterator(impl, new QAtomicInt(0)); executed 1 time by 1 test: return const_iterator(impl, new QAtomicInt(0)); Executed by:
| 1 | ||||||||||||||||||||||||
4135 | } | - | ||||||||||||||||||||||||
4136 | - | |||||||||||||||||||||||||
4137 | /*! | - | ||||||||||||||||||||||||
4138 | Returns an iterator to the item at \a j positions backward from | - | ||||||||||||||||||||||||
4139 | this iterator. | - | ||||||||||||||||||||||||
4140 | - | |||||||||||||||||||||||||
4141 | If the container in the QVariant does not support bi-directional iteration, calling this function | - | ||||||||||||||||||||||||
4142 | leads to undefined results. | - | ||||||||||||||||||||||||
4143 | - | |||||||||||||||||||||||||
4144 | \sa operator+(), operator-=(), canReverseIterate() | - | ||||||||||||||||||||||||
4145 | */ | - | ||||||||||||||||||||||||
4146 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator-(int j) const | - | ||||||||||||||||||||||||
4147 | { | - | ||||||||||||||||||||||||
4148 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||||||||||||||
4149 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4150 | impl.advance(-j); | - | ||||||||||||||||||||||||
4151 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
4152 | } | - | ||||||||||||||||||||||||
4153 | - | |||||||||||||||||||||||||
4154 | /*! | - | ||||||||||||||||||||||||
4155 | \class QAssociativeIterable | - | ||||||||||||||||||||||||
4156 | \since 5.2 | - | ||||||||||||||||||||||||
4157 | \inmodule QtCore | - | ||||||||||||||||||||||||
4158 | \brief The QAssociativeIterable class is an iterable interface for an associative container in a QVariant. | - | ||||||||||||||||||||||||
4159 | - | |||||||||||||||||||||||||
4160 | This class allows several methods of accessing the elements of an associative container held within | - | ||||||||||||||||||||||||
4161 | a QVariant. An instance of QAssociativeIterable can be extracted from a QVariant if it can | - | ||||||||||||||||||||||||
4162 | be converted to a QVariantHash or QVariantMap. | - | ||||||||||||||||||||||||
4163 | - | |||||||||||||||||||||||||
4164 | \snippet code/src_corelib_kernel_qvariant.cpp 10 | - | ||||||||||||||||||||||||
4165 | - | |||||||||||||||||||||||||
4166 | The container itself is not copied before iterating over it. | - | ||||||||||||||||||||||||
4167 | - | |||||||||||||||||||||||||
4168 | \sa QVariant | - | ||||||||||||||||||||||||
4169 | */ | - | ||||||||||||||||||||||||
4170 | - | |||||||||||||||||||||||||
4171 | /*! | - | ||||||||||||||||||||||||
4172 | \internal | - | ||||||||||||||||||||||||
4173 | */ | - | ||||||||||||||||||||||||
4174 | #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) | - | ||||||||||||||||||||||||
4175 | QAssociativeIterable::QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl impl) | - | ||||||||||||||||||||||||
4176 | #else | - | ||||||||||||||||||||||||
4177 | QAssociativeIterable::QAssociativeIterable(const QtMetaTypePrivate::QAssociativeIterableImpl &impl) | - | ||||||||||||||||||||||||
4178 | #endif | - | ||||||||||||||||||||||||
4179 | : m_impl(impl) | - | ||||||||||||||||||||||||
4180 | { | - | ||||||||||||||||||||||||
4181 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||
4182 | - | |||||||||||||||||||||||||
4183 | QAssociativeIterable::const_iterator::const_iterator(const QAssociativeIterable &iter, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
4184 | : m_impl(iter.m_impl), ref(ref_) | - | ||||||||||||||||||||||||
4185 | { | - | ||||||||||||||||||||||||
4186 | ref->ref(); | - | ||||||||||||||||||||||||
4187 | } executed 71 times by 1 test: end of block Executed by:
| 71 | ||||||||||||||||||||||||
4188 | - | |||||||||||||||||||||||||
4189 | QAssociativeIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QAssociativeIterableImpl &impl, QAtomicInt *ref_) | - | ||||||||||||||||||||||||
4190 | : m_impl(impl), ref(ref_) | - | ||||||||||||||||||||||||
4191 | { | - | ||||||||||||||||||||||||
4192 | ref->ref(); | - | ||||||||||||||||||||||||
4193 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||||||||||||||
4194 | - | |||||||||||||||||||||||||
4195 | void QAssociativeIterable::const_iterator::begin() | - | ||||||||||||||||||||||||
4196 | { | - | ||||||||||||||||||||||||
4197 | m_impl.begin(); | - | ||||||||||||||||||||||||
4198 | } executed 21 times by 1 test: end of block Executed by:
| 21 | ||||||||||||||||||||||||
4199 | - | |||||||||||||||||||||||||
4200 | void QAssociativeIterable::const_iterator::end() | - | ||||||||||||||||||||||||
4201 | { | - | ||||||||||||||||||||||||
4202 | m_impl.end(); | - | ||||||||||||||||||||||||
4203 | } executed 35 times by 1 test: end of block Executed by:
| 35 | ||||||||||||||||||||||||
4204 | - | |||||||||||||||||||||||||
4205 | void QAssociativeIterable::const_iterator::find(const QVariant &key) | - | ||||||||||||||||||||||||
4206 | { | - | ||||||||||||||||||||||||
4207 | Q_ASSERT(key.userType() == m_impl._metaType_id_key); | - | ||||||||||||||||||||||||
4208 | const QtMetaTypePrivate::VariantData dkey(key.userType(), key.constData(), 0 /*key.flags()*/); | - | ||||||||||||||||||||||||
4209 | m_impl.find(dkey); | - | ||||||||||||||||||||||||
4210 | } executed 15 times by 1 test: end of block Executed by:
| 15 | ||||||||||||||||||||||||
4211 | - | |||||||||||||||||||||||||
4212 | /*! | - | ||||||||||||||||||||||||
4213 | Returns a QAssociativeIterable::const_iterator for the beginning of the container. This | - | ||||||||||||||||||||||||
4214 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
4215 | - | |||||||||||||||||||||||||
4216 | \sa end() | - | ||||||||||||||||||||||||
4217 | */ | - | ||||||||||||||||||||||||
4218 | QAssociativeIterable::const_iterator QAssociativeIterable::begin() const | - | ||||||||||||||||||||||||
4219 | { | - | ||||||||||||||||||||||||
4220 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
4221 | it.begin(); | - | ||||||||||||||||||||||||
4222 | return it; executed 21 times by 1 test: return it; Executed by:
| 21 | ||||||||||||||||||||||||
4223 | } | - | ||||||||||||||||||||||||
4224 | - | |||||||||||||||||||||||||
4225 | /*! | - | ||||||||||||||||||||||||
4226 | Returns a QAssociativeIterable::const_iterator for the end of the container. This | - | ||||||||||||||||||||||||
4227 | can be used in stl-style iteration. | - | ||||||||||||||||||||||||
4228 | - | |||||||||||||||||||||||||
4229 | \sa begin() | - | ||||||||||||||||||||||||
4230 | */ | - | ||||||||||||||||||||||||
4231 | QAssociativeIterable::const_iterator QAssociativeIterable::end() const | - | ||||||||||||||||||||||||
4232 | { | - | ||||||||||||||||||||||||
4233 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
4234 | it.end(); | - | ||||||||||||||||||||||||
4235 | return it; executed 35 times by 1 test: return it; Executed by:
| 35 | ||||||||||||||||||||||||
4236 | } | - | ||||||||||||||||||||||||
4237 | - | |||||||||||||||||||||||||
4238 | /*! | - | ||||||||||||||||||||||||
4239 | \since 5.5 | - | ||||||||||||||||||||||||
4240 | - | |||||||||||||||||||||||||
4241 | Returns a QAssociativeIterable::const_iterator for the given key \a key | - | ||||||||||||||||||||||||
4242 | in the container, if the types are convertible. | - | ||||||||||||||||||||||||
4243 | - | |||||||||||||||||||||||||
4244 | If the key is not found, returns end(). | - | ||||||||||||||||||||||||
4245 | - | |||||||||||||||||||||||||
4246 | This can be used in stl-style iteration. | - | ||||||||||||||||||||||||
4247 | - | |||||||||||||||||||||||||
4248 | \sa begin(), end(), value() | - | ||||||||||||||||||||||||
4249 | */ | - | ||||||||||||||||||||||||
4250 | QAssociativeIterable::const_iterator QAssociativeIterable::find(const QVariant &key) const | - | ||||||||||||||||||||||||
4251 | { | - | ||||||||||||||||||||||||
4252 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||||||||||||||
4253 | QVariant key_ = key; | - | ||||||||||||||||||||||||
4254 | if (key_.canConvert(m_impl._metaType_id_key) && key_.convert(m_impl._metaType_id_key))
| 0-15 | ||||||||||||||||||||||||
4255 | it.find(key_); executed 15 times by 1 test: it.find(key_); Executed by:
| 15 | ||||||||||||||||||||||||
4256 | else | - | ||||||||||||||||||||||||
4257 | it.end(); never executed: it.end(); | 0 | ||||||||||||||||||||||||
4258 | return it; executed 15 times by 1 test: return it; Executed by:
| 15 | ||||||||||||||||||||||||
4259 | } | - | ||||||||||||||||||||||||
4260 | - | |||||||||||||||||||||||||
4261 | /*! | - | ||||||||||||||||||||||||
4262 | Returns the value for the given \a key in the container, if the types are convertible. | - | ||||||||||||||||||||||||
4263 | - | |||||||||||||||||||||||||
4264 | \sa find() | - | ||||||||||||||||||||||||
4265 | */ | - | ||||||||||||||||||||||||
4266 | QVariant QAssociativeIterable::value(const QVariant &key) const | - | ||||||||||||||||||||||||
4267 | { | - | ||||||||||||||||||||||||
4268 | const const_iterator it = find(key); | - | ||||||||||||||||||||||||
4269 | if (it == end())
| 0-6 | ||||||||||||||||||||||||
4270 | return QVariant(); never executed: return QVariant(); | 0 | ||||||||||||||||||||||||
4271 | return *it; executed 6 times by 1 test: return *it; Executed by:
| 6 | ||||||||||||||||||||||||
4272 | } | - | ||||||||||||||||||||||||
4273 | - | |||||||||||||||||||||||||
4274 | /*! | - | ||||||||||||||||||||||||
4275 | Returns the number of elements in the container. | - | ||||||||||||||||||||||||
4276 | */ | - | ||||||||||||||||||||||||
4277 | int QAssociativeIterable::size() const | - | ||||||||||||||||||||||||
4278 | { | - | ||||||||||||||||||||||||
4279 | return m_impl.size(); executed 6 times by 1 test: return m_impl.size(); Executed by:
| 6 | ||||||||||||||||||||||||
4280 | } | - | ||||||||||||||||||||||||
4281 | - | |||||||||||||||||||||||||
4282 | /*! | - | ||||||||||||||||||||||||
4283 | \class QAssociativeIterable::const_iterator | - | ||||||||||||||||||||||||
4284 | \since 5.2 | - | ||||||||||||||||||||||||
4285 | \inmodule QtCore | - | ||||||||||||||||||||||||
4286 | \brief The QAssociativeIterable::const_iterator allows iteration over a container in a QVariant. | - | ||||||||||||||||||||||||
4287 | - | |||||||||||||||||||||||||
4288 | A QAssociativeIterable::const_iterator can only be created by a QAssociativeIterable instance, | - | ||||||||||||||||||||||||
4289 | and can be used in a way similar to other stl-style iterators. | - | ||||||||||||||||||||||||
4290 | - | |||||||||||||||||||||||||
4291 | \snippet code/src_corelib_kernel_qvariant.cpp 10 | - | ||||||||||||||||||||||||
4292 | - | |||||||||||||||||||||||||
4293 | \sa QAssociativeIterable | - | ||||||||||||||||||||||||
4294 | */ | - | ||||||||||||||||||||||||
4295 | - | |||||||||||||||||||||||||
4296 | - | |||||||||||||||||||||||||
4297 | /*! | - | ||||||||||||||||||||||||
4298 | Destroys the QAssociativeIterable::const_iterator. | - | ||||||||||||||||||||||||
4299 | */ | - | ||||||||||||||||||||||||
4300 | QAssociativeIterable::const_iterator::~const_iterator() | - | ||||||||||||||||||||||||
4301 | { | - | ||||||||||||||||||||||||
4302 | if (!ref->deref()) {
| 1-74 | ||||||||||||||||||||||||
4303 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
4304 | delete ref; | - | ||||||||||||||||||||||||
4305 | } executed 74 times by 1 test: end of block Executed by:
| 74 | ||||||||||||||||||||||||
4306 | } executed 75 times by 1 test: end of block Executed by:
| 75 | ||||||||||||||||||||||||
4307 | - | |||||||||||||||||||||||||
4308 | /*! | - | ||||||||||||||||||||||||
4309 | Creates a copy of \a other. | - | ||||||||||||||||||||||||
4310 | */ | - | ||||||||||||||||||||||||
4311 | QAssociativeIterable::const_iterator::const_iterator(const const_iterator &other) | - | ||||||||||||||||||||||||
4312 | : m_impl(other.m_impl), ref(other.ref) | - | ||||||||||||||||||||||||
4313 | { | - | ||||||||||||||||||||||||
4314 | ref->ref(); | - | ||||||||||||||||||||||||
4315 | } never executed: end of block | 0 | ||||||||||||||||||||||||
4316 | - | |||||||||||||||||||||||||
4317 | /*! | - | ||||||||||||||||||||||||
4318 | Assigns \a other to this. | - | ||||||||||||||||||||||||
4319 | */ | - | ||||||||||||||||||||||||
4320 | QAssociativeIterable::const_iterator& | - | ||||||||||||||||||||||||
4321 | QAssociativeIterable::const_iterator::operator=(const const_iterator &other) | - | ||||||||||||||||||||||||
4322 | { | - | ||||||||||||||||||||||||
4323 | other.ref->ref(); | - | ||||||||||||||||||||||||
4324 | if (!ref->deref()) {
| 0-1 | ||||||||||||||||||||||||
4325 | m_impl.destroyIter(); | - | ||||||||||||||||||||||||
4326 | delete ref; | - | ||||||||||||||||||||||||
4327 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||||||||||||||
4328 | m_impl = other.m_impl; | - | ||||||||||||||||||||||||
4329 | ref = other.ref; | - | ||||||||||||||||||||||||
4330 | return *this; executed 1 time by 1 test: return *this; Executed by:
| 1 | ||||||||||||||||||||||||
4331 | } | - | ||||||||||||||||||||||||
4332 | - | |||||||||||||||||||||||||
4333 | /*! | - | ||||||||||||||||||||||||
4334 | Returns the current value, converted to a QVariant. | - | ||||||||||||||||||||||||
4335 | */ | - | ||||||||||||||||||||||||
4336 | const QVariant QAssociativeIterable::const_iterator::operator*() const | - | ||||||||||||||||||||||||
4337 | { | - | ||||||||||||||||||||||||
4338 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); | - | ||||||||||||||||||||||||
4339 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||||||||||||||
4340 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 0-13 | ||||||||||||||||||||||||
4341 | return *reinterpret_cast<const QVariant*>(d.data); never executed: return *reinterpret_cast<const QVariant*>(d.data); | 0 | ||||||||||||||||||||||||
4342 | return v; executed 13 times by 1 test: return v; Executed by:
| 13 | ||||||||||||||||||||||||
4343 | } | - | ||||||||||||||||||||||||
4344 | - | |||||||||||||||||||||||||
4345 | /*! | - | ||||||||||||||||||||||||
4346 | Returns the current key, converted to a QVariant. | - | ||||||||||||||||||||||||
4347 | */ | - | ||||||||||||||||||||||||
4348 | const QVariant QAssociativeIterable::const_iterator::key() const | - | ||||||||||||||||||||||||
4349 | { | - | ||||||||||||||||||||||||
4350 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentKey(); | - | ||||||||||||||||||||||||
4351 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||||||||||||||
4352 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 0-31 | ||||||||||||||||||||||||
4353 | return *reinterpret_cast<const QVariant*>(d.data); never executed: return *reinterpret_cast<const QVariant*>(d.data); | 0 | ||||||||||||||||||||||||
4354 | return v; executed 31 times by 1 test: return v; Executed by:
| 31 | ||||||||||||||||||||||||
4355 | } | - | ||||||||||||||||||||||||
4356 | - | |||||||||||||||||||||||||
4357 | /*! | - | ||||||||||||||||||||||||
4358 | Returns the current value, converted to a QVariant. | - | ||||||||||||||||||||||||
4359 | */ | - | ||||||||||||||||||||||||
4360 | const QVariant QAssociativeIterable::const_iterator::value() const | - | ||||||||||||||||||||||||
4361 | { | - | ||||||||||||||||||||||||
4362 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); | - | ||||||||||||||||||||||||
4363 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||||||||||||||
4364 | if (d.metaTypeId == qMetaTypeId<QVariant>())
| 6-30 | ||||||||||||||||||||||||
4365 | return *reinterpret_cast<const QVariant*>(d.data); executed 6 times by 1 test: return *reinterpret_cast<const QVariant*>(d.data); Executed by:
| 6 | ||||||||||||||||||||||||
4366 | return v; executed 30 times by 1 test: return v; Executed by:
| 30 | ||||||||||||||||||||||||
4367 | } | - | ||||||||||||||||||||||||
4368 | - | |||||||||||||||||||||||||
4369 | /*! | - | ||||||||||||||||||||||||
4370 | Returns \c true if \a other points to the same item as this | - | ||||||||||||||||||||||||
4371 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
4372 | - | |||||||||||||||||||||||||
4373 | \sa operator!=() | - | ||||||||||||||||||||||||
4374 | */ | - | ||||||||||||||||||||||||
4375 | bool QAssociativeIterable::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||||||||||||||
4376 | { | - | ||||||||||||||||||||||||
4377 | return m_impl.equal(other.m_impl); executed 9 times by 1 test: return m_impl.equal(other.m_impl); Executed by:
| 9 | ||||||||||||||||||||||||
4378 | } | - | ||||||||||||||||||||||||
4379 | - | |||||||||||||||||||||||||
4380 | /*! | - | ||||||||||||||||||||||||
4381 | Returns \c true if \a other points to a different item than this | - | ||||||||||||||||||||||||
4382 | iterator; otherwise returns \c false. | - | ||||||||||||||||||||||||
4383 | - | |||||||||||||||||||||||||
4384 | \sa operator==() | - | ||||||||||||||||||||||||
4385 | */ | - | ||||||||||||||||||||||||
4386 | bool QAssociativeIterable::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||||||||||||||
4387 | { | - | ||||||||||||||||||||||||
4388 | return !m_impl.equal(other.m_impl); executed 60 times by 1 test: return !m_impl.equal(other.m_impl); Executed by:
| 60 | ||||||||||||||||||||||||
4389 | } | - | ||||||||||||||||||||||||
4390 | - | |||||||||||||||||||||||||
4391 | /*! | - | ||||||||||||||||||||||||
4392 | The prefix ++ operator (\c{++it}) advances the iterator to the | - | ||||||||||||||||||||||||
4393 | next item in the container and returns an iterator to the new current | - | ||||||||||||||||||||||||
4394 | item. | - | ||||||||||||||||||||||||
4395 | - | |||||||||||||||||||||||||
4396 | Calling this function on QAssociativeIterable::end() leads to undefined results. | - | ||||||||||||||||||||||||
4397 | - | |||||||||||||||||||||||||
4398 | \sa operator--() | - | ||||||||||||||||||||||||
4399 | */ | - | ||||||||||||||||||||||||
4400 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator++() | - | ||||||||||||||||||||||||
4401 | { | - | ||||||||||||||||||||||||
4402 | m_impl.advance(1); | - | ||||||||||||||||||||||||
4403 | return *this; executed 34 times by 1 test: return *this; Executed by:
| 34 | ||||||||||||||||||||||||
4404 | } | - | ||||||||||||||||||||||||
4405 | - | |||||||||||||||||||||||||
4406 | /*! | - | ||||||||||||||||||||||||
4407 | \overload | - | ||||||||||||||||||||||||
4408 | - | |||||||||||||||||||||||||
4409 | The postfix ++ operator (\c{it++}) advances the iterator to the | - | ||||||||||||||||||||||||
4410 | next item in the container and returns an iterator to the previously | - | ||||||||||||||||||||||||
4411 | current item. | - | ||||||||||||||||||||||||
4412 | */ | - | ||||||||||||||||||||||||
4413 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator++(int) | - | ||||||||||||||||||||||||
4414 | { | - | ||||||||||||||||||||||||
4415 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
4416 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4417 | m_impl.advance(1); | - | ||||||||||||||||||||||||
4418 | return const_iterator(impl, new QAtomicInt(0)); executed 3 times by 1 test: return const_iterator(impl, new QAtomicInt(0)); Executed by:
| 3 | ||||||||||||||||||||||||
4419 | } | - | ||||||||||||||||||||||||
4420 | - | |||||||||||||||||||||||||
4421 | /*! | - | ||||||||||||||||||||||||
4422 | The prefix -- operator (\c{--it}) makes the preceding item | - | ||||||||||||||||||||||||
4423 | current and returns an iterator to the new current item. | - | ||||||||||||||||||||||||
4424 | - | |||||||||||||||||||||||||
4425 | Calling this function on QAssociativeIterable::begin() leads to undefined results. | - | ||||||||||||||||||||||||
4426 | - | |||||||||||||||||||||||||
4427 | \sa operator++() | - | ||||||||||||||||||||||||
4428 | */ | - | ||||||||||||||||||||||||
4429 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator--() | - | ||||||||||||||||||||||||
4430 | { | - | ||||||||||||||||||||||||
4431 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
4432 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
4433 | } | - | ||||||||||||||||||||||||
4434 | - | |||||||||||||||||||||||||
4435 | /*! | - | ||||||||||||||||||||||||
4436 | \overload | - | ||||||||||||||||||||||||
4437 | - | |||||||||||||||||||||||||
4438 | The postfix -- operator (\c{it--}) makes the preceding item | - | ||||||||||||||||||||||||
4439 | current and returns an iterator to the previously current item. | - | ||||||||||||||||||||||||
4440 | */ | - | ||||||||||||||||||||||||
4441 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator--(int) | - | ||||||||||||||||||||||||
4442 | { | - | ||||||||||||||||||||||||
4443 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
4444 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4445 | m_impl.advance(-1); | - | ||||||||||||||||||||||||
4446 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
4447 | } | - | ||||||||||||||||||||||||
4448 | - | |||||||||||||||||||||||||
4449 | /*! | - | ||||||||||||||||||||||||
4450 | Advances the iterator by \a j items. | - | ||||||||||||||||||||||||
4451 | - | |||||||||||||||||||||||||
4452 | \sa operator-=(), operator+() | - | ||||||||||||||||||||||||
4453 | */ | - | ||||||||||||||||||||||||
4454 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator+=(int j) | - | ||||||||||||||||||||||||
4455 | { | - | ||||||||||||||||||||||||
4456 | m_impl.advance(j); | - | ||||||||||||||||||||||||
4457 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
4458 | } | - | ||||||||||||||||||||||||
4459 | - | |||||||||||||||||||||||||
4460 | /*! | - | ||||||||||||||||||||||||
4461 | Makes the iterator go back by \a j items. | - | ||||||||||||||||||||||||
4462 | - | |||||||||||||||||||||||||
4463 | \sa operator+=(), operator-() | - | ||||||||||||||||||||||||
4464 | */ | - | ||||||||||||||||||||||||
4465 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator-=(int j) | - | ||||||||||||||||||||||||
4466 | { | - | ||||||||||||||||||||||||
4467 | m_impl.advance(-j); | - | ||||||||||||||||||||||||
4468 | return *this; never executed: return *this; | 0 | ||||||||||||||||||||||||
4469 | } | - | ||||||||||||||||||||||||
4470 | - | |||||||||||||||||||||||||
4471 | /*! | - | ||||||||||||||||||||||||
4472 | Returns an iterator to the item at \a j positions forward from | - | ||||||||||||||||||||||||
4473 | this iterator. | - | ||||||||||||||||||||||||
4474 | - | |||||||||||||||||||||||||
4475 | \sa operator-(), operator+=() | - | ||||||||||||||||||||||||
4476 | */ | - | ||||||||||||||||||||||||
4477 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator+(int j) const | - | ||||||||||||||||||||||||
4478 | { | - | ||||||||||||||||||||||||
4479 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
4480 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4481 | impl.advance(j); | - | ||||||||||||||||||||||||
4482 | return const_iterator(impl, new QAtomicInt(0)); executed 1 time by 1 test: return const_iterator(impl, new QAtomicInt(0)); Executed by:
| 1 | ||||||||||||||||||||||||
4483 | } | - | ||||||||||||||||||||||||
4484 | - | |||||||||||||||||||||||||
4485 | /*! | - | ||||||||||||||||||||||||
4486 | Returns an iterator to the item at \a j positions backward from | - | ||||||||||||||||||||||||
4487 | this iterator. | - | ||||||||||||||||||||||||
4488 | - | |||||||||||||||||||||||||
4489 | \sa operator+(), operator-=() | - | ||||||||||||||||||||||||
4490 | */ | - | ||||||||||||||||||||||||
4491 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator-(int j) const | - | ||||||||||||||||||||||||
4492 | { | - | ||||||||||||||||||||||||
4493 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||||||||||||||
4494 | impl.copy(m_impl); | - | ||||||||||||||||||||||||
4495 | impl.advance(-j); | - | ||||||||||||||||||||||||
4496 | return const_iterator(impl, new QAtomicInt(0)); never executed: return const_iterator(impl, new QAtomicInt(0)); | 0 | ||||||||||||||||||||||||
4497 | } | - | ||||||||||||||||||||||||
4498 | - | |||||||||||||||||||||||||
4499 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
Source code | Switch to Preprocessed file |