18#include <private/qnumeric_p.h>
35 if (
unsigned(simpleType) < 0x100)
39 qWarning(
"QCborValue: found unknown type 0x%x",
t);
67 const Element &e =
d->elements.at(1);
84#ifndef QT_BOOTSTRAPPED
86 &&
b->len ==
sizeof(
QUuid))
99 if (!
d ||
d->elements.size() != 2)
113 const auto &e =
d->elements.at(idx);
128 return d->stringAt(idx);
132#if defined(QT_JSON_READONLY) || defined(QT_BOOTSTRAPPED)
133 qFatal(
"Writing JSON is disabled.");
162 return encodeTag(e.flags & Element::IsContainer ? e.container :
nullptr);
178#ifdef QT_BOOTSTRAPPED
209 for (
qsizetype idx = 0; idx <
d->elements.size(); ++idx)
222 for (
qsizetype idx = 0; idx <
d->elements.size(); idx += 2)
237 if (!
d ||
d->elements.size() != 2)
243 const auto &e =
d->elements.at(idx);
269 return qt_convertToJson(e.flags & Element::IsContainer ? e.container :
nullptr, -e.type,
401#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
541 return toByteArray();
547 return toArray().toVariantList();
550 return toMap().toVariantMap();
554 return taggedValue().toVariant();
559#ifndef QT_BOOTSTRAPPED
563# if QT_CONFIG(regularexpression)
565 return toRegularExpression();
620 if (
v.value.t == Integer)
621 return v.toInteger();
644 if (
type == QMetaType::QString) {
646 }
else if (
type == QMetaType::QByteArray) {
712 case QMetaType::Nullptr:
714 case QMetaType::Bool:
716 case QMetaType::Short:
717 case QMetaType::UShort:
719 case QMetaType::LongLong:
720 case QMetaType::UInt:
722 case QMetaType::ULongLong:
723 if (
variant.
toULongLong() <=
static_cast<uint64_t
>(std::numeric_limits<qint64>::max()))
726 case QMetaType::Float:
727 case QMetaType::Double:
729 case QMetaType::QString:
731 case QMetaType::QStringList:
733 case QMetaType::QByteArray:
735 case QMetaType::QDateTime:
737#ifndef QT_BOOTSTRAPPED
738 case QMetaType::QUrl:
740 case QMetaType::QUuid:
743 case QMetaType::QVariantList:
745 case QMetaType::QVariantMap:
747 case QMetaType::QVariantHash:
749#ifndef QT_BOOTSTRAPPED
750#if QT_CONFIG(regularexpression)
751 case QMetaType::QRegularExpression:
754 case QMetaType::QJsonValue:
756 case QMetaType::QJsonObject:
758 case QMetaType::QJsonArray:
760 case QMetaType::QJsonDocument: {
766 case QMetaType::QCborValue:
767 return qvariant_cast<QCborValue>(
variant);
768 case QMetaType::QCborArray:
769 return qvariant_cast<QCborArray>(
variant);
770 case QMetaType::QCborMap:
771 return qvariant_cast<QCborMap>(
variant);
772 case QMetaType::QCborSimpleType:
773 return qvariant_cast<QCborSimpleType>(
variant);
804 retval.append(
d->valueAt(
i).toVariant());
917 retval.insert(
makeString(
d.data(),
i),
d->valueAt(
i + 1).toVariant());
957 m.detach(
hash.size());
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray & append(char c)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
\inmodule QtCore\reentrant
QVariantList toVariantList() const
Recursively converts each \l QCborValue in this array using QCborValue::toVariant() and returns the Q...
static QCborArray fromJsonArray(const QJsonArray &array)
Converts all JSON items found in the array array to CBOR using QCborValue::fromJson(),...
QJsonArray toJsonArray() const
Recursively converts every \l QCborValue element in this array to JSON using QCborValue::toJsonValue(...
static QCborArray fromStringList(const QStringList &list)
Returns a QCborArray containing all the strings found in the list list.
static QCborArray fromVariantList(const QVariantList &list)
Converts all the items in the list to CBOR using QCborValue::fromVariant() and returns the array comp...
\inmodule QtCore\reentrant
QVariantMap toVariantMap() const
Converts the CBOR values to QVariant using QCborValue::toVariant() and "stringifies" all the CBOR key...
QVariantHash toVariantHash() const
Converts the CBOR values to QVariant using QCborValue::toVariant() and "stringifies" all the CBOR key...
QJsonObject toJsonObject() const
Recursively converts every \l QCborValue value in this map to JSON using QCborValue::toJsonValue() an...
static QCborMap fromJsonObject(const QJsonObject &o)
Converts all JSON items found in the obj object to CBOR using QCborValue::fromJson(),...
static QCborMap fromVariantMap(const QVariantMap &map)
Converts all the items in map to CBOR using QCborValue::fromVariant() and returns the map composed of...
static QCborMap fromVariantHash(const QVariantHash &hash)
Converts all the items in hash to CBOR using QCborValue::fromVariant() and returns the map composed o...
\inmodule QtCore\reentrant
static QCborValue fromVariant(const QVariant &variant)
Converts the QVariant variant into QCborValue and returns it.
QVariant toVariant() const
Converts this value to a native Qt type and returns the corresponding QVariant.
QJsonValue toJsonValue() const
Converts this QCborValue object to an equivalent representation in JSON and returns it as a QJsonValu...
Type
This enum represents the QCborValue type.
Type type() const
Returns the type of this QCborValue.
static QCborValue fromJsonValue(const QJsonValue &v)
Converts the JSON value contained in v into its corresponding CBOR value and returns it.
T * data() const noexcept
Returns a pointer to the shared data object.
void reserve(qsizetype size)
Ensures that the QHash's internal hash table has space to store at least size items without having to...
\inmodule QtCore\reentrant
void append(const QJsonValue &value)
Inserts value at the end of the array.
\inmodule QtCore\reentrant
bool isArray() const
Returns true if the document contains an array.
QJsonArray array() const
Returns the QJsonArray contained in the document.
QJsonObject object() const
Returns the QJsonObject contained in the document.
\inmodule QtCore\reentrant
static QJsonValue fromTrustedCbor(const QCborValue &v)
static QJsonObject toJsonObject(const QVariantMap &map)
static QJsonArray toJsonArray(const QVariantList &list)
\inmodule QtCore\reentrant
qsizetype size() const noexcept
void reserve(qsizetype size)
iterator insert(const Key &key, const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QUrl fromEncoded(QByteArrayView input, ParsingMode mode=TolerantMode)
Parses input and returns the corresponding QUrl.
static QUuid fromRfc4122(QByteArrayView) noexcept
Creates a QUuid object from the binary representation of the UUID, as specified by RFC 4122 section 4...
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has userType() \l QMetaType::QDateTime,...
QJsonValue toJsonValue() const
double toDouble(bool *ok=nullptr) const
Returns the variant as a double if the variant has userType() \l QMetaType::Double,...
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has userType() \l QMetaType::QVariantList.
QMap< QString, QVariant > toMap() const
Returns the variant as a QVariantMap if the variant has type() \l QMetaType::QVariantMap.
qlonglong toLongLong(bool *ok=nullptr) const
Returns the variant as a long long int if the variant has userType() \l QMetaType::LongLong,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
QJsonArray toJsonArray() const
QHash< QString, QVariant > toHash() const
Returns the variant as a QHash<QString, QVariant> if the variant has type() \l QMetaType::QVariantHas...
bool isNull() const
Returns true if this is a null variant, false otherwise.
QJsonDocument toJsonDocument() const
QJsonObject toJsonObject() const
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has userType() \l QMetaType::QByteArray or \l QMet...
QMetaType metaType() const
qulonglong toULongLong(bool *ok=nullptr) const
Returns the variant as an unsigned long long int if the variant has type() \l QMetaType::ULongLong,...
QStringList toStringList() const
Returns the variant as a QStringList if the variant has userType() \l QMetaType::QStringList,...
QUrl toUrl() const
Returns the variant as a QUrl if the variant has userType() \l QMetaType::QUrl; otherwise returns an ...
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
Combined button and popup list for selecting options.
AudioChannelLayoutTag tag
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static QString simpleTypeString(QCborValue::Type t)
static QString makeString(const QCborContainerPrivate *d, qsizetype idx, ConversionMode mode=ConversionMode::FromRaw)
static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
QJsonValue qt_convertToJson(QCborContainerPrivate *d, qsizetype idx, ConversionMode mode=ConversionMode::FromRaw)
static QString encodeByteArray(const QCborContainerPrivate *d, qsizetype idx, QCborTag encoding)
static QJsonArray convertToJsonArray(QCborContainerPrivate *d, ConversionMode mode=ConversionMode::FromRaw)
static QJsonValue convertExtendedTypeToJson(QCborContainerPrivate *d)
static QJsonObject convertToJsonObject(QCborContainerPrivate *d, ConversionMode mode=ConversionMode::FromRaw)
static QJsonValue fpToJson(double v)
static QString encodeTag(const QCborContainerPrivate *d)
static QString maybeEncodeTag(const QCborContainerPrivate *d)
static Q_DECL_CONST_FUNCTION bool qt_is_finite(double d)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLchar *const * string
[0]
#define QStringLiteral(str)
QList< std::pair< QString, QString > > Map
static double toDouble(Value v)
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]