aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/definitions')
-rw-r--r--lib/csapi/definitions/auth_data.cpp19
-rw-r--r--lib/csapi/definitions/auth_data.h4
-rw-r--r--lib/csapi/definitions/client_device.cpp25
-rw-r--r--lib/csapi/definitions/client_device.h4
-rw-r--r--lib/csapi/definitions/device_keys.cpp29
-rw-r--r--lib/csapi/definitions/device_keys.h4
-rw-r--r--lib/csapi/definitions/event_filter.cpp29
-rw-r--r--lib/csapi/definitions/event_filter.h4
-rw-r--r--lib/csapi/definitions/public_rooms_response.cpp70
-rw-r--r--lib/csapi/definitions/public_rooms_response.h8
-rw-r--r--lib/csapi/definitions/push_condition.cpp25
-rw-r--r--lib/csapi/definitions/push_condition.h4
-rw-r--r--lib/csapi/definitions/push_rule.cpp33
-rw-r--r--lib/csapi/definitions/push_rule.h4
-rw-r--r--lib/csapi/definitions/push_ruleset.cpp29
-rw-r--r--lib/csapi/definitions/push_ruleset.h4
-rw-r--r--lib/csapi/definitions/room_event_filter.cpp21
-rw-r--r--lib/csapi/definitions/room_event_filter.h4
-rw-r--r--lib/csapi/definitions/sync_filter.cpp66
-rw-r--r--lib/csapi/definitions/sync_filter.h8
-rw-r--r--lib/csapi/definitions/user_identifier.cpp15
-rw-r--r--lib/csapi/definitions/user_identifier.h4
22 files changed, 200 insertions, 213 deletions
diff --git a/lib/csapi/definitions/auth_data.cpp b/lib/csapi/definitions/auth_data.cpp
index 94e3c05c..f8639432 100644
--- a/lib/csapi/definitions/auth_data.cpp
+++ b/lib/csapi/definitions/auth_data.cpp
@@ -8,22 +8,21 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const AuthenticationData& pod)
{
- QJsonObject _json = toJson(pod.authInfo);
- addParam<>(_json, QStringLiteral("type"), pod.type);
- addParam<IfNotEmpty>(_json, QStringLiteral("session"), pod.session);
- return _json;
+ QJsonObject jo = toJson(pod.authInfo);
+ addParam<>(jo, QStringLiteral("type"), pod.type);
+ addParam<IfNotEmpty>(jo, QStringLiteral("session"), pod.session);
+ return jo;
}
-AuthenticationData FromJson<AuthenticationData>::operator()(const QJsonValue& jv)
+AuthenticationData FromJsonObject<AuthenticationData>::operator()(QJsonObject jo) const
{
- auto _json = jv.toObject();
AuthenticationData result;
result.type =
- fromJson<QString>(_json.take("type"_ls));
+ fromJson<QString>(jo.take("type"_ls));
result.session =
- fromJson<QString>(_json.take("session"_ls));
-
- result.authInfo = fromJson<QHash<QString, QJsonObject>>(_json);
+ fromJson<QString>(jo.take("session"_ls));
+
+ result.authInfo = fromJson<QHash<QString, QJsonObject>>(jo);
return result;
}
diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h
index dce55396..661d3e5f 100644
--- a/lib/csapi/definitions/auth_data.h
+++ b/lib/csapi/definitions/auth_data.h
@@ -26,9 +26,9 @@ namespace QMatrixClient
QJsonObject toJson(const AuthenticationData& pod);
- template <> struct FromJson<AuthenticationData>
+ template <> struct FromJsonObject<AuthenticationData>
{
- AuthenticationData operator()(const QJsonValue& jv);
+ AuthenticationData operator()(QJsonObject jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/client_device.cpp b/lib/csapi/definitions/client_device.cpp
index bd7acd02..4a192f85 100644
--- a/lib/csapi/definitions/client_device.cpp
+++ b/lib/csapi/definitions/client_device.cpp
@@ -8,27 +8,26 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const Device& pod)
{
- QJsonObject _json;
- addParam<>(_json, QStringLiteral("device_id"), pod.deviceId);
- addParam<IfNotEmpty>(_json, QStringLiteral("display_name"), pod.displayName);
- addParam<IfNotEmpty>(_json, QStringLiteral("last_seen_ip"), pod.lastSeenIp);
- addParam<IfNotEmpty>(_json, QStringLiteral("last_seen_ts"), pod.lastSeenTs);
- return _json;
+ QJsonObject jo;
+ addParam<>(jo, QStringLiteral("device_id"), pod.deviceId);
+ addParam<IfNotEmpty>(jo, QStringLiteral("display_name"), pod.displayName);
+ addParam<IfNotEmpty>(jo, QStringLiteral("last_seen_ip"), pod.lastSeenIp);
+ addParam<IfNotEmpty>(jo, QStringLiteral("last_seen_ts"), pod.lastSeenTs);
+ return jo;
}
-Device FromJson<Device>::operator()(const QJsonValue& jv)
+Device FromJsonObject<Device>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
Device result;
result.deviceId =
- fromJson<QString>(_json.value("device_id"_ls));
+ fromJson<QString>(jo.value("device_id"_ls));
result.displayName =
- fromJson<QString>(_json.value("display_name"_ls));
+ fromJson<QString>(jo.value("display_name"_ls));
result.lastSeenIp =
- fromJson<QString>(_json.value("last_seen_ip"_ls));
+ fromJson<QString>(jo.value("last_seen_ip"_ls));
result.lastSeenTs =
- fromJson<qint64>(_json.value("last_seen_ts"_ls));
-
+ fromJson<qint64>(jo.value("last_seen_ts"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/client_device.h b/lib/csapi/definitions/client_device.h
index ba65483d..9f10888a 100644
--- a/lib/csapi/definitions/client_device.h
+++ b/lib/csapi/definitions/client_device.h
@@ -31,9 +31,9 @@ namespace QMatrixClient
QJsonObject toJson(const Device& pod);
- template <> struct FromJson<Device>
+ template <> struct FromJsonObject<Device>
{
- Device operator()(const QJsonValue& jv);
+ Device operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/device_keys.cpp b/lib/csapi/definitions/device_keys.cpp
index d17f4c12..a0e0ca42 100644
--- a/lib/csapi/definitions/device_keys.cpp
+++ b/lib/csapi/definitions/device_keys.cpp
@@ -8,30 +8,29 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const DeviceKeys& pod)
{
- QJsonObject _json;
- addParam<>(_json, QStringLiteral("user_id"), pod.userId);
- addParam<>(_json, QStringLiteral("device_id"), pod.deviceId);
- addParam<>(_json, QStringLiteral("algorithms"), pod.algorithms);
- addParam<>(_json, QStringLiteral("keys"), pod.keys);
- addParam<>(_json, QStringLiteral("signatures"), pod.signatures);
- return _json;
+ QJsonObject jo;
+ addParam<>(jo, QStringLiteral("user_id"), pod.userId);
+ addParam<>(jo, QStringLiteral("device_id"), pod.deviceId);
+ addParam<>(jo, QStringLiteral("algorithms"), pod.algorithms);
+ addParam<>(jo, QStringLiteral("keys"), pod.keys);
+ addParam<>(jo, QStringLiteral("signatures"), pod.signatures);
+ return jo;
}
-DeviceKeys FromJson<DeviceKeys>::operator()(const QJsonValue& jv)
+DeviceKeys FromJsonObject<DeviceKeys>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
DeviceKeys result;
result.userId =
- fromJson<QString>(_json.value("user_id"_ls));
+ fromJson<QString>(jo.value("user_id"_ls));
result.deviceId =
- fromJson<QString>(_json.value("device_id"_ls));
+ fromJson<QString>(jo.value("device_id"_ls));
result.algorithms =
- fromJson<QStringList>(_json.value("algorithms"_ls));
+ fromJson<QStringList>(jo.value("algorithms"_ls));
result.keys =
- fromJson<QHash<QString, QString>>(_json.value("keys"_ls));
+ fromJson<QHash<QString, QString>>(jo.value("keys"_ls));
result.signatures =
- fromJson<QHash<QString, QHash<QString, QString>>>(_json.value("signatures"_ls));
-
+ fromJson<QHash<QString, QHash<QString, QString>>>(jo.value("signatures"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/device_keys.h b/lib/csapi/definitions/device_keys.h
index 4b223609..6023e7e8 100644
--- a/lib/csapi/definitions/device_keys.h
+++ b/lib/csapi/definitions/device_keys.h
@@ -37,9 +37,9 @@ namespace QMatrixClient
QJsonObject toJson(const DeviceKeys& pod);
- template <> struct FromJson<DeviceKeys>
+ template <> struct FromJsonObject<DeviceKeys>
{
- DeviceKeys operator()(const QJsonValue& jv);
+ DeviceKeys operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/event_filter.cpp b/lib/csapi/definitions/event_filter.cpp
index 336de0dd..2f0bc899 100644
--- a/lib/csapi/definitions/event_filter.cpp
+++ b/lib/csapi/definitions/event_filter.cpp
@@ -8,30 +8,29 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const Filter& pod)
{
- QJsonObject _json;
- addParam<IfNotEmpty>(_json, QStringLiteral("limit"), pod.limit);
- addParam<IfNotEmpty>(_json, QStringLiteral("not_senders"), pod.notSenders);
- addParam<IfNotEmpty>(_json, QStringLiteral("not_types"), pod.notTypes);
- addParam<IfNotEmpty>(_json, QStringLiteral("senders"), pod.senders);
- addParam<IfNotEmpty>(_json, QStringLiteral("types"), pod.types);
- return _json;
+ QJsonObject jo;
+ addParam<IfNotEmpty>(jo, QStringLiteral("limit"), pod.limit);
+ addParam<IfNotEmpty>(jo, QStringLiteral("not_senders"), pod.notSenders);
+ addParam<IfNotEmpty>(jo, QStringLiteral("not_types"), pod.notTypes);
+ addParam<IfNotEmpty>(jo, QStringLiteral("senders"), pod.senders);
+ addParam<IfNotEmpty>(jo, QStringLiteral("types"), pod.types);
+ return jo;
}
-Filter FromJson<Filter>::operator()(const QJsonValue& jv)
+Filter FromJsonObject<Filter>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
Filter result;
result.limit =
- fromJson<int>(_json.value("limit"_ls));
+ fromJson<int>(jo.value("limit"_ls));
result.notSenders =
- fromJson<QStringList>(_json.value("not_senders"_ls));
+ fromJson<QStringList>(jo.value("not_senders"_ls));
result.notTypes =
- fromJson<QStringList>(_json.value("not_types"_ls));
+ fromJson<QStringList>(jo.value("not_types"_ls));
result.senders =
- fromJson<QStringList>(_json.value("senders"_ls));
+ fromJson<QStringList>(jo.value("senders"_ls));
result.types =
- fromJson<QStringList>(_json.value("types"_ls));
-
+ fromJson<QStringList>(jo.value("types"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/event_filter.h b/lib/csapi/definitions/event_filter.h
index 76f08319..2c64181b 100644
--- a/lib/csapi/definitions/event_filter.h
+++ b/lib/csapi/definitions/event_filter.h
@@ -28,9 +28,9 @@ namespace QMatrixClient
QJsonObject toJson(const Filter& pod);
- template <> struct FromJson<Filter>
+ template <> struct FromJsonObject<Filter>
{
- Filter operator()(const QJsonValue& jv);
+ Filter operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
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;
}
diff --git a/lib/csapi/definitions/public_rooms_response.h b/lib/csapi/definitions/public_rooms_response.h
index eea4bc5e..e7fe5ad8 100644
--- a/lib/csapi/definitions/public_rooms_response.h
+++ b/lib/csapi/definitions/public_rooms_response.h
@@ -39,9 +39,9 @@ namespace QMatrixClient
QJsonObject toJson(const PublicRoomsChunk& pod);
- template <> struct FromJson<PublicRoomsChunk>
+ template <> struct FromJsonObject<PublicRoomsChunk>
{
- PublicRoomsChunk operator()(const QJsonValue& jv);
+ PublicRoomsChunk operator()(const QJsonObject& jo) const;
};
/// A list of the rooms on the server.
@@ -64,9 +64,9 @@ namespace QMatrixClient
QJsonObject toJson(const PublicRoomsResponse& pod);
- template <> struct FromJson<PublicRoomsResponse>
+ template <> struct FromJsonObject<PublicRoomsResponse>
{
- PublicRoomsResponse operator()(const QJsonValue& jv);
+ PublicRoomsResponse operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/push_condition.cpp b/lib/csapi/definitions/push_condition.cpp
index 19351ae1..045094bc 100644
--- a/lib/csapi/definitions/push_condition.cpp
+++ b/lib/csapi/definitions/push_condition.cpp
@@ -8,27 +8,26 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const PushCondition& pod)
{
- QJsonObject _json;
- addParam<>(_json, QStringLiteral("kind"), pod.kind);
- addParam<IfNotEmpty>(_json, QStringLiteral("key"), pod.key);
- addParam<IfNotEmpty>(_json, QStringLiteral("pattern"), pod.pattern);
- addParam<IfNotEmpty>(_json, QStringLiteral("is"), pod.is);
- return _json;
+ QJsonObject jo;
+ addParam<>(jo, QStringLiteral("kind"), pod.kind);
+ addParam<IfNotEmpty>(jo, QStringLiteral("key"), pod.key);
+ addParam<IfNotEmpty>(jo, QStringLiteral("pattern"), pod.pattern);
+ addParam<IfNotEmpty>(jo, QStringLiteral("is"), pod.is);
+ return jo;
}
-PushCondition FromJson<PushCondition>::operator()(const QJsonValue& jv)
+PushCondition FromJsonObject<PushCondition>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
PushCondition result;
result.kind =
- fromJson<QString>(_json.value("kind"_ls));
+ fromJson<QString>(jo.value("kind"_ls));
result.key =
- fromJson<QString>(_json.value("key"_ls));
+ fromJson<QString>(jo.value("key"_ls));
result.pattern =
- fromJson<QString>(_json.value("pattern"_ls));
+ fromJson<QString>(jo.value("pattern"_ls));
result.is =
- fromJson<QString>(_json.value("is"_ls));
-
+ fromJson<QString>(jo.value("is"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/push_condition.h b/lib/csapi/definitions/push_condition.h
index 99d7083c..defcebb3 100644
--- a/lib/csapi/definitions/push_condition.h
+++ b/lib/csapi/definitions/push_condition.h
@@ -31,9 +31,9 @@ namespace QMatrixClient
QJsonObject toJson(const PushCondition& pod);
- template <> struct FromJson<PushCondition>
+ template <> struct FromJsonObject<PushCondition>
{
- PushCondition operator()(const QJsonValue& jv);
+ PushCondition operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/push_rule.cpp b/lib/csapi/definitions/push_rule.cpp
index 833135ec..baddd187 100644
--- a/lib/csapi/definitions/push_rule.cpp
+++ b/lib/csapi/definitions/push_rule.cpp
@@ -8,33 +8,32 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const PushRule& pod)
{
- QJsonObject _json;
- addParam<>(_json, QStringLiteral("actions"), pod.actions);
- addParam<>(_json, QStringLiteral("default"), pod.isDefault);
- addParam<>(_json, QStringLiteral("enabled"), pod.enabled);
- addParam<>(_json, QStringLiteral("rule_id"), pod.ruleId);
- addParam<IfNotEmpty>(_json, QStringLiteral("conditions"), pod.conditions);
- addParam<IfNotEmpty>(_json, QStringLiteral("pattern"), pod.pattern);
- return _json;
+ QJsonObject jo;
+ addParam<>(jo, QStringLiteral("actions"), pod.actions);
+ addParam<>(jo, QStringLiteral("default"), pod.isDefault);
+ addParam<>(jo, QStringLiteral("enabled"), pod.enabled);
+ addParam<>(jo, QStringLiteral("rule_id"), pod.ruleId);
+ addParam<IfNotEmpty>(jo, QStringLiteral("conditions"), pod.conditions);
+ addParam<IfNotEmpty>(jo, QStringLiteral("pattern"), pod.pattern);
+ return jo;
}
-PushRule FromJson<PushRule>::operator()(const QJsonValue& jv)
+PushRule FromJsonObject<PushRule>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
PushRule result;
result.actions =
- fromJson<QVector<QVariant>>(_json.value("actions"_ls));
+ fromJson<QVector<QVariant>>(jo.value("actions"_ls));
result.isDefault =
- fromJson<bool>(_json.value("default"_ls));
+ fromJson<bool>(jo.value("default"_ls));
result.enabled =
- fromJson<bool>(_json.value("enabled"_ls));
+ fromJson<bool>(jo.value("enabled"_ls));
result.ruleId =
- fromJson<QString>(_json.value("rule_id"_ls));
+ fromJson<QString>(jo.value("rule_id"_ls));
result.conditions =
- fromJson<QVector<PushCondition>>(_json.value("conditions"_ls));
+ fromJson<QVector<PushCondition>>(jo.value("conditions"_ls));
result.pattern =
- fromJson<QString>(_json.value("pattern"_ls));
-
+ fromJson<QString>(jo.value("pattern"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/push_rule.h b/lib/csapi/definitions/push_rule.h
index c6542aa6..5f52876d 100644
--- a/lib/csapi/definitions/push_rule.h
+++ b/lib/csapi/definitions/push_rule.h
@@ -37,9 +37,9 @@ namespace QMatrixClient
QJsonObject toJson(const PushRule& pod);
- template <> struct FromJson<PushRule>
+ template <> struct FromJsonObject<PushRule>
{
- PushRule operator()(const QJsonValue& jv);
+ PushRule operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/push_ruleset.cpp b/lib/csapi/definitions/push_ruleset.cpp
index c424f686..14b7a4b6 100644
--- a/lib/csapi/definitions/push_ruleset.cpp
+++ b/lib/csapi/definitions/push_ruleset.cpp
@@ -8,30 +8,29 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const PushRuleset& pod)
{
- QJsonObject _json;
- addParam<IfNotEmpty>(_json, QStringLiteral("content"), pod.content);
- addParam<IfNotEmpty>(_json, QStringLiteral("override"), pod.override);
- addParam<IfNotEmpty>(_json, QStringLiteral("room"), pod.room);
- addParam<IfNotEmpty>(_json, QStringLiteral("sender"), pod.sender);
- addParam<IfNotEmpty>(_json, QStringLiteral("underride"), pod.underride);
- return _json;
+ QJsonObject jo;
+ addParam<IfNotEmpty>(jo, QStringLiteral("content"), pod.content);
+ addParam<IfNotEmpty>(jo, QStringLiteral("override"), pod.override);
+ addParam<IfNotEmpty>(jo, QStringLiteral("room"), pod.room);
+ addParam<IfNotEmpty>(jo, QStringLiteral("sender"), pod.sender);
+ addParam<IfNotEmpty>(jo, QStringLiteral("underride"), pod.underride);
+ return jo;
}
-PushRuleset FromJson<PushRuleset>::operator()(const QJsonValue& jv)
+PushRuleset FromJsonObject<PushRuleset>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
PushRuleset result;
result.content =
- fromJson<QVector<PushRule>>(_json.value("content"_ls));
+ fromJson<QVector<PushRule>>(jo.value("content"_ls));
result.override =
- fromJson<QVector<PushRule>>(_json.value("override"_ls));
+ fromJson<QVector<PushRule>>(jo.value("override"_ls));
result.room =
- fromJson<QVector<PushRule>>(_json.value("room"_ls));
+ fromJson<QVector<PushRule>>(jo.value("room"_ls));
result.sender =
- fromJson<QVector<PushRule>>(_json.value("sender"_ls));
+ fromJson<QVector<PushRule>>(jo.value("sender"_ls));
result.underride =
- fromJson<QVector<PushRule>>(_json.value("underride"_ls));
-
+ fromJson<QVector<PushRule>>(jo.value("underride"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/push_ruleset.h b/lib/csapi/definitions/push_ruleset.h
index a5e9ff2c..a274b72a 100644
--- a/lib/csapi/definitions/push_ruleset.h
+++ b/lib/csapi/definitions/push_ruleset.h
@@ -25,9 +25,9 @@ namespace QMatrixClient
QJsonObject toJson(const PushRuleset& pod);
- template <> struct FromJson<PushRuleset>
+ template <> struct FromJsonObject<PushRuleset>
{
- PushRuleset operator()(const QJsonValue& jv);
+ PushRuleset operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/room_event_filter.cpp b/lib/csapi/definitions/room_event_filter.cpp
index 18ce07ec..f6f1e5cb 100644
--- a/lib/csapi/definitions/room_event_filter.cpp
+++ b/lib/csapi/definitions/room_event_filter.cpp
@@ -8,24 +8,23 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const RoomEventFilter& pod)
{
- QJsonObject _json;
- addParam<IfNotEmpty>(_json, QStringLiteral("not_rooms"), pod.notRooms);
- addParam<IfNotEmpty>(_json, QStringLiteral("rooms"), pod.rooms);
- addParam<IfNotEmpty>(_json, QStringLiteral("contains_url"), pod.containsUrl);
- return _json;
+ QJsonObject jo;
+ addParam<IfNotEmpty>(jo, QStringLiteral("not_rooms"), pod.notRooms);
+ addParam<IfNotEmpty>(jo, QStringLiteral("rooms"), pod.rooms);
+ addParam<IfNotEmpty>(jo, QStringLiteral("contains_url"), pod.containsUrl);
+ return jo;
}
-RoomEventFilter FromJson<RoomEventFilter>::operator()(const QJsonValue& jv)
+RoomEventFilter FromJsonObject<RoomEventFilter>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
RoomEventFilter result;
result.notRooms =
- fromJson<QStringList>(_json.value("not_rooms"_ls));
+ fromJson<QStringList>(jo.value("not_rooms"_ls));
result.rooms =
- fromJson<QStringList>(_json.value("rooms"_ls));
+ fromJson<QStringList>(jo.value("rooms"_ls));
result.containsUrl =
- fromJson<bool>(_json.value("contains_url"_ls));
-
+ fromJson<bool>(jo.value("contains_url"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/room_event_filter.h b/lib/csapi/definitions/room_event_filter.h
index 3252af30..1e8d644e 100644
--- a/lib/csapi/definitions/room_event_filter.h
+++ b/lib/csapi/definitions/room_event_filter.h
@@ -25,9 +25,9 @@ namespace QMatrixClient
QJsonObject toJson(const RoomEventFilter& pod);
- template <> struct FromJson<RoomEventFilter>
+ template <> struct FromJsonObject<RoomEventFilter>
{
- RoomEventFilter operator()(const QJsonValue& jv);
+ RoomEventFilter operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/sync_filter.cpp b/lib/csapi/definitions/sync_filter.cpp
index b42f15f5..984e99ae 100644
--- a/lib/csapi/definitions/sync_filter.cpp
+++ b/lib/csapi/definitions/sync_filter.cpp
@@ -8,65 +8,63 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const RoomFilter& pod)
{
- QJsonObject _json;
- addParam<IfNotEmpty>(_json, QStringLiteral("not_rooms"), pod.notRooms);
- addParam<IfNotEmpty>(_json, QStringLiteral("rooms"), pod.rooms);
- addParam<IfNotEmpty>(_json, QStringLiteral("ephemeral"), pod.ephemeral);
- addParam<IfNotEmpty>(_json, QStringLiteral("include_leave"), pod.includeLeave);
- addParam<IfNotEmpty>(_json, QStringLiteral("state"), pod.state);
- addParam<IfNotEmpty>(_json, QStringLiteral("timeline"), pod.timeline);
- addParam<IfNotEmpty>(_json, QStringLiteral("account_data"), pod.accountData);
- return _json;
+ QJsonObject jo;
+ addParam<IfNotEmpty>(jo, QStringLiteral("not_rooms"), pod.notRooms);
+ addParam<IfNotEmpty>(jo, QStringLiteral("rooms"), pod.rooms);
+ addParam<IfNotEmpty>(jo, QStringLiteral("ephemeral"), pod.ephemeral);
+ addParam<IfNotEmpty>(jo, QStringLiteral("include_leave"), pod.includeLeave);
+ addParam<IfNotEmpty>(jo, QStringLiteral("state"), pod.state);
+ addParam<IfNotEmpty>(jo, QStringLiteral("timeline"), pod.timeline);
+ addParam<IfNotEmpty>(jo, QStringLiteral("account_data"), pod.accountData);
+ return jo;
}
-RoomFilter FromJson<RoomFilter>::operator()(const QJsonValue& jv)
+RoomFilter FromJsonObject<RoomFilter>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
RoomFilter result;
result.notRooms =
- fromJson<QStringList>(_json.value("not_rooms"_ls));
+ fromJson<QStringList>(jo.value("not_rooms"_ls));
result.rooms =
- fromJson<QStringList>(_json.value("rooms"_ls));
+ fromJson<QStringList>(jo.value("rooms"_ls));
result.ephemeral =
- fromJson<RoomEventFilter>(_json.value("ephemeral"_ls));
+ fromJson<RoomEventFilter>(jo.value("ephemeral"_ls));
result.includeLeave =
- fromJson<bool>(_json.value("include_leave"_ls));
+ fromJson<bool>(jo.value("include_leave"_ls));
result.state =
- fromJson<RoomEventFilter>(_json.value("state"_ls));
+ fromJson<RoomEventFilter>(jo.value("state"_ls));
result.timeline =
- fromJson<RoomEventFilter>(_json.value("timeline"_ls));
+ fromJson<RoomEventFilter>(jo.value("timeline"_ls));
result.accountData =
- fromJson<RoomEventFilter>(_json.value("account_data"_ls));
-
+ fromJson<RoomEventFilter>(jo.value("account_data"_ls));
+
return result;
}
QJsonObject QMatrixClient::toJson(const SyncFilter& pod)
{
- QJsonObject _json;
- addParam<IfNotEmpty>(_json, QStringLiteral("event_fields"), pod.eventFields);
- addParam<IfNotEmpty>(_json, QStringLiteral("event_format"), pod.eventFormat);
- addParam<IfNotEmpty>(_json, QStringLiteral("presence"), pod.presence);
- addParam<IfNotEmpty>(_json, QStringLiteral("account_data"), pod.accountData);
- addParam<IfNotEmpty>(_json, QStringLiteral("room"), pod.room);
- return _json;
+ QJsonObject jo;
+ addParam<IfNotEmpty>(jo, QStringLiteral("event_fields"), pod.eventFields);
+ addParam<IfNotEmpty>(jo, QStringLiteral("event_format"), pod.eventFormat);
+ addParam<IfNotEmpty>(jo, QStringLiteral("presence"), pod.presence);
+ addParam<IfNotEmpty>(jo, QStringLiteral("account_data"), pod.accountData);
+ addParam<IfNotEmpty>(jo, QStringLiteral("room"), pod.room);
+ return jo;
}
-SyncFilter FromJson<SyncFilter>::operator()(const QJsonValue& jv)
+SyncFilter FromJsonObject<SyncFilter>::operator()(const QJsonObject& jo) const
{
- const auto& _json = jv.toObject();
SyncFilter result;
result.eventFields =
- fromJson<QStringList>(_json.value("event_fields"_ls));
+ fromJson<QStringList>(jo.value("event_fields"_ls));
result.eventFormat =
- fromJson<QString>(_json.value("event_format"_ls));
+ fromJson<QString>(jo.value("event_format"_ls));
result.presence =
- fromJson<Filter>(_json.value("presence"_ls));
+ fromJson<Filter>(jo.value("presence"_ls));
result.accountData =
- fromJson<Filter>(_json.value("account_data"_ls));
+ fromJson<Filter>(jo.value("account_data"_ls));
result.room =
- fromJson<RoomFilter>(_json.value("room"_ls));
-
+ fromJson<RoomFilter>(jo.value("room"_ls));
+
return result;
}
diff --git a/lib/csapi/definitions/sync_filter.h b/lib/csapi/definitions/sync_filter.h
index 7f48f02c..47b5fcdb 100644
--- a/lib/csapi/definitions/sync_filter.h
+++ b/lib/csapi/definitions/sync_filter.h
@@ -35,9 +35,9 @@ namespace QMatrixClient
QJsonObject toJson(const RoomFilter& pod);
- template <> struct FromJson<RoomFilter>
+ template <> struct FromJsonObject<RoomFilter>
{
- RoomFilter operator()(const QJsonValue& jv);
+ RoomFilter operator()(const QJsonObject& jo) const;
};
struct SyncFilter
@@ -56,9 +56,9 @@ namespace QMatrixClient
QJsonObject toJson(const SyncFilter& pod);
- template <> struct FromJson<SyncFilter>
+ template <> struct FromJsonObject<SyncFilter>
{
- SyncFilter operator()(const QJsonValue& jv);
+ SyncFilter operator()(const QJsonObject& jo) const;
};
} // namespace QMatrixClient
diff --git a/lib/csapi/definitions/user_identifier.cpp b/lib/csapi/definitions/user_identifier.cpp
index 3d3acaba..80a6d450 100644
--- a/lib/csapi/definitions/user_identifier.cpp
+++ b/lib/csapi/definitions/user_identifier.cpp
@@ -8,19 +8,18 @@ using namespace QMatrixClient;
QJsonObject QMatrixClient::toJson(const UserIdentifier& pod)
{
- QJsonObject _json = toJson(pod.additionalProperties);
- addParam<>(_json, QStringLiteral("type"), pod.type);
- return _json;
+ QJsonObject jo = toJson(pod.additionalProperties);
+ addParam<>(jo, QStringLiteral("type"), pod.type);
+ return jo;
}
-UserIdentifier FromJson<UserIdentifier>::operator()(const QJsonValue& jv)
+UserIdentifier FromJsonObject<UserIdentifier>::operator()(QJsonObject jo) const
{
- auto _json = jv.toObject();
UserIdentifier result;
result.type =
- fromJson<QString>(_json.take("type"_ls));
-
- result.additionalProperties = fromJson<QVariantHash>(_json);
+ fromJson<QString>(jo.take("type"_ls));
+
+ result.additionalProperties = fromJson<QVariantHash>(jo);
return result;
}
diff --git a/lib/csapi/definitions/user_identifier.h b/lib/csapi/definitions/user_identifier.h
index edc254d3..42614436 100644
--- a/lib/csapi/definitions/user_identifier.h
+++ b/lib/csapi/definitions/user_identifier.h
@@ -23,9 +23,9 @@ namespace QMatrixClient
QJsonObject toJson(const UserIdentifier& pod);
- template <> struct FromJson<UserIdentifier>
+ template <> struct FromJsonObject<UserIdentifier>
{
- UserIdentifier operator()(const QJsonValue& jv);
+ UserIdentifier operator()(QJsonObject jo) const;
};
} // namespace QMatrixClient