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.cpp70
1 files changed, 34 insertions, 36 deletions
diff --git a/lib/csapi/definitions/public_rooms_response.cpp b/lib/csapi/definitions/public_rooms_response.cpp
index 7cdf16af..60ae3749 100644
--- a/lib/csapi/definitions/public_rooms_response.cpp
+++ b/lib/csapi/definitions/public_rooms_response.cpp
@@ -8,68 +8,66 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const PublicRoomsChunk& pod)
{
- QJsonObject _json;
- addParam<IfNotEmpty>(_json, QStringLiteral("aliases"), pod.aliases);
- addParam<IfNotEmpty>(_json, QStringLiteral("canonical_alias"), pod.canonicalAlias);
- addParam<IfNotEmpty>(_json, QStringLiteral("name"), pod.name);
- addParam<>(_json, QStringLiteral("num_joined_members"), pod.numJoinedMembers);
- addParam<>(_json, QStringLiteral("room_id"), pod.roomId);
- addParam<IfNotEmpty>(_json, QStringLiteral("topic"), pod.topic);
- addParam<>(_json, QStringLiteral("world_readable"), pod.worldReadable);
- addParam<>(_json, QStringLiteral("guest_can_join"), pod.guestCanJoin);
- addParam<IfNotEmpty>(_json, QStringLiteral("avatar_url"), pod.avatarUrl);
- return _json;
+ QJsonObject jo;
+ addParam<IfNotEmpty>(jo, QStringLiteral("aliases"), pod.aliases);
+ addParam<IfNotEmpty>(jo, QStringLiteral("canonical_alias"), pod.canonicalAlias);
+ addParam<IfNotEmpty>(jo, QStringLiteral("name"), pod.name);
+ addParam<>(jo, QStringLiteral("num_joined_members"), pod.numJoinedMembers);
+ addParam<>(jo, QStringLiteral("room_id"), pod.roomId);
+ addParam<IfNotEmpty>(jo, QStringLiteral("topic"), pod.topic);
+ 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 FromJson<PublicRoomsChunk>::operator()(const QJsonValue& jv)
+PublicRoomsChunk FromJsonObject<PublicRoomsChunk>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
PublicRoomsChunk result;
result.aliases =
- fromJson<QStringList>(_json.value("aliases"_ls));
+ fromJson<QStringList>(jo.value("aliases"_ls));
result.canonicalAlias =
- fromJson<QString>(_json.value("canonical_alias"_ls));
+ fromJson<QString>(jo.value("canonical_alias"_ls));
result.name =
- fromJson<QString>(_json.value("name"_ls));
+ fromJson<QString>(jo.value("name"_ls));
result.numJoinedMembers =
- fromJson<qint64>(_json.value("num_joined_members"_ls));
+ fromJson<qint64>(jo.value("num_joined_members"_ls));
result.roomId =
- fromJson<QString>(_json.value("room_id"_ls));
+ fromJson<QString>(jo.value("room_id"_ls));
result.topic =
- fromJson<QString>(_json.value("topic"_ls));
+ fromJson<QString>(jo.value("topic"_ls));
result.worldReadable =
- fromJson<bool>(_json.value("world_readable"_ls));
+ fromJson<bool>(jo.value("world_readable"_ls));
result.guestCanJoin =
- fromJson<bool>(_json.value("guest_can_join"_ls));
+ fromJson<bool>(jo.value("guest_can_join"_ls));
result.avatarUrl =
- fromJson<QString>(_json.value("avatar_url"_ls));
-
+ fromJson<QString>(jo.value("avatar_url"_ls));
+
return result;
}
QJsonObject QMatrixClient::toJson(const PublicRoomsResponse& pod)
{
- QJsonObject _json;
- addParam<>(_json, QStringLiteral("chunk"), pod.chunk);
- addParam<IfNotEmpty>(_json, QStringLiteral("next_batch"), pod.nextBatch);
- addParam<IfNotEmpty>(_json, QStringLiteral("prev_batch"), pod.prevBatch);
- addParam<IfNotEmpty>(_json, QStringLiteral("total_room_count_estimate"), pod.totalRoomCountEstimate);
- return _json;
+ 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 FromJson<PublicRoomsResponse>::operator()(const QJsonValue& jv)
+PublicRoomsResponse FromJsonObject<PublicRoomsResponse>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
PublicRoomsResponse result;
result.chunk =
- fromJson<QVector<PublicRoomsChunk>>(_json.value("chunk"_ls));
+ fromJson<QVector<PublicRoomsChunk>>(jo.value("chunk"_ls));
result.nextBatch =
- fromJson<QString>(_json.value("next_batch"_ls));
+ fromJson<QString>(jo.value("next_batch"_ls));
result.prevBatch =
- fromJson<QString>(_json.value("prev_batch"_ls));
+ fromJson<QString>(jo.value("prev_batch"_ls));
result.totalRoomCountEstimate =
- fromJson<qint64>(_json.value("total_room_count_estimate"_ls));
-
+ fromJson<qint64>(jo.value("total_room_count_estimate"_ls));
+
return result;
}