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 QT_CORE_INLINE_SINCE(6, 12)
73 QJsonValue(QJsonValue &&other)
noexcept;
74 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QJsonValue)
76 QT_CORE_INLINE_SINCE(6, 12)
77 void swap(QJsonValue &other)
noexcept;
79 static QJsonValue fromVariant(
const QVariant &variant);
80 QVariant toVariant()
const;
82 static QJsonValue fromJson(QByteArrayView json, QJsonParseError *error =
nullptr);
84 QByteArray toJson(JsonFormat format = JsonFormat::Indented)
const;
87 inline bool isNull()
const {
return type() == Null; }
88 inline bool isBool()
const {
return type() == Bool; }
89 inline bool isDouble()
const {
return type() == Double; }
90 inline bool isString()
const {
return type() == String; }
91 inline bool isArray()
const {
return type() == Array; }
92 inline bool isObject()
const {
return type() == Object; }
93 inline bool isUndefined()
const {
return type() == Undefined; }
95 bool toBool(
bool defaultValue =
false)
const;
96 int toInt(
int defaultValue = 0)
const;
97 qint64 toInteger(qint64 defaultValue = 0)
const;
98 double toDouble(
double defaultValue = 0)
const;
99 QString toString()
const;
100 QString toString(
const QString &defaultValue)
const;
101 QAnyStringView toStringView(QAnyStringView defaultValue = {})
const;
102 QJsonArray toArray()
const;
103 QJsonArray toArray(
const QJsonArray &defaultValue)
const;
104 QJsonObject toObject()
const;
105 QJsonObject toObject(
const QJsonObject &defaultValue)
const;
107 const QJsonValue operator[](
const QString &key)
const;
108 const QJsonValue operator[](QStringView key)
const;
109 const QJsonValue operator[](QLatin1StringView key)
const;
110 const QJsonValue operator[](qsizetype i)
const;
112#if QT_CORE_REMOVED_SINCE(6
, 8
)
113 bool operator==(
const QJsonValue &other)
const;
114 bool operator!=(
const QJsonValue &other)
const;
118 friend Q_CORE_EXPORT
bool comparesEqual(
const QJsonValue &lhs,
119 const QJsonValue &rhs);
120 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonValue)
123 QJsonValue(
const void *) =
delete;
124 friend class QJsonPrivate::Value;
125 friend class QJsonArray;
126 friend class QJsonObject;
127 friend class QCborValue;
128 friend Q_CORE_EXPORT QDebug operator<<(QDebug,
const QJsonValue &);
129 friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &,
const QJsonValue &);
134 static_assert(
sizeof(QExplicitlySharedDataPointer<QCborContainerPrivate>) ==
sizeof(
void *));
135 static_assert(
sizeof(QCborValue::Type) ==
sizeof(QJsonValue::Type));
139Q_CORE_EXPORT size_t qHash(
const QJsonValue &value, size_t seed = 0);
146 inline operator QJsonValue()
const {
return concrete(*
this); }
148 Q_CORE_EXPORT QVariant
toVariant()
const;
150 bool isNull()
const {
return type() == QJsonValue::Null; }
151 bool isBool()
const {
return type() == QJsonValue::Bool; }
152 bool isDouble()
const {
return type() == QJsonValue::Double; }
153 bool isString()
const {
return type() == QJsonValue::String; }
154 bool isArray()
const {
return type() == QJsonValue::Array; }
155 bool isObject()
const {
return type() == QJsonValue::Object; }
156 bool isUndefined()
const {
return type() == QJsonValue::Undefined; }
158 bool toBool(
bool defaultValue =
false)
const
159 {
return concreteBool(*
this, defaultValue); }
160 int toInt(
int defaultValue = 0)
const
161 {
return int(concreteInt(*
this, defaultValue,
true)); }
163 {
return concreteInt(*
this, defaultValue,
false); }
165 {
return concreteDouble(*
this, defaultValue); }
166 QString
toString(
const QString &defaultValue = {})
const
167 {
return concreteString(*
this, defaultValue); }
169 {
return concreteStringView(*
this, defaultValue); }
170 Q_CORE_EXPORT QJsonArray
toArray()
const;
171 Q_CORE_EXPORT QJsonObject
toObject()
const;
173 const QJsonValue
operator[](QStringView key)
const {
return concrete(*
this)[key]; }
174 const QJsonValue
operator[](QLatin1StringView key)
const {
return concrete(*
this)[key]; }
175 const QJsonValue
operator[](qsizetype i)
const {
return concrete(*
this)[i]; }
179 {
return QHashPrivate::ex1to2arg(concrete(key), seed); }
184 return comparesEqual(concrete(lhs), concrete(rhs));
187 const QJsonValue &rhs)
189 return comparesEqual(concrete(lhs), rhs);
196 Q_CORE_EXPORT
static bool
198 Q_CORE_EXPORT
static qint64
200 Q_CORE_EXPORT
static double
213#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
256 friend class QJsonArray;
257 friend class QJsonObject;
262QT6_ONLY(QT_WARNING_DISABLE_MSVC(4275))
263class QT6_ONLY(Q_CORE_EXPORT) QJsonValueRef :
public QJsonValueConstRef
266 QJsonValueRef(
const QJsonValueRef &) =
default;
267 QT7_ONLY(Q_CORE_EXPORT) QJsonValueRef &operator = (
const QJsonValue &val);
268 QT7_ONLY(Q_CORE_EXPORT) QJsonValueRef &operator = (
const QJsonValueRef &val);
270#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
) && !defined(QT_BOOTSTRAPPED)
274 QJsonValueRef(QJsonArray *array, qsizetype idx)
275 : QJsonValueConstRef(array, idx) {}
276 QJsonValueRef(QJsonObject *object, qsizetype idx)
277 : QJsonValueConstRef(object, idx) {}
279 operator QJsonValue()
const {
return toValue(); }
281 QVariant toVariant()
const;
282 inline QJsonValue::Type type()
const {
return QJsonValueConstRef::type(); }
283 inline bool isNull()
const {
return type() == QJsonValue::Null; }
284 inline bool isBool()
const {
return type() == QJsonValue::Bool; }
285 inline bool isDouble()
const {
return type() == QJsonValue::Double; }
286 inline bool isString()
const {
return type() == QJsonValue::String; }
287 inline bool isArray()
const {
return type() == QJsonValue::Array; }
288 inline bool isObject()
const {
return type() == QJsonValue::Object; }
289 inline bool isUndefined()
const {
return type() == QJsonValue::Undefined; }
291 inline bool toBool(
bool defaultValue =
false)
const {
return QJsonValueConstRef::toBool(defaultValue); }
292 inline int toInt(
int defaultValue = 0)
const {
return QJsonValueConstRef::toInt(defaultValue); }
293 inline qint64 toInteger(qint64 defaultValue = 0)
const {
return QJsonValueConstRef::toInteger(defaultValue); }
294 inline double toDouble(
double defaultValue = 0)
const {
return QJsonValueConstRef::toDouble(defaultValue); }
295 inline QString toString(
const QString &defaultValue = {})
const {
return QJsonValueConstRef::toString(defaultValue); }
296 QAnyStringView toStringView(QAnyStringView defaultValue = {})
const
297 {
return QJsonValueConstRef::toStringView(defaultValue); }
298 QJsonArray toArray()
const;
299 QJsonObject toObject()
const;
301 const QJsonValue operator[](QStringView key)
const {
return QJsonValueConstRef::operator[](key); }
302 const QJsonValue operator[](QLatin1StringView key)
const {
return QJsonValueConstRef::operator[](key); }
303 const QJsonValue operator[](qsizetype i)
const {
return QJsonValueConstRef::operator[](i); }
305#if QT_CORE_REMOVED_SINCE(6
, 8
)
306 inline bool operator==(
const QJsonValue &other)
const {
return comparesEqual(*
this, other); }
307 inline bool operator!=(
const QJsonValue &other)
const {
return !comparesEqual(*
this, other); }
311 friend bool comparesEqual(
const QJsonValueRef &lhs,
const QJsonValueRef &rhs)
313 return comparesEqual(QJsonValue(lhs), QJsonValue(rhs));
315 friend bool comparesEqual(
const QJsonValueRef &lhs,
const QJsonValueConstRef &rhs)
317 return comparesEqual(QJsonValue(lhs), QJsonValue(rhs));
319 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonValueRef)
320 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QJsonValueRef, QJsonValueConstRef)
322 QJsonValue toValue()
const;
324 using QJsonValueConstRef::operator[];
325 Q_CORE_EXPORT QJsonValueRef operator[](QAnyStringView key);
326 Q_CORE_EXPORT QJsonValueRef operator[](qsizetype i);
329 using QJsonValueConstRef::QJsonValueConstRef;
332 QT7_ONLY(Q_CORE_EXPORT)
void detach();
333 friend class QJsonArray;
334 friend class QJsonObject;
338inline QJsonValue QCborValueConstRef::toJsonValue()
const
340 return concrete().toJsonValue();
343#if QT_CORE_INLINE_IMPL_SINCE(6
, 12
)
344QJsonValue::QJsonValue(QJsonValue &&other)
noexcept =
default;
346void QJsonValue::swap(QJsonValue &other)
noexcept
348 value.swap(other.value);
352#if !defined(QT_NO_DEBUG_STREAM)
353Q_CORE_EXPORT
QDebug operator<<(QDebug,
const QJsonValue &);
356#ifndef QT_NO_DATASTREAM
357Q_CORE_EXPORT
QDataStream &operator<<(QDataStream &,
const QJsonValue &);
358Q_CORE_EXPORT
QDataStream &operator>>(QDataStream &, QJsonValue &);
\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
friend size_t qHash(const QCborValueConstRef &key, size_t seed=0) noexcept
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
friend size_t qHash(const QJsonValueConstRef &key, size_t seed=0) noexcept
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
\keyword 16-bit Floating Point Support\inmodule QtCore \inheaderfile QFloat16
Combined button and popup list for selecting options.
QMutableListIterator< QByteArray > QMutableByteArrayListIterator
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)