aboutsummaryrefslogtreecommitdiff
path: root/lib/converters.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/converters.cpp')
-rw-r--r--lib/converters.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/lib/converters.cpp b/lib/converters.cpp
index 41a9a65e..88f5267e 100644
--- a/lib/converters.cpp
+++ b/lib/converters.cpp
@@ -22,38 +22,34 @@
using namespace QMatrixClient;
-QJsonValue QMatrixClient::variantToJson(const QVariant& v)
+QJsonValue JsonConverter<QVariant>::dump(const QVariant& v)
{
return QJsonValue::fromVariant(v);
}
-QJsonObject QMatrixClient::toJson(const QVariantMap& map)
+QVariant JsonConverter<QVariant>::load(const QJsonValue& jv)
{
- return QJsonObject::fromVariantMap(map);
+ return jv.toVariant();
}
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
-QJsonObject QMatrixClient::toJson(const QVariantHash& hMap)
+QJsonObject JsonConverter<variant_map_t>::dump(const variant_map_t& map)
{
- return QJsonObject::fromVariantHash(hMap);
-}
+ return
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
+ QJsonObject::fromVariantHash
+#else
+ QJsonObject::fromVariantMap
#endif
-
-QVariant FromJson<QVariant>::operator()(const QJsonValue& jv) const
-{
- return jv.toVariant();
+ (map);
}
-QMap<QString, QVariant>
-FromJson<QMap<QString, QVariant>>::operator()(const QJsonValue& jv) const
+variant_map_t JsonConverter<QVariantHash>::load(const QJsonValue& jv)
{
- return jv.toObject().toVariantMap();
-}
-
+ return jv.toObject().
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
-QHash<QString, QVariant>
-FromJson<QHash<QString, QVariant>>::operator()(const QJsonValue& jv) const
-{
- return jv.toObject().toVariantHash();
-}
+ toVariantHash
+#else
+ toVariantMap
#endif
+ ();
+}