Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcborvalue.h
Go to the documentation of this file.
1// Copyright (C) 2022 Intel Corporation.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:critical reason:data-parser
4
5#ifndef QCBORVALUE_H
6#define QCBORVALUE_H
7
8#include <QtCore/qbytearray.h>
9#include <QtCore/qcborcommon.h>
10#include <QtCore/qcompare.h>
11#include <QtCore/qdatetime.h>
12#if QT_CONFIG(regularexpression)
13# include <QtCore/qregularexpression.h>
14#endif
15#include <QtCore/qstring.h>
16#include <QtCore/qstringview.h>
17#include <QtCore/qurl.h>
18#include <QtCore/quuid.h>
19#include <QtCore/qvariant.h>
20
21/* X11 headers use these values too, but as defines */
22#if defined(False) && defined(True)
23# undef True
24# undef False
25#endif
26
28
29class QCborArray;
30class QCborMap;
31class QCborStreamReader;
32class QCborStreamWriter;
33class QDataStream;
34
35namespace QJsonPrivate { class Value; }
36
38{
41
42 QString errorString() const { return error.toString(); }
43};
44
45class QCborValueRef;
47class Q_CORE_EXPORT QCborValue
48{
49 Q_GADGET
50public:
51 enum EncodingOption {
52 SortKeysInMaps = 0x01,
53 UseFloat = 0x02,
54#ifndef QT_BOOTSTRAPPED
55 UseFloat16 = UseFloat | 0x04,
56#endif
57 UseIntegers = 0x08,
58
59 NoTransformation = 0
60 };
61 Q_DECLARE_FLAGS(EncodingOptions, EncodingOption)
62
63 enum DiagnosticNotationOption {
64 Compact = 0x00,
65 LineWrapped = 0x01,
66 ExtendedFormat = 0x02
67 };
68 Q_DECLARE_FLAGS(DiagnosticNotationOptions, DiagnosticNotationOption)
69
70 // different from QCborStreamReader::Type because we have more types
71 enum Type : int {
72 Integer = 0x00,
73 ByteArray = 0x40,
74 String = 0x60,
75 Array = 0x80,
76 Map = 0xa0,
77 Tag = 0xc0,
78
79 // range 0x100 - 0x1ff for Simple Types
80 SimpleType = 0x100,
81 False = SimpleType + int(QCborSimpleType::False),
82 True = SimpleType + int(QCborSimpleType::True),
83 Null = SimpleType + int(QCborSimpleType::Null),
84 Undefined = SimpleType + int(QCborSimpleType::Undefined),
85
86 Double = 0x202,
87
88 // extended (tagged) types
89 DateTime = 0x10000,
90 Url = 0x10020,
91 RegularExpression = 0x10023,
92 Uuid = 0x10025,
93
94 Invalid = -1
95 };
96 Q_ENUM(Type)
97
98 QCborValue() {}
99 QCborValue(Type t_) : t(t_) {}
100 QCborValue(std::nullptr_t) : t(Null) {}
101 QCborValue(bool b_) : t(b_ ? True : False) {}
102#ifndef Q_QDOC
103 QCborValue(int i) : QCborValue(qint64(i)) {}
104 QCborValue(unsigned u) : QCborValue(qint64(u)) {}
105#endif
106 QCborValue(qint64 i) : n(i), t(Integer) {}
107 QCborValue(double v) : t(Double) { memcpy(&n, &v, sizeof(n)); }
108 QCborValue(QCborSimpleType st) : t(type_helper(st)) {}
109
110 QCborValue(const QByteArray &ba);
111 QCborValue(const QString &s);
112 QCborValue(QStringView s);
113 QCborValue(QLatin1StringView s);
114#ifndef QT_NO_CAST_FROM_ASCII
115 QT_ASCII_CAST_WARN QCborValue(const char *s) : QCborValue(QString::fromUtf8(s)) {}
116#endif
117 QCborValue(const QCborArray &a);
118 QCborValue(QCborArray &&a);
119 QCborValue(const QCborMap &m);
120 QCborValue(QCborMap &&m);
121 QCborValue(QCborTag tag, const QCborValue &taggedValue = QCborValue());
122 QCborValue(QCborKnownTags t_, const QCborValue &tv = QCborValue())
123 : QCborValue(QCborTag(t_), tv)
124 {}
125
126#if QT_CONFIG(datestring)
127 explicit QCborValue(const QDateTime &dt);
128#endif
129#ifndef QT_BOOTSTRAPPED
130 explicit QCborValue(const QUrl &url);
131# if QT_CONFIG(regularexpression)
132 explicit QCborValue(const QRegularExpression &rx);
133# endif
134 explicit QCborValue(const QUuid &uuid);
135#endif
136
137 ~QCborValue() { if (container) dispose(); }
138
139 // make sure const char* doesn't go call the bool constructor
140 QCborValue(const void *) = delete;
141
142 QCborValue(const QCborValue &other) noexcept;
143 QCborValue(QCborValue &&other) noexcept
144 : n(other.n), container(std::exchange(other.container, nullptr)), t(std::exchange(other.t, Undefined))
145 {
146 }
147 QCborValue &operator=(const QCborValue &other) noexcept;
148 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCborValue)
149
150 void swap(QCborValue &other) noexcept
151 {
152 std::swap(n, other.n);
153 qt_ptr_swap(container, other.container);
154 std::swap(t, other.t);
155 }
156
157 Type type() const { return t; }
158 bool isInteger() const { return type() == Integer; }
159 bool isByteArray() const { return type() == ByteArray; }
160 bool isString() const { return type() == String; }
161 bool isArray() const { return type() == Array; }
162 bool isMap() const { return type() == Map; }
163 bool isTag() const { return isTag_helper(type()); }
164 bool isFalse() const { return type() == False; }
165 bool isTrue() const { return type() == True; }
166 bool isBool() const { return isFalse() || isTrue(); }
167 bool isNull() const { return type() == Null; }
168 bool isUndefined() const { return type() == Undefined; }
169 bool isDouble() const { return type() == Double; }
170 bool isDateTime() const { return type() == DateTime; }
171 bool isUrl() const { return type() == Url; }
172 bool isRegularExpression() const { return type() == RegularExpression; }
173 bool isUuid() const { return type() == Uuid; }
174 bool isInvalid() const { return type() == Invalid; }
175 bool isContainer() const { return isMap() || isArray(); }
176
177 bool isSimpleType() const
178 {
179 return int(type()) >> 8 == int(SimpleType) >> 8;
180 }
181 bool isSimpleType(QCborSimpleType st) const
182 {
183 return type() == type_helper(st);
184 }
185 QCborSimpleType toSimpleType(QCborSimpleType defaultValue = QCborSimpleType::Undefined) const
186 {
187 return isSimpleType() ? QCborSimpleType(type() & 0xff) : defaultValue;
188 }
189
190 qint64 toInteger(qint64 defaultValue = 0) const
191 { return isInteger() ? value_helper() : isDouble() ? qint64(fp_helper()) : defaultValue; }
192 bool toBool(bool defaultValue = false) const
193 { return isBool() ? isTrue() : defaultValue; }
194 double toDouble(double defaultValue = 0) const
195 { return isDouble() ? fp_helper() : isInteger() ? double(value_helper()) : defaultValue; }
196
197 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const;
198 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const;
199
200 QByteArray toByteArray(const QByteArray &defaultValue = {}) const;
201 QString toString(const QString &defaultValue = {}) const;
202 QAnyStringView toStringView(QAnyStringView defaultValue = {}) const;
203#if QT_CONFIG(datestring)
204 QDateTime toDateTime(const QDateTime &defaultValue = {}) const;
205#endif
206#ifndef QT_BOOTSTRAPPED
207 QUrl toUrl(const QUrl &defaultValue = {}) const;
208# if QT_CONFIG(regularexpression)
209 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const;
210# endif
211 QUuid toUuid(const QUuid &defaultValue = {}) const;
212#endif
213
214 // only forward-declared, need split functions
215 QCborArray toArray() const;
216 QCborArray toArray(const QCborArray &defaultValue) const;
217 QCborMap toMap() const;
218 QCborMap toMap(const QCborMap &defaultValue) const;
219
220 const QCborValue operator[](const QString &key) const;
221 const QCborValue operator[](QLatin1StringView key) const;
222 const QCborValue operator[](qint64 key) const;
223 QCborValueRef operator[](qint64 key);
224 QCborValueRef operator[](QLatin1StringView key);
225 QCborValueRef operator[](const QString & key);
226
227 int compare(const QCborValue &other) const;
228#if QT_CORE_REMOVED_SINCE(6, 8)
229 bool operator==(const QCborValue &other) const noexcept
230 { return compare(other) == 0; }
231 bool operator!=(const QCborValue &other) const noexcept
232 { return !operator==(other); }
233 bool operator<(const QCborValue &other) const
234 { return compare(other) < 0; }
235#endif
236
237 static QCborValue fromVariant(const QVariant &variant);
238 QVariant toVariant() const;
239 static QCborValue fromJsonValue(const QJsonValue &v);
240 QJsonValue toJsonValue() const;
241
242#if QT_CONFIG(cborstreamreader)
243 static QCborValue fromCbor(QCborStreamReader &reader);
244 static QCborValue fromCbor(const QByteArray &ba, QCborParserError *error = nullptr);
245 static QCborValue fromCbor(const char *data, qsizetype len, QCborParserError *error = nullptr)
246 { return fromCbor(QByteArray(data, int(len)), error); }
247 static QCborValue fromCbor(const quint8 *data, qsizetype len, QCborParserError *error = nullptr)
248 { return fromCbor(QByteArray(reinterpret_cast<const char *>(data), int(len)), error); }
249#endif // QT_CONFIG(cborstreamreader)
250#if QT_CONFIG(cborstreamwriter)
251 QByteArray toCbor(EncodingOptions opt = NoTransformation) const;
252 void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation) const;
253#endif
254
255 QString toDiagnosticNotation(DiagnosticNotationOptions opts = Compact) const;
256
257private:
258 friend Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
259 bool comparesEqual(const QCborValue &lhs, const QCborValue &rhs) noexcept;
260 friend Qt::strong_ordering compareThreeWay(const QCborValue &lhs,
261 const QCborValue &rhs) noexcept
262 {
263 int c = lhs.compare(rhs);
264 return Qt::compareThreeWay(c, 0);
265 }
266
267 Q_DECLARE_STRONGLY_ORDERED(QCborValue)
268 friend class QCborArray;
269 friend class QCborMap;
270 friend class QCborValueConstRef;
271 friend class QCborValueRef;
272 friend class QCborContainerPrivate;
273 friend class QJsonPrivate::Value;
274
275 qint64 n = 0;
276 QCborContainerPrivate *container = nullptr;
277 Type t = Undefined;
278
279 void dispose();
280 qint64 value_helper() const
281 {
282 return n;
283 }
284
285 double fp_helper() const
286 {
287 static_assert(sizeof(double) == sizeof(n));
288 double d;
289 memcpy(&d, &n, sizeof(d));
290 return d;
291 }
292
293 constexpr static Type type_helper(QCborSimpleType st)
294 {
295 return Type(quint8(st) | SimpleType);
296 }
297
298 constexpr static bool isTag_helper(Type tt)
299 {
300 return tt == Tag || tt >= 0x10000;
301 }
302};
304
306{
307public:
310 operator QCborValue() const { return concrete(); }
311
312 QCborValue::Type type() const { return concreteType(*this); }
313 bool isInteger() const { return type() == QCborValue::Integer; }
314 bool isByteArray() const { return type() == QCborValue::ByteArray; }
315 bool isString() const { return type() == QCborValue::String; }
316 bool isArray() const { return type() == QCborValue::Array; }
317 bool isMap() const { return type() == QCborValue::Map; }
318 bool isTag() const { return concrete().isTag(); }
319 bool isFalse() const { return type() == QCborValue::False; }
320 bool isTrue() const { return type() == QCborValue::True; }
321 bool isBool() const { return isFalse() || isTrue(); }
322 bool isNull() const { return type() == QCborValue::Null; }
323 bool isUndefined() const { return type() == QCborValue::Undefined; }
324 bool isDouble() const { return type() == QCborValue::Double; }
325 bool isDateTime() const { return type() == QCborValue::DateTime; }
326 bool isUrl() const { return type() == QCborValue::Url; }
327 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
328 bool isUuid() const { return type() == QCborValue::Uuid; }
329 bool isInvalid() const { return type() == QCborValue::Invalid; }
330 bool isContainer() const { return isMap() || isArray(); }
331 bool isSimpleType() const { return concrete().isSimpleType(); }
332 bool isSimpleType(QCborSimpleType st) const { return concrete().isSimpleType(st); }
333
335 {
336 return concrete().toSimpleType(defaultValue);
337 }
338
339 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
340 { return concrete().tag(defaultValue); }
341 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
342 { return concrete().taggedValue(defaultValue); }
343
344 qint64 toInteger(qint64 defaultValue = 0) const
345 { return concrete().toInteger(defaultValue); }
346 bool toBool(bool defaultValue = false) const
347 { return concrete().toBool(defaultValue); }
348 double toDouble(double defaultValue = 0) const
349 { return concrete().toDouble(defaultValue); }
350
351 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
352 { return concrete().toByteArray(defaultValue); }
353 QString toString(const QString &defaultValue = {}) const
354 { return concrete().toString(defaultValue); }
355 QAnyStringView toStringView(QAnyStringView defaultValue = {}) const
356 { return concreteStringView(*this, defaultValue); }
357#if QT_CONFIG(datestring)
358 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
359 { return concrete().toDateTime(defaultValue); }
360#endif
361#ifndef QT_BOOTSTRAPPED
362 QUrl toUrl(const QUrl &defaultValue = {}) const
363 { return concrete().toUrl(defaultValue); }
364# if QT_CONFIG(regularexpression)
367# endif
368 QUuid toUuid(const QUuid &defaultValue = {}) const
369 { return concrete().toUuid(defaultValue); }
370#endif
371
372 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
373 inline QCborArray toArray() const;
374 inline QCborArray toArray(const QCborArray &a) const;
375 inline QCborMap toMap() const;
376 inline QCborMap toMap(const QCborMap &m) const;
377
378 Q_CORE_EXPORT const QCborValue operator[](const QString &key) const;
381
382 int compare(const QCborValue &other) const
383 { return concrete().compare(other); }
384
385 QVariant toVariant() const { return concrete().toVariant(); }
386 inline QJsonValue toJsonValue() const; // in qjsonvalue.h
387
388#if QT_CONFIG(cborstreamwriter)
390 { return concrete().toCbor(opt); }
392 { return concrete().toCbor(writer, opt); }
393#endif
394
395 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact) const
396 { return concrete().toDiagnosticNotation(opt); }
397
398protected:
399 friend class QCborValue;
400 friend class QCborArray;
401 friend class QCborMap;
403
404 QCborValue concrete() const noexcept { return concrete(*this); }
405 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool
407 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION Qt::strong_ordering
409 friend bool comparesEqual(const QCborValueConstRef &lhs,
410 const QCborValueConstRef &rhs) noexcept
411 {
412 return comparesEqual_helper(lhs, rhs);
413 }
415 const QCborValueConstRef &rhs) noexcept
416 {
417 return compareThreeWay_helper(lhs, rhs);
418 }
420
423 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION Qt::strong_ordering
425 friend bool comparesEqual(const QCborValueConstRef &lhs,
426 const QCborValue &rhs) noexcept
427 {
428 return comparesEqual_helper(lhs, rhs);
429 }
431 const QCborValue &rhs) noexcept
432 {
433 return compareThreeWay_helper(lhs, rhs);
434 }
435 Q_DECLARE_STRONGLY_ORDERED(QCborValueConstRef, QCborValue)
436
438 Q_DECL_PURE_FUNCTION static Q_CORE_EXPORT QCborValue::Type concreteType(QCborValueConstRef that) noexcept;
439 static Q_CORE_EXPORT bool
440 Q_DECL_PURE_FUNCTION concreteBoolean(QCborValueConstRef that, bool defaultValue) noexcept;
441 static Q_CORE_EXPORT double
442 Q_DECL_PURE_FUNCTION concreteDouble(QCborValueConstRef that, double defaultValue) noexcept;
443 static Q_CORE_EXPORT qint64
445 static Q_CORE_EXPORT QByteArray
447 static Q_CORE_EXPORT QString
449 static Q_CORE_EXPORT QAnyStringView
451
452 constexpr QCborValueConstRef() : d(nullptr), i(0) {} // this will actually be invalid
453 constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
454 : d(dd), i(ii)
455 {}
458};
459
460QT_WARNING_PUSH
461QT6_ONLY(QT_WARNING_DISABLE_MSVC(4275)) // non dll-interface class 'QJsonValueConstRef' used as base for dll-interface class 'QJsonValueRef'
462class QT6_ONLY(Q_CORE_EXPORT) QCborValueRef : public QCborValueConstRef
463{
464public:
465 QCborValueRef(const QCborValueRef &) noexcept = default;
466 QCborValueRef(QCborValueRef &&) noexcept = default;
467 QCborValueRef &operator=(const QCborValue &other)
468 { assign(*this, other); return *this; }
469 QCborValueRef &operator=(QCborValue &&other)
470 { assign(*this, std::move(other)); other.container = nullptr; return *this; }
471 QCborValueRef &operator=(const QCborValueRef &other)
472 { assign(*this, other); return *this; }
473
474 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](qint64 key);
475 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](QLatin1StringView key);
476 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](const QString & key);
477
478#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
479 // retained for binary compatibility (due to the Q_CORE_EXPORT) because at
480 // least one compiler emits and exports all inlines in an exported class
481
482 operator QCborValue() const { return concrete(); }
483 QCborValue::Type type() const { return concreteType(); }
484 bool isInteger() const { return type() == QCborValue::Integer; }
485 bool isByteArray() const { return type() == QCborValue::ByteArray; }
486 bool isString() const { return type() == QCborValue::String; }
487 bool isArray() const { return type() == QCborValue::Array; }
488 bool isMap() const { return type() == QCborValue::Map; }
489 bool isTag() const { return QCborValue::isTag_helper(type()); }
490 bool isFalse() const { return type() == QCborValue::False; }
491 bool isTrue() const { return type() == QCborValue::True; }
492 bool isBool() const { return isFalse() || isTrue(); }
493 bool isNull() const { return type() == QCborValue::Null; }
494 bool isUndefined() const { return type() == QCborValue::Undefined; }
495 bool isDouble() const { return type() == QCborValue::Double; }
496 bool isDateTime() const { return type() == QCborValue::DateTime; }
497 bool isUrl() const { return type() == QCborValue::Url; }
498 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
499 bool isUuid() const { return type() == QCborValue::Uuid; }
500 bool isInvalid() const { return type() == QCborValue::Invalid; }
501 bool isContainer() const { return isMap() || isArray(); }
502 bool isSimpleType() const
503 {
504 return type() >= QCborValue::SimpleType && type() < QCborValue::SimpleType + 0x100;
505 }
506 bool isSimpleType(QCborSimpleType st) const
507 {
508 return type() == QCborValue::type_helper(st);
509 }
510 QCborSimpleType toSimpleType(QCborSimpleType defaultValue = QCborSimpleType::Undefined) const
511 {
512 return isSimpleType() ? QCborSimpleType(type() & 0xff) : defaultValue;
513 }
514
515 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
516 { return concrete().tag(defaultValue); }
517 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
518 { return concrete().taggedValue(defaultValue); }
519
520 qint64 toInteger(qint64 defaultValue = 0) const
521 { return concreteIntegral(*this, defaultValue); }
522 bool toBool(bool defaultValue = false) const
523 { return concreteBoolean(*this, defaultValue); }
524 double toDouble(double defaultValue = 0) const
525 { return concreteDouble(*this, defaultValue); }
526
527 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
528 { return concreteByteArray(*this, defaultValue); }
529 QString toString(const QString &defaultValue = {}) const
530 { return concreteString(*this, defaultValue); }
531#if QT_CONFIG(datestring)
532 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
533 { return concrete().toDateTime(defaultValue); }
534#endif
535#ifndef QT_BOOTSTRAPPED
536 QUrl toUrl(const QUrl &defaultValue = {}) const
537 { return concrete().toUrl(defaultValue); }
538# if QT_CONFIG(regularexpression)
539 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
540 { return concrete().toRegularExpression(defaultValue); }
541# endif
542 QUuid toUuid(const QUuid &defaultValue = {}) const
543 { return concrete().toUuid(defaultValue); }
544#endif
545
546 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
547 QCborArray toArray() const;
548 QCborArray toArray(const QCborArray &a) const;
549 QCborMap toMap() const;
550 QCborMap toMap(const QCborMap &m) const;
551
552 const QCborValue operator[](const QString &key) const;
553 const QCborValue operator[](QLatin1StringView key) const;
554 const QCborValue operator[](qint64 key) const;
555
556 int compare(const QCborValue &other) const
557 { return concrete().compare(other); }
558#if QT_CORE_REMOVED_SINCE(6, 8)
559 bool operator==(const QCborValue &other) const
560 { return compare(other) == 0; }
561 bool operator!=(const QCborValue &other) const
562 { return !operator==(other); }
563 bool operator<(const QCborValue &other) const
564 { return compare(other) < 0; }
565#endif
566
567 QVariant toVariant() const { return concrete().toVariant(); }
568 QJsonValue toJsonValue() const;
569
570#if QT_CONFIG(cborstreamwriter)
571 using QCborValueConstRef::toCbor;
572 QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation)
573 { return std::as_const(*this).toCbor(opt); }
574 void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation);
575#endif
576
577 using QCborValueConstRef::toDiagnosticNotation;
578 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact)
579 { return std::as_const(*this).toDiagnosticNotation(opt); }
580
581private:
582 static QCborValue concrete(QCborValueRef that) noexcept;
583 QCborValue concrete() const noexcept { return concrete(*this); }
584
585 Q_DECL_PURE_FUNCTION static QCborValue::Type concreteType(QCborValueRef self) noexcept;
586 QCborValue::Type concreteType() const noexcept { return concreteType(*this); }
587
588 // this will actually be invalid...
589 constexpr QCborValueRef() : QCborValueConstRef(nullptr, 0) {}
590
591 QCborValueRef(QCborContainerPrivate *dd, qsizetype ii)
592 : QCborValueConstRef(dd, ii)
593 {}
594#else
595private:
596 using QCborValueConstRef::QCborValueConstRef;
597#endif // < Qt 7
598
599 friend class QCborValue;
600 friend class QCborArray;
601 friend class QCborMap;
602 friend class QCborContainerPrivate;
603 friend class QCborValueConstRef;
604
605 // static so we can pass this by value
606 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValue &other);
607 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, QCborValue &&other);
608 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValueRef other);
609};
610QT_WARNING_POP
611Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::EncodingOptions)
612Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::DiagnosticNotationOptions)
613
614Q_CORE_EXPORT size_t qHash(const QCborValue &value, size_t seed = 0);
615
616#if !defined(QT_NO_DEBUG_STREAM)
617Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);
618#endif
619
620#ifndef QT_NO_DATASTREAM
621#if QT_CONFIG(cborstreamwriter)
622Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborValue &);
623#endif
624Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborValue &);
625#endif
626
627QT_END_NAMESPACE
628
629#endif // QCBORVALUE_H
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
\inmodule QtCore\reentrant
Definition qcborarray.h:21
\inmodule QtCore\reentrant
Definition qcbormap.h:35
bool isBool() const
Definition qcborvalue.h:321
QCborArray toArray(const QCborArray &a) const
Definition qcborarray.h:384
QCborMap toMap(const QCborMap &m) const
Definition qcbormap.h:495
QCborMap toMap() const
Definition qcbormap.h:490
QVariant toVariant() const
Definition qcborvalue.h:385
bool isInteger() const
Definition qcborvalue.h:313
bool isDateTime() const
Definition qcborvalue.h:325
bool isDouble() const
Definition qcborvalue.h:324
bool isString() const
Definition qcborvalue.h:315
QCborValueConstRef & operator=(const QCborValueConstRef &)=delete
bool isUrl() const
Definition qcborvalue.h:326
bool isNull() const
Definition qcborvalue.h:322
QCborArray toArray() const
Definition qcborarray.h:379
bool isContainer() const
Definition qcborvalue.h:330
bool toBool(bool defaultValue=false) const
Definition qcborvalue.h:346
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
Definition qcborvalue.h:341
bool isByteArray() const
Definition qcborvalue.h:314
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
Definition qcborvalue.h:334
bool isMap() const
Definition qcborvalue.h:317
bool isSimpleType() const
Definition qcborvalue.h:331
bool isRegularExpression() const
Definition qcborvalue.h:327
bool isUndefined() const
Definition qcborvalue.h:323
QCborValue::Type type() const
Definition qcborvalue.h:312
bool isInvalid() const
Definition qcborvalue.h:329
QCborValueConstRef(const QCborValueConstRef &)=default
bool isUuid() const
Definition qcborvalue.h:328
QCborTag tag(QCborTag defaultValue=QCborTag(-1)) const
Definition qcborvalue.h:339
constexpr QCborValueConstRef()
Definition qcborvalue.h:452
QByteArray toByteArray(const QByteArray &defaultValue={}) const
Definition qcborvalue.h:351
qint64 toInteger(qint64 defaultValue=0) const
Definition qcborvalue.h:344
bool isSimpleType(QCborSimpleType st) const
Definition qcborvalue.h:332
bool isTrue() const
Definition qcborvalue.h:320
QUuid toUuid(const QUuid &defaultValue={}) const
Definition qcborvalue.h:368
QCborContainerPrivate * d
Definition qcborvalue.h:456
bool isFalse() const
Definition qcborvalue.h:319
QAnyStringView toStringView(QAnyStringView defaultValue={}) const
Definition qcborvalue.h:355
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcborvalue.h:409
bool isTag() const
Definition qcborvalue.h:318
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
Definition qcborvalue.h:425
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt=QCborValue::Compact) const
Definition qcborvalue.h:395
bool isArray() const
Definition qcborvalue.h:316
int compare(const QCborValue &other) const
Definition qcborvalue.h:382
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
Definition qcborvalue.h:430
operator QCborValue() const
Definition qcborvalue.h:310
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcborvalue.h:414
constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
Definition qcborvalue.h:453
QCborValue concrete() const noexcept
Definition qcborvalue.h:404
QString toString(const QString &defaultValue={}) const
Definition qcborvalue.h:353
QUrl toUrl(const QUrl &defaultValue={}) const
Definition qcborvalue.h:362
QJsonValue toJsonValue() const
double toDouble(double defaultValue=0) const
Definition qcborvalue.h:348
\inmodule QtCore\reentrant
Definition qcborvalue.h:48
\inmodule QtCore\reentrant
Definition qdatastream.h:50
\inmodule QtCore
Definition qhash.h:837
Definition qlist.h:80
void remove(int from, int to)
bool insertIfNotContains(Key k, const T &f)
bool contains(Key k) const
const T * function(Key k) const
\inmodule QtCore\reentrant
Definition qpoint.h:231
\inmodule QtCore\reentrant
Definition qpoint.h:29
The QSequentialIterable class is an iterable interface for a container in a QVariant.
LegacyRegisterOp legacyRegisterOp
Definition qmetatype.h:312
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Definition qfloat16.h:48
QMutableListIterator< QByteArray > QMutableByteArrayListIterator
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
QCborSimpleType
Definition qcborcommon.h:29
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2568
QList< QVariant > QVariantList
Definition qjsonarray.h:16
#define qCWarning(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
#define CONVERT_CBOR_AND_JSON(To)
#define NS(x)
Definition qmetatype.cpp:70
#define QMETATYPE_CONVERTER_ASSIGN_QCHAR(From)
#define QMETATYPE_CONVERTER_ASSIGN_DOUBLE(To, From)
#define INTEGRAL_CONVERTER(To)
static bool tryConvertBuiltinTypes(const void *from, int fromTypeId, void *to, int toTypeId)
#define QMETATYPE_CONVERTER_ASSIGN_NUMBER(To, From)
static bool qIntegerConversionFromFPHelper(From from, To *to)
#define FLOAT_CONVERTER(To)
#define QT_FOR_EACH_STATIC_CORE_POINTER(F)
Definition qmetatype.h:137
#define QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)
Definition qmetatype.h:70
#define QT_FOR_EACH_STATIC_PRIMITIVE_NON_VOID_TYPE(F)
Definition qmetatype.h:50
#define QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)
Definition qmetatype.h:151
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)
Definition qmetatype.h:74
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
Definition qmetatype.h:1365
#define QT_FOR_EACH_STATIC_CORE_CLASS(F)
Definition qmetatype.h:105
#define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)
Definition qmetatype.h:193
#define QT_FOR_EACH_STATIC_TYPE(F)
Definition qmetatype.h:223
#define QMETATYPE_CONVERTER(To, From, assign_and_return)
Definition qmetatype_p.h:23
#define QMETATYPE_CONVERTER_ASSIGN(To, From)
Definition qmetatype_p.h:34
#define QStringLiteral(str)
Definition qstring.h:1826
\inmodule QtCore\reentrant
Definition qcborvalue.h:38
QString errorString() const
\variable QCborParserError::offset
Definition qcborvalue.h:42
QCborError error
Definition qcborvalue.h:40
QListSpecialMethods & operator=(const QListSpecialMethods &)=default
QListSpecialMethods(QListSpecialMethods &&)=default
QListSpecialMethods & operator=(QListSpecialMethods &&)=default
QListSpecialMethods(const QListSpecialMethods &)=default
QByteArray join(QByteArrayView sep={}) const
static T value(const Iterator &it)
Definition qcbormap.h:27
static T value(Iterator &it)
Definition qcbormap.h:28
static QCborValueConstRef key(Iterator &it)
Definition qcbormap.h:26
static QCborValueConstRef key(const Iterator &it)
Definition qcbormap.h:25