Clean-up methods with default values in JSON classes
Task-number: QTBUG-85700 Change-Id: I46e7c58e4cc94cf19cd9f11e03d2a498cd0c8922 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
062bee3a2a
commit
089d72d7d9
@ -450,18 +450,6 @@ QVariant QJsonDocument::toVariant() const
|
|||||||
return QJsonObject(container).toVariantMap();
|
return QJsonObject(container).toVariantMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
Converts the QJsonDocument to an indented, UTF-8 encoded JSON document.
|
|
||||||
|
|
||||||
\sa fromJson()
|
|
||||||
*/
|
|
||||||
#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
|
|
||||||
QByteArray QJsonDocument::toJson() const
|
|
||||||
{
|
|
||||||
return toJson(Indented);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\enum QJsonDocument::JsonFormat
|
\enum QJsonDocument::JsonFormat
|
||||||
\since 5.1
|
\since 5.1
|
||||||
|
@ -136,8 +136,7 @@ public:
|
|||||||
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = nullptr);
|
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = nullptr);
|
||||||
|
|
||||||
#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
|
#if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC)
|
||||||
QByteArray toJson() const; //### Merge in Qt6
|
QByteArray toJson(JsonFormat format = Indented) const;
|
||||||
QByteArray toJson(JsonFormat format) const;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
@ -180,19 +180,13 @@ public:
|
|||||||
inline bool isObject() const { return type() == QJsonValue::Object; }
|
inline bool isObject() const { return type() == QJsonValue::Object; }
|
||||||
inline bool isUndefined() const { return type() == QJsonValue::Undefined; }
|
inline bool isUndefined() const { return type() == QJsonValue::Undefined; }
|
||||||
|
|
||||||
inline bool toBool() const { return toValue().toBool(); }
|
inline bool toBool(bool defaultValue = false) const { return toValue().toBool(defaultValue); }
|
||||||
inline int toInt() const { return toValue().toInt(); }
|
inline int toInt(int defaultValue = 0) const { return toValue().toInt(defaultValue); }
|
||||||
inline double toDouble() const { return toValue().toDouble(); }
|
inline double toDouble(double defaultValue = 0) const { return toValue().toDouble(defaultValue); }
|
||||||
inline QString toString() const { return toValue().toString(); }
|
inline QString toString(const QString &defaultValue = {}) const { return toValue().toString(defaultValue); }
|
||||||
QJsonArray toArray() const;
|
QJsonArray toArray() const;
|
||||||
QJsonObject toObject() const;
|
QJsonObject toObject() const;
|
||||||
|
|
||||||
// ### Qt 6: Add default values
|
|
||||||
inline bool toBool(bool defaultValue) const { return toValue().toBool(defaultValue); }
|
|
||||||
inline int toInt(int defaultValue) const { return toValue().toInt(defaultValue); }
|
|
||||||
inline double toDouble(double defaultValue) const { return toValue().toDouble(defaultValue); }
|
|
||||||
inline QString toString(const QString &defaultValue) const { return toValue().toString(defaultValue); }
|
|
||||||
|
|
||||||
inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
|
inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
|
||||||
inline bool operator!=(const QJsonValue &other) const { return toValue() != other; }
|
inline bool operator!=(const QJsonValue &other) const { return toValue() != other; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user