8#include <QtCore/qcborvalue.h>
9#include <QtCore/qcompare.h>
10#include <QtCore/qglobal.h>
11#if (QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)) && !defined(QT_BOOTSTRAPPED)
12#include <QtCore/qjsondocument.h>
14#include <QtCore/qjsonparseerror.h>
15#include <QtCore/qstring.h>
16#include <QtCore/qshareddata.h>
42#if (QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)) && !defined(QT_BOOTSTRAPPED)
43 using JsonFormat = QJsonDocument::JsonFormat;
45 enum class JsonFormat {
51 QJsonValue(Type = Null);
56 QJsonValue(
const QString &s);
57 QJsonValue(QLatin1StringView s);
58#ifndef QT_NO_CAST_FROM_ASCII
59 QT_ASCII_CAST_WARN
inline QJsonValue(
const char *s)
60 : QJsonValue(QString::fromUtf8(s)) {}
62 QJsonValue(
const QJsonArray &a);
63 QJsonValue(QJsonArray &&a)
noexcept;
64 QJsonValue(
const QJsonObject &o);
65 QJsonValue(QJsonObject &&o)
noexcept;
69 QJsonValue(
const QJsonValue &other)
noexcept;
70 QJsonValue &operator =(
const QJsonValue &other)
noexcept;
72 QJsonValue(QJsonValue &&other)
noexcept;
74 QJsonValue &operator =(QJsonValue &&other)
noexcept
80 void swap(QJsonValue &other)
noexcept;
82 static QJsonValue fromVariant(
const QVariant &variant);
83 QVariant toVariant()
const;
85 static QJsonValue fromJson(QByteArrayView json, QJsonParseError *error =
nullptr);
87 QByteArray toJson(JsonFormat format = JsonFormat::Indented)
const;
90 inline bool isNull()
const {
return type() == Null; }
91 inline bool isBool()
const {
return type() == Bool; }
92 inline bool isDouble()
const {
return type() == Double; }
93 inline bool isString()
const {
return type() == String; }
94 inline bool isArray()
const {
return type() == Array; }
95 inline bool isObject()
const {
return type() == Object; }
96 inline bool isUndefined()
const {
return type() == Undefined; }
98 bool toBool(
bool defaultValue =
false)
const;
99 int toInt(
int defaultValue = 0)
const;
100 qint64 toInteger(qint64 defaultValue = 0)
const;
101 double toDouble(
double defaultValue = 0)
const;
102 QString toString()
const;
103 QString toString(
const QString &defaultValue)
const;
104 QAnyStringView toStringView(QAnyStringView defaultValue = {})
const;
105 QJsonArray toArray()
const;
106 QJsonArray toArray(
const QJsonArray &defaultValue)
const;
107 QJsonObject toObject()
const;
108 QJsonObject toObject(
const QJsonObject &defaultValue)
const;
110 const QJsonValue operator[](
const QString &key)
const;
111 const QJsonValue operator[](QStringView key)
const;
112 const QJsonValue operator[](QLatin1StringView key)
const;
113 const QJsonValue operator[](qsizetype i)
const;
115#if QT_CORE_REMOVED_SINCE(6
, 8
)
116 bool operator==(
const QJsonValue &other)
const;
117 bool operator!=(
const QJsonValue &other)
const;
121 friend Q_CORE_EXPORT
bool comparesEqual(
const QJsonValue &lhs,
122 const QJsonValue &rhs);
123 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonValue)
126 QJsonValue(
const void *) =
delete;
127 friend class QJsonPrivate::Value;
128 friend class QJsonArray;
129 friend class QJsonObject;
130 friend class QCborValue;
131 friend Q_CORE_EXPORT QDebug operator<<(QDebug,
const QJsonValue &);
132 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &,
const QJsonValue &);
137 static_assert(
sizeof(QExplicitlySharedDataPointer<QCborContainerPrivate>) ==
sizeof(
void *));
138 static_assert(
sizeof(QCborValue::Type) ==
sizeof(QJsonValue::Type));
148 inline operator QJsonValue()
const {
return concrete(*
this); }
150 Q_CORE_EXPORT QVariant
toVariant()
const;
152 bool isNull()
const {
return type() == QJsonValue::Null; }
153 bool isBool()
const {
return type() == QJsonValue::Bool; }
154 bool isDouble()
const {
return type() == QJsonValue::Double; }
155 bool isString()
const {
return type() == QJsonValue::String; }
156 bool isArray()
const {
return type() == QJsonValue::Array; }
157 bool isObject()
const {
return type() == QJsonValue::Object; }
158 bool isUndefined()
const {
return type() == QJsonValue::Undefined; }
160 bool toBool(
bool defaultValue =
false)
const
161 {
return concreteBool(*
this, defaultValue); }
162 int toInt(
int defaultValue = 0)
const
163 {
return int(concreteInt(*
this, defaultValue,
true)); }
165 {
return concreteInt(*
this, defaultValue,
false); }
167 {
return concreteDouble(*
this, defaultValue); }
168 QString
toString(
const QString &defaultValue = {})
const
169 {
return concreteString(*
this, defaultValue); }
171 {
return concreteStringView(*
this, defaultValue); }
172 Q_CORE_EXPORT QJsonArray
toArray()
const;
173 Q_CORE_EXPORT QJsonObject
toObject()
const;
175 const QJsonValue
operator[](QStringView key)
const {
return concrete(*
this)[key]; }
176 const QJsonValue
operator[](QLatin1StringView key)
const {
return concrete(*
this)[key]; }
177 const QJsonValue
operator[](qsizetype i)
const {
return concrete(*
this)[i]; }
183 return comparesEqual(concrete(lhs), concrete(rhs));
186 const QJsonValue &rhs)
188 return comparesEqual(concrete(lhs), rhs);
195 Q_CORE_EXPORT
static bool
197 Q_CORE_EXPORT
static qint64
199 Q_CORE_EXPORT
static double
212#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
255 friend class QJsonArray;
256 friend class QJsonObject;
261QT6_ONLY(QT_WARNING_DISABLE_MSVC(4275))
262class QT6_ONLY(Q_CORE_EXPORT) QJsonValueRef :
public QJsonValueConstRef
265 QJsonValueRef(
const QJsonValueRef &) =
default;
266 QT7_ONLY(Q_CORE_EXPORT) QJsonValueRef &operator = (
const QJsonValue &val);
267 QT7_ONLY(Q_CORE_EXPORT) QJsonValueRef &operator = (
const QJsonValueRef &val);
269#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
273 QJsonValueRef(QJsonArray *array, qsizetype idx)
274 : QJsonValueConstRef(array, idx) {}
275 QJsonValueRef(QJsonObject *object, qsizetype idx)
276 : QJsonValueConstRef(object, idx) {}
278 operator QJsonValue()
const {
return toValue(); }
280 QVariant toVariant()
const;
281 inline QJsonValue::Type type()
const {
return QJsonValueConstRef::type(); }
282 inline bool isNull()
const {
return type() == QJsonValue::Null; }
283 inline bool isBool()
const {
return type() == QJsonValue::Bool; }
284 inline bool isDouble()
const {
return type() == QJsonValue::Double; }
285 inline bool isString()
const {
return type() == QJsonValue::String; }
286 inline bool isArray()
const {
return type() == QJsonValue::Array; }
287 inline bool isObject()
const {
return type() == QJsonValue::Object; }
288 inline bool isUndefined()
const {
return type() == QJsonValue::Undefined; }
290 inline bool toBool(
bool defaultValue =
false)
const {
return QJsonValueConstRef::toBool(defaultValue); }
291 inline int toInt(
int defaultValue = 0)
const {
return QJsonValueConstRef::toInt(defaultValue); }
292 inline qint64 toInteger(qint64 defaultValue = 0)
const {
return QJsonValueConstRef::toInteger(defaultValue); }
293 inline double toDouble(
double defaultValue = 0)
const {
return QJsonValueConstRef::toDouble(defaultValue); }
294 inline QString toString(
const QString &defaultValue = {})
const {
return QJsonValueConstRef::toString(defaultValue); }
295 QAnyStringView toStringView(QAnyStringView defaultValue = {})
const
296 {
return QJsonValueConstRef::toStringView(defaultValue); }
297 QJsonArray toArray()
const;
298 QJsonObject toObject()
const;
300 const QJsonValue operator[](QStringView key)
const {
return QJsonValueConstRef::operator[](key); }
301 const QJsonValue operator[](QLatin1StringView key)
const {
return QJsonValueConstRef::operator[](key); }
302 const QJsonValue operator[](qsizetype i)
const {
return QJsonValueConstRef::operator[](i); }
304#if QT_CORE_REMOVED_SINCE(6
, 8
)
305 inline bool operator==(
const QJsonValue &other)
const {
return comparesEqual(*
this, other); }
306 inline bool operator!=(
const QJsonValue &other)
const {
return !comparesEqual(*
this, other); }
310 friend bool comparesEqual(
const QJsonValueRef &lhs,
const QJsonValueRef &rhs)
312 return comparesEqual(QJsonValue(lhs), QJsonValue(rhs));
314 friend bool comparesEqual(
const QJsonValueRef &lhs,
const QJsonValueConstRef &rhs)
316 return comparesEqual(QJsonValue(lhs), QJsonValue(rhs));
318 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonValueRef)
319 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonValueRef, QJsonValueConstRef)
321 QJsonValue toValue()
const;
323 using QJsonValueConstRef::operator[];
324 Q_CORE_EXPORT QJsonValueRef operator[](QAnyStringView key);
325 Q_CORE_EXPORT QJsonValueRef operator[](qsizetype i);
328 using QJsonValueConstRef::QJsonValueConstRef;
331 QT7_ONLY(Q_CORE_EXPORT)
void detach();
332 friend class QJsonArray;
333 friend class QJsonObject;
337inline QJsonValue QCborValueConstRef::toJsonValue()
const
339 return concrete().toJsonValue();
342Q_CORE_EXPORT size_t qHash(
const QJsonValue &value, size_t seed = 0);
344#if !defined(QT_NO_DEBUG_STREAM)
345Q_CORE_EXPORT
QDebug operator<<(QDebug,
const QJsonValue &);
348#ifndef QT_NO_DATASTREAM
349Q_CORE_EXPORT
QDataStream &operator<<(QDataStream &,
const QJsonValue &);
350Q_CORE_EXPORT
QDataStream &operator>>(QDataStream &, QJsonValue &);
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QCborArray toArray(const QCborArray &a) const
QCborMap toMap(const QCborMap &m) const
QVariant toVariant() const
QCborValueConstRef & operator=(const QCborValueConstRef &)=delete
QCborArray toArray() const
bool toBool(bool defaultValue=false) const
QCborValue taggedValue(const QCborValue &defaultValue=QCborValue()) const
QCborSimpleType toSimpleType(QCborSimpleType defaultValue=QCborSimpleType::Undefined) 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
QAnyStringView toStringView(QAnyStringView defaultValue={}) const
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
operator QCborValue() const
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
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
friend bool comparesEqual(const QJsonValueConstRef &lhs, const QJsonValue &rhs)
constexpr QJsonValueConstRef(QCborContainerPrivate *d, size_t index, bool is_object)
friend bool comparesEqual(const QJsonValueConstRef &lhs, const QJsonValueConstRef &rhs)
operator QJsonValue() const
QAnyStringView objectKeyView() const
void rebind(QJsonValueConstRef other)
QString objectKey() const
QAnyStringView toStringView(QAnyStringView defaultValue={}) const
QJsonValueConstRef(const QJsonValueConstRef &)=default
qint64 toInteger(qint64 defaultValue=0) const
bool toBool(bool defaultValue=false) const
QJsonValueConstRef & operator=(const QJsonValueConstRef &)=delete
QString toString(const QString &defaultValue={}) const
QJsonValue::Type type() const
QJsonValueConstRef(QJsonArray *array, qsizetype idx)
QCborContainerPrivate * d
QJsonValueConstRef(QJsonObject *object, qsizetype idx)
double toDouble(double defaultValue=0) const
int toInt(int defaultValue=0) const
const QJsonValue operator[](QStringView key) const
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QSequentialIterable class is an iterable interface for a container in a QVariant.
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
QMutableListIterator< QByteArray > QMutableByteArrayListIterator
Q_DECLARE_TYPEINFO(QByteArrayView, Q_PRIMITIVE_TYPE)
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
QList< QVariant > QVariantList
#define qCWarning(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
#define QStringLiteral(str)
\inmodule QtCore\reentrant
QString errorString() const
\variable QCborParserError::offset
~QListSpecialMethods()=default
QListSpecialMethods & operator=(const QListSpecialMethods &)=default
QListSpecialMethods(QListSpecialMethods &&)=default
QListSpecialMethods & operator=(QListSpecialMethods &&)=default
QListSpecialMethods()=default
QListSpecialMethods(const QListSpecialMethods &)=default
QByteArray join(QByteArrayView sep={}) const
static T value(const Iterator &it)
static T value(Iterator &it)
static QCborValueConstRef key(Iterator &it)
static QCborValueConstRef key(const Iterator &it)
static QAnyStringView key(Iterator &it)
static T value(const Iterator &it)
static QAnyStringView key(const Iterator &it)
static T value(Iterator &it)