aboutsummaryrefslogtreecommitdiff
path: root/converters.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-03-24 16:29:00 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-03-24 16:29:00 +0900
commit6b960db9b33efe6f6a014aed08b9177a2ba201f8 (patch)
tree95c54ee17a7da4ad738ebeb6f85d86cec6ed14f5 /converters.h
parenta5428e53525afbc6fe6f697edb4f742d84c9ae0c (diff)
parent47cb949973a05cea6fb3a13ffd19b6e07e7720ae (diff)
downloadlibquotient-6b960db9b33efe6f6a014aed08b9177a2ba201f8.tar.gz
libquotient-6b960db9b33efe6f6a014aed08b9177a2ba201f8.zip
Merge branch 'kitsune-direct-chats'
Diffstat (limited to 'converters.h')
-rw-r--r--converters.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/converters.h b/converters.h
index 96efe5f8..bba298e0 100644
--- a/converters.h
+++ b/converters.h
@@ -24,14 +24,16 @@
namespace QMatrixClient
{
- template <typename T>
- inline QJsonValue toJson(T&& val)
- {
- return QJsonValue(std::forward<T>(val));
- }
+ // This catches anything implicitly convertible to QJsonValue/Object/Array
+ inline QJsonValue toJson(const QJsonValue& val) { return val; }
+ inline QJsonObject toJson(const QJsonObject& o) { return o; }
+ inline QJsonArray toJson(const QJsonArray& arr) { return arr; }
+#ifdef _MSC_VER // MSVC gets lost and doesn't know which overload to use
+ inline QJsonValue toJson(const QString& s) { return s; }
+#endif
template <typename T>
- inline QJsonValue toJson(const QVector<T>& vals)
+ inline QJsonArray toJson(const QVector<T>& vals)
{
QJsonArray ar;
for (const auto& v: vals)
@@ -39,7 +41,7 @@ namespace QMatrixClient
return ar;
}
- inline QJsonValue toJson(const QStringList& strings)
+ inline QJsonArray toJson(const QStringList& strings)
{
return QJsonArray::fromStringList(strings);
}
@@ -50,7 +52,7 @@ namespace QMatrixClient
}
template <typename T>
- inline QJsonValue toJson(const QHash<QString, T>& hashMap)
+ inline QJsonObject toJson(const QHash<QString, T>& hashMap)
{
QJsonObject json;
for (auto it = hashMap.begin(); it != hashMap.end(); ++it)