diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-03 12:14:10 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-03 21:22:50 +0900 |
commit | 853fda2e7942ffb3bc8051e6411faa23cff6f3c2 (patch) | |
tree | bf72fa7866348df46fe46e189878104a7fc158ef /lib/converters.h | |
parent | 37700bbf2df8b96c82a193c25764d9020b1140e9 (diff) | |
download | libquotient-853fda2e7942ffb3bc8051e6411faa23cff6f3c2.tar.gz libquotient-853fda2e7942ffb3bc8051e6411faa23cff6f3c2.zip |
Cleanup
Diffstat (limited to 'lib/converters.h')
-rw-r--r-- | lib/converters.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/converters.h b/lib/converters.h index cfe9c01c..baa14c7b 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -96,32 +96,32 @@ namespace QMatrixClient template <> struct FromJson<bool> { - bool operator()(const QJsonValue& jv) const { return jv.toBool(); } + auto operator()(const QJsonValue& jv) const { return jv.toBool(); } }; template <> struct FromJson<int> { - int operator()(const QJsonValue& jv) const { return jv.toInt(); } + auto operator()(const QJsonValue& jv) const { return jv.toInt(); } }; template <> struct FromJson<double> { - double operator()(const QJsonValue& jv) const { return jv.toDouble(); } + auto operator()(const QJsonValue& jv) const { return jv.toDouble(); } }; template <> struct FromJson<qint64> { - qint64 operator()(const QJsonValue& jv) const { return qint64(jv.toDouble()); } + auto operator()(const QJsonValue& jv) const { return qint64(jv.toDouble()); } }; template <> struct FromJson<QString> { - QString operator()(const QJsonValue& jv) const { return jv.toString(); } + auto operator()(const QJsonValue& jv) const { return jv.toString(); } }; template <> struct FromJson<QDateTime> { - QDateTime operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return QDateTime::fromMSecsSinceEpoch(fromJson<qint64>(jv), Qt::UTC); } @@ -129,7 +129,7 @@ namespace QMatrixClient template <> struct FromJson<QDate> { - QDate operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return fromJson<QDateTime>(jv).date(); } @@ -137,7 +137,7 @@ namespace QMatrixClient template <> struct FromJson<QJsonObject> { - QJsonObject operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toObject(); } @@ -145,7 +145,7 @@ namespace QMatrixClient template <> struct FromJson<QJsonArray> { - QJsonArray operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toArray(); } @@ -153,10 +153,11 @@ namespace QMatrixClient template <typename T> struct FromJson<std::vector<T>> { - std::vector<T> operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { + using size_type = typename std::vector<T>::size_type; const auto jsonArray = jv.toArray(); - std::vector<T> vect; vect.resize(size_t(jsonArray.size())); + std::vector<T> vect; vect.resize(size_type(jsonArray.size())); std::transform(jsonArray.begin(), jsonArray.end(), vect.begin(), FromJson<T>()); return vect; @@ -165,7 +166,7 @@ namespace QMatrixClient template <typename T> struct FromJson<QVector<T>> { - QVector<T> operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { const auto jsonArray = jv.toArray(); QVector<T> vect; vect.resize(jsonArray.size()); @@ -177,7 +178,7 @@ namespace QMatrixClient template <typename T> struct FromJson<QList<T>> { - QList<T> operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { const auto jsonArray = jv.toArray(); QList<T> sl; sl.reserve(jsonArray.size()); @@ -191,7 +192,7 @@ namespace QMatrixClient template <> struct FromJson<QByteArray> { - inline QByteArray operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return fromJson<QString>(jv).toLatin1(); } @@ -199,7 +200,7 @@ namespace QMatrixClient template <> struct FromJson<QVariantMap> { - inline auto operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toObject().toVariantMap(); } @@ -208,7 +209,7 @@ namespace QMatrixClient #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) template <> struct FromJson<QVariantHash> { - inline auto operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toObject().toVariantHash(); } @@ -217,7 +218,7 @@ namespace QMatrixClient template <typename T> struct FromJson<QHash<QString, T>> { - QHash<QString, T> operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { const auto json = jv.toObject(); QHash<QString, T> h; h.reserve(json.size()); |