aboutsummaryrefslogtreecommitdiff
path: root/lib/application-service/definitions/protocol.cpp
diff options
context:
space:
mode:
authorHubert Chathi <uhoreg@debian.org>2019-06-25 16:33:24 -0400
committerHubert Chathi <uhoreg@debian.org>2019-06-25 16:33:24 -0400
commit72d5660efd0755bb53a8699cd39865155400d288 (patch)
treeed7e7537e6a3eb7e8b92226c4015f9bfc8e11c5a /lib/application-service/definitions/protocol.cpp
parent52407a933bfe1fcc5f3aa1dccaa0b9a8279aa634 (diff)
parent681203f951d13e9e8eaf772435cac28c6d74cd42 (diff)
downloadlibquotient-72d5660efd0755bb53a8699cd39865155400d288.tar.gz
libquotient-72d5660efd0755bb53a8699cd39865155400d288.zip
Merge branch 'upstream' (v0.5.2)
Diffstat (limited to 'lib/application-service/definitions/protocol.cpp')
-rw-r--r--lib/application-service/definitions/protocol.cpp66
1 files changed, 23 insertions, 43 deletions
diff --git a/lib/application-service/definitions/protocol.cpp b/lib/application-service/definitions/protocol.cpp
index 04bb7dfc..2a62b15d 100644
--- a/lib/application-service/definitions/protocol.cpp
+++ b/lib/application-service/definitions/protocol.cpp
@@ -6,75 +6,55 @@
using namespace QMatrixClient;
-QJsonObject QMatrixClient::toJson(const FieldType& pod)
+void JsonObjectConverter<FieldType>::dumpTo(
+ QJsonObject& jo, const FieldType& pod)
{
- QJsonObject jo;
addParam<>(jo, QStringLiteral("regexp"), pod.regexp);
addParam<>(jo, QStringLiteral("placeholder"), pod.placeholder);
- return jo;
}
-FieldType FromJsonObject<FieldType>::operator()(const QJsonObject& jo) const
+void JsonObjectConverter<FieldType>::fillFrom(
+ const QJsonObject& jo, FieldType& result)
{
- FieldType result;
- result.regexp =
- fromJson<QString>(jo.value("regexp"_ls));
- result.placeholder =
- fromJson<QString>(jo.value("placeholder"_ls));
-
- return result;
+ fromJson(jo.value("regexp"_ls), result.regexp);
+ fromJson(jo.value("placeholder"_ls), result.placeholder);
}
-QJsonObject QMatrixClient::toJson(const ProtocolInstance& pod)
+void JsonObjectConverter<ProtocolInstance>::dumpTo(
+ QJsonObject& jo, const ProtocolInstance& pod)
{
- QJsonObject jo;
addParam<>(jo, QStringLiteral("desc"), pod.desc);
addParam<IfNotEmpty>(jo, QStringLiteral("icon"), pod.icon);
addParam<>(jo, QStringLiteral("fields"), pod.fields);
addParam<>(jo, QStringLiteral("network_id"), pod.networkId);
- return jo;
}
-ProtocolInstance FromJsonObject<ProtocolInstance>::operator()(const QJsonObject& jo) const
+void JsonObjectConverter<ProtocolInstance>::fillFrom(
+ const QJsonObject& jo, ProtocolInstance& result)
{
- ProtocolInstance result;
- result.desc =
- fromJson<QString>(jo.value("desc"_ls));
- result.icon =
- fromJson<QString>(jo.value("icon"_ls));
- result.fields =
- fromJson<QJsonObject>(jo.value("fields"_ls));
- result.networkId =
- fromJson<QString>(jo.value("network_id"_ls));
-
- return result;
+ fromJson(jo.value("desc"_ls), result.desc);
+ fromJson(jo.value("icon"_ls), result.icon);
+ fromJson(jo.value("fields"_ls), result.fields);
+ fromJson(jo.value("network_id"_ls), result.networkId);
}
-QJsonObject QMatrixClient::toJson(const ThirdPartyProtocol& pod)
+void JsonObjectConverter<ThirdPartyProtocol>::dumpTo(
+ QJsonObject& jo, const ThirdPartyProtocol& pod)
{
- QJsonObject jo;
addParam<>(jo, QStringLiteral("user_fields"), pod.userFields);
addParam<>(jo, QStringLiteral("location_fields"), pod.locationFields);
addParam<>(jo, QStringLiteral("icon"), pod.icon);
addParam<>(jo, QStringLiteral("field_types"), pod.fieldTypes);
addParam<>(jo, QStringLiteral("instances"), pod.instances);
- return jo;
}
-ThirdPartyProtocol FromJsonObject<ThirdPartyProtocol>::operator()(const QJsonObject& jo) const
+void JsonObjectConverter<ThirdPartyProtocol>::fillFrom(
+ const QJsonObject& jo, ThirdPartyProtocol& result)
{
- ThirdPartyProtocol result;
- result.userFields =
- fromJson<QStringList>(jo.value("user_fields"_ls));
- result.locationFields =
- fromJson<QStringList>(jo.value("location_fields"_ls));
- result.icon =
- fromJson<QString>(jo.value("icon"_ls));
- result.fieldTypes =
- fromJson<QHash<QString, FieldType>>(jo.value("field_types"_ls));
- result.instances =
- fromJson<QVector<ProtocolInstance>>(jo.value("instances"_ls));
-
- return result;
+ fromJson(jo.value("user_fields"_ls), result.userFields);
+ fromJson(jo.value("location_fields"_ls), result.locationFields);
+ fromJson(jo.value("icon"_ls), result.icon);
+ fromJson(jo.value("field_types"_ls), result.fieldTypes);
+ fromJson(jo.value("instances"_ls), result.instances);
}