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
305Q_CORE_EXPORT size_t qHash(const QCborValue &value, size_t seed = 0);
306
308{
309public:
312 operator QCborValue() const { return concrete(); }
313
314 QCborValue::Type type() const { return concreteType(*this); }
315 bool isInteger() const { return type() == QCborValue::Integer; }
316 bool isByteArray() const { return type() == QCborValue::ByteArray; }
317 bool isString() const { return type() == QCborValue::String; }
318 bool isArray() const { return type() == QCborValue::Array; }
319 bool isMap() const { return type() == QCborValue::Map; }
320 bool isTag() const { return concrete().isTag(); }
321 bool isFalse() const { return type() == QCborValue::False; }
322 bool isTrue() const { return type() == QCborValue::True; }
323 bool isBool() const { return isFalse() || isTrue(); }
324 bool isNull() const { return type() == QCborValue::Null; }
325 bool isUndefined() const { return type() == QCborValue::Undefined; }
326 bool isDouble() const { return type() == QCborValue::Double; }
327 bool isDateTime() const { return type() == QCborValue::DateTime; }
328 bool isUrl() const { return type() == QCborValue::Url; }
329 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
330 bool isUuid() const { return type() == QCborValue::Uuid; }
331 bool isInvalid() const { return type() == QCborValue::Invalid; }
332 bool isContainer() const { return isMap() || isArray(); }
333 bool isSimpleType() const { return concrete().isSimpleType(); }
334 bool isSimpleType(QCborSimpleType st) const { return concrete().isSimpleType(st); }
335
337 {
338 return concrete().toSimpleType(defaultValue);
339 }
340
341 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
342 { return concrete().tag(defaultValue); }
343 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
344 { return concrete().taggedValue(defaultValue); }
345
346 qint64 toInteger(qint64 defaultValue = 0) const
347 { return concrete().toInteger(defaultValue); }
348 bool toBool(bool defaultValue = false) const
349 { return concrete().toBool(defaultValue); }
350 double toDouble(double defaultValue = 0) const
351 { return concrete().toDouble(defaultValue); }
352
353 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
354 { return concrete().toByteArray(defaultValue); }
355 QString toString(const QString &defaultValue = {}) const
356 { return concrete().toString(defaultValue); }
357 QAnyStringView toStringView(QAnyStringView defaultValue = {}) const
358 { return concreteStringView(*this, defaultValue); }
359#if QT_CONFIG(datestring)
360 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
361 { return concrete().toDateTime(defaultValue); }
362#endif
363#ifndef QT_BOOTSTRAPPED
364 QUrl toUrl(const QUrl &defaultValue = {}) const
365 { return concrete().toUrl(defaultValue); }
366# if QT_CONFIG(regularexpression)
369# endif
370 QUuid toUuid(const QUuid &defaultValue = {}) const
371 { return concrete().toUuid(defaultValue); }
372#endif
373
374 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
375 inline QCborArray toArray() const;
376 inline QCborArray toArray(const QCborArray &a) const;
377 inline QCborMap toMap() const;
378 inline QCborMap toMap(const QCborMap &m) const;
379
380 Q_CORE_EXPORT const QCborValue operator[](const QString &key) const;
383
384 int compare(const QCborValue &other) const
385 { return concrete().compare(other); }
386
387 QVariant toVariant() const { return concrete().toVariant(); }
388 inline QJsonValue toJsonValue() const; // in qjsonvalue.h
389
390#if QT_CONFIG(cborstreamwriter)
392 { return concrete().toCbor(opt); }
394 { return concrete().toCbor(writer, opt); }
395#endif
396
397 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact) const
398 { return concrete().toDiagnosticNotation(opt); }
399
400protected:
401 friend class QCborValue;
402 friend class QCborArray;
403 friend class QCborMap;
405
406 QCborValue concrete() const noexcept { return concrete(*this); }
407
408 friend size_t qHash(const QCborValueConstRef &key, size_t seed = 0) noexcept
409 { return QHashPrivate::ex1to2arg(key.concrete(), seed); }
410
411 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool
413 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION Qt::strong_ordering
415 friend bool comparesEqual(const QCborValueConstRef &lhs,
416 const QCborValueConstRef &rhs) noexcept
417 {
418 return comparesEqual_helper(lhs, rhs);
419 }
421 const QCborValueConstRef &rhs) noexcept
422 {
423 return compareThreeWay_helper(lhs, rhs);
424 }
426
429 static Q_CORE_EXPORT Q_DECL_PURE_FUNCTION Qt::strong_ordering
431 friend bool comparesEqual(const QCborValueConstRef &lhs,
432 const QCborValue &rhs) noexcept
433 {
434 return comparesEqual_helper(lhs, rhs);
435 }
437 const QCborValue &rhs) noexcept
438 {
439 return compareThreeWay_helper(lhs, rhs);
440 }
441 Q_DECLARE_STRONGLY_ORDERED(QCborValueConstRef, QCborValue)
442
444 Q_DECL_PURE_FUNCTION static Q_CORE_EXPORT QCborValue::Type concreteType(QCborValueConstRef that) noexcept;
445 static Q_CORE_EXPORT bool
446 Q_DECL_PURE_FUNCTION concreteBoolean(QCborValueConstRef that, bool defaultValue) noexcept;
447 static Q_CORE_EXPORT double
448 Q_DECL_PURE_FUNCTION concreteDouble(QCborValueConstRef that, double defaultValue) noexcept;
449 static Q_CORE_EXPORT qint64
451 static Q_CORE_EXPORT QByteArray
453 static Q_CORE_EXPORT QString
455 static Q_CORE_EXPORT QAnyStringView
457
458 constexpr QCborValueConstRef() : d(nullptr), i(0) {} // this will actually be invalid
459 constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
460 : d(dd), i(ii)
461 {}
464};
465
466QT_WARNING_PUSH
467QT6_ONLY(QT_WARNING_DISABLE_MSVC(4275)) // non dll-interface class 'QJsonValueConstRef' used as base for dll-interface class 'QJsonValueRef'
468class QT6_ONLY(Q_CORE_EXPORT) QCborValueRef : public QCborValueConstRef
469{
470public:
471 QCborValueRef(const QCborValueRef &) noexcept = default;
472 QCborValueRef(QCborValueRef &&) noexcept = default;
473 QCborValueRef &operator=(const QCborValue &other)
474 { assign(*this, other); return *this; }
475 QCborValueRef &operator=(QCborValue &&other)
476 { assign(*this, std::move(other)); other.container = nullptr; return *this; }
477 QCborValueRef &operator=(const QCborValueRef &other)
478 { assign(*this, other); return *this; }
479
480 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](qint64 key);
481 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](QLatin1StringView key);
482 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](const QString & key);
483
484#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
485 // retained for binary compatibility (due to the Q_CORE_EXPORT) because at
486 // least one compiler emits and exports all inlines in an exported class
487
488 operator QCborValue() const { return concrete(); }
489 QCborValue::Type type() const { return concreteType(); }
490 bool isInteger() const { return type() == QCborValue::Integer; }
491 bool isByteArray() const { return type() == QCborValue::ByteArray; }
492 bool isString() const { return type() == QCborValue::String; }
493 bool isArray() const { return type() == QCborValue::Array; }
494 bool isMap() const { return type() == QCborValue::Map; }
495 bool isTag() const { return QCborValue::isTag_helper(type()); }
496 bool isFalse() const { return type() == QCborValue::False; }
497 bool isTrue() const { return type() == QCborValue::True; }
498 bool isBool() const { return isFalse() || isTrue(); }
499 bool isNull() const { return type() == QCborValue::Null; }
500 bool isUndefined() const { return type() == QCborValue::Undefined; }
501 bool isDouble() const { return type() == QCborValue::Double; }
502 bool isDateTime() const { return type() == QCborValue::DateTime; }
503 bool isUrl() const { return type() == QCborValue::Url; }
504 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
505 bool isUuid() const { return type() == QCborValue::Uuid; }
506 bool isInvalid() const { return type() == QCborValue::Invalid; }
507 bool isContainer() const { return isMap() || isArray(); }
508 bool isSimpleType() const
509 {
510 return type() >= QCborValue::SimpleType && type() < QCborValue::SimpleType + 0x100;
511 }
512 bool isSimpleType(QCborSimpleType st) const
513 {
514 return type() == QCborValue::type_helper(st);
515 }
516 QCborSimpleType toSimpleType(QCborSimpleType defaultValue = QCborSimpleType::Undefined) const
517 {
518 return isSimpleType() ? QCborSimpleType(type() & 0xff) : defaultValue;
519 }
520
521 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
522 { return concrete().tag(defaultValue); }
523 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
524 { return concrete().taggedValue(defaultValue); }
525
526 qint64 toInteger(qint64 defaultValue = 0) const
527 { return concreteIntegral(*this, defaultValue); }
528 bool toBool(bool defaultValue = false) const
529 { return concreteBoolean(*this, defaultValue); }
530 double toDouble(double defaultValue = 0) const
531 { return concreteDouble(*this, defaultValue); }
532
533 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
534 { return concreteByteArray(*this, defaultValue); }
535 QString toString(const QString &defaultValue = {}) const
536 { return concreteString(*this, defaultValue); }
537#if QT_CONFIG(datestring)
538 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
539 { return concrete().toDateTime(defaultValue); }
540#endif
541#ifndef QT_BOOTSTRAPPED
542 QUrl toUrl(const QUrl &defaultValue = {}) const
543 { return concrete().toUrl(defaultValue); }
544# if QT_CONFIG(regularexpression)
545 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
546 { return concrete().toRegularExpression(defaultValue); }
547# endif
548 QUuid toUuid(const QUuid &defaultValue = {}) const
549 { return concrete().toUuid(defaultValue); }
550#endif
551
552 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
553 QCborArray toArray() const;
554 QCborArray toArray(const QCborArray &a) const;
555 QCborMap toMap() const;
556 QCborMap toMap(const QCborMap &m) const;
557
558 const QCborValue operator[](const QString &key) const;
559 const QCborValue operator[](QLatin1StringView key) const;
560 const QCborValue operator[](qint64 key) const;
561
562 int compare(const QCborValue &other) const
563 { return concrete().compare(other); }
564#if QT_CORE_REMOVED_SINCE(6, 8)
565 bool operator==(const QCborValue &other) const
566 { return compare(other) == 0; }
567 bool operator!=(const QCborValue &other) const
568 { return !operator==(other); }
569 bool operator<(const QCborValue &other) const
570 { return compare(other) < 0; }
571#endif
572
573 QVariant toVariant() const { return concrete().toVariant(); }
574 QJsonValue toJsonValue() const;
575
576#if QT_CONFIG(cborstreamwriter)
577 using QCborValueConstRef::toCbor;
578 QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation)
579 { return std::as_const(*this).toCbor(opt); }
580 void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation);
581#endif
582
583 using QCborValueConstRef::toDiagnosticNotation;
584 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact)
585 { return std::as_const(*this).toDiagnosticNotation(opt); }
586
587private:
588 static QCborValue concrete(QCborValueRef that) noexcept;
589 QCborValue concrete() const noexcept { return concrete(*this); }
590
591 Q_DECL_PURE_FUNCTION static QCborValue::Type concreteType(QCborValueRef self) noexcept;
592 QCborValue::Type concreteType() const noexcept { return concreteType(*this); }
593
594 // this will actually be invalid...
595 constexpr QCborValueRef() : QCborValueConstRef(nullptr, 0) {}
596
597 QCborValueRef(QCborContainerPrivate *dd, qsizetype ii)
598 : QCborValueConstRef(dd, ii)
599 {}
600#else
601private:
602 using QCborValueConstRef::QCborValueConstRef;
603#endif // < Qt 7
604
605 friend class QCborValue;
606 friend class QCborArray;
607 friend class QCborMap;
608 friend class QCborContainerPrivate;
609 friend class QCborValueConstRef;
610
611 // static so we can pass this by value
612 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValue &other);
613 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, QCborValue &&other);
614 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValueRef other);
615};
616QT_WARNING_POP
617Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::EncodingOptions)
618Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::DiagnosticNotationOptions)
619
620#if !defined(QT_NO_DEBUG_STREAM)
621Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);
622#endif
623
624#ifndef QT_NO_DATASTREAM
625#if QT_CONFIG(cborstreamwriter)
626Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborValue &);
627#endif
628Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborValue &);
629#endif
630
631QT_END_NAMESPACE
632
633#endif // QCBORVALUE_H
\inmodule QtCore\reentrant
Definition qcborarray.h:21
\inmodule QtCore\reentrant
Definition qcbormap.h:35
bool isBool() const
Definition qcborvalue.h:323
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:387
bool isInteger() const
Definition qcborvalue.h:315
bool isDateTime() const
Definition qcborvalue.h:327
bool isDouble() const
Definition qcborvalue.h:326
bool isString() const
Definition qcborvalue.h:317
QCborValueConstRef & operator=(const QCborValueConstRef &)=delete
bool isUrl() const
Definition qcborvalue.h:328
bool isNull() const
Definition qcborvalue.h:324
QCborArray toArray() const
Definition qcborarray.h:379
bool isContainer() const
Definition qcborvalue.h:332
bool toBool(bool defaultValue=false) const
Definition qcborvalue.h:348
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
Definition qcborvalue.h:343
bool isByteArray() const
Definition qcborvalue.h:316
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
Definition qcborvalue.h:336
bool isMap() const
Definition qcborvalue.h:319
bool isSimpleType() const
Definition qcborvalue.h:333
bool isRegularExpression() const
Definition qcborvalue.h:329
bool isUndefined() const
Definition qcborvalue.h:325
QCborValue::Type type() const
Definition qcborvalue.h:314
bool isInvalid() const
Definition qcborvalue.h:331
QCborValueConstRef(const QCborValueConstRef &)=default
bool isUuid() const
Definition qcborvalue.h:330
QCborTag tag(QCborTag defaultValue=QCborTag(-1)) const
Definition qcborvalue.h:341
constexpr QCborValueConstRef()
Definition qcborvalue.h:458
QByteArray toByteArray(const QByteArray &defaultValue={}) const
Definition qcborvalue.h:353
qint64 toInteger(qint64 defaultValue=0) const
Definition qcborvalue.h:346
bool isSimpleType(QCborSimpleType st) const
Definition qcborvalue.h:334
bool isTrue() const
Definition qcborvalue.h:322
QUuid toUuid(const QUuid &defaultValue={}) const
Definition qcborvalue.h:370
QCborContainerPrivate * d
Definition qcborvalue.h:462
bool isFalse() const
Definition qcborvalue.h:321
QAnyStringView toStringView(QAnyStringView defaultValue={}) const
Definition qcborvalue.h:357
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcborvalue.h:415
bool isTag() const
Definition qcborvalue.h:320
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
Definition qcborvalue.h:431
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt=QCborValue::Compact) const
Definition qcborvalue.h:397
bool isArray() const
Definition qcborvalue.h:318
int compare(const QCborValue &other) const
Definition qcborvalue.h:384
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
Definition qcborvalue.h:436
operator QCborValue() const
Definition qcborvalue.h:312
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcborvalue.h:420
constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
Definition qcborvalue.h:459
QCborValue concrete() const noexcept
Definition qcborvalue.h:406
QString toString(const QString &defaultValue={}) const
Definition qcborvalue.h:355
QUrl toUrl(const QUrl &defaultValue={}) const
Definition qcborvalue.h:364
QJsonValue toJsonValue() const
friend size_t qHash(const QCborValueConstRef &key, size_t seed=0) noexcept
Definition qcborvalue.h:408
double toDouble(double defaultValue=0) const
Definition qcborvalue.h:350
\inmodule QtCore\reentrant
Definition qcborvalue.h:48
\inmodule QtCore\reentrant
Definition qdatastream.h:50
\inmodule QtCore
Definition qhash.h:843
Definition qlist.h:81
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:2582
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:1375
#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:1825
\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