diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-07-24 11:29:30 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-07-26 18:47:08 +0200 |
commit | 089d72d7d932bcde34d08b308fd55fcb054ef6c4 (patch) | |
tree | e125e5c88496c37a22d89fbe3d0bc92f967e0c05 /src/corelib/serialization | |
parent | 062bee3a2a93ea09b39affddb12172acd72851ae (diff) |
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>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r-- | src/corelib/serialization/qjsondocument.cpp | 12 | ||||
-rw-r--r-- | src/corelib/serialization/qjsondocument.h | 3 | ||||
-rw-r--r-- | src/corelib/serialization/qjsonvalue.h | 14 |
3 files changed, 5 insertions, 24 deletions
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 338b752f13..642f058c72 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -451,18 +451,6 @@ QVariant QJsonDocument::toVariant() const } /*! - 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 \since 5.1 diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index 8c2840eda7..a09bd91601 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -136,8 +136,7 @@ public: static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error = nullptr); #if !defined(QT_JSON_READONLY) || defined(Q_CLANG_QDOC) - QByteArray toJson() const; //### Merge in Qt6 - QByteArray toJson(JsonFormat format) const; + QByteArray toJson(JsonFormat format = Indented) const; #endif bool isEmpty() const; diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h index eb160f7f8f..734493984c 100644 --- a/src/corelib/serialization/qjsonvalue.h +++ b/src/corelib/serialization/qjsonvalue.h @@ -180,19 +180,13 @@ public: inline bool isObject() const { return type() == QJsonValue::Object; } inline bool isUndefined() const { return type() == QJsonValue::Undefined; } - inline bool toBool() const { return toValue().toBool(); } - inline int toInt() const { return toValue().toInt(); } - inline double toDouble() const { return toValue().toDouble(); } - inline QString toString() const { return toValue().toString(); } + inline bool toBool(bool defaultValue = false) const { return toValue().toBool(defaultValue); } + inline int toInt(int defaultValue = 0) const { return toValue().toInt(defaultValue); } + inline double toDouble(double defaultValue = 0) const { return toValue().toDouble(defaultValue); } + inline QString toString(const QString &defaultValue = {}) const { return toValue().toString(defaultValue); } QJsonArray toArray() 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; } |