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 { if (isTag_helper(t_)) adjustDefaultConstructedExtendedType(); }
101 QCborValue(std::nullptr_t) : t(Null) {}
102 QCborValue(bool b_) : t(b_ ? True : False) {}
103#ifndef Q_QDOC
104 QCborValue(int i) : QCborValue(qint64(i)) {}
105 QCborValue(unsigned u) : QCborValue(qint64(u)) {}
106#endif
107 QCborValue(qint64 i) : n(i), t(Integer) {}
108 QCborValue(double v) : t(Double) { memcpy(&n, &v, sizeof(n)); }
109 QCborValue(QCborSimpleType st) : t(type_helper(st)) {}
110
111 QCborValue(const QByteArray &ba);
112 QCborValue(const QString &s);
113 QCborValue(QStringView s);
114 QCborValue(QLatin1StringView s);
115#ifndef QT_NO_CAST_FROM_ASCII
116 QT_ASCII_CAST_WARN QCborValue(const char *s) : QCborValue(QString::fromUtf8(s)) {}
117#endif
118 QCborValue(const QCborArray &a);
119 QCborValue(QCborArray &&a);
120 QCborValue(const QCborMap &m);
121 QCborValue(QCborMap &&m);
122 QCborValue(QCborTag tag, const QCborValue &taggedValue = QCborValue());
123 QCborValue(QCborKnownTags t_, const QCborValue &tv = QCborValue())
124 : QCborValue(QCborTag(t_), tv)
125 {}
126
127#if QT_CONFIG(datestring)
128 explicit QCborValue(const QDateTime &dt);
129#endif
130#ifndef QT_BOOTSTRAPPED
131 explicit QCborValue(const QUrl &url);
132# if QT_CONFIG(regularexpression)
133 explicit QCborValue(const QRegularExpression &rx);
134# endif
135 explicit QCborValue(const QUuid &uuid);
136#endif
137
138 ~QCborValue() { if (container) dispose(); }
139
140 // make sure const char* doesn't go call the bool constructor
141 QCborValue(const void *) = delete;
142
143 QCborValue(const QCborValue &other) noexcept;
144 QCborValue(QCborValue &&other) noexcept
145 : n(other.n), container(std::exchange(other.container, nullptr)), t(std::exchange(other.t, Undefined))
146 {
147 }
148 QCborValue &operator=(const QCborValue &other) noexcept;
149 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCborValue)
150
151 void swap(QCborValue &other) noexcept
152 {
153 std::swap(n, other.n);
154 qt_ptr_swap(container, other.container);
155 std::swap(t, other.t);
156 }
157
158 Type type() const { return t; }
159 bool isInteger() const { return type() == Integer; }
160 bool isByteArray() const { return type() == ByteArray; }
161 bool isString() const { return type() == String; }
162 bool isArray() const { return type() == Array; }
163 bool isMap() const { return type() == Map; }
164 bool isTag() const { return isTag_helper(type()); }
165 bool isFalse() const { return type() == False; }
166 bool isTrue() const { return type() == True; }
167 bool isBool() const { return isFalse() || isTrue(); }
168 bool isNull() const { return type() == Null; }
169 bool isUndefined() const { return type() == Undefined; }
170 bool isDouble() const { return type() == Double; }
171 bool isDateTime() const { return type() == DateTime; }
172 bool isUrl() const { return type() == Url; }
173 bool isRegularExpression() const { return type() == RegularExpression; }
174 bool isUuid() const { return type() == Uuid; }
175 bool isInvalid() const { return type() == Invalid; }
176 bool isContainer() const { return isMap() || isArray(); }
177
178 bool isSimpleType() const
179 {
180 return int(type()) >> 8 == int(SimpleType) >> 8;
181 }
182 bool isSimpleType(QCborSimpleType st) const
183 {
184 return type() == type_helper(st);
185 }
186 QCborSimpleType toSimpleType(QCborSimpleType defaultValue = QCborSimpleType::Undefined) const
187 {
188 return isSimpleType() ? QCborSimpleType(type() & 0xff) : defaultValue;
189 }
190
191 qint64 toInteger(qint64 defaultValue = 0) const
192 { return isInteger() ? value_helper() : isDouble() ? qint64(fp_helper()) : defaultValue; }
193 bool toBool(bool defaultValue = false) const
194 { return isBool() ? isTrue() : defaultValue; }
195 double toDouble(double defaultValue = 0) const
196 { return isDouble() ? fp_helper() : isInteger() ? double(value_helper()) : defaultValue; }
197
198 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const;
199 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const;
200
201 QByteArray toByteArray(const QByteArray &defaultValue = {}) const;
202 QString toString(const QString &defaultValue = {}) const;
203 QAnyStringView toStringView(QAnyStringView defaultValue = {}) const;
204#if QT_CONFIG(datestring)
205 QDateTime toDateTime(const QDateTime &defaultValue = {}) const;
206#endif
207#ifndef QT_BOOTSTRAPPED
208 QUrl toUrl(const QUrl &defaultValue = {}) const;
209# if QT_CONFIG(regularexpression)
210 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const;
211# endif
212 QUuid toUuid(const QUuid &defaultValue = {}) const;
213#endif
214
215 // only forward-declared, need split functions
216 QCborArray toArray() const;
217 QCborArray toArray(const QCborArray &defaultValue) const;
218 QCborMap toMap() const;
219 QCborMap toMap(const QCborMap &defaultValue) const;
220
221 const QCborValue operator[](const QString &key) const;
222 const QCborValue operator[](QLatin1StringView key) const;
223 const QCborValue operator[](qint64 key) const;
224 QCborValueRef operator[](qint64 key);
225 QCborValueRef operator[](QLatin1StringView key);
226 QCborValueRef operator[](const QString & key);
227
228 int compare(const QCborValue &other) const;
229#if QT_CORE_REMOVED_SINCE(6, 8)
230 bool operator==(const QCborValue &other) const noexcept
231 { return compare(other) == 0; }
232 bool operator!=(const QCborValue &other) const noexcept
233 { return !operator==(other); }
234 bool operator<(const QCborValue &other) const
235 { return compare(other) < 0; }
236#endif
237
238 static QCborValue fromVariant(const QVariant &variant);
239 QVariant toVariant() const;
240 static QCborValue fromJsonValue(const QJsonValue &v);
241 QJsonValue toJsonValue() const;
242
243#if QT_CONFIG(cborstreamreader)
244 static QCborValue fromCbor(QCborStreamReader &reader);
245 static QCborValue fromCbor(const QByteArray &ba, QCborParserError *error = nullptr);
246 static QCborValue fromCbor(const char *data, qsizetype len, QCborParserError *error = nullptr)
247 { return fromCbor(QByteArray(data, len), error); }
248 static QCborValue fromCbor(const quint8 *data, qsizetype len, QCborParserError *error = nullptr)
249 { return fromCbor(QByteArray(reinterpret_cast<const char *>(data), len), error); }
250#endif // QT_CONFIG(cborstreamreader)
251#if QT_CONFIG(cborstreamwriter)
252 QByteArray toCbor(EncodingOptions opt = NoTransformation) const;
253 void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation) const;
254#endif
255
256 QString toDiagnosticNotation(DiagnosticNotationOptions opts = Compact) const;
257
258private:
259 friend Q_CORE_EXPORT Q_DECL_PURE_FUNCTION
260 bool comparesEqual(const QCborValue &lhs, const QCborValue &rhs) noexcept;
261 friend Qt::strong_ordering compareThreeWay(const QCborValue &lhs,
262 const QCborValue &rhs) noexcept
263 {
264 int c = lhs.compare(rhs);
265 return Qt::compareThreeWay(c, 0);
266 }
267
268 Q_DECLARE_STRONGLY_ORDERED(QCborValue)
269 friend class QCborArray;
270 friend class QCborMap;
271 friend class QCborValueConstRef;
272 friend class QCborValueRef;
273 friend class QCborContainerPrivate;
274 friend class QJsonPrivate::Value;
275
276 qint64 n = 0;
277 QCborContainerPrivate *container = nullptr;
278 Type t = Undefined;
279
280 void dispose();
281 void adjustDefaultConstructedExtendedType();
282 qint64 value_helper() const
283 {
284 return n;
285 }
286
287 double fp_helper() const
288 {
289 static_assert(sizeof(double) == sizeof(n));
290 double d;
291 memcpy(&d, &n, sizeof(d));
292 return d;
293 }
294
295 constexpr static Type type_helper(QCborSimpleType st)
296 {
297 return Type(quint8(st) | SimpleType);
298 }
299
300 constexpr static bool isTag_helper(Type tt)
301 {
302 return tt == Tag || tt >= 0x10000;
303 }
304};
306
307Q_CORE_EXPORT size_t qHash(const QCborValue &value, size_t seed = 0);
308
310{
311public:
314 operator QCborValue() const { return concrete(); }
315
316 QCborValue::Type type() const { return concreteType(*this); }
317 bool isInteger() const { return type() == QCborValue::Integer; }
318 bool isByteArray() const { return type() == QCborValue::ByteArray; }
319 bool isString() const { return type() == QCborValue::String; }
320 bool isArray() const { return type() == QCborValue::Array; }
321 bool isMap() const { return type() == QCborValue::Map; }
322 bool isTag() const { return concrete().isTag(); }
323 bool isFalse() const { return type() == QCborValue::False; }
324 bool isTrue() const { return type() == QCborValue::True; }
325 bool isBool() const { return isFalse() || isTrue(); }
326 bool isNull() const { return type() == QCborValue::Null; }
327 bool isUndefined() const { return type() == QCborValue::Undefined; }
328 bool isDouble() const { return type() == QCborValue::Double; }
329 bool isDateTime() const { return type() == QCborValue::DateTime; }
330 bool isUrl() const { return type() == QCborValue::Url; }
331 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
332 bool isUuid() const { return type() == QCborValue::Uuid; }
333 bool isInvalid() const { return type() == QCborValue::Invalid; }
334 bool isContainer() const { return isMap() || isArray(); }
335 bool isSimpleType() const { return concrete().isSimpleType(); }
336 bool isSimpleType(QCborSimpleType st) const { return concrete().isSimpleType(st); }
337
339 {
340 return concrete().toSimpleType(defaultValue);
341 }
342
343 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
344 { return concrete().tag(defaultValue); }
345 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
346 { return concrete().taggedValue(defaultValue); }
347
348 qint64 toInteger(qint64 defaultValue = 0) const
349 { return concrete().toInteger(defaultValue); }
350 bool toBool(bool defaultValue = false) const
351 { return concrete().toBool(defaultValue); }
352 double toDouble(double defaultValue = 0) const
353 { return concrete().toDouble(defaultValue); }
354
355 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
356 { return concrete().toByteArray(defaultValue); }
357 QString toString(const QString &defaultValue = {}) const
358 { return concrete().toString(defaultValue); }
359 QAnyStringView toStringView(QAnyStringView defaultValue = {}) const
360 { return concreteStringView(*this, defaultValue); }
361#if QT_CONFIG(datestring)
362 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
363 { return concrete().toDateTime(defaultValue); }
364#endif
365#ifndef QT_BOOTSTRAPPED
366 QUrl toUrl(const QUrl &defaultValue = {}) const
367 { return concrete().toUrl(defaultValue); }
368# if QT_CONFIG(regularexpression)
371# endif
372 QUuid toUuid(const QUuid &defaultValue = {}) const
373 { return concrete().toUuid(defaultValue); }
374#endif
375
376 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
377 inline QCborArray toArray() const;
378 inline QCborArray toArray(const QCborArray &a) const;
379 inline QCborMap toMap() const;
380 inline QCborMap toMap(const QCborMap &m) const;
381
382 Q_CORE_EXPORT const QCborValue operator[](const QString &key) const;
385
386 int compare(const QCborValue &other) const
387 { return concrete().compare(other); }
388
389 QVariant toVariant() const { return concrete().toVariant(); }
390 inline QJsonValue toJsonValue() const; // in qjsonvalue.h
391
392#if QT_CONFIG(cborstreamwriter)
394 { return concrete().toCbor(opt); }
396 { return concrete().toCbor(writer, opt); }
397#endif
398
399 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact) const
400 { return concrete().toDiagnosticNotation(opt); }
401
402protected:
403 friend class QCborValue;
404 friend class QCborArray;
405 friend class QCborMap;
407
408 QCborValue concrete() const noexcept { return concrete(*this); }
409
410 friend size_t qHash(const QCborValueConstRef &key, size_t seed = 0) noexcept
411 { return QHashPrivate::ex1to2arg(key.concrete(), seed); }
412
413 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool
415 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION Qt::strong_ordering
417 friend bool comparesEqual(const QCborValueConstRef &lhs,
418 const QCborValueConstRef &rhs) noexcept
419 {
420 return comparesEqual_helper(lhs, rhs);
421 }
423 const QCborValueConstRef &rhs) noexcept
424 {
425 return compareThreeWay_helper(lhs, rhs);
426 }
428
431 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION Qt::strong_ordering
433 friend bool comparesEqual(const QCborValueConstRef &lhs,
434 const QCborValue &rhs) noexcept
435 {
436 return comparesEqual_helper(lhs, rhs);
437 }
439 const QCborValue &rhs) noexcept
440 {
441 return compareThreeWay_helper(lhs, rhs);
442 }
443 Q_DECLARE_STRONGLY_ORDERED(QCborValueConstRef, QCborValue)
444
446 Q_DECL_PURE_FUNCTION static Q_CORE_EXPORT QCborValue::Type concreteType(QCborValueConstRef that) noexcept;
447 static Q_CORE_EXPORT bool
448 Q_DECL_PURE_FUNCTION concreteBoolean(QCborValueConstRef that, bool defaultValue) noexcept;
449 static Q_CORE_EXPORT double
450 Q_DECL_PURE_FUNCTION concreteDouble(QCborValueConstRef that, double defaultValue) noexcept;
451 static Q_CORE_EXPORT qint64
453 static Q_CORE_EXPORT QByteArray
455 static Q_CORE_EXPORT QString
457 static Q_CORE_EXPORT QAnyStringView
459
460 constexpr QCborValueConstRef() : d(nullptr), i(0) {} // this will actually be invalid
461 constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
462 : d(dd), i(ii)
463 {}
466};
467
468QT_WARNING_PUSH
469QT6_ONLY(QT_WARNING_DISABLE_MSVC(4275)) // non dll-interface class 'QJsonValueConstRef' used as base for dll-interface class 'QJsonValueRef'
470class QT6_ONLY(Q_CORE_EXPORT) QCborValueRef : public QCborValueConstRef
471{
472public:
473 QCborValueRef(const QCborValueRef &) noexcept = default;
474 QCborValueRef(QCborValueRef &&) noexcept = default;
475 QCborValueRef &operator=(const QCborValue &other)
476 { assign(*this, other); return *this; }
477 QCborValueRef &operator=(QCborValue &&other)
478 { assign(*this, std::move(other)); other.container = nullptr; return *this; }
479 QCborValueRef &operator=(const QCborValueRef &other)
480 { assign(*this, other); return *this; }
481
482 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](qint64 key);
483 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](QLatin1StringView key);
484 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](const QString & key);
485
486#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
487 // retained for binary compatibility (due to the Q_CORE_EXPORT) because at
488 // least one compiler emits and exports all inlines in an exported class
489
490 operator QCborValue() const { return concrete(); }
491 QCborValue::Type type() const { return concreteType(); }
492 bool isInteger() const { return type() == QCborValue::Integer; }
493 bool isByteArray() const { return type() == QCborValue::ByteArray; }
494 bool isString() const { return type() == QCborValue::String; }
495 bool isArray() const { return type() == QCborValue::Array; }
496 bool isMap() const { return type() == QCborValue::Map; }
497 bool isTag() const { return QCborValue::isTag_helper(type()); }
498 bool isFalse() const { return type() == QCborValue::False; }
499 bool isTrue() const { return type() == QCborValue::True; }
500 bool isBool() const { return isFalse() || isTrue(); }
501 bool isNull() const { return type() == QCborValue::Null; }
502 bool isUndefined() const { return type() == QCborValue::Undefined; }
503 bool isDouble() const { return type() == QCborValue::Double; }
504 bool isDateTime() const { return type() == QCborValue::DateTime; }
505 bool isUrl() const { return type() == QCborValue::Url; }
506 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
507 bool isUuid() const { return type() == QCborValue::Uuid; }
508 bool isInvalid() const { return type() == QCborValue::Invalid; }
509 bool isContainer() const { return isMap() || isArray(); }
510 bool isSimpleType() const
511 {
512 return type() >= QCborValue::SimpleType && type() < QCborValue::SimpleType + 0x100;
513 }
514 bool isSimpleType(QCborSimpleType st) const
515 {
516 return type() == QCborValue::type_helper(st);
517 }
518 QCborSimpleType toSimpleType(QCborSimpleType defaultValue = QCborSimpleType::Undefined) const
519 {
520 return isSimpleType() ? QCborSimpleType(type() & 0xff) : defaultValue;
521 }
522
523 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
524 { return concrete().tag(defaultValue); }
525 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
526 { return concrete().taggedValue(defaultValue); }
527
528 qint64 toInteger(qint64 defaultValue = 0) const
529 { return concreteIntegral(*this, defaultValue); }
530 bool toBool(bool defaultValue = false) const
531 { return concreteBoolean(*this, defaultValue); }
532 double toDouble(double defaultValue = 0) const
533 { return concreteDouble(*this, defaultValue); }
534
535 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
536 { return concreteByteArray(*this, defaultValue); }
537 QString toString(const QString &defaultValue = {}) const
538 { return concreteString(*this, defaultValue); }
539#if QT_CONFIG(datestring)
540 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
541 { return concrete().toDateTime(defaultValue); }
542#endif
543#ifndef QT_BOOTSTRAPPED
544 QUrl toUrl(const QUrl &defaultValue = {}) const
545 { return concrete().toUrl(defaultValue); }
546# if QT_CONFIG(regularexpression)
547 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
548 { return concrete().toRegularExpression(defaultValue); }
549# endif
550 QUuid toUuid(const QUuid &defaultValue = {}) const
551 { return concrete().toUuid(defaultValue); }
552#endif
553
554 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
555 QCborArray toArray() const;
556 QCborArray toArray(const QCborArray &a) const;
557 QCborMap toMap() const;
558 QCborMap toMap(const QCborMap &m) const;
559
560 const QCborValue operator[](const QString &key) const;
561 const QCborValue operator[](QLatin1StringView key) const;
562 const QCborValue operator[](qint64 key) const;
563
564 int compare(const QCborValue &other) const
565 { return concrete().compare(other); }
566#if QT_CORE_REMOVED_SINCE(6, 8)
567 bool operator==(const QCborValue &other) const
568 { return compare(other) == 0; }
569 bool operator!=(const QCborValue &other) const
570 { return !operator==(other); }
571 bool operator<(const QCborValue &other) const
572 { return compare(other) < 0; }
573#endif
574
575 QVariant toVariant() const { return concrete().toVariant(); }
576 QJsonValue toJsonValue() const;
577
578#if QT_CONFIG(cborstreamwriter)
579 using QCborValueConstRef::toCbor;
580 QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation)
581 { return std::as_const(*this).toCbor(opt); }
582 void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation);
583#endif
584
585 using QCborValueConstRef::toDiagnosticNotation;
586 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact)
587 { return std::as_const(*this).toDiagnosticNotation(opt); }
588
589private:
590 static QCborValue concrete(QCborValueRef that) noexcept;
591 QCborValue concrete() const noexcept { return concrete(*this); }
592
593 Q_DECL_PURE_FUNCTION static QCborValue::Type concreteType(QCborValueRef self) noexcept;
594 QCborValue::Type concreteType() const noexcept { return concreteType(*this); }
595
596 // this will actually be invalid...
597 constexpr QCborValueRef() : QCborValueConstRef(nullptr, 0) {}
598
599 QCborValueRef(QCborContainerPrivate *dd, qsizetype ii)
600 : QCborValueConstRef(dd, ii)
601 {}
602#else
603private:
604 using QCborValueConstRef::QCborValueConstRef;
605#endif // < Qt 7
606
607 friend class QCborValue;
608 friend class QCborArray;
609 friend class QCborMap;
610 friend class QCborContainerPrivate;
611 friend class QCborValueConstRef;
612
613 // static so we can pass this by value
614 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValue &other);
615 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, QCborValue &&other);
616 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValueRef other);
617};
618QT_WARNING_POP
619Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::EncodingOptions)
620Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::DiagnosticNotationOptions)
621
622#if !defined(QT_NO_DEBUG_STREAM)
623Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);
624#endif
625
626#ifndef QT_NO_DATASTREAM
627#if QT_CONFIG(cborstreamwriter)
628Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborValue &);
629#endif
630Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborValue &);
631#endif
632
633QT_END_NAMESPACE
634
635#endif // QCBORVALUE_H
\inmodule QtCore\reentrant
Definition qcborarray.h:21
\inmodule QtCore\reentrant
Definition qcbormap.h:35
bool isBool() const
Definition qcborvalue.h:325
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:389
bool isInteger() const
Definition qcborvalue.h:317
bool isDateTime() const
Definition qcborvalue.h:329
bool isDouble() const
Definition qcborvalue.h:328
bool isString() const
Definition qcborvalue.h:319
QCborValueConstRef & operator=(const QCborValueConstRef &)=delete
bool isUrl() const
Definition qcborvalue.h:330
bool isNull() const
Definition qcborvalue.h:326
QCborArray toArray() const
Definition qcborarray.h:379
bool isContainer() const
Definition qcborvalue.h:334
bool toBool(bool defaultValue=false) const
Definition qcborvalue.h:350
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
Definition qcborvalue.h:345
bool isByteArray() const
Definition qcborvalue.h:318
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
Definition qcborvalue.h:338
bool isMap() const
Definition qcborvalue.h:321
bool isSimpleType() const
Definition qcborvalue.h:335
bool isRegularExpression() const
Definition qcborvalue.h:331
bool isUndefined() const
Definition qcborvalue.h:327
QCborValue::Type type() const
Definition qcborvalue.h:316
bool isInvalid() const
Definition qcborvalue.h:333
QCborValueConstRef(const QCborValueConstRef &)=default
bool isUuid() const
Definition qcborvalue.h:332
QCborTag tag(QCborTag defaultValue=QCborTag(-1)) const
Definition qcborvalue.h:343
constexpr QCborValueConstRef()
Definition qcborvalue.h:460
QByteArray toByteArray(const QByteArray &defaultValue={}) const
Definition qcborvalue.h:355
qint64 toInteger(qint64 defaultValue=0) const
Definition qcborvalue.h:348
bool isSimpleType(QCborSimpleType st) const
Definition qcborvalue.h:336
bool isTrue() const
Definition qcborvalue.h:324
QUuid toUuid(const QUuid &defaultValue={}) const
Definition qcborvalue.h:372
QCborContainerPrivate * d
Definition qcborvalue.h:464
bool isFalse() const
Definition qcborvalue.h:323
QAnyStringView toStringView(QAnyStringView defaultValue={}) const
Definition qcborvalue.h:359
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcborvalue.h:417
bool isTag() const
Definition qcborvalue.h:322
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
Definition qcborvalue.h:433
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt=QCborValue::Compact) const
Definition qcborvalue.h:399
bool isArray() const
Definition qcborvalue.h:320
int compare(const QCborValue &other) const
Definition qcborvalue.h:386
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
Definition qcborvalue.h:438
operator QCborValue() const
Definition qcborvalue.h:314
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcborvalue.h:422
constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
Definition qcborvalue.h:461
QCborValue concrete() const noexcept
Definition qcborvalue.h:408
QString toString(const QString &defaultValue={}) const
Definition qcborvalue.h:357
QUrl toUrl(const QUrl &defaultValue={}) const
Definition qcborvalue.h:366
QJsonValue toJsonValue() const
friend size_t qHash(const QCborValueConstRef &key, size_t seed=0) noexcept
Definition qcborvalue.h:410
double toDouble(double defaultValue=0) const
Definition qcborvalue.h:352
\inmodule QtCore\reentrant
Definition qcborvalue.h:48
\inmodule QtCore\reentrant
Definition qdatastream.h:50
\inmodule QtCore
Definition qhash.h:844
Definition qlist.h:82
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:232
\inmodule QtCore\reentrant
Definition qpoint.h:30
LegacyRegisterOp legacyRegisterOp
Definition qmetatype.h:313
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Definition qfloat16.h:57
Combined button and popup list for selecting options.
QMutableListIterator< QByteArray > QMutableByteArrayListIterator
QCborSimpleType
Definition qcborcommon.h:29
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
Definition qdir.cpp:2620
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:73
#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:138
#define QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)
Definition qmetatype.h:71
#define QT_FOR_EACH_STATIC_PRIMITIVE_NON_VOID_TYPE(F)
Definition qmetatype.h:51
#define QT_FOR_EACH_STATIC_CORE_TEMPLATE(F)
Definition qmetatype.h:152
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)
Definition qmetatype.h:75
#define QT_IMPL_METATYPE_EXTERN_TAGGED(TYPE, TAG)
Definition qmetatype.h:1420
#define QT_FOR_EACH_STATIC_CORE_CLASS(F)
Definition qmetatype.h:106
#define QT_FOR_EACH_STATIC_ALIAS_TYPE(F)
Definition qmetatype.h:194
#define QT_FOR_EACH_STATIC_TYPE(F)
Definition qmetatype.h:224
#define QMETATYPE_CONVERTER(To, From, assign_and_return)
Definition qmetatype_p.h:24
#define QMETATYPE_CONVERTER_ASSIGN(To, From)
Definition qmetatype_p.h:35
#define QStringLiteral(str)
Definition qstring.h:1865
\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