aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/public_rooms_response.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/definitions/public_rooms_response.cpp')
-rw-r--r--lib/csapi/definitions/public_rooms_response.cpp61
1 files changed, 21 insertions, 40 deletions
diff --git a/lib/csapi/definitions/public_rooms_response.cpp b/lib/csapi/definitions/public_rooms_response.cpp
index 2f52501d..0d26662c 100644
--- a/lib/csapi/definitions/public_rooms_response.cpp
+++ b/lib/csapi/definitions/public_rooms_response.cpp
@@ -6,9 +6,9 @@
using namespace QMatrixClient;
-QJsonObject QMatrixClient::toJson(const PublicRoomsChunk& pod)
+void JsonObjectConverter<PublicRoomsChunk>::dumpTo(
+ QJsonObject& jo, const PublicRoomsChunk& pod)
{
- QJsonObject jo;
addParam<IfNotEmpty>(jo, QStringLiteral("aliases"), pod.aliases);
addParam<IfNotEmpty>(jo, QStringLiteral("canonical_alias"), pod.canonicalAlias);
addParam<IfNotEmpty>(jo, QStringLiteral("name"), pod.name);
@@ -18,56 +18,37 @@ QJsonObject QMatrixClient::toJson(const PublicRoomsChunk& pod)
addParam<>(jo, QStringLiteral("world_readable"), pod.worldReadable);
addParam<>(jo, QStringLiteral("guest_can_join"), pod.guestCanJoin);
addParam<IfNotEmpty>(jo, QStringLiteral("avatar_url"), pod.avatarUrl);
- return jo;
}
-PublicRoomsChunk FromJsonObject<PublicRoomsChunk>::operator()(const QJsonObject& jo) const
+void JsonObjectConverter<PublicRoomsChunk>::fillFrom(
+ const QJsonObject& jo, PublicRoomsChunk& result)
{
- PublicRoomsChunk result;
- result.aliases =
- fromJson<QStringList>(jo.value("aliases"_ls));
- result.canonicalAlias =
- fromJson<QString>(jo.value("canonical_alias"_ls));
- result.name =
- fromJson<QString>(jo.value("name"_ls));
- result.numJoinedMembers =
- fromJson<int>(jo.value("num_joined_members"_ls));
- result.roomId =
- fromJson<QString>(jo.value("room_id"_ls));
- result.topic =
- fromJson<QString>(jo.value("topic"_ls));
- result.worldReadable =
- fromJson<bool>(jo.value("world_readable"_ls));
- result.guestCanJoin =
- fromJson<bool>(jo.value("guest_can_join"_ls));
- result.avatarUrl =
- fromJson<QString>(jo.value("avatar_url"_ls));
-
- return result;
+ fromJson(jo.value("aliases"_ls), result.aliases);
+ fromJson(jo.value("canonical_alias"_ls), result.canonicalAlias);
+ fromJson(jo.value("name"_ls), result.name);
+ fromJson(jo.value("num_joined_members"_ls), result.numJoinedMembers);
+ fromJson(jo.value("room_id"_ls), result.roomId);
+ fromJson(jo.value("topic"_ls), result.topic);
+ fromJson(jo.value("world_readable"_ls), result.worldReadable);
+ fromJson(jo.value("guest_can_join"_ls), result.guestCanJoin);
+ fromJson(jo.value("avatar_url"_ls), result.avatarUrl);
}
-QJsonObject QMatrixClient::toJson(const PublicRoomsResponse& pod)
+void JsonObjectConverter<PublicRoomsResponse>::dumpTo(
+ QJsonObject& jo, const PublicRoomsResponse& pod)
{
- QJsonObject jo;
addParam<>(jo, QStringLiteral("chunk"), pod.chunk);
addParam<IfNotEmpty>(jo, QStringLiteral("next_batch"), pod.nextBatch);
addParam<IfNotEmpty>(jo, QStringLiteral("prev_batch"), pod.prevBatch);
addParam<IfNotEmpty>(jo, QStringLiteral("total_room_count_estimate"), pod.totalRoomCountEstimate);
- return jo;
}
-PublicRoomsResponse FromJsonObject<PublicRoomsResponse>::operator()(const QJsonObject& jo) const
+void JsonObjectConverter<PublicRoomsResponse>::fillFrom(
+ const QJsonObject& jo, PublicRoomsResponse& result)
{
- PublicRoomsResponse result;
- result.chunk =
- fromJson<QVector<PublicRoomsChunk>>(jo.value("chunk"_ls));
- result.nextBatch =
- fromJson<QString>(jo.value("next_batch"_ls));
- result.prevBatch =
- fromJson<QString>(jo.value("prev_batch"_ls));
- result.totalRoomCountEstimate =
- fromJson<int>(jo.value("total_room_count_estimate"_ls));
-
- return result;
+ fromJson(jo.value("chunk"_ls), result.chunk);
+ fromJson(jo.value("next_batch"_ls), result.nextBatch);
+ fromJson(jo.value("prev_batch"_ls), result.prevBatch);
+ fromJson(jo.value("total_room_count_estimate"_ls), result.totalRoomCountEstimate);
}