7#include <QtCore/qbytearray.h>
8#include <QtCore/qcborcommon.h>
9#include <QtCore/qcompare.h>
10#include <QtCore/qdatetime.h>
11#if QT_CONFIG(regularexpression)
12# include <QtCore/qregularexpression.h>
14#include <QtCore/qstring.h>
15#include <QtCore/qstringview.h>
16#include <QtCore/qurl.h>
17#include <QtCore/quuid.h>
18#include <QtCore/qvariant.h>
21#if defined(False) && defined(True)
51 SortKeysInMaps = 0x01,
53#ifndef QT_BOOTSTRAPPED
54 UseFloat16 = UseFloat | 0x04,
113#ifndef QT_NO_CAST_FROM_ASCII
126#ifndef QT_BOOTSTRAPPED
128# if QT_CONFIG(regularexpression)
145 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(
QCborValue)
163 bool isBool()
const {
return isFalse() || isTrue(); }
176 return int(
type()) >> 8 == int(SimpleType) >> 8;
180 return type() == type_helper(st);
188 {
return isInteger() ? value_helper() : isDouble() ?
qint64(fp_helper()) : defaultValue; }
189 bool toBool(
bool defaultValue =
false)
const
190 {
return isBool() ? isTrue() : defaultValue; }
192 {
return isDouble() ? fp_helper() : isInteger() ? double(value_helper()) : defaultValue; }
200#ifndef QT_BOOTSTRAPPED
201 QUrl toUrl(
const QUrl &defaultValue = {})
const;
202# if QT_CONFIG(regularexpression)
205 QUuid toUuid(
const QUuid &defaultValue = {})
const;
219 QCborValueRef operator[](
const QString &
key);
222#if QT_CORE_REMOVED_SINCE(6, 8)
236#if QT_CONFIG(cborstreamreader)
244#if QT_CONFIG(cborstreamwriter)
245 QByteArray toCbor(EncodingOptions
opt = NoTransformation)
const;
249 QString toDiagnosticNotation(DiagnosticNotationOptions opts = Compact)
const;
257 int c = lhs.compare(rhs);
265 friend class QCborValueRef;
274 qint64 value_helper()
const
279 double fp_helper()
const
281 static_assert(
sizeof(double) ==
sizeof(
n));
283 memcpy(&
d, &
n,
sizeof(
d));
292 constexpr static bool isTag_helper(
Type tt)
294 return tt ==
Tag || tt >= 0x10000;
312 bool isTag()
const {
return concrete().isTag(); }
315 bool isBool()
const {
return isFalse() || isTrue(); }
330 return concrete().toSimpleType(defaultValue);
334 {
return concrete().tag(defaultValue); }
339 {
return concrete().toInteger(defaultValue); }
340 bool toBool(
bool defaultValue =
false)
const
341 {
return concrete().toBool(defaultValue); }
343 {
return concrete().toDouble(defaultValue); }
346 {
return concrete().toByteArray(defaultValue); }
348 {
return concrete().toString(defaultValue); }
350 {
return concrete().toDateTime(defaultValue); }
351#ifndef QT_BOOTSTRAPPED
353 {
return concrete().toUrl(defaultValue); }
354# if QT_CONFIG(regularexpression)
356 {
return concrete().toRegularExpression(defaultValue); }
359 {
return concrete().toUuid(defaultValue); }
373 {
return concrete().compare(
other); }
378#if QT_CONFIG(cborstreamwriter)
380 {
return concrete().toCbor(
opt); }
382 {
return concrete().toCbor(writer,
opt); }
386 {
return concrete().toDiagnosticNotation(
opt); }
402 return comparesEqual_helper(lhs, rhs);
407 return compareThreeWay_helper(lhs, rhs);
418 return comparesEqual_helper(lhs, rhs);
423 return compareThreeWay_helper(lhs, rhs);
429 static Q_CORE_EXPORT
bool
431 static Q_CORE_EXPORT
double
433 static Q_CORE_EXPORT
qint64
453 QCborValueRef(
const QCborValueRef &)
noexcept =
default;
454 QCborValueRef(QCborValueRef &&)
noexcept =
default;
456 { assign(*
this,
other);
return *
this; }
458 { assign(*
this, std::move(
other));
other.container =
nullptr;
return *
this; }
460 { assign(*
this,
other);
return *
this; }
462 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](
qint64 key);
464 QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](
const QString &
key);
466#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
470 operator QCborValue()
const {
return concrete(); }
477 bool isTag()
const {
return QCborValue::isTag_helper(
type()); }
480 bool isBool()
const {
return isFalse() || isTrue(); }
489 bool isContainer()
const {
return isMap() || isArray(); }
496 return type() == QCborValue::type_helper(st);
504 {
return concrete().tag(defaultValue); }
509 {
return concreteIntegral(*
this, defaultValue); }
510 bool toBool(
bool defaultValue =
false)
const
511 {
return concreteBoolean(*
this, defaultValue); }
512 double toDouble(
double defaultValue = 0)
const
513 {
return concreteDouble(*
this, defaultValue); }
516 {
return concreteByteArray(*
this, defaultValue); }
518 {
return concreteString(*
this, defaultValue); }
520 {
return concrete().toDateTime(defaultValue); }
521#ifndef QT_BOOTSTRAPPED
522 QUrl toUrl(
const QUrl &defaultValue = {})
const
523 {
return concrete().toUrl(defaultValue); }
524# if QT_CONFIG(regularexpression)
526 {
return concrete().toRegularExpression(defaultValue); }
528 QUuid toUuid(
const QUuid &defaultValue = {})
const
529 {
return concrete().toUuid(defaultValue); }
543 {
return concrete().compare(
other); }
544#if QT_CORE_REMOVED_SINCE(6, 8)
556#if QT_CONFIG(cborstreamwriter)
557 using QCborValueConstRef::toCbor;
559 {
return std::as_const(*this).toCbor(
opt); }
565 {
return std::as_const(*this).toDiagnosticNotation(
opt); }
568 static QCborValue concrete(QCborValueRef that)
noexcept;
569 QCborValue concrete() const noexcept {
return concrete(*
this); }
572 QCborValue::Type concreteType() const noexcept {
return concreteType(*
this); }
592 QT7_ONLY(Q_CORE_EXPORT)
static void assign(QCborValueRef that,
const QCborValue &
other);
593 QT7_ONLY(Q_CORE_EXPORT)
static void assign(QCborValueRef that,
QCborValue &&
other);
594 QT7_ONLY(Q_CORE_EXPORT)
static void assign(QCborValueRef that,
const QCborValueRef
other);
602#if !defined(QT_NO_DEBUG_STREAM)
606#ifndef QT_NO_DATASTREAM
607#if QT_CONFIG(cborstreamwriter)
615#if defined(QT_X11_DEFINES_FOUND)
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QVariant toVariant() const
QCborValueConstRef & operator=(const QCborValueConstRef &)=delete
bool toBool(bool defaultValue=false) const
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
QDateTime toDateTime(const QDateTime &defaultValue={}) const
bool isSimpleType() const
bool isRegularExpression() const
QCborValue::Type type() const
QCborValueConstRef(const QCborValueConstRef &)=default
QCborTag tag(QCborTag defaultValue=QCborTag(-1)) const
constexpr QCborValueConstRef()
QByteArray toByteArray(const QByteArray &defaultValue={}) const
qint64 toInteger(qint64 defaultValue=0) const
bool isSimpleType(QCborSimpleType st) const
QUuid toUuid(const QUuid &defaultValue={}) const
QCborContainerPrivate * d
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
friend bool comparesEqual(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt=QCborValue::Compact) const
int compare(const QCborValue &other) const
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValue &rhs) noexcept
friend Qt::strong_ordering compareThreeWay(const QCborValueConstRef &lhs, const QCborValueConstRef &rhs) noexcept
constexpr QCborValueConstRef(QCborContainerPrivate *dd, qsizetype ii)
QCborValue concrete() const noexcept
QString toString(const QString &defaultValue={}) const
QUrl toUrl(const QUrl &defaultValue={}) const
QJsonValue toJsonValue() const
double toDouble(double defaultValue=0) const
\inmodule QtCore\reentrant
bool isUndefined() const
Returns true if this QCborValue is of the undefined type.
friend Qt::strong_ordering compareThreeWay(const QCborValue &lhs, const QCborValue &rhs) noexcept
bool isSimpleType() const
Returns true if this QCborValue is of one of the CBOR simple types.
bool isDateTime() const
Returns true if this QCborValue is of the date/time type.
bool isString() const
Returns true if this QCborValue is of the string type.
EncodingOption
This enum is used in the options argument to toCbor(), modifying the behavior of the encoder.
bool isNull() const
Returns true if this QCborValue is of the null type.
QCborValue(QCborSimpleType st)
Creates a QCborValue of simple type st.
QCborValue(QCborKnownTags t_, const QCborValue &tv=QCborValue())
This is an overloaded member function, provided for convenience. It differs from the above function o...
QCborValue(double v)
Creates a QCborValue with floating point value d.
QCborValue(QCborValue &&other) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
QCborValue(Type t_)
Creates a QCborValue of type t_.
bool isUrl() const
Returns true if this QCborValue is of the URL type.
bool isByteArray() const
Returns true if this QCborValue is of the byte array type.
qint64 toInteger(qint64 defaultValue=0) const
Returns the integer value stored in this QCborValue, if it is of the integer type.
Type
This enum represents the QCborValue type.
~QCborValue()
Disposes of the current QCborValue object and frees any associated resources.
bool isBool() const
Returns true if this QCborValue is a boolean.
bool isRegularExpression() const
Returns true if this QCborValue contains a regular expression's pattern.
bool isDouble() const
Returns true if this QCborValue is of the floating-point type.
bool isContainer() const
This convenience function returns true if the QCborValue is either an array or a map.
bool isInvalid() const
Returns true if this QCborValue is not of any valid type.
QCborValue(bool b_)
Creates a QCborValue with boolean value b.
bool isInteger() const
Returns true if this QCborValue is of the integer type.
Type type() const
Returns the type of this QCborValue.
double toDouble(double defaultValue=0) const
Returns the floating point value stored in this QCborValue, if it is of the Double type.
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) const
Returns the simple type this QCborValue is of, if it is a simple type.
bool isTag() const
Returns true if this QCborValue is of the tag type.
bool isArray() const
Returns true if this QCborValue is of the array type.
QCborValue(qint64 i)
Creates a QCborValue with integer value i.
bool isUuid() const
Returns true if this QCborValue contains a UUID.
QCborValue(std::nullptr_t)
Creates a QCborValue of the \l {Type}{Null} type.
QCborValue(const void *)=delete
bool isTrue() const
Returns true if this QCborValue is a boolean with true value.
bool isFalse() const
Returns true if this QCborValue is a boolean with false value.
bool isSimpleType(QCborSimpleType st) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QT_ASCII_CAST_WARN QCborValue(const char *s)
bool isMap() const
Returns true if this QCborValue is of the map type.
DiagnosticNotationOption
This enum is used in the option argument to toDiagnosticNotation(), to modify the output format.
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
Returns the tagged value of this extended QCborValue object, if it is of the tag type,...
bool toBool(bool defaultValue=false) const
Returns the boolean value stored in this QCborValue, if it is of a boolean type.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore \reentrant
QSharedData & operator=(const QSharedData &)=delete
\macro QT_RESTRICTED_CAST_FROM_ASCII
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
Combined button and popup list for selecting options.
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
void toByteArray(QByteArray &)
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 &)
class QT6_ONLY(Q_CORE_EXPORT) QChar
#define Q_DECLARE_STRONGLY_ORDERED(...)
#define Q_DECL_PURE_FUNCTION
#define QT_WARNING_DISABLE_MSVC(number)
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
bool comparesEqual(const QDir &lhs, const QDir &rhs)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
#define QT_ASCII_CAST_WARN
static int compare(quint64 a, quint64 b)
QList< std::pair< QString, QString > > Map
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, JSToQVariantConversionBehavior conversionBehavior, V4ObjectSet *visitedObjects)
static double toDouble(Value v)
QUrl url("example.com")
[constructor-url-reference]
QCborValue(QCborTag(2), QByteArray("\x01\0\0\0\0\0\0\0\0", 9))
[0]
value toMap().value(key)
[3]
value isSimpleType(QCborSimpleType(12))
[1]
char * toString(const MyType &t)
[31]
\inmodule QtCore \inheaderfile QtCborCommon \reentrant
QString toString() const
Returns a text string that matches the error code in this QCborError object.
\inmodule QtCore\reentrant
QString errorString() const
\variable QCborParserError::offset
QT_BEGIN_NAMESPACE bool toBool(const QString &str)