Qt 6.x
The Qt SDK
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
4#ifndef QCBORVALUE_H
5#define QCBORVALUE_H
6
7#include <QtCore/qbytearray.h>
8#include <QtCore/qdatetime.h>
9#include <QtCore/qcborcommon.h>
10#if QT_CONFIG(regularexpression)
11# include <QtCore/qregularexpression.h>
12#endif
13#include <QtCore/qstring.h>
14#include <QtCore/qstringview.h>
15#include <QtCore/qurl.h>
16#include <QtCore/quuid.h>
17#include <QtCore/qvariant.h>
18
19/* X11 headers use these values too, but as defines */
20#if defined(False) && defined(True)
21# undef True
22# undef False
23#endif
24
25#if 0 && __has_include(<compare>)
26# include <compare>
27#endif
28
30
31class QCborArray;
32class QCborMap;
35class QDataStream;
36
37namespace QJsonPrivate { class Value; }
38
40{
43
44 QString errorString() const { return error.toString(); }
45};
46
47class QCborValueRef;
49class Q_CORE_EXPORT QCborValue
50{
52public:
54 SortKeysInMaps = 0x01,
55 UseFloat = 0x02,
56#ifndef QT_BOOTSTRAPPED
57 UseFloat16 = UseFloat | 0x04,
58#endif
59 UseIntegers = 0x08,
60
61 NoTransformation = 0
62 };
63 Q_DECLARE_FLAGS(EncodingOptions, EncodingOption)
64
66 Compact = 0x00,
67 LineWrapped = 0x01,
68 ExtendedFormat = 0x02
69 };
70 Q_DECLARE_FLAGS(DiagnosticNotationOptions, DiagnosticNotationOption)
71
72 // different from QCborStreamReader::Type because we have more types
73 enum Type : int {
74 Integer = 0x00,
75 ByteArray = 0x40,
76 String = 0x60,
77 Array = 0x80,
78 Map = 0xa0,
79 Tag = 0xc0,
80
81 // range 0x100 - 0x1ff for Simple Types
82 SimpleType = 0x100,
83 False = SimpleType + int(QCborSimpleType::False),
84 True = SimpleType + int(QCborSimpleType::True),
85 Null = SimpleType + int(QCborSimpleType::Null),
87
88 Double = 0x202,
89
90 // extended (tagged) types
91 DateTime = 0x10000,
92 Url = 0x10020,
94 Uuid = 0x10025,
95
96 Invalid = -1
97 };
99
101 QCborValue(Type t_) : t(t_) {}
102 QCborValue(std::nullptr_t) : t(Null) {}
103 QCborValue(bool b_) : t(b_ ? True : False) {}
104#ifndef Q_QDOC
106 QCborValue(unsigned u) : QCborValue(qint64(u)) {}
107#endif
109 QCborValue(double v) : t(Double) { memcpy(&n, &v, sizeof(n)); }
110 QCborValue(QCborSimpleType st) : t(type_helper(st)) {}
111
112 QCborValue(const QByteArray &ba);
113 QCborValue(const QString &s);
116#ifndef QT_NO_CAST_FROM_ASCII
117 QT_ASCII_CAST_WARN QCborValue(const char *s) : QCborValue(QString::fromUtf8(s)) {}
118#endif
119 QCborValue(const QCborArray &a);
121 QCborValue(const QCborMap &m);
123 QCborValue(QCborTag tag, const QCborValue &taggedValue = QCborValue());
125 : QCborValue(QCborTag(t_), tv)
126 {}
127
128 explicit QCborValue(const QDateTime &dt);
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;
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 }
182 {
183 return type() == type_helper(st);
184 }
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 QDateTime toDateTime(const QDateTime &defaultValue = {}) const;
203#ifndef QT_BOOTSTRAPPED
204 QUrl toUrl(const QUrl &defaultValue = {}) const;
205# if QT_CONFIG(regularexpression)
206 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const;
207# endif
208 QUuid toUuid(const QUuid &defaultValue = {}) const;
209#endif
210
211 // only forward-declared, need split functions
212 QCborArray toArray() const;
213 QCborArray toArray(const QCborArray &defaultValue) const;
214 QCborMap toMap() const;
215 QCborMap toMap(const QCborMap &defaultValue) const;
216
217 const QCborValue operator[](const QString &key) const;
218 const QCborValue operator[](QLatin1StringView key) const;
219 const QCborValue operator[](qint64 key) const;
220 QCborValueRef operator[](qint64 key);
221 QCborValueRef operator[](QLatin1StringView key);
222 QCborValueRef operator[](const QString & key);
223
224 int compare(const QCborValue &other) const;
225#if 0 && __has_include(<compare>)
226 std::strong_ordering operator<=>(const QCborValue &other) const
227 {
228 int c = compare(other);
229 if (c > 0) return std::partial_ordering::greater;
230 if (c == 0) return std::partial_ordering::equivalent;
231 return std::partial_ordering::less;
232 }
233#else
234 bool operator==(const QCborValue &other) const noexcept
235 { return compare(other) == 0; }
236 bool operator!=(const QCborValue &other) const noexcept
237 { return !(*this == other); }
238 bool operator<(const QCborValue &other) const
239 { return compare(other) < 0; }
240#endif
241
242 static QCborValue fromVariant(const QVariant &variant);
243 QVariant toVariant() const;
244 static QCborValue fromJsonValue(const QJsonValue &v);
245 QJsonValue toJsonValue() const;
246
247#if QT_CONFIG(cborstreamreader)
248 static QCborValue fromCbor(QCborStreamReader &reader);
249 static QCborValue fromCbor(const QByteArray &ba, QCborParserError *error = nullptr);
250 static QCborValue fromCbor(const char *data, qsizetype len, QCborParserError *error = nullptr)
251 { return fromCbor(QByteArray(data, int(len)), error); }
252 static QCborValue fromCbor(const quint8 *data, qsizetype len, QCborParserError *error = nullptr)
253 { return fromCbor(QByteArray(reinterpret_cast<const char *>(data), int(len)), error); }
254#endif // QT_CONFIG(cborstreamreader)
255#if QT_CONFIG(cborstreamwriter)
256 QByteArray toCbor(EncodingOptions opt = NoTransformation) const;
257 void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation) const;
258#endif
259
260 QString toDiagnosticNotation(DiagnosticNotationOptions opts = Compact) const;
261
262private:
263 friend class QCborValueRef;
266
267 qint64 n = 0;
268 QCborContainerPrivate *container = nullptr;
269 Type t = Undefined;
270
271 void dispose();
272 qint64 value_helper() const
273 {
274 return n;
275 }
276
277 double fp_helper() const
278 {
279 static_assert(sizeof(double) == sizeof(n));
280 double d;
281 memcpy(&d, &n, sizeof(d));
282 return d;
283 }
284
285 constexpr static Type type_helper(QCborSimpleType st)
286 {
287 return Type(quint8(st) | SimpleType);
288 }
289
290 constexpr static bool isTag_helper(Type tt)
291 {
292 return tt == Tag || tt >= 0x10000;
293 }
294};
295Q_DECLARE_SHARED(QCborValue)
296
298{
299public:
302 operator QCborValue() const { return concrete(); }
303
304 QCborValue::Type type() const { return concreteType(*this); }
305 bool isInteger() const { return type() == QCborValue::Integer; }
306 bool isByteArray() const { return type() == QCborValue::ByteArray; }
307 bool isString() const { return type() == QCborValue::String; }
308 bool isArray() const { return type() == QCborValue::Array; }
309 bool isMap() const { return type() == QCborValue::Map; }
310 bool isTag() const { return concrete().isTag(); }
311 bool isFalse() const { return type() == QCborValue::False; }
312 bool isTrue() const { return type() == QCborValue::True; }
313 bool isBool() const { return isFalse() || isTrue(); }
314 bool isNull() const { return type() == QCborValue::Null; }
315 bool isUndefined() const { return type() == QCborValue::Undefined; }
316 bool isDouble() const { return type() == QCborValue::Double; }
317 bool isDateTime() const { return type() == QCborValue::DateTime; }
318 bool isUrl() const { return type() == QCborValue::Url; }
320 bool isUuid() const { return type() == QCborValue::Uuid; }
321 bool isInvalid() const { return type() == QCborValue::Invalid; }
322 bool isContainer() const { return isMap() || isArray(); }
323 bool isSimpleType() const { return concrete().isSimpleType(); }
324 bool isSimpleType(QCborSimpleType st) const { return concrete().isSimpleType(st); }
325
327 {
328 return concrete().toSimpleType(defaultValue);
329 }
330
331 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
332 { return concrete().tag(defaultValue); }
333 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
334 { return concrete().taggedValue(defaultValue); }
335
336 qint64 toInteger(qint64 defaultValue = 0) const
337 { return concrete().toInteger(defaultValue); }
338 bool toBool(bool defaultValue = false) const
339 { return concrete().toBool(defaultValue); }
340 double toDouble(double defaultValue = 0) const
341 { return concrete().toDouble(defaultValue); }
342
343 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
344 { return concrete().toByteArray(defaultValue); }
345 QString toString(const QString &defaultValue = {}) const
346 { return concrete().toString(defaultValue); }
347 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
348 { return concrete().toDateTime(defaultValue); }
349#ifndef QT_BOOTSTRAPPED
350 QUrl toUrl(const QUrl &defaultValue = {}) const
351 { return concrete().toUrl(defaultValue); }
352# if QT_CONFIG(regularexpression)
353 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
354 { return concrete().toRegularExpression(defaultValue); }
355# endif
356 QUuid toUuid(const QUuid &defaultValue = {}) const
357 { return concrete().toUuid(defaultValue); }
358#endif
359
360 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
361 inline QCborArray toArray() const;
362 inline QCborArray toArray(const QCborArray &a) const;
363 inline QCborMap toMap() const;
364 inline QCborMap toMap(const QCborMap &m) const;
365
366 Q_CORE_EXPORT const QCborValue operator[](const QString &key) const;
367 Q_CORE_EXPORT const QCborValue operator[](QLatin1StringView key) const;
368 Q_CORE_EXPORT const QCborValue operator[](qint64 key) const;
369
370 int compare(const QCborValue &other) const
371 { return concrete().compare(other); }
372#if 0 && __has_include(<compare>)
373 std::strong_ordering operator<=>(const QCborValue &other) const
374 {
375 int c = compare(other);
376 if (c > 0) return std::strong_ordering::greater;
377 if (c == 0) return std::strong_ordering::equivalent;
378 return std::strong_ordering::less;
379 }
380#else
381 bool operator==(const QCborValue &other) const
382 { return compare(other) == 0; }
383 bool operator!=(const QCborValue &other) const
384 { return !(*this == other); }
385 bool operator<(const QCborValue &other) const
386 { return compare(other) < 0; }
387#endif
388
389 QVariant toVariant() const { return concrete().toVariant(); }
390 inline QJsonValue toJsonValue() const; // in qjsonvalue.h
391
392#if QT_CONFIG(cborstreamwriter)
393 QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation) const
394 { return concrete().toCbor(opt); }
395 void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation) const
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 static Q_CORE_EXPORT QCborValue concrete(QCborValueConstRef that) noexcept;
411 static Q_CORE_EXPORT QCborValue::Type concreteType(QCborValueConstRef that) noexcept Q_DECL_PURE_FUNCTION;
412 static Q_CORE_EXPORT bool
413 concreteBoolean(QCborValueConstRef that, bool defaultValue) noexcept Q_DECL_PURE_FUNCTION;
414 static Q_CORE_EXPORT double
415 concreteDouble(QCborValueConstRef that, double defaultValue) noexcept Q_DECL_PURE_FUNCTION;
416 static Q_CORE_EXPORT qint64
417 concreteIntegral(QCborValueConstRef that, qint64 defaultValue) noexcept Q_DECL_PURE_FUNCTION;
418 static Q_CORE_EXPORT QByteArray
419 concreteByteArray(QCborValueConstRef that, const QByteArray &defaultValue);
420 static Q_CORE_EXPORT QString
421 concreteString(QCborValueConstRef that, const QString &defaultValue);
422
423 constexpr QCborValueConstRef() : d(nullptr), i(0) {} // this will actually be invalid
425 : d(dd), i(ii)
426 {}
429};
430
432QT6_ONLY(QT_WARNING_DISABLE_MSVC(4275)) // non dll-interface class 'QJsonValueConstRef' used as base for dll-interface class 'QJsonValueRef'
433class QT6_ONLY(Q_CORE_EXPORT) QCborValueRef : public QCborValueConstRef
434{
435public:
436 QCborValueRef(const QCborValueRef &) noexcept = default;
437 QCborValueRef(QCborValueRef &&) noexcept = default;
438 QCborValueRef &operator=(const QCborValue &other)
439 { assign(*this, other); return *this; }
440 QCborValueRef &operator=(QCborValue &&other)
441 { assign(*this, std::move(other)); other.container = nullptr; return *this; }
442 QCborValueRef &operator=(const QCborValueRef &other)
443 { assign(*this, other); return *this; }
444
445 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](qint64 key);
446 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](QLatin1StringView key);
447 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](const QString & key);
448
449#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
450 // retained for binary compatibility (due to the Q_CORE_EXPORT) because at
451 // least one compiler emits and exports all inlines in an exported class
452
453 operator QCborValue() const { return concrete(); }
454 QCborValue::Type type() const { return concreteType(); }
455 bool isInteger() const { return type() == QCborValue::Integer; }
456 bool isByteArray() const { return type() == QCborValue::ByteArray; }
457 bool isString() const { return type() == QCborValue::String; }
458 bool isArray() const { return type() == QCborValue::Array; }
459 bool isMap() const { return type() == QCborValue::Map; }
460 bool isTag() const { return QCborValue::isTag_helper(type()); }
461 bool isFalse() const { return type() == QCborValue::False; }
462 bool isTrue() const { return type() == QCborValue::True; }
463 bool isBool() const { return isFalse() || isTrue(); }
464 bool isNull() const { return type() == QCborValue::Null; }
465 bool isUndefined() const { return type() == QCborValue::Undefined; }
466 bool isDouble() const { return type() == QCborValue::Double; }
467 bool isDateTime() const { return type() == QCborValue::DateTime; }
468 bool isUrl() const { return type() == QCborValue::Url; }
469 bool isRegularExpression() const { return type() == QCborValue::RegularExpression; }
470 bool isUuid() const { return type() == QCborValue::Uuid; }
471 bool isInvalid() const { return type() == QCborValue::Invalid; }
472 bool isContainer() const { return isMap() || isArray(); }
473 bool isSimpleType() const
474 {
475 return type() >= QCborValue::SimpleType && type() < QCborValue::SimpleType + 0x100;
476 }
477 bool isSimpleType(QCborSimpleType st) const
478 {
479 return type() == QCborValue::type_helper(st);
480 }
481 QCborSimpleType toSimpleType(QCborSimpleType defaultValue = QCborSimpleType::Undefined) const
482 {
483 return isSimpleType() ? QCborSimpleType(type() & 0xff) : defaultValue;
484 }
485
486 QCborTag tag(QCborTag defaultValue = QCborTag(-1)) const
487 { return concrete().tag(defaultValue); }
488 QCborValue taggedValue(const QCborValue &defaultValue = QCborValue()) const
489 { return concrete().taggedValue(defaultValue); }
490
491 qint64 toInteger(qint64 defaultValue = 0) const
492 { return concreteIntegral(*this, defaultValue); }
493 bool toBool(bool defaultValue = false) const
494 { return concreteBoolean(*this, defaultValue); }
495 double toDouble(double defaultValue = 0) const
496 { return concreteDouble(*this, defaultValue); }
497
498 QByteArray toByteArray(const QByteArray &defaultValue = {}) const
499 { return concreteByteArray(*this, defaultValue); }
500 QString toString(const QString &defaultValue = {}) const
501 { return concreteString(*this, defaultValue); }
502 QDateTime toDateTime(const QDateTime &defaultValue = {}) const
503 { return concrete().toDateTime(defaultValue); }
504#ifndef QT_BOOTSTRAPPED
505 QUrl toUrl(const QUrl &defaultValue = {}) const
506 { return concrete().toUrl(defaultValue); }
507# if QT_CONFIG(regularexpression)
508 QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
509 { return concrete().toRegularExpression(defaultValue); }
510# endif
511 QUuid toUuid(const QUuid &defaultValue = {}) const
512 { return concrete().toUuid(defaultValue); }
513#endif
514
515 // only forward-declared, need split functions. Implemented in qcbor{array,map}.h
516 QCborArray toArray() const;
517 QCborArray toArray(const QCborArray &a) const;
518 QCborMap toMap() const;
519 QCborMap toMap(const QCborMap &m) const;
520
521 const QCborValue operator[](const QString &key) const;
522 const QCborValue operator[](QLatin1StringView key) const;
523 const QCborValue operator[](qint64 key) const;
524
525 int compare(const QCborValue &other) const
526 { return concrete().compare(other); }
527#if 0 && __has_include(<compare>)
528 std::strong_ordering operator<=>(const QCborValue &other) const
529 {
530 int c = compare(other);
531 if (c > 0) return std::strong_ordering::greater;
532 if (c == 0) return std::strong_ordering::equivalent;
533 return std::strong_ordering::less;
534 }
535#else
536 bool operator==(const QCborValue &other) const
537 { return compare(other) == 0; }
538 bool operator!=(const QCborValue &other) const
539 { return !(*this == other); }
540 bool operator<(const QCborValue &other) const
541 { return compare(other) < 0; }
542#endif
543
544 QVariant toVariant() const { return concrete().toVariant(); }
545 QJsonValue toJsonValue() const;
546
547#if QT_CONFIG(cborstreamwriter)
548 using QCborValueConstRef::toCbor;
549 QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation)
550 { return std::as_const(*this).toCbor(opt); }
551 void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation);
552#endif
553
555 QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact)
556 { return std::as_const(*this).toDiagnosticNotation(opt); }
557
558private:
559 static QCborValue concrete(QCborValueRef that) noexcept;
560 QCborValue concrete() const noexcept { return concrete(*this); }
561
562 static QCborValue::Type concreteType(QCborValueRef self) noexcept Q_DECL_PURE_FUNCTION;
563 QCborValue::Type concreteType() const noexcept { return concreteType(*this); }
564
565 // this will actually be invalid...
566 constexpr QCborValueRef() : QCborValueConstRef(nullptr, 0) {}
567
568 QCborValueRef(QCborContainerPrivate *dd, qsizetype ii)
569 : QCborValueConstRef(dd, ii)
570 {}
571#else
572private:
574#endif // < Qt 7
575
576 friend class QCborValue;
577 friend class QCborArray;
578 friend class QCborMap;
579 friend class QCborContainerPrivate;
580 friend class QCborValueConstRef;
581
582 // static so we can pass this by value
583 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValue &other);
584 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, QCborValue &&other);
585 QT7_ONLY(Q_CORE_EXPORT) static void assign(QCborValueRef that, const QCborValueRef other);
586};
588Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::EncodingOptions)
589Q_DECLARE_OPERATORS_FOR_FLAGS(QCborValue::DiagnosticNotationOptions)
590
591Q_CORE_EXPORT size_t qHash(const QCborValue &value, size_t seed = 0);
592
593#if !defined(QT_NO_DEBUG_STREAM)
594Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v);
595#endif
596
597#ifndef QT_NO_DATASTREAM
598#if QT_CONFIG(cborstreamwriter)
599Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborValue &);
600#endif
601Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborValue &);
602#endif
603
605
606#if defined(QT_X11_DEFINES_FOUND)
607# define True 1
608# define False 0
609#endif
610
611#endif // QCBORVALUE_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qcborarray.h:20
\inmodule QtCore\reentrant
Definition qcbormap.h:21
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
bool isBool() const
Definition qcborvalue.h:313
QVariant toVariant() const
Definition qcborvalue.h:389
bool isInteger() const
Definition qcborvalue.h:305
bool isDateTime() const
Definition qcborvalue.h:317
bool isDouble() const
Definition qcborvalue.h:316
bool isString() const
Definition qcborvalue.h:307
QCborValueConstRef & operator=(const QCborValueConstRef &)=delete
bool operator!=(const QCborValue &other) const
Definition qcborvalue.h:383
bool isUrl() const
Definition qcborvalue.h:318
bool isNull() const
Definition qcborvalue.h:314
bool isContainer() const
Definition qcborvalue.h:322
bool toBool(bool defaultValue=false) const
Definition qcborvalue.h:338
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
Definition qcborvalue.h:333
bool operator<(const QCborValue &other) const
Definition qcborvalue.h:385
bool isByteArray() const
Definition qcborvalue.h:306
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
Definition qcborvalue.h:326
QDateTime toDateTime(const QDateTime &defaultValue={}) const
Definition qcborvalue.h:347
bool isMap() const
Definition qcborvalue.h:309
bool isSimpleType() const
Definition qcborvalue.h:323
bool isRegularExpression() const
Definition qcborvalue.h:319
bool isUndefined() const
Definition qcborvalue.h:315
QCborValue::Type type() const
Definition qcborvalue.h:304
bool isInvalid() const
Definition qcborvalue.h:321
QCborValueConstRef(const QCborValueConstRef &)=default
bool isUuid() const
Definition qcborvalue.h:320
QCborTag tag(QCborTag defaultValue=QCborTag(-1)) const
Definition qcborvalue.h:331
constexpr QCborValueConstRef()
Definition qcborvalue.h:423
QByteArray toByteArray(const QByteArray &defaultValue={}) const
Definition qcborvalue.h:343
qint64 toInteger(qint64 defaultValue=0) const
Definition qcborvalue.h:336
bool isSimpleType(QCborSimpleType st) const
Definition qcborvalue.h:324
bool isTrue() const
Definition qcborvalue.h:312
QUuid toUuid(const QUuid &defaultValue={}) const
Definition qcborvalue.h:356
QCborContainerPrivate * d
Definition qcborvalue.h:427
bool isFalse() const
Definition qcborvalue.h:311
bool isTag() const
Definition qcborvalue.h:310
bool operator==(const QCborValue &other) const
Definition qcborvalue.h:381
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt=QCborValue::Compact) const
Definition qcborvalue.h:399
bool isArray() const
Definition qcborvalue.h:308
int compare(const QCborValue &other) const
Definition qcborvalue.h:370
constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
Definition qcborvalue.h:424
QCborValue concrete() const noexcept
Definition qcborvalue.h:408
QString toString(const QString &defaultValue={}) const
Definition qcborvalue.h:345
QUrl toUrl(const QUrl &defaultValue={}) const
Definition qcborvalue.h:350
QJsonValue toJsonValue() const
double toDouble(double defaultValue=0) const
Definition qcborvalue.h:340
\inmodule QtCore\reentrant
Definition qcborvalue.h:50
bool isUndefined() const
Returns true if this QCborValue is of the undefined type.
Definition qcborvalue.h:168
bool isSimpleType() const
Returns true if this QCborValue is of one of the CBOR simple types.
Definition qcborvalue.h:177
bool isDateTime() const
Returns true if this QCborValue is of the date/time type.
Definition qcborvalue.h:170
bool isString() const
Returns true if this QCborValue is of the string type.
Definition qcborvalue.h:160
bool operator==(const QCborValue &other) const noexcept
Compares this value and other, and returns true if they hold the same contents, false otherwise.
Definition qcborvalue.h:234
EncodingOption
This enum is used in the options argument to toCbor(), modifying the behavior of the encoder.
Definition qcborvalue.h:53
@ NoTransformation
Definition qcborvalue.h:61
bool isNull() const
Returns true if this QCborValue is of the null type.
Definition qcborvalue.h:167
bool operator!=(const QCborValue &other) const noexcept
Compares this value and other, and returns true if contents differ, false otherwise.
Definition qcborvalue.h:236
QCborValue(QCborSimpleType st)
Creates a QCborValue of simple type st.
Definition qcborvalue.h:110
QCborValue(QCborKnownTags t_, const QCborValue &tv=QCborValue())
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcborvalue.h:124
QCborValue(double v)
Creates a QCborValue with floating point value d.
Definition qcborvalue.h:109
QCborValue(QCborValue &&other) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcborvalue.h:143
QCborValue(Type t_)
Creates a QCborValue of type t_.
Definition qcborvalue.h:101
bool isUrl() const
Returns true if this QCborValue is of the URL type.
Definition qcborvalue.h:171
bool isByteArray() const
Returns true if this QCborValue is of the byte array type.
Definition qcborvalue.h:159
qint64 toInteger(qint64 defaultValue=0) const
Returns the integer value stored in this QCborValue, if it is of the integer type.
Definition qcborvalue.h:190
Type
This enum represents the QCborValue type.
Definition qcborvalue.h:73
@ RegularExpression
Definition qcborvalue.h:93
bool operator<(const QCborValue &other) const
Compares this value and other, and returns true if this value should be sorted before other,...
Definition qcborvalue.h:238
~QCborValue()
Disposes of the current QCborValue object and frees any associated resources.
Definition qcborvalue.h:137
bool isBool() const
Returns true if this QCborValue is a boolean.
Definition qcborvalue.h:166
bool isRegularExpression() const
Returns true if this QCborValue contains a regular expression's pattern.
Definition qcborvalue.h:172
bool isDouble() const
Returns true if this QCborValue is of the floating-point type.
Definition qcborvalue.h:169
bool isContainer() const
This convenience function returns true if the QCborValue is either an array or a map.
Definition qcborvalue.h:175
QCborValue(int i)
Definition qcborvalue.h:105
bool isInvalid() const
Returns true if this QCborValue is not of any valid type.
Definition qcborvalue.h:174
QCborValue(bool b_)
Creates a QCborValue with boolean value b.
Definition qcborvalue.h:103
bool isInteger() const
Returns true if this QCborValue is of the integer type.
Definition qcborvalue.h:158
Type type() const
Returns the type of this QCborValue.
Definition qcborvalue.h:157
double toDouble(double defaultValue=0) const
Returns the floating point value stored in this QCborValue, if it is of the Double type.
Definition qcborvalue.h:194
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
Returns the simple type this QCborValue is of, if it is a simple type.
Definition qcborvalue.h:185
bool isTag() const
Returns true if this QCborValue is of the tag type.
Definition qcborvalue.h:163
bool isArray() const
Returns true if this QCborValue is of the array type.
Definition qcborvalue.h:161
QCborValue(qint64 i)
Creates a QCborValue with integer value i.
Definition qcborvalue.h:108
bool isUuid() const
Returns true if this QCborValue contains a UUID.
Definition qcborvalue.h:173
QCborValue(std::nullptr_t)
Creates a QCborValue of the \l {Type}{Null} type.
Definition qcborvalue.h:102
QCborValue(const void *)=delete
bool isTrue() const
Returns true if this QCborValue is a boolean with true value.
Definition qcborvalue.h:165
bool isFalse() const
Returns true if this QCborValue is a boolean with false value.
Definition qcborvalue.h:164
bool isSimpleType(QCborSimpleType st) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcborvalue.h:181
QT_ASCII_CAST_WARN QCborValue(const char *s)
Definition qcborvalue.h:117
bool isMap() const
Returns true if this QCborValue is of the map type.
Definition qcborvalue.h:162
DiagnosticNotationOption
This enum is used in the option argument to toDiagnosticNotation(), to modify the output format.
Definition qcborvalue.h:65
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
Returns the tagged value of this extended QCborValue object, if it is of the tag type,...
QCborValue(unsigned u)
Definition qcborvalue.h:106
bool toBool(bool defaultValue=false) const
Returns the boolean value stored in this QCborValue, if it is of a boolean type.
Definition qcborvalue.h:192
\inmodule QtCore\reentrant
Definition qdatastream.h:30
\inmodule QtCore\reentrant
Definition qdatetime.h:257
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qjsonvalue.h:24
\inmodule QtCore \reentrant
QSharedData & operator=(const QSharedData &)=delete
\inmodule QtCore
Definition qstringview.h:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition quuid.h:31
\inmodule QtCore
Definition qvariant.h:64
QStyleOptionButton opt
Combined button and popup list for selecting options.
bool isNull(const T &t)
void toByteArray(QByteArray &)
Definition qctf_p.h:78
QCborKnownTags
Definition qcborcommon.h:31
QCborTag
Definition qcborcommon.h:30
QCborSimpleType
Definition qcborcommon.h:23
QT_WARNING_PUSH class QT6_ONLY(Q_CORE_EXPORT) QCborValueRef QT_WARNING_POP Q_CORE_EXPORT size_t qHash(const QCborValue &value, size_t seed=0)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborValue &v)
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &, QCborValue &)
#define Q_DECL_PURE_FUNCTION
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_MSVC(number)
#define QT_WARNING_PUSH
constexpr bool operator!=(const timespec &t1, const timespec &t2)
AudioChannelLayoutTag tag
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
@ Invalid
GLsizei const GLfloat * v
[13]
const GLfloat * m
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum type
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLfloat n
const GLubyte * c
GLenum GLsizei len
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble s
[6]
Definition qopenglext.h:235
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
QT_BEGIN_NAMESPACE class QT6_ONLY(Q_CORE_EXPORT) QReadWriteLock
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:43
#define QT_ASCII_CAST_WARN
#define Q_ENUM(x)
#define Q_GADGET
Tag
static int compare(quint64 a, quint64 b)
ptrdiff_t qsizetype
Definition qtypes.h:70
long long qint64
Definition qtypes.h:55
unsigned char quint8
Definition qtypes.h:41
QList< QPair< QString, QString > > Map
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols, V4ObjectSet *visitedObjects)
static double toDouble(Value v)
QByteArray ba
[0]
QUrl url("example.com")
[constructor-url-reference]
QObject::connect nullptr
QVariant variant
[1]
value toMap().value(key)
[3]
value isSimpleType(QCborSimpleType(12))
[1]
p rx()++
QSharedPointer< T > other(t)
[5]
char * toString(const MyType &t)
[31]
\inmodule QtCore \inheaderfile QtCborCommon \reentrant
Definition qcborcommon.h:63
QString toString() const
Returns a text string that matches the error code in this QCborError object.
\inmodule QtCore\reentrant
Definition qcborvalue.h:40
QString errorString() const
\variable QCborParserError::offset
Definition qcborvalue.h:44
QCborError error
Definition qcborvalue.h:42
Definition moc.h:24
QT_BEGIN_NAMESPACE bool toBool(const QString &str)
Definition utils.h:14