Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qvariant.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
const int log10_2_10000 = 30103; | ||||||||||||||
const int max_digits10_double = (53 * log10_2_10000) / 100000 + 2; | ||||||||||||||
const int max_digits10_float = (24 * log10_2_10000) / 100000 + 2;namespace { | ||||||||||||||
11 | class HandlersManager | - | ||||||||||||
12 | { | - | ||||||||||||
13 | static const QVariant::Handler *Handlers[QModulesPrivate::ModulesCount]; | - | ||||||||||||
14 | public: | - | ||||||||||||
15 | const QVariant::Handler *operator[] (const uint typeId) const | - | ||||||||||||
16 | { | - | ||||||||||||
17 | return Handlers[QModulesPrivate::moduleForType(typeId)]; | - | ||||||||||||
18 | } | - | ||||||||||||
19 | - | |||||||||||||
20 | void registerHandler(const QModulesPrivate::Names name, const QVariant::Handler *handler) | - | ||||||||||||
21 | { | - | ||||||||||||
22 | Handlers[name] = handler; | - | ||||||||||||
23 | } | - | ||||||||||||
24 | }; | - | ||||||||||||
25 | } | - | ||||||||||||
26 | - | |||||||||||||
27 | namespace { | - | ||||||||||||
28 | struct CoreTypesFilter { | - | ||||||||||||
29 | template<typename T> | - | ||||||||||||
30 | struct Acceptor { | - | ||||||||||||
31 | static const bool IsAccepted = QModulesPrivate::QTypeModuleInfo<T>::IsCore && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable; | - | ||||||||||||
32 | }; | - | ||||||||||||
33 | }; | - | ||||||||||||
34 | } | - | ||||||||||||
35 | - | |||||||||||||
36 | namespace { | - | ||||||||||||
37 | - | |||||||||||||
38 | static void construct(QVariant::Private *x, const void *copy) | - | ||||||||||||
39 | { | - | ||||||||||||
40 | QVariantConstructor<CoreTypesFilter> constructor(x, copy); | - | ||||||||||||
41 | QMetaTypeSwitcher::switcher<void>(constructor, x->type, 0); | - | ||||||||||||
42 | } | - | ||||||||||||
43 | - | |||||||||||||
44 | static void clear(QVariant::Private *d) | - | ||||||||||||
45 | { | - | ||||||||||||
46 | QVariantDestructor<CoreTypesFilter> cleaner(d); | - | ||||||||||||
47 | QMetaTypeSwitcher::switcher<void>(cleaner, d->type, 0); | - | ||||||||||||
48 | } | - | ||||||||||||
49 | - | |||||||||||||
50 | static bool isNull(const QVariant::Private *d) | - | ||||||||||||
51 | { | - | ||||||||||||
52 | QVariantIsNull<CoreTypesFilter> isNull(d); | - | ||||||||||||
53 | return QMetaTypeSwitcher::switcher<bool>(isNull, d->type, 0); | - | ||||||||||||
54 | } | - | ||||||||||||
55 | - | |||||||||||||
56 | - | |||||||||||||
57 | - | |||||||||||||
58 | - | |||||||||||||
59 | - | |||||||||||||
60 | - | |||||||||||||
61 | - | |||||||||||||
62 | static bool compare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||||||||
63 | { | - | ||||||||||||
64 | QVariantComparator<CoreTypesFilter> comparator(a, b); | - | ||||||||||||
65 | return QMetaTypeSwitcher::switcher<bool>(comparator, a->type, 0); | - | ||||||||||||
66 | } | - | ||||||||||||
67 | - | |||||||||||||
68 | - | |||||||||||||
69 | - | |||||||||||||
70 | - | |||||||||||||
71 | static qlonglong qMetaTypeNumber(const QVariant::Private *d) | - | ||||||||||||
72 | { | - | ||||||||||||
73 | switch (d->type) { | - | ||||||||||||
74 | case QMetaType::Int: | - | ||||||||||||
75 | return d->data.i; | - | ||||||||||||
76 | case QMetaType::LongLong: | - | ||||||||||||
77 | return d->data.ll; | - | ||||||||||||
78 | case QMetaType::Char: | - | ||||||||||||
79 | return qlonglong(d->data.c); | - | ||||||||||||
80 | case QMetaType::SChar: | - | ||||||||||||
81 | return qlonglong(d->data.sc); | - | ||||||||||||
82 | case QMetaType::Short: | - | ||||||||||||
83 | return qlonglong(d->data.s); | - | ||||||||||||
84 | case QMetaType::Long: | - | ||||||||||||
85 | return qlonglong(d->data.l); | - | ||||||||||||
86 | case QMetaType::Float: | - | ||||||||||||
87 | return qRound64(d->data.f); | - | ||||||||||||
88 | case QVariant::Double: | - | ||||||||||||
89 | return qRound64(d->data.d); | - | ||||||||||||
90 | - | |||||||||||||
91 | case QMetaType::QJsonValue: | - | ||||||||||||
92 | return v_cast<QJsonValue>(d)->toDouble(); | - | ||||||||||||
93 | - | |||||||||||||
94 | } | - | ||||||||||||
95 | ((!(false)) ? qt_assert("false",__FILE__,171167) : qt_noop()); | - | ||||||||||||
96 | return 0; | - | ||||||||||||
97 | } | - | ||||||||||||
98 | - | |||||||||||||
99 | static qulonglong qMetaTypeUNumber(const QVariant::Private *d) | - | ||||||||||||
100 | { | - | ||||||||||||
101 | switch (d->type) { | - | ||||||||||||
102 | case QVariant::UInt: | - | ||||||||||||
103 | return d->data.u; | - | ||||||||||||
104 | case QVariant::ULongLong: | - | ||||||||||||
105 | return d->data.ull; | - | ||||||||||||
106 | case QMetaType::UChar: | - | ||||||||||||
107 | return d->data.uc; | - | ||||||||||||
108 | case QMetaType::UShort: | - | ||||||||||||
109 | return d->data.us; | - | ||||||||||||
110 | case QMetaType::ULong: | - | ||||||||||||
111 | return d->data.ul; | - | ||||||||||||
112 | } | - | ||||||||||||
113 | ((!(false)) ? qt_assert("false",__FILE__,189185) : qt_noop()); | - | ||||||||||||
114 | return 0; | - | ||||||||||||
115 | } | - | ||||||||||||
116 | - | |||||||||||||
117 | static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||
118 | { | - | ||||||||||||
119 | *ok = true; | - | ||||||||||||
120 | - | |||||||||||||
121 | switch (uint(d->type)) { | - | ||||||||||||
122 | case QVariant::String: | - | ||||||||||||
123 | return v_cast<QString>(d)->toLongLong(ok); | - | ||||||||||||
124 | case QVariant::Char: | - | ||||||||||||
125 | return v_cast<QChar>(d)->unicode(); | - | ||||||||||||
126 | case QVariant::ByteArray: | - | ||||||||||||
127 | return v_cast<QByteArray>(d)->toLongLong(ok); | - | ||||||||||||
128 | case QVariant::Bool: | - | ||||||||||||
129 | return qlonglong(d->data.b); | - | ||||||||||||
130 | - | |||||||||||||
131 | case QMetaType::QJsonValue: | - | ||||||||||||
132 | if (!v_cast<QJsonValue>(d)->isDouble()) | - | ||||||||||||
133 | break; | - | ||||||||||||
134 | - | |||||||||||||
135 | - | |||||||||||||
136 | case QVariant::Double: | - | ||||||||||||
137 | case QVariant::Int: | - | ||||||||||||
138 | case QMetaType::Char: | - | ||||||||||||
139 | case QMetaType::SChar: | - | ||||||||||||
140 | case QMetaType::Short: | - | ||||||||||||
141 | case QMetaType::Long: | - | ||||||||||||
142 | case QMetaType::Float: | - | ||||||||||||
143 | case QMetaType::LongLong: | - | ||||||||||||
144 | return qMetaTypeNumber(d); | - | ||||||||||||
145 | case QVariant::ULongLong: | - | ||||||||||||
146 | case QVariant::UInt: | - | ||||||||||||
147 | case QMetaType::UChar: | - | ||||||||||||
148 | case QMetaType::UShort: | - | ||||||||||||
149 | case QMetaType::ULong: | - | ||||||||||||
150 | - | |||||||||||||
151 | return qlonglong(qMetaTypeUNumber(d)); | - | ||||||||||||
152 | } | - | ||||||||||||
153 | - | |||||||||||||
154 | QMetaType typeInfo(d->type); | - | ||||||||||||
155 | if (typeInfo.flags() & QMetaType::IsEnumeration) { | - | ||||||||||||
156 | switch (typeInfo.sizeOf()) { | - | ||||||||||||
157 | case 1: | - | ||||||||||||
158 | return d->is_shared ? *reinterpret_cast<signed char *>(d->data.shared->ptr) : d->data.sc; | - | ||||||||||||
159 | case 2: | - | ||||||||||||
160 | return d->is_shared ? *reinterpret_cast<qint16 *>(d->data.shared->ptr) : d->data.s; | - | ||||||||||||
161 | case 4: | - | ||||||||||||
162 | return d->is_shared ? *reinterpret_cast<qint32 *>(d->data.shared->ptr) : d->data.i; | - | ||||||||||||
163 | case 8: | - | ||||||||||||
164 | return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ll; | - | ||||||||||||
165 | } | - | ||||||||||||
166 | } | - | ||||||||||||
167 | - | |||||||||||||
168 | *ok = false; | - | ||||||||||||
169 | return static_cast<long long>(0LL); | - | ||||||||||||
170 | } | - | ||||||||||||
171 | - | |||||||||||||
172 | static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||
173 | { | - | ||||||||||||
174 | *ok = true; | - | ||||||||||||
175 | switch (uint(d->type)) { | - | ||||||||||||
176 | case QVariant::Double: | - | ||||||||||||
177 | return qreal(d->data.d); | - | ||||||||||||
178 | case QMetaType::Float: | - | ||||||||||||
179 | return qreal(d->data.f); | - | ||||||||||||
180 | case QVariant::ULongLong: | - | ||||||||||||
181 | case QVariant::UInt: | - | ||||||||||||
182 | case QMetaType::UChar: | - | ||||||||||||
183 | case QMetaType::UShort: | - | ||||||||||||
184 | case QMetaType::ULong: | - | ||||||||||||
185 | return qreal(qMetaTypeUNumber(d)); | - | ||||||||||||
186 | default: | - | ||||||||||||
187 | - | |||||||||||||
188 | return qreal(qConvertToNumber(d, ok)); | - | ||||||||||||
189 | } | - | ||||||||||||
190 | } | - | ||||||||||||
191 | - | |||||||||||||
192 | static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) | - | ||||||||||||
193 | { | - | ||||||||||||
194 | *ok = true; | - | ||||||||||||
195 | - | |||||||||||||
196 | switch (uint(d->type)) { | - | ||||||||||||
197 | case QVariant::String: | - | ||||||||||||
198 | return v_cast<QString>(d)->toULongLong(ok); | - | ||||||||||||
199 | case QVariant::Char: | - | ||||||||||||
200 | return v_cast<QChar>(d)->unicode(); | - | ||||||||||||
201 | case QVariant::ByteArray: | - | ||||||||||||
202 | return v_cast<QByteArray>(d)->toULongLong(ok); | - | ||||||||||||
203 | case QVariant::Bool: | - | ||||||||||||
204 | return qulonglong(d->data.b); | - | ||||||||||||
205 | - | |||||||||||||
206 | case QMetaType::QJsonValue: | - | ||||||||||||
207 | if (!v_cast<QJsonValue>(d)->isDouble()) | - | ||||||||||||
208 | break; | - | ||||||||||||
209 | - | |||||||||||||
210 | - | |||||||||||||
211 | case QVariant::Double: | - | ||||||||||||
212 | case QVariant::Int: | - | ||||||||||||
213 | case QMetaType::Char: | - | ||||||||||||
214 | case QMetaType::SChar: | - | ||||||||||||
215 | case QMetaType::Short: | - | ||||||||||||
216 | case QMetaType::Long: | - | ||||||||||||
217 | case QMetaType::Float: | - | ||||||||||||
218 | case QMetaType::LongLong: | - | ||||||||||||
219 | return qulonglong(qMetaTypeNumber(d)); | - | ||||||||||||
220 | case QVariant::ULongLong: | - | ||||||||||||
221 | case QVariant::UInt: | - | ||||||||||||
222 | case QMetaType::UChar: | - | ||||||||||||
223 | case QMetaType::UShort: | - | ||||||||||||
224 | case QMetaType::ULong: | - | ||||||||||||
225 | return qMetaTypeUNumber(d); | - | ||||||||||||
226 | } | - | ||||||||||||
227 | - | |||||||||||||
228 | QMetaType typeInfo(d->type); | - | ||||||||||||
229 | if (typeInfo.flags() & QMetaType::IsEnumeration) { | - | ||||||||||||
230 | switch (typeInfo.sizeOf()) { | - | ||||||||||||
231 | case 1: | - | ||||||||||||
232 | return d->is_shared ? *reinterpret_cast<uchar *>(d->data.shared->ptr) : d->data.uc; | - | ||||||||||||
233 | case 2: | - | ||||||||||||
234 | return d->is_shared ? *reinterpret_cast<quint16 *>(d->data.shared->ptr) : d->data.us; | - | ||||||||||||
235 | case 4: | - | ||||||||||||
236 | return d->is_shared ? *reinterpret_cast<quint32 *>(d->data.shared->ptr) : d->data.u; | - | ||||||||||||
237 | case 8: | - | ||||||||||||
238 | return d->is_shared ? *reinterpret_cast<qint64 *>(d->data.shared->ptr) : d->data.ull; | - | ||||||||||||
239 | } | - | ||||||||||||
240 | } | - | ||||||||||||
241 | - | |||||||||||||
242 | *ok = false; | - | ||||||||||||
243 | return static_cast<unsigned long long>(0ULL); | - | ||||||||||||
244 | } | - | ||||||||||||
245 | - | |||||||||||||
246 | template<typename TInput, typename LiteralWrapper> | - | ||||||||||||
247 | inline bool qt_convertToBool(const QVariant::Private *const d) | - | ||||||||||||
248 | { | - | ||||||||||||
249 | TInput str = v_cast<TInput>(d)->toLower(); | - | ||||||||||||
250 | return !(str == LiteralWrapper("0") || str == LiteralWrapper("false") || str.isEmpty()); | - | ||||||||||||
251 | } | - | ||||||||||||
252 | - | |||||||||||||
253 | - | |||||||||||||
254 | - | |||||||||||||
255 | - | |||||||||||||
256 | - | |||||||||||||
257 | - | |||||||||||||
258 | static const void *constData(const QVariant::Private &d) | - | ||||||||||||
259 | { | - | ||||||||||||
260 | return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.c); | - | ||||||||||||
261 | } | - | ||||||||||||
262 | - | |||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | - | |||||||||||||
268 | static QMetaEnum metaEnumFromType(int type) | - | ||||||||||||
269 | { | - | ||||||||||||
270 | QMetaType t(type); | - | ||||||||||||
271 | if (t.flags() & QMetaType::IsEnumeration) { | - | ||||||||||||
272 | if (const QMetaObject *metaObject = t.metaObject()) { | - | ||||||||||||
273 | const char *enumName = QMetaType::typeName(type); | - | ||||||||||||
274 | const char *lastColon = std::strrchr(enumName, ':'); | - | ||||||||||||
275 | if (lastColon) | - | ||||||||||||
276 | enumName = lastColon + 1; | - | ||||||||||||
277 | return metaObject->enumerator(metaObject->indexOfEnumerator(enumName)); | - | ||||||||||||
278 | } | - | ||||||||||||
279 | } | - | ||||||||||||
280 | return QMetaEnum(); | - | ||||||||||||
281 | } | - | ||||||||||||
282 | - | |||||||||||||
283 | - | |||||||||||||
284 | - | |||||||||||||
285 | - | |||||||||||||
286 | - | |||||||||||||
287 | - | |||||||||||||
288 | - | |||||||||||||
289 | static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) | - | ||||||||||||
290 | { | - | ||||||||||||
291 | ((!(d->type != uint(t))) ? qt_assert("d->type != uint(t)",__FILE__,367363) : qt_noop()); | - | ||||||||||||
292 | ((!(result)) ? qt_assert("result",__FILE__,368364) : qt_noop()); | - | ||||||||||||
293 | - | |||||||||||||
294 | if (d->type >= QMetaType::User
| 228-422562 | ||||||||||||
295 | const bool isOk = QMetaType::convert(constData(*d), d->type, result, t); | - | ||||||||||||
296 | if (ok
| 27-807 | ||||||||||||
297 | * executed 27 times by 1 test: ok = isOk;*ok = isOk; Executed by:
executed 27 times by 1 test: *ok = isOk; Executed by:
| 27 | ||||||||||||
298 | if (isOk
| 27-807 | ||||||||||||
299 | return executed 27 times by 2 tests: true;return true; Executed by:
executed 27 times by 2 tests: return true; Executed by:
| 27 | ||||||||||||
300 | } executed 807 times by 24 tests: end of block Executed by:
| 807 | ||||||||||||
301 | - | |||||||||||||
302 | bool dummy; | - | ||||||||||||
303 | if (!ok
| 653-422488 | ||||||||||||
304 | ok = &dummy; executed 422488 times by 203 tests: ok = &dummy; Executed by:
| 422488 | ||||||||||||
305 | - | |||||||||||||
306 | switch (uint(t)) { | - | ||||||||||||
307 | - | |||||||||||||
308 | case executed 6 times by 3 tests: QVariant::Url:case QVariant::Url: Executed by:
executed 6 times by 3 tests: case QVariant::Url: Executed by:
| 6 | ||||||||||||
309 | switch (d->type) { | - | ||||||||||||
310 | case executed 6 times by 3 tests: QVariant::String:case QVariant::String: Executed by:
executed 6 times by 3 tests: case QVariant::String: Executed by:
| 6 | ||||||||||||
311 | *static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d)); | - | ||||||||||||
312 | break; executed 6 times by 3 tests: break; Executed by:
| 6 | ||||||||||||
313 | default never executed: :default: never executed: default: | 0 | ||||||||||||
314 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
315 | } | - | ||||||||||||
316 | break; executed 6 times by 3 tests: break; Executed by:
| 6 | ||||||||||||
317 | case executed 1 time by 1 test: QVariant::ModelIndex:case QVariant::ModelIndex: Executed by:
executed 1 time by 1 test: case QVariant::ModelIndex: Executed by:
| 1 | ||||||||||||
318 | switch (d->type) { | - | ||||||||||||
319 | case executed 1 time by 1 test: QVariant::PersistentModelIndex:case QVariant::PersistentModelIndex: Executed by:
executed 1 time by 1 test: case QVariant::PersistentModelIndex: Executed by:
| 1 | ||||||||||||
320 | *static_cast<QModelIndex *>(result) = QModelIndex(*v_cast<QPersistentModelIndex>(d)); | - | ||||||||||||
321 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
322 | default never executed: :default: never executed: default: | 0 | ||||||||||||
323 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
324 | } | - | ||||||||||||
325 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
326 | case executed 1 time by 1 test: QVariant::PersistentModelIndex:case QVariant::PersistentModelIndex: Executed by:
executed 1 time by 1 test: case QVariant::PersistentModelIndex: Executed by:
| 1 | ||||||||||||
327 | switch (d->type) { | - | ||||||||||||
328 | case executed 1 time by 1 test: QVariant::ModelIndex:case QVariant::ModelIndex: Executed by:
executed 1 time by 1 test: case QVariant::ModelIndex: Executed by:
| 1 | ||||||||||||
329 | *static_cast<QPersistentModelIndex *>(result) = QPersistentModelIndex(*v_cast<QModelIndex>(d)); | - | ||||||||||||
330 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
331 | default never executed: :default: never executed: default: | 0 | ||||||||||||
332 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
333 | } | - | ||||||||||||
334 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
335 | - | |||||||||||||
336 | case executed 55537 times by 77 tests: QVariant::String:case QVariant::String: Executed by:
executed 55537 times by 77 tests: {case QVariant::String: Executed by:
| 55537 | ||||||||||||
337 | QString *str = static_cast<QString *>(result); | - | ||||||||||||
338 | switch (d->type) { | - | ||||||||||||
339 | case executed 5106 times by 14 tests: QVariant::Char:case QVariant::Char: Executed by:
executed 5106 times by 14 tests: case QVariant::Char: Executed by:
| 5106 | ||||||||||||
340 | *str = *v_cast<QChar>(d); | - | ||||||||||||
341 | break; executed 5106 times by 14 tests: break; Executed by:
| 5106 | ||||||||||||
342 | case executed 29 times by 1 test: QMetaType::Char:case QMetaType::Char: Executed by:
executed 29 times by 1 test: case QMetaType::Char: Executed by:
| 29 | ||||||||||||
343 | case executed 36 times by 1 test: QMetaType::SChar:case QMetaType::SChar: Executed by:
executed 36 times by 1 test: case QMetaType::SChar: Executed by:
| 36 | ||||||||||||
344 | case executed 10 times by 1 test: QMetaType::UChar:case QMetaType::UChar: Executed by:
executed 10 times by 1 test: case QMetaType::UChar: Executed by:
| 10 | ||||||||||||
345 | *str = QChar::fromLatin1(d->data.c); | - | ||||||||||||
346 | break; executed 75 times by 1 test: break; Executed by:
| 75 | ||||||||||||
347 | case executed 10 times by 1 test: QMetaType::Short:case QMetaType::Short: Executed by:
executed 10 times by 1 test: case QMetaType::Short: Executed by:
| 10 | ||||||||||||
348 | case never executed: QMetaType::Long:case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||
349 | case executed 29283 times by 45 tests: QVariant::Int:case QVariant::Int: Executed by:
executed 29283 times by 45 tests: case QVariant::Int: Executed by:
| 29283 | ||||||||||||
350 | case executed 250 times by 9 tests: QVariant::LongLong:case QVariant::LongLong: Executed by:
executed 250 times by 9 tests: case QVariant::LongLong: Executed by:
| 250 | ||||||||||||
351 | *str = QString::number(qMetaTypeNumber(d)); | - | ||||||||||||
352 | break; executed 29543 times by 47 tests: break; Executed by:
| 29543 | ||||||||||||
353 | case executed 179 times by 5 tests: QVariant::UInt:case QVariant::UInt: Executed by:
executed 179 times by 5 tests: case QVariant::UInt: Executed by:
| 179 | ||||||||||||
354 | case executed 43 times by 2 tests: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 43 times by 2 tests: case QVariant::ULongLong: Executed by:
| 43 | ||||||||||||
355 | case executed 10 times by 1 test: QMetaType::UShort:case QMetaType::UShort: Executed by:
executed 10 times by 1 test: case QMetaType::UShort: Executed by:
| 10 | ||||||||||||
356 | case never executed: QMetaType::ULong:case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||
357 | *str = QString::number(qMetaTypeUNumber(d)); | - | ||||||||||||
358 | break; executed 232 times by 5 tests: break; Executed by:
| 232 | ||||||||||||
359 | case executed 39 times by 1 test: QMetaType::Float:case QMetaType::Float: Executed by:
executed 39 times by 1 test: case QMetaType::Float: Executed by:
| 39 | ||||||||||||
360 | *str = QString::number(d->data.f, 'g', max_digits10_floatQLocale::FloatingPointShortest); | - | ||||||||||||
361 | break; executed 39 times by 1 test: break; Executed by:
| 39 | ||||||||||||
362 | case executed 120 times by 13 tests: QVariant::Double:case QVariant::Double: Executed by:
executed 120 times by 13 tests: case QVariant::Double: Executed by:
| 120 | ||||||||||||
363 | *str = QString::number(d->data.d, 'g', max_digits10_doubleQLocale::FloatingPointShortest); | - | ||||||||||||
364 | break; executed 120 times by 13 tests: break; Executed by:
| 120 | ||||||||||||
365 | - | |||||||||||||
366 | case executed 5 times by 2 tests: QVariant::Date:case QVariant::Date: Executed by:
executed 5 times by 2 tests: case QVariant::Date: Executed by:
| 5 | ||||||||||||
367 | *str = v_cast<QDate>(d)->toString(Qt::ISODate); | - | ||||||||||||
368 | break; executed 5 times by 2 tests: break; Executed by:
| 5 | ||||||||||||
369 | case executed 3 times by 1 test: QVariant::Time:case QVariant::Time: Executed by:
executed 3 times by 1 test: case QVariant::Time: Executed by:
| 3 | ||||||||||||
370 | *str = v_cast<QTime>(d)->toString(Qt::ISODate); | - | ||||||||||||
371 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
372 | case executed 11 times by 2 tests: QVariant::DateTime:case QVariant::DateTime: Executed by:
executed 11 times by 2 tests: case QVariant::DateTime: Executed by:
| 11 | ||||||||||||
373 | *str = v_cast<QDateTime>(d)->toString(Qt::ISODate); | - | ||||||||||||
374 | break; executed 11 times by 2 tests: break; Executed by:
| 11 | ||||||||||||
375 | - | |||||||||||||
376 | case executed 77 times by 6 tests: QVariant::Bool:case QVariant::Bool: Executed by:
executed 77 times by 6 tests: case QVariant::Bool: Executed by:
| 77 | ||||||||||||
377 | *str = QLatin1String(d->data.b
executed 44 times by 6 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 44 times by 6 tests: }()) : ([]() -> QString { enum { Size = sizeof(u"" "false")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "false" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn qstring_literal_temp; Executed by:
executed 33 times by 4 tests: return qstring_literal_temp; Executed by:
executed 33 times by 4 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 33 times by 4 tests: }());return qstring_literal_temp; Executed by:
| 33-44 | ||||||||||||
378 | break; executed 77 times by 6 tests: break; Executed by:
| 77 | ||||||||||||
379 | case executed 25 times by 2 tests: QVariant::ByteArray:case QVariant::ByteArray: Executed by:
executed 25 times by 2 tests: case QVariant::ByteArray: Executed by:
| 25 | ||||||||||||
380 | *str = QString::fromUtf8(v_cast<QByteArray>(d)->constData()); | - | ||||||||||||
381 | break; executed 25 times by 2 tests: break; Executed by:
| 25 | ||||||||||||
382 | case executed 18 times by 2 tests: QVariant::StringList:case QVariant::StringList: Executed by:
executed 18 times by 2 tests: case QVariant::StringList: Executed by:
| 18 | ||||||||||||
383 | if (v_cast<QStringList>(d)->count() == 1
| 3-15 | ||||||||||||
384 | * executed 3 times by 1 test: str = v_cast<QStringList>(d)->at(0);*str = v_cast<QStringList>(d)->at(0); Executed by:
executed 3 times by 1 test: *str = v_cast<QStringList>(d)->at(0); Executed by:
| 3 | ||||||||||||
385 | break; executed 18 times by 2 tests: break; Executed by:
| 18 | ||||||||||||
386 | - | |||||||||||||
387 | case executed 8 times by 2 tests: QVariant::Url:case QVariant::Url: Executed by:
executed 8 times by 2 tests: case QVariant::Url: Executed by:
| 8 | ||||||||||||
388 | *str = v_cast<QUrl>(d)->toString(); | - | ||||||||||||
389 | break; executed 8 times by 2 tests: break; Executed by:
| 8 | ||||||||||||
390 | case executed 2 times by 1 test: QMetaType::QJsonValue:case QMetaType::QJsonValue: Executed by:
executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||
391 | if (v_cast<QJsonValue>(d)->isString()
| 1 | ||||||||||||
392 | * executed 1 time by 1 test: str = v_cast<QJsonValue>(d)->toString();*str = v_cast<QJsonValue>(d)->toString(); Executed by:
executed 1 time by 1 test: *str = v_cast<QJsonValue>(d)->toString(); Executed by:
| 1 | ||||||||||||
393 | else if (!v_cast<QJsonValue>(d)->isNull()
| 0-1 | ||||||||||||
394 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
395 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
396 | - | |||||||||||||
397 | case executed 19 times by 2 tests: QVariant::Uuid:case QVariant::Uuid: Executed by:
executed 19 times by 2 tests: case QVariant::Uuid: Executed by:
| 19 | ||||||||||||
398 | *str = v_cast<QUuid>(d)->toString(); | - | ||||||||||||
399 | break; executed 19 times by 2 tests: break; Executed by:
| 19 | ||||||||||||
400 | default executed 20254 times by 37 tests: :default: Executed by:
executed 20254 times by 37 tests: default: Executed by:
| 20254 | ||||||||||||
401 | - | |||||||||||||
402 | { | - | ||||||||||||
403 | QMetaEnum en = metaEnumFromType(d->type); | - | ||||||||||||
404 | if (en.isValid()
| 10-20244 | ||||||||||||
405 | *str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok))); | - | ||||||||||||
406 | return executed 10 times by 1 test: *ok;return *ok; Executed by:
executed 10 times by 1 test: return *ok; Executed by:
| 10 | ||||||||||||
407 | } | - | ||||||||||||
408 | } | - | ||||||||||||
409 | - | |||||||||||||
410 | return executed 20244 times by 37 tests: false;return false; Executed by:
executed 20244 times by 37 tests: return false; Executed by:
| 20244 | ||||||||||||
411 | } | - | ||||||||||||
412 | break; executed 35283 times by 65 tests: break; Executed by:
| 35283 | ||||||||||||
413 | } | - | ||||||||||||
414 | case executed 4 times by 2 tests: QVariant::Char:case QVariant::Char: Executed by:
executed 4 times by 2 tests: {case QVariant::Char: Executed by:
| 4 | ||||||||||||
415 | QChar *c = static_cast<QChar *>(result); | - | ||||||||||||
416 | switch (d->type) { | - | ||||||||||||
417 | case executed 2 times by 1 test: QVariant::Int:case QVariant::Int: Executed by:
executed 2 times by 1 test: case QVariant::Int: Executed by:
| 2 | ||||||||||||
418 | case executed 1 time by 1 test: QVariant::LongLong:case QVariant::LongLong: Executed by:
executed 1 time by 1 test: case QVariant::LongLong: Executed by:
| 1 | ||||||||||||
419 | case never executed: QMetaType::Char:case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||
420 | case never executed: QMetaType::SChar:case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||
421 | case never executed: QMetaType::Short:case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||
422 | case never executed: QMetaType::Long:case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||
423 | case never executed: QMetaType::Float:case QMetaType::Float: never executed: case QMetaType::Float: | 0 | ||||||||||||
424 | *c = QChar(ushort(qMetaTypeNumber(d))); | - | ||||||||||||
425 | break; executed 3 times by 2 tests: break; Executed by:
| 3 | ||||||||||||
426 | case never executed: QVariant::UInt:case QVariant::UInt: never executed: case QVariant::UInt: | 0 | ||||||||||||
427 | case executed 1 time by 1 test: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 1 time by 1 test: case QVariant::ULongLong: Executed by:
| 1 | ||||||||||||
428 | case never executed: QMetaType::UChar:case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||
429 | case never executed: QMetaType::UShort:case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||
430 | case never executed: QMetaType::ULong:case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||
431 | *c = QChar(ushort(qMetaTypeUNumber(d))); | - | ||||||||||||
432 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
433 | default never executed: :default: never executed: default: | 0 | ||||||||||||
434 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
435 | } | - | ||||||||||||
436 | break; executed 4 times by 2 tests: break; Executed by:
| 4 | ||||||||||||
437 | } | - | ||||||||||||
438 | - | |||||||||||||
439 | case executed 62 times by 5 tests: QVariant::Size:case QVariant::Size: Executed by:
executed 62 times by 5 tests: {case QVariant::Size: Executed by:
| 62 | ||||||||||||
440 | QSize *s = static_cast<QSize *>(result); | - | ||||||||||||
441 | switch (d->type) { | - | ||||||||||||
442 | case executed 4 times by 1 test: QVariant::SizeF:case QVariant::SizeF: Executed by:
executed 4 times by 1 test: case QVariant::SizeF: Executed by:
| 4 | ||||||||||||
443 | *s = v_cast<QSizeF>(d)->toSize(); | - | ||||||||||||
444 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
445 | default executed 58 times by 4 tests: :default: Executed by:
executed 58 times by 4 tests: default: Executed by:
| 58 | ||||||||||||
446 | return executed 58 times by 4 tests: false;return false; Executed by:
executed 58 times by 4 tests: return false; Executed by:
| 58 | ||||||||||||
447 | } | - | ||||||||||||
448 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
449 | } | - | ||||||||||||
450 | - | |||||||||||||
451 | case executed 23 times by 3 tests: QVariant::SizeF:case QVariant::SizeF: Executed by:
executed 23 times by 3 tests: {case QVariant::SizeF: Executed by:
| 23 | ||||||||||||
452 | QSizeF *s = static_cast<QSizeF *>(result); | - | ||||||||||||
453 | switch (d->type) { | - | ||||||||||||
454 | case executed 21 times by 2 tests: QVariant::Size:case QVariant::Size: Executed by:
executed 21 times by 2 tests: case QVariant::Size: Executed by:
| 21 | ||||||||||||
455 | *s = QSizeF(*(v_cast<QSize>(d))); | - | ||||||||||||
456 | break; executed 21 times by 2 tests: break; Executed by:
| 21 | ||||||||||||
457 | default executed 2 times by 1 test: :default: Executed by:
executed 2 times by 1 test: default: Executed by:
| 2 | ||||||||||||
458 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
459 | } | - | ||||||||||||
460 | break; executed 21 times by 2 tests: break; Executed by:
| 21 | ||||||||||||
461 | } | - | ||||||||||||
462 | - | |||||||||||||
463 | case executed 4 times by 1 test: QVariant::Line:case QVariant::Line: Executed by:
executed 4 times by 1 test: {case QVariant::Line: Executed by:
| 4 | ||||||||||||
464 | QLine *s = static_cast<QLine *>(result); | - | ||||||||||||
465 | switch (d->type) { | - | ||||||||||||
466 | case executed 4 times by 1 test: QVariant::LineF:case QVariant::LineF: Executed by:
executed 4 times by 1 test: case QVariant::LineF: Executed by:
| 4 | ||||||||||||
467 | *s = v_cast<QLineF>(d)->toLine(); | - | ||||||||||||
468 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
469 | default never executed: :default: never executed: default: | 0 | ||||||||||||
470 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
471 | } | - | ||||||||||||
472 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
473 | } | - | ||||||||||||
474 | - | |||||||||||||
475 | case executed 6 times by 2 tests: QVariant::LineF:case QVariant::LineF: Executed by:
executed 6 times by 2 tests: {case QVariant::LineF: Executed by:
| 6 | ||||||||||||
476 | QLineF *s = static_cast<QLineF *>(result); | - | ||||||||||||
477 | switch (d->type) { | - | ||||||||||||
478 | case executed 4 times by 1 test: QVariant::Line:case QVariant::Line: Executed by:
executed 4 times by 1 test: case QVariant::Line: Executed by:
| 4 | ||||||||||||
479 | *s = QLineF(*(v_cast<QLine>(d))); | - | ||||||||||||
480 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
481 | default executed 2 times by 1 test: :default: Executed by:
executed 2 times by 1 test: default: Executed by:
| 2 | ||||||||||||
482 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
483 | } | - | ||||||||||||
484 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
485 | } | - | ||||||||||||
486 | - | |||||||||||||
487 | case executed 30 times by 26 tests: QVariant::StringList:case QVariant::StringList: Executed by:
executed 30 times by 26 tests: case QVariant::StringList: Executed by:
| 30 | ||||||||||||
488 | if (d->type == QVariant::List
| 0-30 | ||||||||||||
489 | QStringList *slst = static_cast<QStringList *>(result); | - | ||||||||||||
490 | const QVariantList *list = v_cast<QVariantList >(d); | - | ||||||||||||
491 | const int size = list->size(); | - | ||||||||||||
492 | slst->reserve(size); | - | ||||||||||||
493 | for (int i = 0; i < list->size();
| 0 | ||||||||||||
494 | slst->append(list->at(i).toString()); never executed: slst->append(list->at(i).toString()); | 0 | ||||||||||||
495 | } never executed: else if (d->type == QVariant::Stringend of block
| 0-30 | ||||||||||||
496 | QStringList *slst = static_cast<QStringList *>(result); | - | ||||||||||||
497 | *slst = QStringList(*v_cast<QString>(d)); | - | ||||||||||||
498 | } never executed: else {end of block | 0 | ||||||||||||
499 | return executed 30 times by 26 tests: false;return false; Executed by:
executed 30 times by 26 tests: return false; Executed by:
| 30 | ||||||||||||
500 | } | - | ||||||||||||
501 | break; never executed: break; | 0 | ||||||||||||
502 | case executed 12673 times by 4 tests: QVariant::Date:case QVariant::Date: Executed by:
executed 12673 times by 4 tests: {case QVariant::Date: Executed by:
| 12673 | ||||||||||||
503 | QDate *dt = static_cast<QDate *>(result); | - | ||||||||||||
504 | if (d->type == QVariant::DateTime
| 2-12671 | ||||||||||||
505 | * executed 12671 times by 4 tests: dt = v_cast<QDateTime>(d)->date();*dt = v_cast<QDateTime>(d)->date(); Executed by:
executed 12671 times by 4 tests: *dt = v_cast<QDateTime>(d)->date(); Executed by:
| 12671 | ||||||||||||
506 | - | |||||||||||||
507 | else if (d->type == QVariant::String
| 0-2 | ||||||||||||
508 | * executed 2 times by 1 test: dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);*dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate); Executed by:
executed 2 times by 1 test: *dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate); Executed by:
| 2 | ||||||||||||
509 | - | |||||||||||||
510 | else | - | ||||||||||||
511 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
512 | - | |||||||||||||
513 | return executed 12673 times by 4 tests: dt->isValid();return dt->isValid(); Executed by:
executed 12673 times by 4 tests: return dt->isValid(); Executed by:
| 12673 | ||||||||||||
514 | } | - | ||||||||||||
515 | case executed 10943 times by 5 tests: QVariant::Time:case QVariant::Time: Executed by:
executed 10943 times by 5 tests: {case QVariant::Time: Executed by:
| 10943 | ||||||||||||
516 | QTime *t = static_cast<QTime *>(result); | - | ||||||||||||
517 | switch (d->type) { | - | ||||||||||||
518 | case executed 10941 times by 5 tests: QVariant::DateTime:case QVariant::DateTime: Executed by:
executed 10941 times by 5 tests: case QVariant::DateTime: Executed by:
| 10941 | ||||||||||||
519 | *t = v_cast<QDateTime>(d)->time(); | - | ||||||||||||
520 | break; executed 10941 times by 5 tests: break; Executed by:
| 10941 | ||||||||||||
521 | - | |||||||||||||
522 | case executed 2 times by 1 test: QVariant::String:case QVariant::String: Executed by:
executed 2 times by 1 test: case QVariant::String: Executed by:
| 2 | ||||||||||||
523 | *t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate); | - | ||||||||||||
524 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
525 | - | |||||||||||||
526 | default never executed: :default: never executed: default: | 0 | ||||||||||||
527 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
528 | } | - | ||||||||||||
529 | return executed 10943 times by 5 tests: t->isValid();return t->isValid(); Executed by:
executed 10943 times by 5 tests: return t->isValid(); Executed by:
| 10943 | ||||||||||||
530 | } | - | ||||||||||||
531 | case executed 940 times by 7 tests: QVariant::DateTime:case QVariant::DateTime: Executed by:
executed 940 times by 7 tests: {case QVariant::DateTime: Executed by:
| 940 | ||||||||||||
532 | QDateTime *dt = static_cast<QDateTime *>(result); | - | ||||||||||||
533 | switch (d->type) { | - | ||||||||||||
534 | - | |||||||||||||
535 | case executed 9 times by 2 tests: QVariant::String:case QVariant::String: Executed by:
executed 9 times by 2 tests: case QVariant::String: Executed by:
| 9 | ||||||||||||
536 | *dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate); | - | ||||||||||||
537 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||
538 | - | |||||||||||||
539 | case executed 2 times by 2 tests: QVariant::Date:case QVariant::Date: Executed by:
executed 2 times by 2 tests: case QVariant::Date: Executed by:
| 2 | ||||||||||||
540 | *dt = QDateTime(*v_cast<QDate>(d)); | - | ||||||||||||
541 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||
542 | default executed 929 times by 5 tests: :default: Executed by:
executed 929 times by 5 tests: default: Executed by:
| 929 | ||||||||||||
543 | return executed 929 times by 5 tests: false;return false; Executed by:
executed 929 times by 5 tests: return false; Executed by:
| 929 | ||||||||||||
544 | } | - | ||||||||||||
545 | return executed 11 times by 3 tests: dt->isValid();return dt->isValid(); Executed by:
executed 11 times by 3 tests: return dt->isValid(); Executed by:
| 11 | ||||||||||||
546 | } | - | ||||||||||||
547 | case executed 611 times by 11 tests: QVariant::ByteArray:case QVariant::ByteArray: Executed by:
executed 611 times by 11 tests: {case QVariant::ByteArray: Executed by:
| 611 | ||||||||||||
548 | QByteArray *ba = static_cast<QByteArray *>(result); | - | ||||||||||||
549 | switch (d->type) { | - | ||||||||||||
550 | case executed 118 times by 6 tests: QVariant::String:case QVariant::String: Executed by:
executed 118 times by 6 tests: case QVariant::String: Executed by:
| 118 | ||||||||||||
551 | *ba = v_cast<QString>(d)->toUtf8(); | - | ||||||||||||
552 | break; executed 118 times by 6 tests: break; Executed by:
| 118 | ||||||||||||
553 | case executed 3 times by 1 test: QVariant::Double:case QVariant::Double: Executed by:
executed 3 times by 1 test: case QVariant::Double: Executed by:
| 3 | ||||||||||||
554 | *ba = QByteArray::number(d->data.d, 'g', max_digits10_doubleQLocale::FloatingPointShortest); | - | ||||||||||||
555 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
556 | case executed 3 times by 1 test: QMetaType::Float:case QMetaType::Float: Executed by:
executed 3 times by 1 test: case QMetaType::Float: Executed by:
| 3 | ||||||||||||
557 | *ba = QByteArray::number(d->data.f, 'g', max_digits10_floatQLocale::FloatingPointShortest); | - | ||||||||||||
558 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
559 | case never executed: QMetaType::Char:case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||
560 | case never executed: QMetaType::SChar:case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||
561 | case never executed: QMetaType::UChar:case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||
562 | *ba = QByteArray(1, d->data.c); | - | ||||||||||||
563 | break; never executed: break; | 0 | ||||||||||||
564 | case executed 6 times by 4 tests: QVariant::Int:case QVariant::Int: Executed by:
executed 6 times by 4 tests: case QVariant::Int: Executed by:
| 6 | ||||||||||||
565 | case executed 249 times by 5 tests: QVariant::LongLong:case QVariant::LongLong: Executed by:
executed 249 times by 5 tests: case QVariant::LongLong: Executed by:
| 249 | ||||||||||||
566 | case never executed: QMetaType::Short:case QMetaType::Short: never executed: case QMetaType::Short: | 0 | ||||||||||||
567 | case never executed: QMetaType::Long:case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||
568 | *ba = QByteArray::number(qMetaTypeNumber(d)); | - | ||||||||||||
569 | break; executed 255 times by 6 tests: break; Executed by:
| 255 | ||||||||||||
570 | case executed 2 times by 1 test: QVariant::UInt:case QVariant::UInt: Executed by:
executed 2 times by 1 test: case QVariant::UInt: Executed by:
| 2 | ||||||||||||
571 | case executed 2 times by 1 test: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 2 times by 1 test: case QVariant::ULongLong: Executed by:
| 2 | ||||||||||||
572 | case never executed: QMetaType::UShort:case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||
573 | case never executed: QMetaType::ULong:case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||
574 | *ba = QByteArray::number(qMetaTypeUNumber(d)); | - | ||||||||||||
575 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
576 | case executed 3 times by 1 test: QVariant::Bool:case QVariant::Bool: Executed by:
executed 3 times by 1 test: case QVariant::Bool: Executed by:
| 3 | ||||||||||||
577 | *ba = QByteArray(d->data.b ? "true" : "false"); | - | ||||||||||||
578 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
579 | default executed 225 times by 4 tests: :default: Executed by:
executed 225 times by 4 tests: default: Executed by:
| 225 | ||||||||||||
580 | - | |||||||||||||
581 | { | - | ||||||||||||
582 | QMetaEnum en = metaEnumFromType(d->type); | - | ||||||||||||
583 | if (en.isValid()
| 10-215 | ||||||||||||
584 | *ba = en.valueToKey(qConvertToNumber(d, ok)); | - | ||||||||||||
585 | return executed 10 times by 1 test: *ok;return *ok; Executed by:
executed 10 times by 1 test: return *ok; Executed by:
| 10 | ||||||||||||
586 | } | - | ||||||||||||
587 | } | - | ||||||||||||
588 | - | |||||||||||||
589 | return executed 215 times by 3 tests: false;return false; Executed by:
executed 215 times by 3 tests: return false; Executed by:
| 215 | ||||||||||||
590 | } | - | ||||||||||||
591 | } | - | ||||||||||||
592 | break; executed 386 times by 8 tests: break; Executed by:
| 386 | ||||||||||||
593 | case executed 28 times by 2 tests: QMetaType::Short:case QMetaType::Short: Executed by:
executed 28 times by 2 tests: case QMetaType::Short: Executed by:
| 28 | ||||||||||||
594 | *static_cast<short *>(result) = short(qConvertToNumber(d, ok)); | - | ||||||||||||
595 | return executed 28 times by 2 tests: *ok;return *ok; Executed by:
executed 28 times by 2 tests: return *ok; Executed by:
| 28 | ||||||||||||
596 | case executed 1 time by 1 test: QMetaType::Long:case QMetaType::Long: Executed by:
executed 1 time by 1 test: case QMetaType::Long: Executed by:
| 1 | ||||||||||||
597 | *static_cast<long *>(result) = long(qConvertToNumber(d, ok)); | - | ||||||||||||
598 | return executed 1 time by 1 test: *ok;return *ok; Executed by:
executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||
599 | case executed 31 times by 1 test: QMetaType::UShort:case QMetaType::UShort: Executed by:
executed 31 times by 1 test: case QMetaType::UShort: Executed by:
| 31 | ||||||||||||
600 | *static_cast<ushort *>(result) = ushort(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||
601 | return executed 31 times by 1 test: *ok;return *ok; Executed by:
executed 31 times by 1 test: return *ok; Executed by:
| 31 | ||||||||||||
602 | case executed 7 times by 1 test: QMetaType::ULong:case QMetaType::ULong: Executed by:
executed 7 times by 1 test: case QMetaType::ULong: Executed by:
| 7 | ||||||||||||
603 | *static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||
604 | return executed 7 times by 1 test: *ok;return *ok; Executed by:
executed 7 times by 1 test: return *ok; Executed by:
| 7 | ||||||||||||
605 | case executed 16313 times by 69 tests: QVariant::Int:case QVariant::Int: Executed by:
executed 16313 times by 69 tests: case QVariant::Int: Executed by:
| 16313 | ||||||||||||
606 | *static_cast<int *>(result) = int(qConvertToNumber(d, ok)); | - | ||||||||||||
607 | return executed 16313 times by 69 tests: *ok;return *ok; Executed by:
executed 16313 times by 69 tests: return *ok; Executed by:
| 16313 | ||||||||||||
608 | case executed 189 times by 24 tests: QVariant::UInt:case QVariant::UInt: Executed by:
executed 189 times by 24 tests: case QVariant::UInt: Executed by:
| 189 | ||||||||||||
609 | *static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok)); | - | ||||||||||||
610 | return executed 189 times by 24 tests: *ok;return *ok; Executed by:
executed 189 times by 24 tests: return *ok; Executed by:
| 189 | ||||||||||||
611 | case executed 10784 times by 15 tests: QVariant::LongLong:case QVariant::LongLong: Executed by:
executed 10784 times by 15 tests: case QVariant::LongLong: Executed by:
| 10784 | ||||||||||||
612 | *static_cast<qlonglong *>(result) = qConvertToNumber(d, ok); | - | ||||||||||||
613 | return executed 10784 times by 15 tests: *ok;return *ok; Executed by:
executed 10784 times by 15 tests: return *ok; Executed by:
| 10784 | ||||||||||||
614 | case executed 135 times by 12 tests: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 135 times by 12 tests: {case QVariant::ULongLong: Executed by:
| 135 | ||||||||||||
615 | *static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok); | - | ||||||||||||
616 | return executed 135 times by 12 tests: *ok;return *ok; Executed by:
executed 135 times by 12 tests: return *ok; Executed by:
| 135 | ||||||||||||
617 | } | - | ||||||||||||
618 | case executed 1 time by 1 test: QMetaType::SChar:case QMetaType::SChar: Executed by:
executed 1 time by 1 test: {case QMetaType::SChar: Executed by:
| 1 | ||||||||||||
619 | signed char s = qConvertToNumber(d, ok); | - | ||||||||||||
620 | *static_cast<signed char*>(result) = s; | - | ||||||||||||
621 | return executed 1 time by 1 test: *ok;return *ok; Executed by:
executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||
622 | } | - | ||||||||||||
623 | case executed 1 time by 1 test: QMetaType::UChar:case QMetaType::UChar: Executed by:
executed 1 time by 1 test: {case QMetaType::UChar: Executed by:
| 1 | ||||||||||||
624 | *static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok); | - | ||||||||||||
625 | return executed 1 time by 1 test: *ok;return *ok; Executed by:
executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||
626 | } | - | ||||||||||||
627 | case executed 39499 times by 116 tests: QVariant::Bool:case QVariant::Bool: Executed by:
executed 39499 times by 116 tests: {case QVariant::Bool: Executed by:
| 39499 | ||||||||||||
628 | bool *b = static_cast<bool *>(result); | - | ||||||||||||
629 | switch(d->type) { | - | ||||||||||||
630 | case executed 10 times by 1 test: QVariant::ByteArray:case QVariant::ByteArray: Executed by:
executed 10 times by 1 test: case QVariant::ByteArray: Executed by:
| 10 | ||||||||||||
631 | *b = qt_convertToBool<QByteArray, QByteArray>(d); | - | ||||||||||||
632 | break; executed 10 times by 1 test: break; Executed by:
| 10 | ||||||||||||
633 | case executed 20 times by 3 tests: QVariant::String:case QVariant::String: Executed by:
executed 20 times by 3 tests: case QVariant::String: Executed by:
| 20 | ||||||||||||
634 | *b = qt_convertToBool<QString, QLatin1String>(d); | - | ||||||||||||
635 | break; executed 20 times by 3 tests: break; Executed by:
| 20 | ||||||||||||
636 | case executed 2 times by 1 test: QVariant::Char:case QVariant::Char: Executed by:
executed 2 times by 1 test: case QVariant::Char: Executed by:
| 2 | ||||||||||||
637 | *b = !v_cast<QChar>(d)->isNull(); | - | ||||||||||||
638 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
639 | case executed 11 times by 2 tests: QVariant::Double:case QVariant::Double: Executed by:
executed 11 times by 2 tests: case QVariant::Double: Executed by:
| 11 | ||||||||||||
640 | case executed 35 times by 4 tests: QVariant::Int:case QVariant::Int: Executed by:
executed 35 times by 4 tests: case QVariant::Int: Executed by:
| 35 | ||||||||||||
641 | case executed 16 times by 2 tests: QVariant::LongLong:case QVariant::LongLong: Executed by:
executed 16 times by 2 tests: case QVariant::LongLong: Executed by:
| 16 | ||||||||||||
642 | case executed 4 times by 1 test: QMetaType::Char:case QMetaType::Char: Executed by:
executed 4 times by 1 test: case QMetaType::Char: Executed by:
| 4 | ||||||||||||
643 | case executed 8 times by 1 test: QMetaType::SChar:case QMetaType::SChar: Executed by:
executed 8 times by 1 test: case QMetaType::SChar: Executed by:
| 8 | ||||||||||||
644 | case executed 8 times by 1 test: QMetaType::Short:case QMetaType::Short: Executed by:
executed 8 times by 1 test: case QMetaType::Short: Executed by:
| 8 | ||||||||||||
645 | case never executed: QMetaType::Long:case QMetaType::Long: never executed: case QMetaType::Long: | 0 | ||||||||||||
646 | case executed 6 times by 1 test: QMetaType::Float:case QMetaType::Float: Executed by:
executed 6 times by 1 test: case QMetaType::Float: Executed by:
| 6 | ||||||||||||
647 | *b = qMetaTypeNumber(d) != static_cast<long long>(0LL); | - | ||||||||||||
648 | break; executed 88 times by 6 tests: break; Executed by:
| 88 | ||||||||||||
649 | case executed 1266 times by 12 tests: QVariant::UInt:case QVariant::UInt: Executed by:
executed 1266 times by 12 tests: case QVariant::UInt: Executed by:
| 1266 | ||||||||||||
650 | case executed 10 times by 1 test: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 10 times by 1 test: case QVariant::ULongLong: Executed by:
| 10 | ||||||||||||
651 | case executed 8 times by 1 test: QMetaType::UChar:case QMetaType::UChar: Executed by:
executed 8 times by 1 test: case QMetaType::UChar: Executed by:
| 8 | ||||||||||||
652 | case executed 8 times by 1 test: QMetaType::UShort:case QMetaType::UShort: Executed by:
executed 8 times by 1 test: case QMetaType::UShort: Executed by:
| 8 | ||||||||||||
653 | case never executed: QMetaType::ULong:case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||
654 | *b = qMetaTypeUNumber(d) != static_cast<unsigned long long>(0ULL); | - | ||||||||||||
655 | break; executed 1292 times by 12 tests: break; Executed by:
| 1292 | ||||||||||||
656 | - | |||||||||||||
657 | case executed 2 times by 1 test: QMetaType::QJsonValue:case QMetaType::QJsonValue: Executed by:
executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||
658 | *b = v_cast<QJsonValue>(d)->toBool(false); | - | ||||||||||||
659 | if (!v_cast<QJsonValue>(d)->isBool()
| 0-2 | ||||||||||||
660 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
661 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
662 | - | |||||||||||||
663 | default executed 38085 times by 111 tests: :default: Executed by:
executed 38085 times by 111 tests: default: Executed by:
| 38085 | ||||||||||||
664 | *b = false; | - | ||||||||||||
665 | return executed 38085 times by 111 tests: false;return false; Executed by:
executed 38085 times by 111 tests: return false; Executed by:
| 38085 | ||||||||||||
666 | } | - | ||||||||||||
667 | break; executed 1414 times by 17 tests: break; Executed by:
| 1414 | ||||||||||||
668 | } | - | ||||||||||||
669 | case executed 635 times by 17 tests: QVariant::Double:case QVariant::Double: Executed by:
executed 635 times by 17 tests: {case QVariant::Double: Executed by:
| 635 | ||||||||||||
670 | double *f = static_cast<double *>(result); | - | ||||||||||||
671 | switch (d->type) { | - | ||||||||||||
672 | case executed 370 times by 13 tests: QVariant::String:case QVariant::String: Executed by:
executed 370 times by 13 tests: case QVariant::String: Executed by:
| 370 | ||||||||||||
673 | *f = v_cast<QString>(d)->toDouble(ok); | - | ||||||||||||
674 | break; executed 370 times by 13 tests: break; Executed by:
| 370 | ||||||||||||
675 | case executed 3 times by 1 test: QVariant::ByteArray:case QVariant::ByteArray: Executed by:
executed 3 times by 1 test: case QVariant::ByteArray: Executed by:
| 3 | ||||||||||||
676 | *f = v_cast<QByteArray>(d)->toDouble(ok); | - | ||||||||||||
677 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
678 | case executed 8 times by 1 test: QVariant::Bool:case QVariant::Bool: Executed by:
executed 8 times by 1 test: case QVariant::Bool: Executed by:
| 8 | ||||||||||||
679 | *f = double(d->data.b); | - | ||||||||||||
680 | break; executed 8 times by 1 test: break; Executed by:
| 8 | ||||||||||||
681 | case executed 9 times by 2 tests: QMetaType::Float:case QMetaType::Float: Executed by:
executed 9 times by 2 tests: case QMetaType::Float: Executed by:
| 9 | ||||||||||||
682 | *f = double(d->data.f); | - | ||||||||||||
683 | break; executed 9 times by 2 tests: break; Executed by:
| 9 | ||||||||||||
684 | case executed 10 times by 2 tests: QVariant::LongLong:case QVariant::LongLong: Executed by:
executed 10 times by 2 tests: case QVariant::LongLong: Executed by:
| 10 | ||||||||||||
685 | case executed 47 times by 4 tests: QVariant::Int:case QVariant::Int: Executed by:
executed 47 times by 4 tests: case QVariant::Int: Executed by:
| 47 | ||||||||||||
686 | case executed 4 times by 1 test: QMetaType::Char:case QMetaType::Char: Executed by:
executed 4 times by 1 test: case QMetaType::Char: Executed by:
| 4 | ||||||||||||
687 | case executed 8 times by 1 test: QMetaType::SChar:case QMetaType::SChar: Executed by:
executed 8 times by 1 test: case QMetaType::SChar: Executed by:
| 8 | ||||||||||||
688 | case executed 9 times by 1 test: QMetaType::Short:case QMetaType::Short: Executed by:
executed 9 times by 1 test: case QMetaType::Short: Executed by:
| 9 | ||||||||||||
689 | case executed 3 times by 1 test: QMetaType::Long:case QMetaType::Long: Executed by:
executed 3 times by 1 test: case QMetaType::Long: Executed by:
| 3 | ||||||||||||
690 | *f = double(qMetaTypeNumber(d)); | - | ||||||||||||
691 | break; executed 81 times by 5 tests: break; Executed by:
| 81 | ||||||||||||
692 | case executed 6 times by 1 test: QVariant::UInt:case QVariant::UInt: Executed by:
executed 6 times by 1 test: case QVariant::UInt: Executed by:
| 6 | ||||||||||||
693 | case executed 10 times by 1 test: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 10 times by 1 test: case QVariant::ULongLong: Executed by:
| 10 | ||||||||||||
694 | case executed 8 times by 1 test: QMetaType::UChar:case QMetaType::UChar: Executed by:
executed 8 times by 1 test: case QMetaType::UChar: Executed by:
| 8 | ||||||||||||
695 | case executed 8 times by 1 test: QMetaType::UShort:case QMetaType::UShort: Executed by:
executed 8 times by 1 test: case QMetaType::UShort: Executed by:
| 8 | ||||||||||||
696 | case never executed: QMetaType::ULong:case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||
697 | *f = double(qMetaTypeUNumber(d)); | - | ||||||||||||
698 | break; executed 32 times by 1 test: break; Executed by:
| 32 | ||||||||||||
699 | - | |||||||||||||
700 | case executed 2 times by 1 test: QMetaType::QJsonValue:case QMetaType::QJsonValue: Executed by:
executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||
701 | *f = v_cast<QJsonValue>(d)->toDouble(0.0); | - | ||||||||||||
702 | if (!v_cast<QJsonValue>(d)->isDouble()
| 1 | ||||||||||||
703 | return executed 1 time by 1 test: false;return false; Executed by:
executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||
704 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
705 | - | |||||||||||||
706 | default executed 130 times by 1 test: :default: Executed by:
executed 130 times by 1 test: default: Executed by:
| 130 | ||||||||||||
707 | *f = 0.0; | - | ||||||||||||
708 | return executed 130 times by 1 test: false;return false; Executed by:
executed 130 times by 1 test: return false; Executed by:
| 130 | ||||||||||||
709 | } | - | ||||||||||||
710 | break; executed 504 times by 17 tests: break; Executed by:
| 504 | ||||||||||||
711 | } | - | ||||||||||||
712 | case executed 25 times by 3 tests: QMetaType::Float:case QMetaType::Float: Executed by:
executed 25 times by 3 tests: {case QMetaType::Float: Executed by:
| 25 | ||||||||||||
713 | float *f = static_cast<float *>(result); | - | ||||||||||||
714 | switch (d->type) { | - | ||||||||||||
715 | case executed 7 times by 2 tests: QVariant::String:case QVariant::String: Executed by:
executed 7 times by 2 tests: case QVariant::String: Executed by:
| 7 | ||||||||||||
716 | *f = v_cast<QString>(d)->toFloat(ok); | - | ||||||||||||
717 | break; executed 7 times by 2 tests: break; Executed by:
| 7 | ||||||||||||
718 | case executed 3 times by 1 test: QVariant::ByteArray:case QVariant::ByteArray: Executed by:
executed 3 times by 1 test: case QVariant::ByteArray: Executed by:
| 3 | ||||||||||||
719 | *f = v_cast<QByteArray>(d)->toFloat(ok); | - | ||||||||||||
720 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
721 | case never executed: QVariant::Bool:case QVariant::Bool: never executed: case QVariant::Bool: | 0 | ||||||||||||
722 | *f = float(d->data.b); | - | ||||||||||||
723 | break; never executed: break; | 0 | ||||||||||||
724 | case executed 3 times by 1 test: QVariant::Double:case QVariant::Double: Executed by:
executed 3 times by 1 test: case QVariant::Double: Executed by:
| 3 | ||||||||||||
725 | *f = float(d->data.d); | - | ||||||||||||
726 | break; executed 3 times by 1 test: break; Executed by:
| 3 | ||||||||||||
727 | case never executed: QVariant::LongLong:case QVariant::LongLong: never executed: case QVariant::LongLong: | 0 | ||||||||||||
728 | case executed 3 times by 1 test: QVariant::Int:case QVariant::Int: Executed by:
executed 3 times by 1 test: case QVariant::Int: Executed by:
| 3 | ||||||||||||
729 | case never executed: QMetaType::Char:case QMetaType::Char: never executed: case QMetaType::Char: | 0 | ||||||||||||
730 | case never executed: QMetaType::SChar:case QMetaType::SChar: never executed: case QMetaType::SChar: | 0 | ||||||||||||
731 | case executed 1 time by 1 test: QMetaType::Short:case QMetaType::Short: Executed by:
executed 1 time by 1 test: case QMetaType::Short: Executed by:
| 1 | ||||||||||||
732 | case executed 2 times by 1 test: QMetaType::Long:case QMetaType::Long: Executed by:
executed 2 times by 1 test: case QMetaType::Long: Executed by:
| 2 | ||||||||||||
733 | *f = float(qMetaTypeNumber(d)); | - | ||||||||||||
734 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||
735 | case executed 1 time by 1 test: QVariant::UInt:case QVariant::UInt: Executed by:
executed 1 time by 1 test: case QVariant::UInt: Executed by:
| 1 | ||||||||||||
736 | case executed 1 time by 1 test: QVariant::ULongLong:case QVariant::ULongLong: Executed by:
executed 1 time by 1 test: case QVariant::ULongLong: Executed by:
| 1 | ||||||||||||
737 | case never executed: QMetaType::UChar:case QMetaType::UChar: never executed: case QMetaType::UChar: | 0 | ||||||||||||
738 | case never executed: QMetaType::UShort:case QMetaType::UShort: never executed: case QMetaType::UShort: | 0 | ||||||||||||
739 | case never executed: QMetaType::ULong:case QMetaType::ULong: never executed: case QMetaType::ULong: | 0 | ||||||||||||
740 | *f = float(qMetaTypeUNumber(d)); | - | ||||||||||||
741 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
742 | - | |||||||||||||
743 | case executed 2 times by 1 test: QMetaType::QJsonValue:case QMetaType::QJsonValue: Executed by:
executed 2 times by 1 test: case QMetaType::QJsonValue: Executed by:
| 2 | ||||||||||||
744 | *f = v_cast<QJsonValue>(d)->toDouble(0.0); | - | ||||||||||||
745 | if (!v_cast<QJsonValue>(d)->isDouble()
| 1 | ||||||||||||
746 | return executed 1 time by 1 test: false;return false; Executed by:
executed 1 time by 1 test: return false; Executed by:
| 1 | ||||||||||||
747 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
748 | - | |||||||||||||
749 | default executed 2 times by 1 test: :default: Executed by:
executed 2 times by 1 test: default: Executed by:
| 2 | ||||||||||||
750 | *f = 0.0f; | - | ||||||||||||
751 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
752 | } | - | ||||||||||||
753 | break; executed 22 times by 2 tests: break; Executed by:
| 22 | ||||||||||||
754 | } | - | ||||||||||||
755 | case executed 489 times by 6 tests: QVariant::List:case QVariant::List: Executed by:
executed 489 times by 6 tests: case QVariant::List: Executed by:
| 489 | ||||||||||||
756 | if (d->type == QVariant::StringList
| 0-489 | ||||||||||||
757 | QVariantList *lst = static_cast<QVariantList *>(result); | - | ||||||||||||
758 | const QStringList *slist = v_cast<QStringList>(d); | - | ||||||||||||
759 | const int size = slist->size(); | - | ||||||||||||
760 | lst->reserve(size); | - | ||||||||||||
761 | for (int i = 0; i < slist->size();
| 489-813 | ||||||||||||
762 | lst->append(QVariant(slist->at(i))); executed 813 times by 6 tests: lst->append(QVariant(slist->at(i))); Executed by:
| 813 | ||||||||||||
763 | } executed 489 times by 6 tests: else if (qstrcmp(QMetaType::typeName(d->type), "QList<QVariant>") == 0end of block Executed by:
| 0-489 | ||||||||||||
764 | *static_cast<QVariantList *>(result) = | - | ||||||||||||
765 | *static_cast<QList<QVariant> *>(d->data.shared->ptr); | - | ||||||||||||
766 | - | |||||||||||||
767 | } never executed: else if (d->type == QMetaType::QJsonValueend of block
| 0 | ||||||||||||
768 | if (!v_cast<QJsonValue>(d)->isArray()
| 0 | ||||||||||||
769 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
770 | *static_cast<QVariantList *>(result) = v_cast<QJsonValue>(d)->toArray().toVariantList(); | - | ||||||||||||
771 | } never executed: else if (d->type == QMetaType::QJsonArrayend of block
| 0 | ||||||||||||
772 | *static_cast<QVariantList *>(result) = v_cast<QJsonArray>(d)->toVariantList(); | - | ||||||||||||
773 | - | |||||||||||||
774 | } never executed: else {end of block | 0 | ||||||||||||
775 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
776 | } | - | ||||||||||||
777 | break; executed 489 times by 6 tests: break; Executed by:
| 489 | ||||||||||||
778 | case executed 2 times by 1 test: QVariant::Map:case QVariant::Map: Executed by:
executed 2 times by 1 test: case QVariant::Map: Executed by:
| 2 | ||||||||||||
779 | if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0
| 0-2 | ||||||||||||
780 | *static_cast<QVariantMap *>(result) = | - | ||||||||||||
781 | *static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr); | - | ||||||||||||
782 | - | |||||||||||||
783 | } never executed: else if (d->type == QMetaType::QJsonValueend of block
| 0-2 | ||||||||||||
784 | if (!v_cast<QJsonValue>(d)->isObject()
| 0 | ||||||||||||
785 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
786 | *static_cast<QVariantMap *>(result) = v_cast<QJsonValue>(d)->toObject().toVariantMap(); | - | ||||||||||||
787 | } never executed: else if (d->type == QMetaType::QJsonObjectend of block
| 0-2 | ||||||||||||
788 | *static_cast<QVariantMap *>(result) = v_cast<QJsonObject>(d)->toVariantMap(); | - | ||||||||||||
789 | - | |||||||||||||
790 | } never executed: else {end of block | 0 | ||||||||||||
791 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
792 | } | - | ||||||||||||
793 | break; never executed: break; | 0 | ||||||||||||
794 | case never executed: QVariant::Hash:case QVariant::Hash: never executed: case QVariant::Hash: | 0 | ||||||||||||
795 | if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0
| 0 | ||||||||||||
796 | *static_cast<QVariantHash *>(result) = | - | ||||||||||||
797 | *static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr); | - | ||||||||||||
798 | - | |||||||||||||
799 | } never executed: else if (d->type == QMetaType::QJsonValueend of block
| 0 | ||||||||||||
800 | if (!v_cast<QJsonValue>(d)->isObject()
| 0 | ||||||||||||
801 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
802 | *static_cast<QVariantHash *>(result) = v_cast<QJsonValue>(d)->toObject().toVariantHash(); | - | ||||||||||||
803 | } never executed: else if (d->type == QMetaType::QJsonObjectend of block
| 0 | ||||||||||||
804 | *static_cast<QVariantHash *>(result) = v_cast<QJsonObject>(d)->toVariantHash(); | - | ||||||||||||
805 | - | |||||||||||||
806 | } never executed: else {end of block | 0 | ||||||||||||
807 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
808 | } | - | ||||||||||||
809 | break; never executed: break; | 0 | ||||||||||||
810 | - | |||||||||||||
811 | case executed 8 times by 4 tests: QVariant::Rect:case QVariant::Rect: Executed by:
executed 8 times by 4 tests: case QVariant::Rect: Executed by:
| 8 | ||||||||||||
812 | if (d->type == QVariant::RectF
| 0-8 | ||||||||||||
813 | *static_cast< executed 8 times by 4 tests: QRect *>(result) = (v_cast<QRectF>(d))->toRect();*static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect(); Executed by:
executed 8 times by 4 tests: *static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect(); Executed by:
| 8 | ||||||||||||
814 | else | - | ||||||||||||
815 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
816 | break; executed 8 times by 4 tests: break; Executed by:
| 8 | ||||||||||||
817 | case executed 3 times by 2 tests: QVariant::RectF:case QVariant::RectF: Executed by:
executed 3 times by 2 tests: case QVariant::RectF: Executed by:
| 3 | ||||||||||||
818 | if (d->type == QVariant::Rect
| 1-2 | ||||||||||||
819 | *static_cast< executed 1 time by 1 test: QRectF *>(result) = *v_cast<QRect>(d);*static_cast<QRectF *>(result) = *v_cast<QRect>(d); Executed by:
executed 1 time by 1 test: *static_cast<QRectF *>(result) = *v_cast<QRect>(d); Executed by:
| 1 | ||||||||||||
820 | else | - | ||||||||||||
821 | return executed 2 times by 1 test: false;return false; Executed by:
executed 2 times by 1 test: return false; Executed by:
| 2 | ||||||||||||
822 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
823 | case executed 4 times by 2 tests: QVariant::PointF:case QVariant::PointF: Executed by:
executed 4 times by 2 tests: case QVariant::PointF: Executed by:
| 4 | ||||||||||||
824 | if (d->type == QVariant::Point
| 0-4 | ||||||||||||
825 | *static_cast< never executed: QPointF *>(result) = *v_cast<QPoint>(d);*static_cast<QPointF *>(result) = *v_cast<QPoint>(d); never executed: *static_cast<QPointF *>(result) = *v_cast<QPoint>(d); | 0 | ||||||||||||
826 | else | - | ||||||||||||
827 | return executed 4 times by 2 tests: false;return false; Executed by:
executed 4 times by 2 tests: return false; Executed by:
| 4 | ||||||||||||
828 | break; never executed: break; | 0 | ||||||||||||
829 | case executed 28 times by 3 tests: QVariant::Point:case QVariant::Point: Executed by:
executed 28 times by 3 tests: case QVariant::Point: Executed by:
| 28 | ||||||||||||
830 | if (d->type == QVariant::PointF
| 0-28 | ||||||||||||
831 | *static_cast< executed 28 times by 3 tests: QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();*static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint(); Executed by:
executed 28 times by 3 tests: *static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint(); Executed by:
| 28 | ||||||||||||
832 | else | - | ||||||||||||
833 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
834 | break; executed 28 times by 3 tests: break; Executed by:
| 28 | ||||||||||||
835 | case executed 1 time by 1 test: QMetaType::Char:case QMetaType::Char: Executed by:
executed 1 time by 1 test: case QMetaType::Char: Executed by:
| 1 | ||||||||||||
836 | { | - | ||||||||||||
837 | *static_cast<qint8 *>(result) = qint8(qConvertToNumber(d, ok)); | - | ||||||||||||
838 | return executed 1 time by 1 test: *ok;return *ok; Executed by:
executed 1 time by 1 test: return *ok; Executed by:
| 1 | ||||||||||||
839 | } | - | ||||||||||||
840 | - | |||||||||||||
841 | case executed 2 times by 2 tests: QVariant::Uuid:case QVariant::Uuid: Executed by:
executed 2 times by 2 tests: case QVariant::Uuid: Executed by:
| 2 | ||||||||||||
842 | switch (d->type) { | - | ||||||||||||
843 | case executed 2 times by 2 tests: QVariant::String:case QVariant::String: Executed by:
executed 2 times by 2 tests: case QVariant::String: Executed by:
| 2 | ||||||||||||
844 | *static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d)); | - | ||||||||||||
845 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||
846 | default never executed: :default: never executed: default: | 0 | ||||||||||||
847 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
848 | } | - | ||||||||||||
849 | break; executed 2 times by 2 tests: break; Executed by:
| 2 | ||||||||||||
850 | default executed 274114 times by 97 tests: :default: Executed by:
executed 274114 times by 97 tests: default: Executed by:
| 274114 | ||||||||||||
851 | - | |||||||||||||
852 | if (d->type == QVariant::String
| 7-274102 | ||||||||||||
853 | QMetaEnum en = metaEnumFromType(t); | - | ||||||||||||
854 | if (en.isValid()
| 2-17 | ||||||||||||
855 | QByteArray keys = (
| 7-10 | ||||||||||||
856 | int value = en.keysToValue(keys.constData(), ok); | - | ||||||||||||
857 | if (*
| 0-17 | ||||||||||||
858 | switch (QMetaType::sizeOf(t)) { | - | ||||||||||||
859 | case executed 2 times by 1 test: 1:case 1: Executed by:
executed 2 times by 1 test: case 1: Executed by:
| 2 | ||||||||||||
860 | *static_cast<signed char *>(result) = value; | - | ||||||||||||
861 | return executed 2 times by 1 test: true;return true; Executed by:
executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||
862 | case executed 2 times by 1 test: 2:case 2: Executed by:
executed 2 times by 1 test: case 2: Executed by:
| 2 | ||||||||||||
863 | *static_cast<qint16 *>(result) = value; | - | ||||||||||||
864 | return executed 2 times by 1 test: true;return true; Executed by:
executed 2 times by 1 test: return true; Executed by:
| 2 | ||||||||||||
865 | case executed 4 times by 1 test: 4:case 4: Executed by:
executed 4 times by 1 test: case 4: Executed by:
| 4 | ||||||||||||
866 | *static_cast<qint32 *>(result) = value; | - | ||||||||||||
867 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||
868 | case executed 9 times by 1 test: 8:case 8: Executed by:
executed 9 times by 1 test: case 8: Executed by:
| 9 | ||||||||||||
869 | *static_cast<qint64 *>(result) = value; | - | ||||||||||||
870 | return executed 9 times by 1 test: true;return true; Executed by:
executed 9 times by 1 test: return true; Executed by:
| 9 | ||||||||||||
871 | } | - | ||||||||||||
872 | } never executed: end of block | 0 | ||||||||||||
873 | } never executed: end of block | 0 | ||||||||||||
874 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
875 | - | |||||||||||||
876 | if (QMetaType::typeFlags(t) & QMetaType::IsEnumeration
| 40-274057 | ||||||||||||
877 | qlonglong value = qConvertToNumber(d, ok); | - | ||||||||||||
878 | if (*
| 0-40 | ||||||||||||
879 | switch (QMetaType::sizeOf(t)) { | - | ||||||||||||
880 | case executed 4 times by 1 test: 1:case 1: Executed by:
executed 4 times by 1 test: case 1: Executed by:
| 4 | ||||||||||||
881 | *static_cast<signed char *>(result) = value; | - | ||||||||||||
882 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||
883 | case executed 4 times by 1 test: 2:case 2: Executed by:
executed 4 times by 1 test: case 2: Executed by:
| 4 | ||||||||||||
884 | *static_cast<qint16 *>(result) = value; | - | ||||||||||||
885 | return executed 4 times by 1 test: true;return true; Executed by:
executed 4 times by 1 test: return true; Executed by:
| 4 | ||||||||||||
886 | case executed 12 times by 1 test: 4:case 4: Executed by:
executed 12 times by 1 test: case 4: Executed by:
| 12 | ||||||||||||
887 | *static_cast<qint32 *>(result) = value; | - | ||||||||||||
888 | return executed 12 times by 1 test: true;return true; Executed by:
executed 12 times by 1 test: return true; Executed by:
| 12 | ||||||||||||
889 | case executed 20 times by 1 test: 8:case 8: Executed by:
executed 20 times by 1 test: case 8: Executed by:
| 20 | ||||||||||||
890 | *static_cast<qint64 *>(result) = value; | - | ||||||||||||
891 | return executed 20 times by 1 test: true;return true; Executed by:
executed 20 times by 1 test: return true; Executed by:
| 20 | ||||||||||||
892 | } | - | ||||||||||||
893 | } never executed: end of block | 0 | ||||||||||||
894 | return never executed: *ok;return *ok; never executed: return *ok; | 0 | ||||||||||||
895 | } | - | ||||||||||||
896 | return executed 274057 times by 97 tests: false;return false; Executed by:
executed 274057 times by 97 tests: return false; Executed by:
| 274057 | ||||||||||||
897 | } | - | ||||||||||||
898 | return executed 38182 times by 84 tests: true;return true; Executed by:
executed 38182 times by 84 tests: return true; Executed by:
| 38182 | ||||||||||||
899 | } | - | ||||||||||||
900 | - | |||||||||||||
901 | - | |||||||||||||
902 | static void streamDebug(QDebug dbg, const QVariant &v) | - | ||||||||||||
903 | { | - | ||||||||||||
904 | QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); | - | ||||||||||||
905 | QVariantDebugStream<CoreTypesFilter> stream(dbg, d); | - | ||||||||||||
906 | QMetaTypeSwitcher::switcher<void>(stream, d->type, 0); | - | ||||||||||||
907 | } | - | ||||||||||||
908 | - | |||||||||||||
909 | - | |||||||||||||
910 | const QVariant::Handler qt_kernel_variant_handler = { | - | ||||||||||||
911 | construct, | - | ||||||||||||
912 | clear, | - | ||||||||||||
913 | isNull, | - | ||||||||||||
914 | - | |||||||||||||
915 | 0, | - | ||||||||||||
916 | 0, | - | ||||||||||||
917 | - | |||||||||||||
918 | compare, | - | ||||||||||||
919 | convert, | - | ||||||||||||
920 | 0, | - | ||||||||||||
921 | - | |||||||||||||
922 | streamDebug | - | ||||||||||||
923 | - | |||||||||||||
924 | - | |||||||||||||
925 | - | |||||||||||||
926 | }; | - | ||||||||||||
927 | - | |||||||||||||
928 | static void dummyConstruct(QVariant::Private *, const void *) { ((!(false)) ? qt_assert_x("QVariant", "Trying to construct an unknown type",__FILE__,1000) : qt_noop()); } | - | ||||||||||||
929 | static void dummyClear(QVariant::Private *) { ((!(false)) ? qt_assert_x("QVariant", "Trying to clear an unknown type",__FILE__,1001) : qt_noop()); } | - | ||||||||||||
930 | static bool dummyIsNull(const QVariant::Private *d) { ((!(false)) ? qt_assert_x("QVariant::isNull", "Trying to call isNull on an unknown type",__FILE__,1002) : qt_noop()); return d->is_null; } | - | ||||||||||||
931 | static bool dummyCompare(const QVariant::Private *, const QVariant::Private *) { ((!(false)) ? qt_assert_x("QVariant", "Trying to compare an unknown types",__FILE__,1003) : qt_noop()); return false; } | - | ||||||||||||
932 | static bool dummyConvert(const QVariant::Private *, int, void *, bool *) { ((!(false)) ? qt_assert_x("QVariant", "Trying to convert an unknown type",__FILE__,1004) : qt_noop()); return false; } | - | ||||||||||||
933 | - | |||||||||||||
934 | static void dummyStreamDebug(QDebug, const QVariant &) { ((!(false)) ? qt_assert_x("QVariant", "Trying to convert an unknown type",__FILE__,1006) : qt_noop()); } | - | ||||||||||||
935 | - | |||||||||||||
936 | const QVariant::Handler qt_dummy_variant_handler = { | - | ||||||||||||
937 | dummyConstruct, | - | ||||||||||||
938 | dummyClear, | - | ||||||||||||
939 | dummyIsNull, | - | ||||||||||||
940 | - | |||||||||||||
941 | 0, | - | ||||||||||||
942 | 0, | - | ||||||||||||
943 | - | |||||||||||||
944 | dummyCompare, | - | ||||||||||||
945 | dummyConvert, | - | ||||||||||||
946 | 0, | - | ||||||||||||
947 | - | |||||||||||||
948 | dummyStreamDebug | - | ||||||||||||
949 | - | |||||||||||||
950 | - | |||||||||||||
951 | - | |||||||||||||
952 | }; | - | ||||||||||||
953 | - | |||||||||||||
954 | static void customConstruct(QVariant::Private *d, const void *copy) | - | ||||||||||||
955 | { | - | ||||||||||||
956 | const QMetaType type(d->type); | - | ||||||||||||
957 | const uint size = type.sizeOf(); | - | ||||||||||||
958 | if (!size) { | - | ||||||||||||
959 | QMessageLogger(__FILE__, 1031, __PRETTY_FUNCTION__).warning("Trying to construct an instance of an invalid type, type id: %i", d->type); | - | ||||||||||||
960 | d->type = QVariant::Invalid; | - | ||||||||||||
961 | return; | - | ||||||||||||
962 | } | - | ||||||||||||
963 | - | |||||||||||||
964 | - | |||||||||||||
965 | if (size <= sizeof(QVariant::Private::Data) | - | ||||||||||||
966 | && (type.flags() & (QMetaType::MovableType | QMetaType::IsEnumeration))) { | - | ||||||||||||
967 | type.construct(&d->data.ptr, copy); | - | ||||||||||||
968 | d->is_shared = false; | - | ||||||||||||
969 | } else { | - | ||||||||||||
970 | void *ptr = type.create(copy); | - | ||||||||||||
971 | d->is_shared = true; | - | ||||||||||||
972 | d->data.shared = new QVariant::PrivateShared(ptr); | - | ||||||||||||
973 | } | - | ||||||||||||
974 | } | - | ||||||||||||
975 | - | |||||||||||||
976 | static void customClear(QVariant::Private *d) | - | ||||||||||||
977 | { | - | ||||||||||||
978 | if (!d->is_shared) { | - | ||||||||||||
979 | QMetaType::destruct(d->type, &d->data.ptr); | - | ||||||||||||
980 | } else { | - | ||||||||||||
981 | QMetaType::destroy(d->type, d->data.shared->ptr); | - | ||||||||||||
982 | delete d->data.shared; | - | ||||||||||||
983 | } | - | ||||||||||||
984 | } | - | ||||||||||||
985 | - | |||||||||||||
986 | static bool customIsNull(const QVariant::Private *d) | - | ||||||||||||
987 | { | - | ||||||||||||
988 | return d->is_null; | - | ||||||||||||
989 | } | - | ||||||||||||
990 | - | |||||||||||||
991 | static bool customCompare(const QVariant::Private *a, const QVariant::Private *b) | - | ||||||||||||
992 | { | - | ||||||||||||
993 | const char *const typeName = QMetaType::typeName(a->type); | - | ||||||||||||
994 | if (__builtin_expect(!!(!typeName), false) && __builtin_expect(!!(!QMetaType::isRegistered(a->type)), true)) | - | ||||||||||||
995 | QMessageLogger(__FILE__, 1067, __PRETTY_FUNCTION__).fatal("QVariant::compare: type %d unknown to QVariant.", a->type); | - | ||||||||||||
996 | - | |||||||||||||
997 | const void *a_ptr = a->is_shared ? a->data.shared->ptr : &(a->data.ptr); | - | ||||||||||||
998 | const void *b_ptr = b->is_shared ? b->data.shared->ptr : &(b->data.ptr); | - | ||||||||||||
999 | - | |||||||||||||
1000 | uint typeNameLen = qstrlen(typeName); | - | ||||||||||||
1001 | if (typeNameLen > 0 && typeName[typeNameLen - 1] == '*') | - | ||||||||||||
1002 | return *static_cast<void *const *>(a_ptr) == *static_cast<void *const *>(b_ptr); | - | ||||||||||||
1003 | - | |||||||||||||
1004 | if (a->is_null && b->is_null) | - | ||||||||||||
1005 | return true; | - | ||||||||||||
1006 | - | |||||||||||||
1007 | return !memcmp(a_ptr, b_ptr, QMetaType::sizeOf(a->type)); | - | ||||||||||||
1008 | } | - | ||||||||||||
1009 | - | |||||||||||||
1010 | static bool customConvert(const QVariant::Private *d, int t, void *result, bool *ok) | - | ||||||||||||
1011 | { | - | ||||||||||||
1012 | if (d->type >= QMetaType::User || t >= QMetaType::User) { | - | ||||||||||||
1013 | if (QMetaType::convert(constData(*d), d->type, result, t)) { | - | ||||||||||||
1014 | if (ok) | - | ||||||||||||
1015 | *ok = true; | - | ||||||||||||
1016 | return true; | - | ||||||||||||
1017 | } | - | ||||||||||||
1018 | } | - | ||||||||||||
1019 | return convert(d, t, result, ok); | - | ||||||||||||
1020 | } | - | ||||||||||||
1021 | - | |||||||||||||
1022 | - | |||||||||||||
1023 | static void customStreamDebug(QDebug dbg, const QVariant &variant) { | - | ||||||||||||
1024 | - | |||||||||||||
1025 | QMetaType::TypeFlags flags = QMetaType::typeFlags(variant.userType()); | - | ||||||||||||
1026 | if (flags & QMetaType::PointerToQObject) | - | ||||||||||||
1027 | dbg.nospace() << variant.value<QObject*>(); | - | ||||||||||||
1028 | - | |||||||||||||
1029 | - | |||||||||||||
1030 | - | |||||||||||||
1031 | - | |||||||||||||
1032 | } | - | ||||||||||||
1033 | - | |||||||||||||
1034 | - | |||||||||||||
1035 | const QVariant::Handler qt_custom_variant_handler = { | - | ||||||||||||
1036 | customConstruct, | - | ||||||||||||
1037 | customClear, | - | ||||||||||||
1038 | customIsNull, | - | ||||||||||||
1039 | - | |||||||||||||
1040 | 0, | - | ||||||||||||
1041 | 0, | - | ||||||||||||
1042 | - | |||||||||||||
1043 | customCompare, | - | ||||||||||||
1044 | customConvert, | - | ||||||||||||
1045 | 0, | - | ||||||||||||
1046 | - | |||||||||||||
1047 | customStreamDebug | - | ||||||||||||
1048 | - | |||||||||||||
1049 | - | |||||||||||||
1050 | - | |||||||||||||
1051 | }; | - | ||||||||||||
1052 | - | |||||||||||||
1053 | } | - | ||||||||||||
1054 | - | |||||||||||||
1055 | static HandlersManager handlerManager; | - | ||||||||||||
1056 | static_assert(bool(!QModulesPrivate::Core), "Initialization assumes that ModulesNames::Core is 0"); | - | ||||||||||||
1057 | const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount] | - | ||||||||||||
1058 | = { &qt_kernel_variant_handler, &qt_dummy_variant_handler, | - | ||||||||||||
1059 | &qt_dummy_variant_handler, &qt_custom_variant_handler }; | - | ||||||||||||
1060 | - | |||||||||||||
1061 | __attribute__((visibility("default"))) const QVariant::Handler *qcoreVariantHandler() | - | ||||||||||||
1062 | { | - | ||||||||||||
1063 | return &qt_kernel_variant_handler; | - | ||||||||||||
1064 | } | - | ||||||||||||
1065 | - | |||||||||||||
1066 | __attribute__((visibility("default"))) void QVariantPrivate::registerHandler(const int name, const QVariant::Handler *handler) | - | ||||||||||||
1067 | { | - | ||||||||||||
1068 | handlerManager.registerHandler(static_cast<QModulesPrivate::Names>(name), handler); | - | ||||||||||||
1069 | } | - | ||||||||||||
1070 | void QVariant::create(int type, const void *copy) | - | ||||||||||||
1071 | { | - | ||||||||||||
1072 | d.type = type; | - | ||||||||||||
1073 | handlerManager[type]->construct(&d, copy); | - | ||||||||||||
1074 | } | - | ||||||||||||
1075 | QVariant::~QVariant() | - | ||||||||||||
1076 | { | - | ||||||||||||
1077 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char)) | - | ||||||||||||
1078 | handlerManager[d.type]->clear(&d); | - | ||||||||||||
1079 | } | - | ||||||||||||
1080 | QVariant::QVariant(const QVariant &p) | - | ||||||||||||
1081 | : d(p.d) | - | ||||||||||||
1082 | { | - | ||||||||||||
1083 | if (d.is_shared) { | - | ||||||||||||
1084 | d.data.shared->ref.ref(); | - | ||||||||||||
1085 | } else if (p.d.type > Char) { | - | ||||||||||||
1086 | handlerManager[d.type]->construct(&d, p.constData()); | - | ||||||||||||
1087 | d.is_null = p.d.is_null; | - | ||||||||||||
1088 | } | - | ||||||||||||
1089 | } | - | ||||||||||||
1090 | - | |||||||||||||
1091 | - | |||||||||||||
1092 | - | |||||||||||||
1093 | - | |||||||||||||
1094 | - | |||||||||||||
1095 | QVariant::QVariant(QDataStream &s) | - | ||||||||||||
1096 | { | - | ||||||||||||
1097 | d.is_null = true; | - | ||||||||||||
1098 | s >> *this; | - | ||||||||||||
1099 | } | - | ||||||||||||
1100 | QVariant::QVariant(const char *val) | - | ||||||||||||
1101 | { | - | ||||||||||||
1102 | QString s = QString::fromUtf8(val); | - | ||||||||||||
1103 | create(String, &s); | - | ||||||||||||
1104 | } | - | ||||||||||||
1105 | QVariant::QVariant(Type type) | - | ||||||||||||
1106 | { create(type, 0); } | - | ||||||||||||
1107 | QVariant::QVariant(int typeId, const void *copy) | - | ||||||||||||
1108 | { create(typeId, copy); d.is_null = false; } | - | ||||||||||||
1109 | - | |||||||||||||
1110 | - | |||||||||||||
1111 | - | |||||||||||||
1112 | - | |||||||||||||
1113 | - | |||||||||||||
1114 | QVariant::QVariant(int typeId, const void *copy, uint flags) | - | ||||||||||||
1115 | { | - | ||||||||||||
1116 | if (flags) { | - | ||||||||||||
1117 | d.type = typeId; | - | ||||||||||||
1118 | d.data.ptr = *reinterpret_cast<void *const*>(copy); | - | ||||||||||||
1119 | } else { | - | ||||||||||||
1120 | create(typeId, copy); | - | ||||||||||||
1121 | } | - | ||||||||||||
1122 | d.is_null = false; | - | ||||||||||||
1123 | } | - | ||||||||||||
1124 | - | |||||||||||||
1125 | QVariant::QVariant(int val) | - | ||||||||||||
1126 | : d(Int) | - | ||||||||||||
1127 | { d.data.i = val; } | - | ||||||||||||
1128 | QVariant::QVariant(uint val) | - | ||||||||||||
1129 | : d(UInt) | - | ||||||||||||
1130 | { d.data.u = val; } | - | ||||||||||||
1131 | QVariant::QVariant(qlonglong val) | - | ||||||||||||
1132 | : d(LongLong) | - | ||||||||||||
1133 | { d.data.ll = val; } | - | ||||||||||||
1134 | QVariant::QVariant(qulonglong val) | - | ||||||||||||
1135 | : d(ULongLong) | - | ||||||||||||
1136 | { d.data.ull = val; } | - | ||||||||||||
1137 | QVariant::QVariant(bool val) | - | ||||||||||||
1138 | : d(Bool) | - | ||||||||||||
1139 | { d.data.b = val; } | - | ||||||||||||
1140 | QVariant::QVariant(double val) | - | ||||||||||||
1141 | : d(Double) | - | ||||||||||||
1142 | { d.data.d = val; } | - | ||||||||||||
1143 | QVariant::QVariant(float val) | - | ||||||||||||
1144 | : d(QMetaType::Float) | - | ||||||||||||
1145 | { d.data.f = val; } | - | ||||||||||||
1146 | - | |||||||||||||
1147 | QVariant::QVariant(const QByteArray &val) | - | ||||||||||||
1148 | : d(ByteArray) | - | ||||||||||||
1149 | { v_construct<QByteArray>(&d, val); } | - | ||||||||||||
1150 | QVariant::QVariant(const QBitArray &val) | - | ||||||||||||
1151 | : d(BitArray) | - | ||||||||||||
1152 | { v_construct<QBitArray>(&d, val); } | - | ||||||||||||
1153 | QVariant::QVariant(const QString &val) | - | ||||||||||||
1154 | : d(String) | - | ||||||||||||
1155 | { v_construct<QString>(&d, val); } | - | ||||||||||||
1156 | QVariant::QVariant(QChar val) | - | ||||||||||||
1157 | : d(Char) | - | ||||||||||||
1158 | { v_construct<QChar>(&d, val); } | - | ||||||||||||
1159 | QVariant::QVariant(QLatin1String val) | - | ||||||||||||
1160 | : d(String) | - | ||||||||||||
1161 | { v_construct<QString>(&d, val); } | - | ||||||||||||
1162 | QVariant::QVariant(const QStringList &val) | - | ||||||||||||
1163 | : d(StringList) | - | ||||||||||||
1164 | { v_construct<QStringList>(&d, val); } | - | ||||||||||||
1165 | - | |||||||||||||
1166 | QVariant::QVariant(const QDate &val) | - | ||||||||||||
1167 | : d(Date) | - | ||||||||||||
1168 | { v_construct<QDate>(&d, val); } | - | ||||||||||||
1169 | QVariant::QVariant(const QTime &val) | - | ||||||||||||
1170 | : d(Time) | - | ||||||||||||
1171 | { v_construct<QTime>(&d, val); } | - | ||||||||||||
1172 | QVariant::QVariant(const QDateTime &val) | - | ||||||||||||
1173 | : d(DateTime) | - | ||||||||||||
1174 | { v_construct<QDateTime>(&d, val); } | - | ||||||||||||
1175 | - | |||||||||||||
1176 | QVariant::QVariant(const QEasingCurve &val) | - | ||||||||||||
1177 | : d(EasingCurve) | - | ||||||||||||
1178 | { v_construct<QEasingCurve>(&d, val); } | - | ||||||||||||
1179 | - | |||||||||||||
1180 | QVariant::QVariant(const QList<QVariant> &list) | - | ||||||||||||
1181 | : d(List) | - | ||||||||||||
1182 | { v_construct<QVariantList>(&d, list); } | - | ||||||||||||
1183 | QVariant::QVariant(const QMap<QString, QVariant> &map) | - | ||||||||||||
1184 | : d(Map) | - | ||||||||||||
1185 | { v_construct<QVariantMap>(&d, map); } | - | ||||||||||||
1186 | QVariant::QVariant(const QHash<QString, QVariant> &hash) | - | ||||||||||||
1187 | : d(Hash) | - | ||||||||||||
1188 | { v_construct<QVariantHash>(&d, hash); } | - | ||||||||||||
1189 | - | |||||||||||||
1190 | QVariant::QVariant(const QPoint &pt) | - | ||||||||||||
1191 | : d(Point) | - | ||||||||||||
1192 | { v_construct<QPoint>(&d, pt); } | - | ||||||||||||
1193 | QVariant::QVariant(const QPointF &pt) | - | ||||||||||||
1194 | : d(PointF) | - | ||||||||||||
1195 | { v_construct<QPointF>(&d, pt); } | - | ||||||||||||
1196 | QVariant::QVariant(const QRectF &r) | - | ||||||||||||
1197 | : d(RectF) | - | ||||||||||||
1198 | { v_construct<QRectF>(&d, r); } | - | ||||||||||||
1199 | QVariant::QVariant(const QLineF &l) | - | ||||||||||||
1200 | : d(LineF) | - | ||||||||||||
1201 | { v_construct<QLineF>(&d, l); } | - | ||||||||||||
1202 | QVariant::QVariant(const QLine &l) | - | ||||||||||||
1203 | : d(Line) | - | ||||||||||||
1204 | { v_construct<QLine>(&d, l); } | - | ||||||||||||
1205 | QVariant::QVariant(const QRect &r) | - | ||||||||||||
1206 | : d(Rect) | - | ||||||||||||
1207 | { v_construct<QRect>(&d, r); } | - | ||||||||||||
1208 | QVariant::QVariant(const QSize &s) | - | ||||||||||||
1209 | : d(Size) | - | ||||||||||||
1210 | { v_construct<QSize>(&d, s); } | - | ||||||||||||
1211 | QVariant::QVariant(const QSizeF &s) | - | ||||||||||||
1212 | : d(SizeF) | - | ||||||||||||
1213 | { v_construct<QSizeF>(&d, s); } | - | ||||||||||||
1214 | - | |||||||||||||
1215 | - | |||||||||||||
1216 | QVariant::QVariant(const QUrl &u) | - | ||||||||||||
1217 | : d(Url) | - | ||||||||||||
1218 | { v_construct<QUrl>(&d, u); } | - | ||||||||||||
1219 | - | |||||||||||||
1220 | QVariant::QVariant(const QLocale &l) | - | ||||||||||||
1221 | : d(Locale) | - | ||||||||||||
1222 | { v_construct<QLocale>(&d, l); } | - | ||||||||||||
1223 | - | |||||||||||||
1224 | QVariant::QVariant(const QRegExp ®Exp) | - | ||||||||||||
1225 | : d(RegExp) | - | ||||||||||||
1226 | { v_construct<QRegExp>(&d, regExp); } | - | ||||||||||||
1227 | - | |||||||||||||
1228 | - | |||||||||||||
1229 | - | |||||||||||||
1230 | QVariant::QVariant(const QRegularExpression &re) | - | ||||||||||||
1231 | : d(RegularExpression) | - | ||||||||||||
1232 | { v_construct<QRegularExpression>(&d, re); } | - | ||||||||||||
1233 | - | |||||||||||||
1234 | QVariant::QVariant(const QUuid &uuid) | - | ||||||||||||
1235 | : d(Uuid) | - | ||||||||||||
1236 | { v_construct<QUuid>(&d, uuid); } | - | ||||||||||||
1237 | QVariant::QVariant(const QModelIndex &modelIndex) | - | ||||||||||||
1238 | : d(ModelIndex) | - | ||||||||||||
1239 | { v_construct<QModelIndex>(&d, modelIndex); } | - | ||||||||||||
1240 | QVariant::QVariant(const QPersistentModelIndex &modelIndex) | - | ||||||||||||
1241 | : d(PersistentModelIndex) | - | ||||||||||||
1242 | { v_construct<QPersistentModelIndex>(&d, modelIndex); } | - | ||||||||||||
1243 | QVariant::QVariant(const QJsonValue &jsonValue) | - | ||||||||||||
1244 | : d(QMetaType::QJsonValue) | - | ||||||||||||
1245 | { v_construct<QJsonValue>(&d, jsonValue); } | - | ||||||||||||
1246 | QVariant::QVariant(const QJsonObject &jsonObject) | - | ||||||||||||
1247 | : d(QMetaType::QJsonObject) | - | ||||||||||||
1248 | { v_construct<QJsonObject>(&d, jsonObject); } | - | ||||||||||||
1249 | QVariant::QVariant(const QJsonArray &jsonArray) | - | ||||||||||||
1250 | : d(QMetaType::QJsonArray) | - | ||||||||||||
1251 | { v_construct<QJsonArray>(&d, jsonArray); } | - | ||||||||||||
1252 | QVariant::QVariant(const QJsonDocument &jsonDocument) | - | ||||||||||||
1253 | : d(QMetaType::QJsonDocument) | - | ||||||||||||
1254 | { v_construct<QJsonDocument>(&d, jsonDocument); } | - | ||||||||||||
1255 | QVariant::Type QVariant::type() const | - | ||||||||||||
1256 | { | - | ||||||||||||
1257 | return d.type >= QMetaType::User ? UserType : static_cast<Type>(d.type); | - | ||||||||||||
1258 | } | - | ||||||||||||
1259 | int QVariant::userType() const | - | ||||||||||||
1260 | { | - | ||||||||||||
1261 | return d.type; | - | ||||||||||||
1262 | } | - | ||||||||||||
1263 | - | |||||||||||||
1264 | - | |||||||||||||
1265 | - | |||||||||||||
1266 | - | |||||||||||||
1267 | QVariant& QVariant::operator=(const QVariant &variant) | - | ||||||||||||
1268 | { | - | ||||||||||||
1269 | if (this == &variant) | - | ||||||||||||
1270 | return *this; | - | ||||||||||||
1271 | - | |||||||||||||
1272 | clear(); | - | ||||||||||||
1273 | if (variant.d.is_shared) { | - | ||||||||||||
1274 | variant.d.data.shared->ref.ref(); | - | ||||||||||||
1275 | d = variant.d; | - | ||||||||||||
1276 | } else if (variant.d.type > Char) { | - | ||||||||||||
1277 | d.type = variant.d.type; | - | ||||||||||||
1278 | handlerManager[d.type]->construct(&d, variant.constData()); | - | ||||||||||||
1279 | d.is_null = variant.d.is_null; | - | ||||||||||||
1280 | } else { | - | ||||||||||||
1281 | d = variant.d; | - | ||||||||||||
1282 | } | - | ||||||||||||
1283 | - | |||||||||||||
1284 | return *this; | - | ||||||||||||
1285 | } | - | ||||||||||||
1286 | void QVariant::detach() | - | ||||||||||||
1287 | { | - | ||||||||||||
1288 | if (!d.is_shared || d.data.shared->ref.load() == 1) | - | ||||||||||||
1289 | return; | - | ||||||||||||
1290 | - | |||||||||||||
1291 | Private dd; | - | ||||||||||||
1292 | dd.type = d.type; | - | ||||||||||||
1293 | handlerManager[d.type]->construct(&dd, constData()); | - | ||||||||||||
1294 | if (!d.data.shared->ref.deref()) | - | ||||||||||||
1295 | handlerManager[d.type]->clear(&d); | - | ||||||||||||
1296 | d.data.shared = dd.data.shared; | - | ||||||||||||
1297 | } | - | ||||||||||||
1298 | const char *QVariant::typeName() const | - | ||||||||||||
1299 | { | - | ||||||||||||
1300 | return QMetaType::typeName(d.type); | - | ||||||||||||
1301 | } | - | ||||||||||||
1302 | - | |||||||||||||
1303 | - | |||||||||||||
1304 | - | |||||||||||||
1305 | - | |||||||||||||
1306 | - | |||||||||||||
1307 | void QVariant::clear() | - | ||||||||||||
1308 | { | - | ||||||||||||
1309 | if ((d.is_shared && !d.data.shared->ref.deref()) || (!d.is_shared && d.type > Char)) | - | ||||||||||||
1310 | handlerManager[d.type]->clear(&d); | - | ||||||||||||
1311 | d.type = Invalid; | - | ||||||||||||
1312 | d.is_null = true; | - | ||||||||||||
1313 | d.is_shared = false; | - | ||||||||||||
1314 | } | - | ||||||||||||
1315 | - | |||||||||||||
1316 | - | |||||||||||||
1317 | - | |||||||||||||
1318 | - | |||||||||||||
1319 | - | |||||||||||||
1320 | - | |||||||||||||
1321 | - | |||||||||||||
1322 | const char *QVariant::typeToName(int typeId) | - | ||||||||||||
1323 | { | - | ||||||||||||
1324 | return QMetaType::typeName(typeId); | - | ||||||||||||
1325 | } | - | ||||||||||||
1326 | QVariant::Type QVariant::nameToType(const char *name) | - | ||||||||||||
1327 | { | - | ||||||||||||
1328 | int metaType = QMetaType::type(name); | - | ||||||||||||
1329 | return metaType <= int(UserType) ? QVariant::Type(metaType) : UserType; | - | ||||||||||||
1330 | } | - | ||||||||||||
1331 | - | |||||||||||||
1332 | - | |||||||||||||
1333 | enum { MapFromThreeCount = 36 }; | - | ||||||||||||
1334 | static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] = | - | ||||||||||||
1335 | { | - | ||||||||||||
1336 | QVariant::Invalid, | - | ||||||||||||
1337 | QVariant::Map, | - | ||||||||||||
1338 | QVariant::List, | - | ||||||||||||
1339 | QVariant::String, | - | ||||||||||||
1340 | QVariant::StringList, | - | ||||||||||||
1341 | QVariant::Font, | - | ||||||||||||
1342 | QVariant::Pixmap, | - | ||||||||||||
1343 | QVariant::Brush, | - | ||||||||||||
1344 | QVariant::Rect, | - | ||||||||||||
1345 | QVariant::Size, | - | ||||||||||||
1346 | QVariant::Color, | - | ||||||||||||
1347 | QVariant::Palette, | - | ||||||||||||
1348 | 0, | - | ||||||||||||
1349 | QVariant::Icon, | - | ||||||||||||
1350 | QVariant::Point, | - | ||||||||||||
1351 | QVariant::Image, | - | ||||||||||||
1352 | QVariant::Int, | - | ||||||||||||
1353 | QVariant::UInt, | - | ||||||||||||
1354 | QVariant::Bool, | - | ||||||||||||
1355 | QVariant::Double, | - | ||||||||||||
1356 | 0, | - | ||||||||||||
1357 | QVariant::Polygon, | - | ||||||||||||
1358 | QVariant::Region, | - | ||||||||||||
1359 | QVariant::Bitmap, | - | ||||||||||||
1360 | QVariant::Cursor, | - | ||||||||||||
1361 | QVariant::SizePolicy, | - | ||||||||||||
1362 | QVariant::Date, | - | ||||||||||||
1363 | QVariant::Time, | - | ||||||||||||
1364 | QVariant::DateTime, | - | ||||||||||||
1365 | QVariant::ByteArray, | - | ||||||||||||
1366 | QVariant::BitArray, | - | ||||||||||||
1367 | QVariant::KeySequence, | - | ||||||||||||
1368 | QVariant::Pen, | - | ||||||||||||
1369 | QVariant::LongLong, | - | ||||||||||||
1370 | QVariant::ULongLong, | - | ||||||||||||
1371 | QVariant::EasingCurve | - | ||||||||||||
1372 | }; | - | ||||||||||||
1373 | - | |||||||||||||
1374 | - | |||||||||||||
1375 | - | |||||||||||||
1376 | - | |||||||||||||
1377 | - | |||||||||||||
1378 | - | |||||||||||||
1379 | - | |||||||||||||
1380 | void QVariant::load(QDataStream &s) | - | ||||||||||||
1381 | { | - | ||||||||||||
1382 | clear(); | - | ||||||||||||
1383 | - | |||||||||||||
1384 | quint32 typeId; | - | ||||||||||||
1385 | s >> typeId; | - | ||||||||||||
1386 | if (s.version() < QDataStream::Qt_4_0) { | - | ||||||||||||
1387 | if (typeId >= MapFromThreeCount) | - | ||||||||||||
1388 | return; | - | ||||||||||||
1389 | typeId = mapIdFromQt3ToCurrent[typeId]; | - | ||||||||||||
1390 | } else if (s.version() < QDataStream::Qt_5_0) { | - | ||||||||||||
1391 | if (typeId == 127 ) { | - | ||||||||||||
1392 | typeId = QMetaType::User; | - | ||||||||||||
1393 | } else if (typeId >= 128 && typeId != QVariant::UserType) { | - | ||||||||||||
1394 | - | |||||||||||||
1395 | - | |||||||||||||
1396 | typeId -= 97; | - | ||||||||||||
1397 | } else if (typeId == 75 ) { | - | ||||||||||||
1398 | typeId = QMetaType::QSizePolicy; | - | ||||||||||||
1399 | } else if (typeId > 75 && typeId <= 86) { | - | ||||||||||||
1400 | - | |||||||||||||
1401 | - | |||||||||||||
1402 | typeId -=1; | - | ||||||||||||
1403 | } | - | ||||||||||||
1404 | } | - | ||||||||||||
1405 | - | |||||||||||||
1406 | qint8 is_null = false; | - | ||||||||||||
1407 | if (s.version() >= QDataStream::Qt_4_2) | - | ||||||||||||
1408 | s >> is_null; | - | ||||||||||||
1409 | if (typeId == QVariant::UserType) { | - | ||||||||||||
1410 | QByteArray name; | - | ||||||||||||
1411 | s >> name; | - | ||||||||||||
1412 | typeId = QMetaType::type(name.constData()); | - | ||||||||||||
1413 | if (typeId == QMetaType::UnknownType) { | - | ||||||||||||
1414 | s.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||
1415 | return; | - | ||||||||||||
1416 | } | - | ||||||||||||
1417 | } | - | ||||||||||||
1418 | create(typeId, 0); | - | ||||||||||||
1419 | d.is_null = is_null; | - | ||||||||||||
1420 | - | |||||||||||||
1421 | if (!isValid()) { | - | ||||||||||||
1422 | if (s.version() < QDataStream::Qt_5_0) { | - | ||||||||||||
1423 | - | |||||||||||||
1424 | QString x; | - | ||||||||||||
1425 | s >> x; | - | ||||||||||||
1426 | } | - | ||||||||||||
1427 | d.is_null = true; | - | ||||||||||||
1428 | return; | - | ||||||||||||
1429 | } | - | ||||||||||||
1430 | - | |||||||||||||
1431 | - | |||||||||||||
1432 | if (!QMetaType::load(s, d.type, const_cast<void *>(constData()))) { | - | ||||||||||||
1433 | s.setStatus(QDataStream::ReadCorruptData); | - | ||||||||||||
1434 | QMessageLogger(__FILE__, 2085, __PRETTY_FUNCTION__).warning("QVariant::load: unable to load type %d.", d.type); | - | ||||||||||||
1435 | } | - | ||||||||||||
1436 | } | - | ||||||||||||
1437 | - | |||||||||||||
1438 | - | |||||||||||||
1439 | - | |||||||||||||
1440 | - | |||||||||||||
1441 | - | |||||||||||||
1442 | - | |||||||||||||
1443 | - | |||||||||||||
1444 | void QVariant::save(QDataStream &s) const | - | ||||||||||||
1445 | { | - | ||||||||||||
1446 | quint32 typeId = type(); | - | ||||||||||||
1447 | bool fakeUserType = false; | - | ||||||||||||
1448 | if (s.version() < QDataStream::Qt_4_0) { | - | ||||||||||||
1449 | int i; | - | ||||||||||||
1450 | for (i = 0; i <= MapFromThreeCount - 1; ++i) { | - | ||||||||||||
1451 | if (mapIdFromQt3ToCurrent[i] == typeId) { | - | ||||||||||||
1452 | typeId = i; | - | ||||||||||||
1453 | break; | - | ||||||||||||
1454 | } | - | ||||||||||||
1455 | } | - | ||||||||||||
1456 | if (i >= MapFromThreeCount) { | - | ||||||||||||
1457 | s << QVariant(); | - | ||||||||||||
1458 | return; | - | ||||||||||||
1459 | } | - | ||||||||||||
1460 | } else if (s.version() < QDataStream::Qt_5_0) { | - | ||||||||||||
1461 | if (typeId == QMetaType::User) { | - | ||||||||||||
1462 | typeId = 127; | - | ||||||||||||
1463 | } else if (typeId >= 128 - 97 && typeId <= LastCoreType) { | - | ||||||||||||
1464 | - | |||||||||||||
1465 | - | |||||||||||||
1466 | typeId += 97; | - | ||||||||||||
1467 | } else if (typeId == QMetaType::QSizePolicy) { | - | ||||||||||||
1468 | typeId = 75; | - | ||||||||||||
1469 | } else if (typeId >= QMetaType::QKeySequence && typeId <= QMetaType::QQuaternion) { | - | ||||||||||||
1470 | - | |||||||||||||
1471 | typeId +=1; | - | ||||||||||||
1472 | } else if (typeId == QMetaType::QPolygonF) { | - | ||||||||||||
1473 | - | |||||||||||||
1474 | typeId = 127; | - | ||||||||||||
1475 | fakeUserType = true; | - | ||||||||||||
1476 | } | - | ||||||||||||
1477 | } | - | ||||||||||||
1478 | s << typeId; | - | ||||||||||||
1479 | if (s.version() >= QDataStream::Qt_4_2) | - | ||||||||||||
1480 | s << qint8(d.is_null); | - | ||||||||||||
1481 | if (d.type >= QVariant::UserType || fakeUserType) { | - | ||||||||||||
1482 | s << QMetaType::typeName(userType()); | - | ||||||||||||
1483 | } | - | ||||||||||||
1484 | - | |||||||||||||
1485 | if (!isValid()) { | - | ||||||||||||
1486 | if (s.version() < QDataStream::Qt_5_0) | - | ||||||||||||
1487 | s << QString(); | - | ||||||||||||
1488 | return; | - | ||||||||||||
1489 | } | - | ||||||||||||
1490 | - | |||||||||||||
1491 | if (!QMetaType::save(s, d.type, constData())) { | - | ||||||||||||
1492 | QMessageLogger(__FILE__, 2143, __PRETTY_FUNCTION__).warning("QVariant::save: unable to save type '%s' (type id: %d).\n", QMetaType::typeName(d.type), d.type); | - | ||||||||||||
1493 | ((!(false)) ? qt_assert_x("QVariant::save", "Invalid type to save",__FILE__,2144) : qt_noop()); | - | ||||||||||||
1494 | } | - | ||||||||||||
1495 | } | - | ||||||||||||
1496 | QDataStream& operator>>(QDataStream &s, QVariant &p) | - | ||||||||||||
1497 | { | - | ||||||||||||
1498 | p.load(s); | - | ||||||||||||
1499 | return s; | - | ||||||||||||
1500 | } | - | ||||||||||||
1501 | - | |||||||||||||
1502 | - | |||||||||||||
1503 | - | |||||||||||||
1504 | - | |||||||||||||
1505 | - | |||||||||||||
1506 | - | |||||||||||||
1507 | QDataStream& operator<<(QDataStream &s, const QVariant &p) | - | ||||||||||||
1508 | { | - | ||||||||||||
1509 | p.save(s); | - | ||||||||||||
1510 | return s; | - | ||||||||||||
1511 | } | - | ||||||||||||
1512 | - | |||||||||||||
1513 | - | |||||||||||||
1514 | - | |||||||||||||
1515 | - | |||||||||||||
1516 | QDataStream& operator>>(QDataStream &s, QVariant::Type &p) | - | ||||||||||||
1517 | { | - | ||||||||||||
1518 | quint32 u; | - | ||||||||||||
1519 | s >> u; | - | ||||||||||||
1520 | p = (QVariant::Type)u; | - | ||||||||||||
1521 | - | |||||||||||||
1522 | return s; | - | ||||||||||||
1523 | } | - | ||||||||||||
1524 | - | |||||||||||||
1525 | - | |||||||||||||
1526 | - | |||||||||||||
1527 | - | |||||||||||||
1528 | QDataStream& operator<<(QDataStream &s, const QVariant::Type p) | - | ||||||||||||
1529 | { | - | ||||||||||||
1530 | s << static_cast<quint32>(p); | - | ||||||||||||
1531 | - | |||||||||||||
1532 | return s; | - | ||||||||||||
1533 | } | - | ||||||||||||
1534 | template <typename T> | - | ||||||||||||
1535 | inline T qVariantToHelper(const QVariant::Private &d, const HandlersManager &handlerManager) | - | ||||||||||||
1536 | { | - | ||||||||||||
1537 | const uint targetType = qMetaTypeId<T>(); | - | ||||||||||||
1538 | if (d.type == targetType) | - | ||||||||||||
1539 | return *v_cast<T>(&d); | - | ||||||||||||
1540 | - | |||||||||||||
1541 | T ret; | - | ||||||||||||
1542 | if (d.type >= QMetaType::User || targetType >= QMetaType::User) { | - | ||||||||||||
1543 | const void * const from = constData(d); | - | ||||||||||||
1544 | if (QMetaType::convert(from, d.type, &ret, targetType)) | - | ||||||||||||
1545 | return ret; | - | ||||||||||||
1546 | } | - | ||||||||||||
1547 | - | |||||||||||||
1548 | handlerManager[d.type]->convert(&d, targetType, &ret, 0); | - | ||||||||||||
1549 | return ret; | - | ||||||||||||
1550 | } | - | ||||||||||||
1551 | QStringList QVariant::toStringList() const | - | ||||||||||||
1552 | { | - | ||||||||||||
1553 | return qVariantToHelper<QStringList>(d, handlerManager); | - | ||||||||||||
1554 | } | - | ||||||||||||
1555 | QString QVariant::toString() const | - | ||||||||||||
1556 | { | - | ||||||||||||
1557 | return qVariantToHelper<QString>(d, handlerManager); | - | ||||||||||||
1558 | } | - | ||||||||||||
1559 | - | |||||||||||||
1560 | - | |||||||||||||
1561 | - | |||||||||||||
1562 | - | |||||||||||||
1563 | - | |||||||||||||
1564 | - | |||||||||||||
1565 | - | |||||||||||||
1566 | QVariantMap QVariant::toMap() const | - | ||||||||||||
1567 | { | - | ||||||||||||
1568 | return qVariantToHelper<QVariantMap>(d, handlerManager); | - | ||||||||||||
1569 | } | - | ||||||||||||
1570 | - | |||||||||||||
1571 | - | |||||||||||||
1572 | - | |||||||||||||
1573 | - | |||||||||||||
1574 | - | |||||||||||||
1575 | - | |||||||||||||
1576 | - | |||||||||||||
1577 | QVariantHash QVariant::toHash() const | - | ||||||||||||
1578 | { | - | ||||||||||||
1579 | return qVariantToHelper<QVariantHash>(d, handlerManager); | - | ||||||||||||
1580 | } | - | ||||||||||||
1581 | QDate QVariant::toDate() const | - | ||||||||||||
1582 | { | - | ||||||||||||
1583 | return qVariantToHelper<QDate>(d, handlerManager); | - | ||||||||||||
1584 | } | - | ||||||||||||
1585 | QTime QVariant::toTime() const | - | ||||||||||||
1586 | { | - | ||||||||||||
1587 | return qVariantToHelper<QTime>(d, handlerManager); | - | ||||||||||||
1588 | } | - | ||||||||||||
1589 | QDateTime QVariant::toDateTime() const | - | ||||||||||||
1590 | { | - | ||||||||||||
1591 | return qVariantToHelper<QDateTime>(d, handlerManager); | - | ||||||||||||
1592 | } | - | ||||||||||||
1593 | QEasingCurve QVariant::toEasingCurve() const | - | ||||||||||||
1594 | { | - | ||||||||||||
1595 | return qVariantToHelper<QEasingCurve>(d, handlerManager); | - | ||||||||||||
1596 | } | - | ||||||||||||
1597 | QByteArray QVariant::toByteArray() const | - | ||||||||||||
1598 | { | - | ||||||||||||
1599 | return qVariantToHelper<QByteArray>(d, handlerManager); | - | ||||||||||||
1600 | } | - | ||||||||||||
1601 | QPoint QVariant::toPoint() const | - | ||||||||||||
1602 | { | - | ||||||||||||
1603 | return qVariantToHelper<QPoint>(d, handlerManager); | - | ||||||||||||
1604 | } | - | ||||||||||||
1605 | QRect QVariant::toRect() const | - | ||||||||||||
1606 | { | - | ||||||||||||
1607 | return qVariantToHelper<QRect>(d, handlerManager); | - | ||||||||||||
1608 | } | - | ||||||||||||
1609 | QSize QVariant::toSize() const | - | ||||||||||||
1610 | { | - | ||||||||||||
1611 | return qVariantToHelper<QSize>(d, handlerManager); | - | ||||||||||||
1612 | } | - | ||||||||||||
1613 | QSizeF QVariant::toSizeF() const | - | ||||||||||||
1614 | { | - | ||||||||||||
1615 | return qVariantToHelper<QSizeF>(d, handlerManager); | - | ||||||||||||
1616 | } | - | ||||||||||||
1617 | QRectF QVariant::toRectF() const | - | ||||||||||||
1618 | { | - | ||||||||||||
1619 | return qVariantToHelper<QRectF>(d, handlerManager); | - | ||||||||||||
1620 | } | - | ||||||||||||
1621 | QLineF QVariant::toLineF() const | - | ||||||||||||
1622 | { | - | ||||||||||||
1623 | return qVariantToHelper<QLineF>(d, handlerManager); | - | ||||||||||||
1624 | } | - | ||||||||||||
1625 | QLine QVariant::toLine() const | - | ||||||||||||
1626 | { | - | ||||||||||||
1627 | return qVariantToHelper<QLine>(d, handlerManager); | - | ||||||||||||
1628 | } | - | ||||||||||||
1629 | QPointF QVariant::toPointF() const | - | ||||||||||||
1630 | { | - | ||||||||||||
1631 | return qVariantToHelper<QPointF>(d, handlerManager); | - | ||||||||||||
1632 | } | - | ||||||||||||
1633 | QUrl QVariant::toUrl() const | - | ||||||||||||
1634 | { | - | ||||||||||||
1635 | return qVariantToHelper<QUrl>(d, handlerManager); | - | ||||||||||||
1636 | } | - | ||||||||||||
1637 | QLocale QVariant::toLocale() const | - | ||||||||||||
1638 | { | - | ||||||||||||
1639 | return qVariantToHelper<QLocale>(d, handlerManager); | - | ||||||||||||
1640 | } | - | ||||||||||||
1641 | QRegExp QVariant::toRegExp() const | - | ||||||||||||
1642 | { | - | ||||||||||||
1643 | return qVariantToHelper<QRegExp>(d, handlerManager); | - | ||||||||||||
1644 | } | - | ||||||||||||
1645 | QRegularExpression QVariant::toRegularExpression() const | - | ||||||||||||
1646 | { | - | ||||||||||||
1647 | return qVariantToHelper<QRegularExpression>(d, handlerManager); | - | ||||||||||||
1648 | } | - | ||||||||||||
1649 | QUuid QVariant::toUuid() const | - | ||||||||||||
1650 | { | - | ||||||||||||
1651 | return qVariantToHelper<QUuid>(d, handlerManager); | - | ||||||||||||
1652 | } | - | ||||||||||||
1653 | QModelIndex QVariant::toModelIndex() const | - | ||||||||||||
1654 | { | - | ||||||||||||
1655 | return qVariantToHelper<QModelIndex>(d, handlerManager); | - | ||||||||||||
1656 | } | - | ||||||||||||
1657 | QPersistentModelIndex QVariant::toPersistentModelIndex() const | - | ||||||||||||
1658 | { | - | ||||||||||||
1659 | return qVariantToHelper<QPersistentModelIndex>(d, handlerManager); | - | ||||||||||||
1660 | } | - | ||||||||||||
1661 | QJsonValue QVariant::toJsonValue() const | - | ||||||||||||
1662 | { | - | ||||||||||||
1663 | return qVariantToHelper<QJsonValue>(d, handlerManager); | - | ||||||||||||
1664 | } | - | ||||||||||||
1665 | QJsonObject QVariant::toJsonObject() const | - | ||||||||||||
1666 | { | - | ||||||||||||
1667 | return qVariantToHelper<QJsonObject>(d, handlerManager); | - | ||||||||||||
1668 | } | - | ||||||||||||
1669 | QJsonArray QVariant::toJsonArray() const | - | ||||||||||||
1670 | { | - | ||||||||||||
1671 | return qVariantToHelper<QJsonArray>(d, handlerManager); | - | ||||||||||||
1672 | } | - | ||||||||||||
1673 | QJsonDocument QVariant::toJsonDocument() const | - | ||||||||||||
1674 | { | - | ||||||||||||
1675 | return qVariantToHelper<QJsonDocument>(d, handlerManager); | - | ||||||||||||
1676 | } | - | ||||||||||||
1677 | QChar QVariant::toChar() const | - | ||||||||||||
1678 | { | - | ||||||||||||
1679 | return qVariantToHelper<QChar>(d, handlerManager); | - | ||||||||||||
1680 | } | - | ||||||||||||
1681 | - | |||||||||||||
1682 | - | |||||||||||||
1683 | - | |||||||||||||
1684 | - | |||||||||||||
1685 | - | |||||||||||||
1686 | - | |||||||||||||
1687 | - | |||||||||||||
1688 | QBitArray QVariant::toBitArray() const | - | ||||||||||||
1689 | { | - | ||||||||||||
1690 | return qVariantToHelper<QBitArray>(d, handlerManager); | - | ||||||||||||
1691 | } | - | ||||||||||||
1692 | - | |||||||||||||
1693 | template <typename T> | - | ||||||||||||
1694 | inline T qNumVariantToHelper(const QVariant::Private &d, | - | ||||||||||||
1695 | const HandlersManager &handlerManager, bool *ok, const T& val) | - | ||||||||||||
1696 | { | - | ||||||||||||
1697 | const uint t = qMetaTypeId<T>(); | - | ||||||||||||
1698 | if (ok) | - | ||||||||||||
1699 | *ok = true; | - | ||||||||||||
1700 | - | |||||||||||||
1701 | if (d.type == t) | - | ||||||||||||
1702 | return val; | - | ||||||||||||
1703 | - | |||||||||||||
1704 | T ret = 0; | - | ||||||||||||
1705 | if ((d.type >= QMetaType::User || t >= QMetaType::User) | - | ||||||||||||
1706 | && QMetaType::convert(constData(d), d.type, &ret, t)) | - | ||||||||||||
1707 | return ret; | - | ||||||||||||
1708 | - | |||||||||||||
1709 | if (!handlerManager[d.type]->convert(&d, t, &ret, ok) && ok) | - | ||||||||||||
1710 | *ok = false; | - | ||||||||||||
1711 | return ret; | - | ||||||||||||
1712 | } | - | ||||||||||||
1713 | int QVariant::toInt(bool *ok) const | - | ||||||||||||
1714 | { | - | ||||||||||||
1715 | return qNumVariantToHelper<int>(d, handlerManager, ok, d.data.i); | - | ||||||||||||
1716 | } | - | ||||||||||||
1717 | uint QVariant::toUInt(bool *ok) const | - | ||||||||||||
1718 | { | - | ||||||||||||
1719 | return qNumVariantToHelper<uint>(d, handlerManager, ok, d.data.u); | - | ||||||||||||
1720 | } | - | ||||||||||||
1721 | qlonglong QVariant::toLongLong(bool *ok) const | - | ||||||||||||
1722 | { | - | ||||||||||||
1723 | return qNumVariantToHelper<qlonglong>(d, handlerManager, ok, d.data.ll); | - | ||||||||||||
1724 | } | - | ||||||||||||
1725 | qulonglong QVariant::toULongLong(bool *ok) const | - | ||||||||||||
1726 | { | - | ||||||||||||
1727 | return qNumVariantToHelper<qulonglong>(d, handlerManager, ok, d.data.ull); | - | ||||||||||||
1728 | } | - | ||||||||||||
1729 | bool QVariant::toBool() const | - | ||||||||||||
1730 | { | - | ||||||||||||
1731 | if (d.type == Bool) | - | ||||||||||||
1732 | return d.data.b; | - | ||||||||||||
1733 | - | |||||||||||||
1734 | bool res = false; | - | ||||||||||||
1735 | handlerManager[d.type]->convert(&d, Bool, &res, 0); | - | ||||||||||||
1736 | - | |||||||||||||
1737 | return res; | - | ||||||||||||
1738 | } | - | ||||||||||||
1739 | double QVariant::toDouble(bool *ok) const | - | ||||||||||||
1740 | { | - | ||||||||||||
1741 | return qNumVariantToHelper<double>(d, handlerManager, ok, d.data.d); | - | ||||||||||||
1742 | } | - | ||||||||||||
1743 | float QVariant::toFloat(bool *ok) const | - | ||||||||||||
1744 | { | - | ||||||||||||
1745 | return qNumVariantToHelper<float>(d, handlerManager, ok, d.data.f); | - | ||||||||||||
1746 | } | - | ||||||||||||
1747 | qreal QVariant::toReal(bool *ok) const | - | ||||||||||||
1748 | { | - | ||||||||||||
1749 | return qNumVariantToHelper<qreal>(d, handlerManager, ok, d.data.real); | - | ||||||||||||
1750 | } | - | ||||||||||||
1751 | QVariantList QVariant::toList() const | - | ||||||||||||
1752 | { | - | ||||||||||||
1753 | return qVariantToHelper<QVariantList>(d, handlerManager); | - | ||||||||||||
1754 | } | - | ||||||||||||
1755 | - | |||||||||||||
1756 | - | |||||||||||||
1757 | static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = | - | ||||||||||||
1758 | { | - | ||||||||||||
1759 | 0, | - | ||||||||||||
1760 | - | |||||||||||||
1761 | 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt | - | ||||||||||||
1762 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray | - | ||||||||||||
1763 | | 1 << QVariant::String | 1 << QVariant::Char, | - | ||||||||||||
1764 | - | |||||||||||||
1765 | 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||
1766 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - | ||||||||||||
1767 | | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, | - | ||||||||||||
1768 | - | |||||||||||||
1769 | 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||
1770 | | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | - | ||||||||||||
1771 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||
1772 | - | |||||||||||||
1773 | 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||
1774 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong | - | ||||||||||||
1775 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||
1776 | - | |||||||||||||
1777 | 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | - | ||||||||||||
1778 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||
1779 | | 1 << QVariant::Char | 1 << QVariant::ByteArray, | - | ||||||||||||
1780 | - | |||||||||||||
1781 | 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong | - | ||||||||||||
1782 | | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||
1783 | | 1 << QVariant::ByteArray, | - | ||||||||||||
1784 | - | |||||||||||||
1785 | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong | - | ||||||||||||
1786 | | 1 << QVariant::ULongLong, | - | ||||||||||||
1787 | - | |||||||||||||
1788 | 0, | - | ||||||||||||
1789 | - | |||||||||||||
1790 | 1 << QVariant::StringList, | - | ||||||||||||
1791 | - | |||||||||||||
1792 | 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int | - | ||||||||||||
1793 | | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double | - | ||||||||||||
1794 | | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime | - | ||||||||||||
1795 | | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char | - | ||||||||||||
1796 | | 1 << QVariant::Url | 1 << QVariant::Uuid, | - | ||||||||||||
1797 | - | |||||||||||||
1798 | 1 << QVariant::List | 1 << QVariant::String, | - | ||||||||||||
1799 | - | |||||||||||||
1800 | 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool | - | ||||||||||||
1801 | | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong, | - | ||||||||||||
1802 | - | |||||||||||||
1803 | 0, | - | ||||||||||||
1804 | - | |||||||||||||
1805 | 1 << QVariant::String | 1 << QVariant::DateTime, | - | ||||||||||||
1806 | - | |||||||||||||
1807 | 1 << QVariant::String | 1 << QVariant::DateTime, | - | ||||||||||||
1808 | - | |||||||||||||
1809 | 1 << QVariant::String | 1 << QVariant::Date, | - | ||||||||||||
1810 | - | |||||||||||||
1811 | 1 << QVariant::String, | - | ||||||||||||
1812 | - | |||||||||||||
1813 | 0, | - | ||||||||||||
1814 | - | |||||||||||||
1815 | 1 << QVariant::RectF, | - | ||||||||||||
1816 | - | |||||||||||||
1817 | 1 << QVariant::Rect, | - | ||||||||||||
1818 | - | |||||||||||||
1819 | 1 << QVariant::SizeF, | - | ||||||||||||
1820 | - | |||||||||||||
1821 | 1 << QVariant::Size, | - | ||||||||||||
1822 | - | |||||||||||||
1823 | 1 << QVariant::LineF, | - | ||||||||||||
1824 | - | |||||||||||||
1825 | 1 << QVariant::Line, | - | ||||||||||||
1826 | - | |||||||||||||
1827 | 1 << QVariant::PointF, | - | ||||||||||||
1828 | - | |||||||||||||
1829 | 1 << QVariant::Point, | - | ||||||||||||
1830 | - | |||||||||||||
1831 | 0, | - | ||||||||||||
1832 | - | |||||||||||||
1833 | 0, | - | ||||||||||||
1834 | - | |||||||||||||
1835 | 0, | - | ||||||||||||
1836 | - | |||||||||||||
1837 | 1 << QVariant::String | - | ||||||||||||
1838 | }; | - | ||||||||||||
1839 | static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix); | - | ||||||||||||
1840 | - | |||||||||||||
1841 | - | |||||||||||||
1842 | - | |||||||||||||
1843 | - | |||||||||||||
1844 | - | |||||||||||||
1845 | static bool canConvertMetaObject(const QMetaObject *from, const QMetaObject *to) | - | ||||||||||||
1846 | { | - | ||||||||||||
1847 | if (from && to == &QObject::staticMetaObject) | - | ||||||||||||
1848 | return true; | - | ||||||||||||
1849 | - | |||||||||||||
1850 | while (from) { | - | ||||||||||||
1851 | if (from == to) | - | ||||||||||||
1852 | return true; | - | ||||||||||||
1853 | from = from->superClass(); | - | ||||||||||||
1854 | } | - | ||||||||||||
1855 | - | |||||||||||||
1856 | return false; | - | ||||||||||||
1857 | } | - | ||||||||||||
1858 | - | |||||||||||||
1859 | - | |||||||||||||
1860 | static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject) | - | ||||||||||||
1861 | { | - | ||||||||||||
1862 | - | |||||||||||||
1863 | QMetaType toType(toId); | - | ||||||||||||
1864 | if ((QMetaType::typeFlags(fromId) & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) { | - | ||||||||||||
1865 | if (!fromObject) | - | ||||||||||||
1866 | return true; | - | ||||||||||||
1867 | return canConvertMetaObject(fromObject->metaObject(), toType.metaObject()); | - | ||||||||||||
1868 | } | - | ||||||||||||
1869 | - | |||||||||||||
1870 | - | |||||||||||||
1871 | - | |||||||||||||
1872 | - | |||||||||||||
1873 | - | |||||||||||||
1874 | return false; | - | ||||||||||||
1875 | } | - | ||||||||||||
1876 | bool QVariant::canConvert(int targetTypeId) const | - | ||||||||||||
1877 | { | - | ||||||||||||
1878 | if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex) | - | ||||||||||||
1879 | || (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex)) | - | ||||||||||||
1880 | return true; | - | ||||||||||||
1881 | - | |||||||||||||
1882 | if (targetTypeId == QMetaType::QVariantList | - | ||||||||||||
1883 | && (d.type == QMetaType::QVariantList | - | ||||||||||||
1884 | || d.type == QMetaType::QStringList | - | ||||||||||||
1885 | || d.type == QMetaType::QByteArrayList | - | ||||||||||||
1886 | || QMetaType::hasRegisteredConverterFunction(d.type, | - | ||||||||||||
1887 | qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>()))) { | - | ||||||||||||
1888 | return true; | - | ||||||||||||
1889 | } | - | ||||||||||||
1890 | - | |||||||||||||
1891 | if ((targetTypeId == QMetaType::QVariantHash || targetTypeId == QMetaType::QVariantMap) | - | ||||||||||||
1892 | && (d.type == QMetaType::QVariantMap | - | ||||||||||||
1893 | || d.type == QMetaType::QVariantHash | - | ||||||||||||
1894 | || QMetaType::hasRegisteredConverterFunction(d.type, | - | ||||||||||||
1895 | qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>()))) { | - | ||||||||||||
1896 | return true; | - | ||||||||||||
1897 | } | - | ||||||||||||
1898 | - | |||||||||||||
1899 | if (targetTypeId == qMetaTypeId<QPair<QVariant, QVariant> >() && | - | ||||||||||||
1900 | QMetaType::hasRegisteredConverterFunction(d.type, | - | ||||||||||||
1901 | qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) { | - | ||||||||||||
1902 | return true; | - | ||||||||||||
1903 | } | - | ||||||||||||
1904 | - | |||||||||||||
1905 | if ((d.type >= QMetaType::User || targetTypeId >= QMetaType::User) | - | ||||||||||||
1906 | && QMetaType::hasRegisteredConverterFunction(d.type, targetTypeId)) { | - | ||||||||||||
1907 | return true; | - | ||||||||||||
1908 | } | - | ||||||||||||
1909 | - | |||||||||||||
1910 | - | |||||||||||||
1911 | uint currentType = ((d.type == QMetaType::Float) ? QVariant::Double : d.type); | - | ||||||||||||
1912 | if (currentType == QMetaType::SChar || currentType == QMetaType::Char) | - | ||||||||||||
1913 | currentType = QMetaType::UInt; | - | ||||||||||||
1914 | if (targetTypeId == QMetaType::SChar || currentType == QMetaType::Char) | - | ||||||||||||
1915 | targetTypeId = QMetaType::UInt; | - | ||||||||||||
1916 | if (uint(targetTypeId) == uint(QMetaType::Float)) targetTypeId = QVariant::Double; | - | ||||||||||||
1917 | - | |||||||||||||
1918 | - | |||||||||||||
1919 | if (currentType == uint(targetTypeId)) | - | ||||||||||||
1920 | return true; | - | ||||||||||||
1921 | - | |||||||||||||
1922 | if (targetTypeId < 0) | - | ||||||||||||
1923 | return false; | - | ||||||||||||
1924 | if (targetTypeId >= QMetaType::User) { | - | ||||||||||||
1925 | if (QMetaType::typeFlags(targetTypeId) & QMetaType::IsEnumeration) { | - | ||||||||||||
1926 | targetTypeId = QMetaType::Int; | - | ||||||||||||
1927 | } else { | - | ||||||||||||
1928 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); | - | ||||||||||||
1929 | } | - | ||||||||||||
1930 | } | - | ||||||||||||
1931 | - | |||||||||||||
1932 | if (currentType == QMetaType::QJsonValue) { | - | ||||||||||||
1933 | switch (targetTypeId) { | - | ||||||||||||
1934 | case QMetaType::QString: | - | ||||||||||||
1935 | case QMetaType::Bool: | - | ||||||||||||
1936 | case QMetaType::Int: | - | ||||||||||||
1937 | case QMetaType::UInt: | - | ||||||||||||
1938 | case QMetaType::Double: | - | ||||||||||||
1939 | case QMetaType::Float: | - | ||||||||||||
1940 | case QMetaType::ULong: | - | ||||||||||||
1941 | case QMetaType::Long: | - | ||||||||||||
1942 | case QMetaType::LongLong: | - | ||||||||||||
1943 | case QMetaType::ULongLong: | - | ||||||||||||
1944 | case QMetaType::UShort: | - | ||||||||||||
1945 | case QMetaType::UChar: | - | ||||||||||||
1946 | case QMetaType::Char: | - | ||||||||||||
1947 | case QMetaType::SChar: | - | ||||||||||||
1948 | case QMetaType::Short: | - | ||||||||||||
1949 | case QMetaType::QVariantList: | - | ||||||||||||
1950 | case QMetaType::QVariantMap: | - | ||||||||||||
1951 | case QMetaType::QVariantHash: | - | ||||||||||||
1952 | return true; | - | ||||||||||||
1953 | default: | - | ||||||||||||
1954 | return false; | - | ||||||||||||
1955 | } | - | ||||||||||||
1956 | } | - | ||||||||||||
1957 | if (currentType == QMetaType::QJsonArray) | - | ||||||||||||
1958 | return targetTypeId == QMetaType::QVariantList; | - | ||||||||||||
1959 | if (currentType == QMetaType::QJsonObject) | - | ||||||||||||
1960 | return targetTypeId == QMetaType::QVariantMap || targetTypeId == QMetaType::QVariantHash; | - | ||||||||||||
1961 | - | |||||||||||||
1962 | - | |||||||||||||
1963 | if (currentType > int(QMetaType::QUuid) || targetTypeId > int(QMetaType::QUuid)) { | - | ||||||||||||
1964 | switch (uint(targetTypeId)) { | - | ||||||||||||
1965 | case QVariant::Int: | - | ||||||||||||
1966 | if (currentType == QVariant::KeySequence) | - | ||||||||||||
1967 | return true; | - | ||||||||||||
1968 | - | |||||||||||||
1969 | case QVariant::UInt: | - | ||||||||||||
1970 | case QVariant::LongLong: | - | ||||||||||||
1971 | case QVariant::ULongLong: | - | ||||||||||||
1972 | return currentType == QMetaType::ULong | - | ||||||||||||
1973 | || currentType == QMetaType::Long | - | ||||||||||||
1974 | || currentType == QMetaType::UShort | - | ||||||||||||
1975 | || currentType == QMetaType::UChar | - | ||||||||||||
1976 | || currentType == QMetaType::Char | - | ||||||||||||
1977 | || currentType == QMetaType::SChar | - | ||||||||||||
1978 | || currentType == QMetaType::Short | - | ||||||||||||
1979 | || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; | - | ||||||||||||
1980 | case QVariant::Image: | - | ||||||||||||
1981 | return currentType == QVariant::Pixmap || currentType == QVariant::Bitmap; | - | ||||||||||||
1982 | case QVariant::Pixmap: | - | ||||||||||||
1983 | return currentType == QVariant::Image || currentType == QVariant::Bitmap | - | ||||||||||||
1984 | || currentType == QVariant::Brush; | - | ||||||||||||
1985 | case QVariant::Bitmap: | - | ||||||||||||
1986 | return currentType == QVariant::Pixmap || currentType == QVariant::Image; | - | ||||||||||||
1987 | case QVariant::ByteArray: | - | ||||||||||||
1988 | return currentType == QVariant::Color | - | ||||||||||||
1989 | || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); | - | ||||||||||||
1990 | case QVariant::String: | - | ||||||||||||
1991 | return currentType == QVariant::KeySequence || currentType == QVariant::Font | - | ||||||||||||
1992 | || currentType == QVariant::Color | - | ||||||||||||
1993 | || ((QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration) && QMetaType::metaObjectForType(currentType)); | - | ||||||||||||
1994 | case QVariant::KeySequence: | - | ||||||||||||
1995 | return currentType == QVariant::String || currentType == QVariant::Int; | - | ||||||||||||
1996 | case QVariant::Font: | - | ||||||||||||
1997 | return currentType == QVariant::String; | - | ||||||||||||
1998 | case QVariant::Color: | - | ||||||||||||
1999 | return currentType == QVariant::String || currentType == QVariant::ByteArray | - | ||||||||||||
2000 | || currentType == QVariant::Brush; | - | ||||||||||||
2001 | case QVariant::Brush: | - | ||||||||||||
2002 | return currentType == QVariant::Color || currentType == QVariant::Pixmap; | - | ||||||||||||
2003 | case QMetaType::Long: | - | ||||||||||||
2004 | case QMetaType::Char: | - | ||||||||||||
2005 | case QMetaType::SChar: | - | ||||||||||||
2006 | case QMetaType::UChar: | - | ||||||||||||
2007 | case QMetaType::ULong: | - | ||||||||||||
2008 | case QMetaType::Short: | - | ||||||||||||
2009 | case QMetaType::UShort: | - | ||||||||||||
2010 | return currentType == QVariant::Int | - | ||||||||||||
2011 | || (currentType < qCanConvertMatrixMaximumTargetType | - | ||||||||||||
2012 | && qCanConvertMatrix[QVariant::Int] & (1U << currentType)) | - | ||||||||||||
2013 | || QMetaType::typeFlags(currentType) & QMetaType::IsEnumeration; | - | ||||||||||||
2014 | case QMetaType::QObjectStar: | - | ||||||||||||
2015 | return canConvertMetaObject(currentType, targetTypeId, d.data.o); | - | ||||||||||||
2016 | default: | - | ||||||||||||
2017 | return false; | - | ||||||||||||
2018 | } | - | ||||||||||||
2019 | } | - | ||||||||||||
2020 | - | |||||||||||||
2021 | if (targetTypeId == String && currentType == StringList) | - | ||||||||||||
2022 | return v_cast<QStringList>(&d)->count() == 1; | - | ||||||||||||
2023 | return currentType < qCanConvertMatrixMaximumTargetType | - | ||||||||||||
2024 | && qCanConvertMatrix[targetTypeId] & (1U << currentType); | - | ||||||||||||
2025 | } | - | ||||||||||||
2026 | bool QVariant::convert(int targetTypeId) | - | ||||||||||||
2027 | { | - | ||||||||||||
2028 | if (d.type == uint(targetTypeId)) | - | ||||||||||||
2029 | return true; | - | ||||||||||||
2030 | - | |||||||||||||
2031 | QVariant oldValue = *this; | - | ||||||||||||
2032 | - | |||||||||||||
2033 | clear(); | - | ||||||||||||
2034 | if (!oldValue.canConvert(targetTypeId)) | - | ||||||||||||
2035 | return false; | - | ||||||||||||
2036 | - | |||||||||||||
2037 | create(targetTypeId, 0); | - | ||||||||||||
2038 | if (oldValue.isNull()) | - | ||||||||||||
2039 | return false; | - | ||||||||||||
2040 | - | |||||||||||||
2041 | if ((QMetaType::typeFlags(oldValue.userType()) & QMetaType::PointerToQObject) && (QMetaType::typeFlags(targetTypeId) & QMetaType::PointerToQObject)) { | - | ||||||||||||
2042 | create(targetTypeId, &oldValue.d.data.o); | - | ||||||||||||
2043 | return true; | - | ||||||||||||
2044 | } | - | ||||||||||||
2045 | - | |||||||||||||
2046 | bool isOk = true; | - | ||||||||||||
2047 | int converterType = std::max(oldValue.userType(), targetTypeId); | - | ||||||||||||
2048 | if (!handlerManager[converterType]->convert(&oldValue.d, targetTypeId, data(), &isOk)) | - | ||||||||||||
2049 | isOk = false; | - | ||||||||||||
2050 | d.is_null = !isOk; | - | ||||||||||||
2051 | return isOk; | - | ||||||||||||
2052 | } | - | ||||||||||||
2053 | - | |||||||||||||
2054 | - | |||||||||||||
2055 | - | |||||||||||||
2056 | - | |||||||||||||
2057 | - | |||||||||||||
2058 | - | |||||||||||||
2059 | bool QVariant::convert(const int type, void *ptr) const | - | ||||||||||||
2060 | { | - | ||||||||||||
2061 | return handlerManager[type]->convert(&d, type, ptr, 0); | - | ||||||||||||
2062 | } | - | ||||||||||||
2063 | static bool qIsNumericType(uint tp) | - | ||||||||||||
2064 | { | - | ||||||||||||
2065 | static const qulonglong numericTypeBits = | - | ||||||||||||
2066 | static_cast<unsigned long long>(1ULL) << QMetaType::Bool | | - | ||||||||||||
2067 | static_cast<unsigned long long>(1ULL) << QMetaType::Double | | - | ||||||||||||
2068 | static_cast<unsigned long long>(1ULL) << QMetaType::Float | | - | ||||||||||||
2069 | static_cast<unsigned long long>(1ULL) << QMetaType::Char | | - | ||||||||||||
2070 | static_cast<unsigned long long>(1ULL) << QMetaType::SChar | | - | ||||||||||||
2071 | static_cast<unsigned long long>(1ULL) << QMetaType::UChar | | - | ||||||||||||
2072 | static_cast<unsigned long long>(1ULL) << QMetaType::Short | | - | ||||||||||||
2073 | static_cast<unsigned long long>(1ULL) << QMetaType::UShort | | - | ||||||||||||
2074 | static_cast<unsigned long long>(1ULL) << QMetaType::Int | | - | ||||||||||||
2075 | static_cast<unsigned long long>(1ULL) << QMetaType::UInt | | - | ||||||||||||
2076 | static_cast<unsigned long long>(1ULL) << QMetaType::Long | | - | ||||||||||||
2077 | static_cast<unsigned long long>(1ULL) << QMetaType::ULong | | - | ||||||||||||
2078 | static_cast<unsigned long long>(1ULL) << QMetaType::LongLong | | - | ||||||||||||
2079 | static_cast<unsigned long long>(1ULL) << QMetaType::ULongLong; | - | ||||||||||||
2080 | return tp < (8 * sizeof numericTypeBits) ? numericTypeBits & (static_cast<unsigned long long>(1ULL) << tp) : false; | - | ||||||||||||
2081 | } | - | ||||||||||||
2082 | - | |||||||||||||
2083 | static bool qIsFloatingPoint(uint tp) | - | ||||||||||||
2084 | { | - | ||||||||||||
2085 | return tp == QVariant::Double || tp == QMetaType::Float; | - | ||||||||||||
2086 | } | - | ||||||||||||
2087 | - | |||||||||||||
2088 | static int normalizeLowerRanks(uint tp) | - | ||||||||||||
2089 | { | - | ||||||||||||
2090 | static const qulonglong numericTypeBits = | - | ||||||||||||
2091 | static_cast<unsigned long long>(1ULL) << QMetaType::Bool | | - | ||||||||||||
2092 | static_cast<unsigned long long>(1ULL) << QMetaType::Char | | - | ||||||||||||
2093 | static_cast<unsigned long long>(1ULL) << QMetaType::SChar | | - | ||||||||||||
2094 | static_cast<unsigned long long>(1ULL) << QMetaType::UChar | | - | ||||||||||||
2095 | static_cast<unsigned long long>(1ULL) << QMetaType::Short | | - | ||||||||||||
2096 | static_cast<unsigned long long>(1ULL) << QMetaType::UShort; | - | ||||||||||||
2097 | return numericTypeBits & (static_cast<unsigned long long>(1ULL) << tp) ? QVariant::Int : tp; | - | ||||||||||||
2098 | } | - | ||||||||||||
2099 | - | |||||||||||||
2100 | static int normalizeLong(uint tp) | - | ||||||||||||
2101 | { | - | ||||||||||||
2102 | const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong; | - | ||||||||||||
2103 | const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong; | - | ||||||||||||
2104 | return tp == QMetaType::Long ? IntType : | - | ||||||||||||
2105 | tp == QMetaType::ULong ? UIntType : tp; | - | ||||||||||||
2106 | } | - | ||||||||||||
2107 | - | |||||||||||||
2108 | static int numericTypePromotion(uint t1, uint t2) | - | ||||||||||||
2109 | { | - | ||||||||||||
2110 | ((!(qIsNumericType(t1))) ? qt_assert("qIsNumericType(t1)",__FILE__,33973395) : qt_noop()); | - | ||||||||||||
2111 | ((!(qIsNumericType(t2))) ? qt_assert("qIsNumericType(t2)",__FILE__,33983396) : qt_noop()); | - | ||||||||||||
2112 | if (qIsFloatingPoint(t1) || qIsFloatingPoint(t2)) | - | ||||||||||||
2113 | return QMetaType::QReal; | - | ||||||||||||
2114 | - | |||||||||||||
2115 | - | |||||||||||||
2116 | - | |||||||||||||
2117 | t1 = normalizeLowerRanks(t1); | - | ||||||||||||
2118 | t2 = normalizeLowerRanks(t2); | - | ||||||||||||
2119 | - | |||||||||||||
2120 | - | |||||||||||||
2121 | t1 = normalizeLong(t1); | - | ||||||||||||
2122 | t2 = normalizeLong(t2); | - | ||||||||||||
2123 | - | |||||||||||||
2124 | - | |||||||||||||
2125 | - | |||||||||||||
2126 | - | |||||||||||||
2127 | - | |||||||||||||
2128 | - | |||||||||||||
2129 | if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong) | - | ||||||||||||
2130 | return QVariant::ULongLong; | - | ||||||||||||
2131 | if (t1 == QVariant::LongLong || t2 == QVariant::LongLong) | - | ||||||||||||
2132 | return QVariant::LongLong; | - | ||||||||||||
2133 | if (t1 == QVariant::UInt || t2 == QVariant::UInt) | - | ||||||||||||
2134 | return QVariant::UInt; | - | ||||||||||||
2135 | return QVariant::Int; | - | ||||||||||||
2136 | } | - | ||||||||||||
2137 | - | |||||||||||||
2138 | static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2) | - | ||||||||||||
2139 | { | - | ||||||||||||
2140 | - | |||||||||||||
2141 | bool ok; | - | ||||||||||||
2142 | qlonglong l1 = qConvertToNumber(d1, &ok); | - | ||||||||||||
2143 | ((!(ok)) ? qt_assert("ok",__FILE__,34463444) : qt_noop()); | - | ||||||||||||
2144 | - | |||||||||||||
2145 | qlonglong l2 = qConvertToNumber(d2, &ok); | - | ||||||||||||
2146 | ((!(ok)) ? qt_assert("ok",__FILE__,34493447) : qt_noop()); | - | ||||||||||||
2147 | - | |||||||||||||
2148 | if (promotedType == QVariant::Int) | - | ||||||||||||
2149 | return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1; | - | ||||||||||||
2150 | if (promotedType == QVariant::UInt) | - | ||||||||||||
2151 | return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1; | - | ||||||||||||
2152 | if (promotedType == QVariant::LongLong) | - | ||||||||||||
2153 | return l1 < l2 ? -1 : l1 == l2 ? 0 : 1; | - | ||||||||||||
2154 | if (promotedType == QVariant::ULongLong) | - | ||||||||||||
2155 | return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1; | - | ||||||||||||
2156 | - | |||||||||||||
2157 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,34603458) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||
2158 | return 0; | - | ||||||||||||
2159 | } | - | ||||||||||||
2160 | - | |||||||||||||
2161 | static int numericCompare(const QVariant::Private *d1, const QVariant::Private *d2) | - | ||||||||||||
2162 | { | - | ||||||||||||
2163 | uint promotedType = numericTypePromotion(d1->type, d2->type); | - | ||||||||||||
2164 | if (promotedType != QMetaType::QReal) | - | ||||||||||||
2165 | return integralCompare(promotedType, d1, d2); | - | ||||||||||||
2166 | - | |||||||||||||
2167 | - | |||||||||||||
2168 | bool ok; | - | ||||||||||||
2169 | qreal r1 = qConvertToRealNumber(d1, &ok); | - | ||||||||||||
2170 | ((!(ok)) ? qt_assert("ok",__FILE__,34733471) : qt_noop()); | - | ||||||||||||
2171 | qreal r2 = qConvertToRealNumber(d2, &ok); | - | ||||||||||||
2172 | ((!(ok)) ? qt_assert("ok",__FILE__,34753473) : qt_noop()); | - | ||||||||||||
2173 | if (r1 == r2 || qFuzzyCompare(r1, r2)) | - | ||||||||||||
2174 | return 0; | - | ||||||||||||
2175 | return r1 < r2 ? -1 : 1; | - | ||||||||||||
2176 | } | - | ||||||||||||
2177 | - | |||||||||||||
2178 | - | |||||||||||||
2179 | - | |||||||||||||
2180 | - | |||||||||||||
2181 | bool QVariant::cmp(const QVariant &v) const | - | ||||||||||||
2182 | { | - | ||||||||||||
2183 | - | |||||||||||||
2184 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) | - | ||||||||||||
2185 | return numericCompare(&d, &v.d) == 0; | - | ||||||||||||
2186 | - | |||||||||||||
2187 | QVariant v1 = *this; | - | ||||||||||||
2188 | QVariant v2 = v; | - | ||||||||||||
2189 | if (d.type != v2.d.type) { | - | ||||||||||||
2190 | if (v2.canConvert(v1.d.type)) { | - | ||||||||||||
2191 | if (!v2.convert(v1.d.type)) | - | ||||||||||||
2192 | return false; | - | ||||||||||||
2193 | } else { | - | ||||||||||||
2194 | - | |||||||||||||
2195 | qSwap(v1, v2); | - | ||||||||||||
2196 | if (!v2.convert(v1.d.type)) | - | ||||||||||||
2197 | return false; | - | ||||||||||||
2198 | } | - | ||||||||||||
2199 | } | - | ||||||||||||
2200 | if (v1.d.type >= QMetaType::User) { | - | ||||||||||||
2201 | int result; | - | ||||||||||||
2202 | if (QMetaType::equals(::constData(v1.d), ::constData(v2.d), v1.d.type, &result)) | - | ||||||||||||
2203 | return result == 0; | - | ||||||||||||
2204 | } | - | ||||||||||||
2205 | return handlerManager[v1.d.type]->compare(&v1.d, &v2.d); | - | ||||||||||||
2206 | } | - | ||||||||||||
2207 | - | |||||||||||||
2208 | - | |||||||||||||
2209 | - | |||||||||||||
2210 | - | |||||||||||||
2211 | int QVariant::compare(const QVariant &v) const | - | ||||||||||||
2212 | { | - | ||||||||||||
2213 | - | |||||||||||||
2214 | if (qIsNumericType(d.type) && qIsNumericType(v.d.type)) | - | ||||||||||||
2215 | return numericCompare(&d, &v.d); | - | ||||||||||||
2216 | - | |||||||||||||
2217 | - | |||||||||||||
2218 | if (cmp(v)) | - | ||||||||||||
2219 | return 0; | - | ||||||||||||
2220 | - | |||||||||||||
2221 | QVariant v1 = *this; | - | ||||||||||||
2222 | QVariant v2 = v; | - | ||||||||||||
2223 | - | |||||||||||||
2224 | if (v1.d.type != v2.d.type) { | - | ||||||||||||
2225 | - | |||||||||||||
2226 | if (v2.canConvert(v1.d.type)) { | - | ||||||||||||
2227 | QVariant temp = v2; | - | ||||||||||||
2228 | if (temp.convert(v1.d.type)) | - | ||||||||||||
2229 | v2 = temp; | - | ||||||||||||
2230 | } | - | ||||||||||||
2231 | if (v1.d.type != v2.d.type && v1.canConvert(v2.d.type)) { | - | ||||||||||||
2232 | QVariant temp = v1; | - | ||||||||||||
2233 | if (temp.convert(v2.d.type)) | - | ||||||||||||
2234 | v1 = temp; | - | ||||||||||||
2235 | } | - | ||||||||||||
2236 | if (v1.d.type != v2.d.type) { | - | ||||||||||||
2237 | - | |||||||||||||
2238 | int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); | - | ||||||||||||
2239 | if (r == 0) { | - | ||||||||||||
2240 | - | |||||||||||||
2241 | return (v1.d.type < v2.d.type) ? -1 : 1; | - | ||||||||||||
2242 | } | - | ||||||||||||
2243 | return r; | - | ||||||||||||
2244 | } | - | ||||||||||||
2245 | - | |||||||||||||
2246 | - | |||||||||||||
2247 | if (qIsNumericType(v1.d.type) && qIsNumericType(v2.d.type)) | - | ||||||||||||
2248 | return v1.compare(v2); | - | ||||||||||||
2249 | } | - | ||||||||||||
2250 | if (v1.d.type >= QMetaType::User) { | - | ||||||||||||
2251 | int result; | - | ||||||||||||
2252 | if (QMetaType::compare(::constData(d), ::constData(v2.d), d.type, &result)) | - | ||||||||||||
2253 | return result; | - | ||||||||||||
2254 | } | - | ||||||||||||
2255 | switch (v1.d.type) { | - | ||||||||||||
2256 | case QVariant::Date: | - | ||||||||||||
2257 | return v1.toDate() < v2.toDate() ? -1 : 1; | - | ||||||||||||
2258 | case QVariant::Time: | - | ||||||||||||
2259 | return v1.toTime() < v2.toTime() ? -1 : 1; | - | ||||||||||||
2260 | case QVariant::DateTime: | - | ||||||||||||
2261 | return v1.toDateTime() < v2.toDateTime() ? -1 : 1; | - | ||||||||||||
2262 | case QVariant::StringList: | - | ||||||||||||
2263 | return v1.toStringList() < v2.toStringList() ? -1 : 1; | - | ||||||||||||
2264 | } | - | ||||||||||||
2265 | int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive); | - | ||||||||||||
2266 | if (r == 0) { | - | ||||||||||||
2267 | - | |||||||||||||
2268 | return (d.type < v.d.type) ? -1 : 1; | - | ||||||||||||
2269 | } | - | ||||||||||||
2270 | return r; | - | ||||||||||||
2271 | } | - | ||||||||||||
2272 | - | |||||||||||||
2273 | - | |||||||||||||
2274 | - | |||||||||||||
2275 | - | |||||||||||||
2276 | - | |||||||||||||
2277 | const void *QVariant::constData() const | - | ||||||||||||
2278 | { | - | ||||||||||||
2279 | return d.is_shared ? d.data.shared->ptr : reinterpret_cast<const void *>(&d.data.ptr); | - | ||||||||||||
2280 | } | - | ||||||||||||
2281 | void* QVariant::data() | - | ||||||||||||
2282 | { | - | ||||||||||||
2283 | detach(); | - | ||||||||||||
2284 | return const_cast<void *>(constData()); | - | ||||||||||||
2285 | } | - | ||||||||||||
2286 | bool QVariant::isNull() const | - | ||||||||||||
2287 | { | - | ||||||||||||
2288 | return handlerManager[d.type]->isNull(&d); | - | ||||||||||||
2289 | } | - | ||||||||||||
2290 | - | |||||||||||||
2291 | - | |||||||||||||
2292 | QDebug operator<<(QDebug dbg, const QVariant &v) | - | ||||||||||||
2293 | { | - | ||||||||||||
2294 | QDebugStateSaver saver(dbg); | - | ||||||||||||
2295 | const uint typeId = v.d.type; | - | ||||||||||||
2296 | dbg.nospace() << "QVariant("; | - | ||||||||||||
2297 | if (typeId != QMetaType::UnknownType) { | - | ||||||||||||
2298 | dbg << QMetaType::typeName(typeId) << ", "; | - | ||||||||||||
2299 | bool userStream = false; | - | ||||||||||||
2300 | bool canConvertToString = false; | - | ||||||||||||
2301 | if (typeId >= QMetaType::User) { | - | ||||||||||||
2302 | userStream = QMetaType::debugStream(dbg, constData(v.d), typeId); | - | ||||||||||||
2303 | canConvertToString = v.canConvert<QString>(); | - | ||||||||||||
2304 | } | - | ||||||||||||
2305 | if (!userStream && canConvertToString) | - | ||||||||||||
2306 | dbg << v.toString(); | - | ||||||||||||
2307 | else if (!userStream) | - | ||||||||||||
2308 | handlerManager[typeId]->debugStream(dbg, v); | - | ||||||||||||
2309 | } else { | - | ||||||||||||
2310 | dbg << "Invalid"; | - | ||||||||||||
2311 | } | - | ||||||||||||
2312 | dbg << ')'; | - | ||||||||||||
2313 | return dbg; | - | ||||||||||||
2314 | } | - | ||||||||||||
2315 | - | |||||||||||||
2316 | QDebug operator<<(QDebug dbg, const QVariant::Type p) | - | ||||||||||||
2317 | { | - | ||||||||||||
2318 | QDebugStateSaver saver(dbg); | - | ||||||||||||
2319 | dbg.nospace() << "QVariant::" | - | ||||||||||||
2320 | << (int(p) != int(QMetaType::UnknownType) | - | ||||||||||||
2321 | ? QMetaType::typeName(p) | - | ||||||||||||
2322 | : "Invalid"); | - | ||||||||||||
2323 | return dbg; | - | ||||||||||||
2324 | } | - | ||||||||||||
2325 | QSequentialIterable::QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl impl) | - | ||||||||||||
2326 | - | |||||||||||||
2327 | - | |||||||||||||
2328 | - | |||||||||||||
2329 | : m_impl(impl) | - | ||||||||||||
2330 | { | - | ||||||||||||
2331 | } | - | ||||||||||||
2332 | - | |||||||||||||
2333 | QSequentialIterable::const_iterator::const_iterator(const QSequentialIterable &iter, QAtomicInt *ref_) | - | ||||||||||||
2334 | : m_impl(iter.m_impl), ref(ref_) | - | ||||||||||||
2335 | { | - | ||||||||||||
2336 | ref->ref(); | - | ||||||||||||
2337 | } | - | ||||||||||||
2338 | - | |||||||||||||
2339 | QSequentialIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QSequentialIterableImpl &impl, QAtomicInt *ref_) | - | ||||||||||||
2340 | : m_impl(impl), ref(ref_) | - | ||||||||||||
2341 | { | - | ||||||||||||
2342 | ref->ref(); | - | ||||||||||||
2343 | } | - | ||||||||||||
2344 | - | |||||||||||||
2345 | void QSequentialIterable::const_iterator::begin() | - | ||||||||||||
2346 | { | - | ||||||||||||
2347 | m_impl.moveToBegin(); | - | ||||||||||||
2348 | } | - | ||||||||||||
2349 | - | |||||||||||||
2350 | void QSequentialIterable::const_iterator::end() | - | ||||||||||||
2351 | { | - | ||||||||||||
2352 | m_impl.moveToEnd(); | - | ||||||||||||
2353 | } | - | ||||||||||||
2354 | QSequentialIterable::const_iterator QSequentialIterable::begin() const | - | ||||||||||||
2355 | { | - | ||||||||||||
2356 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||
2357 | it.begin(); | - | ||||||||||||
2358 | return it; | - | ||||||||||||
2359 | } | - | ||||||||||||
2360 | - | |||||||||||||
2361 | - | |||||||||||||
2362 | - | |||||||||||||
2363 | - | |||||||||||||
2364 | - | |||||||||||||
2365 | - | |||||||||||||
2366 | - | |||||||||||||
2367 | QSequentialIterable::const_iterator QSequentialIterable::end() const | - | ||||||||||||
2368 | { | - | ||||||||||||
2369 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||
2370 | it.end(); | - | ||||||||||||
2371 | return it; | - | ||||||||||||
2372 | } | - | ||||||||||||
2373 | - | |||||||||||||
2374 | - | |||||||||||||
2375 | - | |||||||||||||
2376 | - | |||||||||||||
2377 | QVariant QSequentialIterable::at(int idx) const | - | ||||||||||||
2378 | { | - | ||||||||||||
2379 | const QtMetaTypePrivate::VariantData d = m_impl.at(idx); | - | ||||||||||||
2380 | if (d.metaTypeId == qMetaTypeId<QVariant>()) | - | ||||||||||||
2381 | return *reinterpret_cast<const QVariant*>(d.data); | - | ||||||||||||
2382 | return QVariant(d.metaTypeId, d.data, d.flags); | - | ||||||||||||
2383 | } | - | ||||||||||||
2384 | - | |||||||||||||
2385 | - | |||||||||||||
2386 | - | |||||||||||||
2387 | - | |||||||||||||
2388 | int QSequentialIterable::size() const | - | ||||||||||||
2389 | { | - | ||||||||||||
2390 | return m_impl.size(); | - | ||||||||||||
2391 | } | - | ||||||||||||
2392 | - | |||||||||||||
2393 | - | |||||||||||||
2394 | - | |||||||||||||
2395 | - | |||||||||||||
2396 | - | |||||||||||||
2397 | - | |||||||||||||
2398 | bool QSequentialIterable::canReverseIterate() const | - | ||||||||||||
2399 | { | - | ||||||||||||
2400 | return m_impl._iteratorCapabilities & QtMetaTypePrivate::BiDirectionalCapability; | - | ||||||||||||
2401 | } | - | ||||||||||||
2402 | QSequentialIterable::const_iterator::~const_iterator() { | - | ||||||||||||
2403 | if (!ref->deref()) { | - | ||||||||||||
2404 | m_impl.destroyIter(); | - | ||||||||||||
2405 | delete ref; | - | ||||||||||||
2406 | } | - | ||||||||||||
2407 | } | - | ||||||||||||
2408 | - | |||||||||||||
2409 | - | |||||||||||||
2410 | - | |||||||||||||
2411 | - | |||||||||||||
2412 | QSequentialIterable::const_iterator::const_iterator(const const_iterator &other) | - | ||||||||||||
2413 | : m_impl(other.m_impl), ref(other.ref) | - | ||||||||||||
2414 | { | - | ||||||||||||
2415 | ref->ref(); | - | ||||||||||||
2416 | } | - | ||||||||||||
2417 | - | |||||||||||||
2418 | - | |||||||||||||
2419 | - | |||||||||||||
2420 | - | |||||||||||||
2421 | QSequentialIterable::const_iterator& | - | ||||||||||||
2422 | QSequentialIterable::const_iterator::operator=(const const_iterator &other) | - | ||||||||||||
2423 | { | - | ||||||||||||
2424 | other.ref->ref(); | - | ||||||||||||
2425 | if (!ref->deref()) { | - | ||||||||||||
2426 | m_impl.destroyIter(); | - | ||||||||||||
2427 | delete ref; | - | ||||||||||||
2428 | } | - | ||||||||||||
2429 | m_impl = other.m_impl; | - | ||||||||||||
2430 | ref = other.ref; | - | ||||||||||||
2431 | return *this; | - | ||||||||||||
2432 | } | - | ||||||||||||
2433 | - | |||||||||||||
2434 | - | |||||||||||||
2435 | - | |||||||||||||
2436 | - | |||||||||||||
2437 | const QVariant QSequentialIterable::const_iterator::operator*() const | - | ||||||||||||
2438 | { | - | ||||||||||||
2439 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrent(); | - | ||||||||||||
2440 | if (d.metaTypeId == qMetaTypeId<QVariant>()) | - | ||||||||||||
2441 | return *reinterpret_cast<const QVariant*>(d.data); | - | ||||||||||||
2442 | return QVariant(d.metaTypeId, d.data, d.flags); | - | ||||||||||||
2443 | } | - | ||||||||||||
2444 | - | |||||||||||||
2445 | - | |||||||||||||
2446 | - | |||||||||||||
2447 | - | |||||||||||||
2448 | - | |||||||||||||
2449 | - | |||||||||||||
2450 | - | |||||||||||||
2451 | bool QSequentialIterable::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||
2452 | { | - | ||||||||||||
2453 | return m_impl.equal(other.m_impl); | - | ||||||||||||
2454 | } | - | ||||||||||||
2455 | - | |||||||||||||
2456 | - | |||||||||||||
2457 | - | |||||||||||||
2458 | - | |||||||||||||
2459 | - | |||||||||||||
2460 | - | |||||||||||||
2461 | - | |||||||||||||
2462 | bool QSequentialIterable::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||
2463 | { | - | ||||||||||||
2464 | return !m_impl.equal(other.m_impl); | - | ||||||||||||
2465 | } | - | ||||||||||||
2466 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator++() | - | ||||||||||||
2467 | { | - | ||||||||||||
2468 | m_impl.advance(1); | - | ||||||||||||
2469 | return *this; | - | ||||||||||||
2470 | } | - | ||||||||||||
2471 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator++(int) | - | ||||||||||||
2472 | { | - | ||||||||||||
2473 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||
2474 | impl.copy(m_impl); | - | ||||||||||||
2475 | m_impl.advance(1); | - | ||||||||||||
2476 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2477 | } | - | ||||||||||||
2478 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator--() | - | ||||||||||||
2479 | { | - | ||||||||||||
2480 | m_impl.advance(-1); | - | ||||||||||||
2481 | return *this; | - | ||||||||||||
2482 | } | - | ||||||||||||
2483 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator--(int) | - | ||||||||||||
2484 | { | - | ||||||||||||
2485 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||
2486 | impl.copy(m_impl); | - | ||||||||||||
2487 | m_impl.advance(-1); | - | ||||||||||||
2488 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2489 | } | - | ||||||||||||
2490 | - | |||||||||||||
2491 | - | |||||||||||||
2492 | - | |||||||||||||
2493 | - | |||||||||||||
2494 | - | |||||||||||||
2495 | - | |||||||||||||
2496 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator+=(int j) | - | ||||||||||||
2497 | { | - | ||||||||||||
2498 | m_impl.advance(j); | - | ||||||||||||
2499 | return *this; | - | ||||||||||||
2500 | } | - | ||||||||||||
2501 | QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator-=(int j) | - | ||||||||||||
2502 | { | - | ||||||||||||
2503 | m_impl.advance(-j); | - | ||||||||||||
2504 | return *this; | - | ||||||||||||
2505 | } | - | ||||||||||||
2506 | - | |||||||||||||
2507 | - | |||||||||||||
2508 | - | |||||||||||||
2509 | - | |||||||||||||
2510 | - | |||||||||||||
2511 | - | |||||||||||||
2512 | - | |||||||||||||
2513 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator+(int j) const | - | ||||||||||||
2514 | { | - | ||||||||||||
2515 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||
2516 | impl.copy(m_impl); | - | ||||||||||||
2517 | impl.advance(j); | - | ||||||||||||
2518 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2519 | } | - | ||||||||||||
2520 | QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator-(int j) const | - | ||||||||||||
2521 | { | - | ||||||||||||
2522 | QtMetaTypePrivate::QSequentialIterableImpl impl; | - | ||||||||||||
2523 | impl.copy(m_impl); | - | ||||||||||||
2524 | impl.advance(-j); | - | ||||||||||||
2525 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2526 | } | - | ||||||||||||
2527 | QAssociativeIterable::QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl impl) | - | ||||||||||||
2528 | - | |||||||||||||
2529 | - | |||||||||||||
2530 | - | |||||||||||||
2531 | : m_impl(impl) | - | ||||||||||||
2532 | { | - | ||||||||||||
2533 | } | - | ||||||||||||
2534 | - | |||||||||||||
2535 | QAssociativeIterable::const_iterator::const_iterator(const QAssociativeIterable &iter, QAtomicInt *ref_) | - | ||||||||||||
2536 | : m_impl(iter.m_impl), ref(ref_) | - | ||||||||||||
2537 | { | - | ||||||||||||
2538 | ref->ref(); | - | ||||||||||||
2539 | } | - | ||||||||||||
2540 | - | |||||||||||||
2541 | QAssociativeIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QAssociativeIterableImpl &impl, QAtomicInt *ref_) | - | ||||||||||||
2542 | : m_impl(impl), ref(ref_) | - | ||||||||||||
2543 | { | - | ||||||||||||
2544 | ref->ref(); | - | ||||||||||||
2545 | } | - | ||||||||||||
2546 | - | |||||||||||||
2547 | void QAssociativeIterable::const_iterator::begin() | - | ||||||||||||
2548 | { | - | ||||||||||||
2549 | m_impl.begin(); | - | ||||||||||||
2550 | } | - | ||||||||||||
2551 | - | |||||||||||||
2552 | void QAssociativeIterable::const_iterator::end() | - | ||||||||||||
2553 | { | - | ||||||||||||
2554 | m_impl.end(); | - | ||||||||||||
2555 | } | - | ||||||||||||
2556 | - | |||||||||||||
2557 | void QAssociativeIterable::const_iterator::find(const QVariant &key) | - | ||||||||||||
2558 | { | - | ||||||||||||
2559 | ((!(key.userType() == m_impl._metaType_id_key)) ? qt_assert("key.userType() == m_impl._metaType_id_key",__FILE__,42074205) : qt_noop()); | - | ||||||||||||
2560 | const QtMetaTypePrivate::VariantData dkey(key.userType(), key.constData(), 0 ); | - | ||||||||||||
2561 | m_impl.find(dkey); | - | ||||||||||||
2562 | } | - | ||||||||||||
2563 | - | |||||||||||||
2564 | - | |||||||||||||
2565 | - | |||||||||||||
2566 | - | |||||||||||||
2567 | - | |||||||||||||
2568 | - | |||||||||||||
2569 | - | |||||||||||||
2570 | QAssociativeIterable::const_iterator QAssociativeIterable::begin() const | - | ||||||||||||
2571 | { | - | ||||||||||||
2572 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||
2573 | it.begin(); | - | ||||||||||||
2574 | return it; | - | ||||||||||||
2575 | } | - | ||||||||||||
2576 | - | |||||||||||||
2577 | - | |||||||||||||
2578 | - | |||||||||||||
2579 | - | |||||||||||||
2580 | - | |||||||||||||
2581 | - | |||||||||||||
2582 | - | |||||||||||||
2583 | QAssociativeIterable::const_iterator QAssociativeIterable::end() const | - | ||||||||||||
2584 | { | - | ||||||||||||
2585 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||
2586 | it.end(); | - | ||||||||||||
2587 | return it; | - | ||||||||||||
2588 | } | - | ||||||||||||
2589 | QAssociativeIterable::const_iterator QAssociativeIterable::find(const QVariant &key) const | - | ||||||||||||
2590 | { | - | ||||||||||||
2591 | const_iterator it(*this, new QAtomicInt(0)); | - | ||||||||||||
2592 | QVariant key_ = key; | - | ||||||||||||
2593 | if (key_.canConvert(m_impl._metaType_id_key) && key_.convert(m_impl._metaType_id_key)) | - | ||||||||||||
2594 | it.find(key_); | - | ||||||||||||
2595 | else | - | ||||||||||||
2596 | it.end(); | - | ||||||||||||
2597 | return it; | - | ||||||||||||
2598 | } | - | ||||||||||||
2599 | - | |||||||||||||
2600 | - | |||||||||||||
2601 | - | |||||||||||||
2602 | - | |||||||||||||
2603 | - | |||||||||||||
2604 | - | |||||||||||||
2605 | QVariant QAssociativeIterable::value(const QVariant &key) const | - | ||||||||||||
2606 | { | - | ||||||||||||
2607 | const const_iterator it = find(key); | - | ||||||||||||
2608 | if (it == end()) | - | ||||||||||||
2609 | return QVariant(); | - | ||||||||||||
2610 | return *it; | - | ||||||||||||
2611 | } | - | ||||||||||||
2612 | - | |||||||||||||
2613 | - | |||||||||||||
2614 | - | |||||||||||||
2615 | - | |||||||||||||
2616 | int QAssociativeIterable::size() const | - | ||||||||||||
2617 | { | - | ||||||||||||
2618 | return m_impl.size(); | - | ||||||||||||
2619 | } | - | ||||||||||||
2620 | QAssociativeIterable::const_iterator::~const_iterator() | - | ||||||||||||
2621 | { | - | ||||||||||||
2622 | if (!ref->deref()) { | - | ||||||||||||
2623 | m_impl.destroyIter(); | - | ||||||||||||
2624 | delete ref; | - | ||||||||||||
2625 | } | - | ||||||||||||
2626 | } | - | ||||||||||||
2627 | - | |||||||||||||
2628 | - | |||||||||||||
2629 | - | |||||||||||||
2630 | - | |||||||||||||
2631 | QAssociativeIterable::const_iterator::const_iterator(const const_iterator &other) | - | ||||||||||||
2632 | : m_impl(other.m_impl), ref(other.ref) | - | ||||||||||||
2633 | { | - | ||||||||||||
2634 | ref->ref(); | - | ||||||||||||
2635 | } | - | ||||||||||||
2636 | - | |||||||||||||
2637 | - | |||||||||||||
2638 | - | |||||||||||||
2639 | - | |||||||||||||
2640 | QAssociativeIterable::const_iterator& | - | ||||||||||||
2641 | QAssociativeIterable::const_iterator::operator=(const const_iterator &other) | - | ||||||||||||
2642 | { | - | ||||||||||||
2643 | other.ref->ref(); | - | ||||||||||||
2644 | if (!ref->deref()) { | - | ||||||||||||
2645 | m_impl.destroyIter(); | - | ||||||||||||
2646 | delete ref; | - | ||||||||||||
2647 | } | - | ||||||||||||
2648 | m_impl = other.m_impl; | - | ||||||||||||
2649 | ref = other.ref; | - | ||||||||||||
2650 | return *this; | - | ||||||||||||
2651 | } | - | ||||||||||||
2652 | - | |||||||||||||
2653 | - | |||||||||||||
2654 | - | |||||||||||||
2655 | - | |||||||||||||
2656 | const QVariant QAssociativeIterable::const_iterator::operator*() const | - | ||||||||||||
2657 | { | - | ||||||||||||
2658 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); | - | ||||||||||||
2659 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||
2660 | if (d.metaTypeId == qMetaTypeId<QVariant>()) | - | ||||||||||||
2661 | return *reinterpret_cast<const QVariant*>(d.data); | - | ||||||||||||
2662 | return v; | - | ||||||||||||
2663 | } | - | ||||||||||||
2664 | - | |||||||||||||
2665 | - | |||||||||||||
2666 | - | |||||||||||||
2667 | - | |||||||||||||
2668 | const QVariant QAssociativeIterable::const_iterator::key() const | - | ||||||||||||
2669 | { | - | ||||||||||||
2670 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentKey(); | - | ||||||||||||
2671 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||
2672 | if (d.metaTypeId == qMetaTypeId<QVariant>()) | - | ||||||||||||
2673 | return *reinterpret_cast<const QVariant*>(d.data); | - | ||||||||||||
2674 | return v; | - | ||||||||||||
2675 | } | - | ||||||||||||
2676 | - | |||||||||||||
2677 | - | |||||||||||||
2678 | - | |||||||||||||
2679 | - | |||||||||||||
2680 | const QVariant QAssociativeIterable::const_iterator::value() const | - | ||||||||||||
2681 | { | - | ||||||||||||
2682 | const QtMetaTypePrivate::VariantData d = m_impl.getCurrentValue(); | - | ||||||||||||
2683 | QVariant v(d.metaTypeId, d.data, d.flags); | - | ||||||||||||
2684 | if (d.metaTypeId == qMetaTypeId<QVariant>()) | - | ||||||||||||
2685 | return *reinterpret_cast<const QVariant*>(d.data); | - | ||||||||||||
2686 | return v; | - | ||||||||||||
2687 | } | - | ||||||||||||
2688 | - | |||||||||||||
2689 | - | |||||||||||||
2690 | - | |||||||||||||
2691 | - | |||||||||||||
2692 | - | |||||||||||||
2693 | - | |||||||||||||
2694 | - | |||||||||||||
2695 | bool QAssociativeIterable::const_iterator::operator==(const const_iterator &other) const | - | ||||||||||||
2696 | { | - | ||||||||||||
2697 | return m_impl.equal(other.m_impl); | - | ||||||||||||
2698 | } | - | ||||||||||||
2699 | - | |||||||||||||
2700 | - | |||||||||||||
2701 | - | |||||||||||||
2702 | - | |||||||||||||
2703 | - | |||||||||||||
2704 | - | |||||||||||||
2705 | - | |||||||||||||
2706 | bool QAssociativeIterable::const_iterator::operator!=(const const_iterator &other) const | - | ||||||||||||
2707 | { | - | ||||||||||||
2708 | return !m_impl.equal(other.m_impl); | - | ||||||||||||
2709 | } | - | ||||||||||||
2710 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator++() | - | ||||||||||||
2711 | { | - | ||||||||||||
2712 | m_impl.advance(1); | - | ||||||||||||
2713 | return *this; | - | ||||||||||||
2714 | } | - | ||||||||||||
2715 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator++(int) | - | ||||||||||||
2716 | { | - | ||||||||||||
2717 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||
2718 | impl.copy(m_impl); | - | ||||||||||||
2719 | m_impl.advance(1); | - | ||||||||||||
2720 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2721 | } | - | ||||||||||||
2722 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator--() | - | ||||||||||||
2723 | { | - | ||||||||||||
2724 | m_impl.advance(-1); | - | ||||||||||||
2725 | return *this; | - | ||||||||||||
2726 | } | - | ||||||||||||
2727 | - | |||||||||||||
2728 | - | |||||||||||||
2729 | - | |||||||||||||
2730 | - | |||||||||||||
2731 | - | |||||||||||||
2732 | - | |||||||||||||
2733 | - | |||||||||||||
2734 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator--(int) | - | ||||||||||||
2735 | { | - | ||||||||||||
2736 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||
2737 | impl.copy(m_impl); | - | ||||||||||||
2738 | m_impl.advance(-1); | - | ||||||||||||
2739 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2740 | } | - | ||||||||||||
2741 | - | |||||||||||||
2742 | - | |||||||||||||
2743 | - | |||||||||||||
2744 | - | |||||||||||||
2745 | - | |||||||||||||
2746 | - | |||||||||||||
2747 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator+=(int j) | - | ||||||||||||
2748 | { | - | ||||||||||||
2749 | m_impl.advance(j); | - | ||||||||||||
2750 | return *this; | - | ||||||||||||
2751 | } | - | ||||||||||||
2752 | - | |||||||||||||
2753 | - | |||||||||||||
2754 | - | |||||||||||||
2755 | - | |||||||||||||
2756 | - | |||||||||||||
2757 | - | |||||||||||||
2758 | QAssociativeIterable::const_iterator &QAssociativeIterable::const_iterator::operator-=(int j) | - | ||||||||||||
2759 | { | - | ||||||||||||
2760 | m_impl.advance(-j); | - | ||||||||||||
2761 | return *this; | - | ||||||||||||
2762 | } | - | ||||||||||||
2763 | - | |||||||||||||
2764 | - | |||||||||||||
2765 | - | |||||||||||||
2766 | - | |||||||||||||
2767 | - | |||||||||||||
2768 | - | |||||||||||||
2769 | - | |||||||||||||
2770 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator+(int j) const | - | ||||||||||||
2771 | { | - | ||||||||||||
2772 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||
2773 | impl.copy(m_impl); | - | ||||||||||||
2774 | impl.advance(j); | - | ||||||||||||
2775 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2776 | } | - | ||||||||||||
2777 | - | |||||||||||||
2778 | - | |||||||||||||
2779 | - | |||||||||||||
2780 | - | |||||||||||||
2781 | - | |||||||||||||
2782 | - | |||||||||||||
2783 | - | |||||||||||||
2784 | QAssociativeIterable::const_iterator QAssociativeIterable::const_iterator::operator-(int j) const | - | ||||||||||||
2785 | { | - | ||||||||||||
2786 | QtMetaTypePrivate::QAssociativeIterableImpl impl; | - | ||||||||||||
2787 | impl.copy(m_impl); | - | ||||||||||||
2788 | impl.advance(-j); | - | ||||||||||||
2789 | return const_iterator(impl, new QAtomicInt(0)); | - | ||||||||||||
2790 | } | - | ||||||||||||
2791 | - | |||||||||||||
2792 | - | |||||||||||||
Switch to Source code | Preprocessed file |