aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/create_room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-14 23:32:16 +0900
committerGitHub <noreply@github.com>2018-12-14 23:32:16 +0900
commitfcc8d2ca615fce6e42bf1cf6585d60f94a2db926 (patch)
treeb0dd17b632a5c5775f2221fd0b53b21a8c02ce58 /lib/csapi/create_room.cpp
parent50571a92b4e9f634c4daf546222fa082120db6c7 (diff)
parent12a0b95fdcfea15cd0ef313aec8868656629b986 (diff)
downloadlibquotient-fcc8d2ca615fce6e42bf1cf6585d60f94a2db926.tar.gz
libquotient-fcc8d2ca615fce6e42bf1cf6585d60f94a2db926.zip
Merge pull request #263 from QMatrixClient/kitsune-lazy-loading
Lazy loading members
Diffstat (limited to 'lib/csapi/create_room.cpp')
-rw-r--r--lib/csapi/create_room.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/lib/csapi/create_room.cpp b/lib/csapi/create_room.cpp
index 36f83727..448547ae 100644
--- a/lib/csapi/create_room.cpp
+++ b/lib/csapi/create_room.cpp
@@ -16,23 +16,25 @@ namespace QMatrixClient
{
// Converters
- QJsonObject toJson(const CreateRoomJob::Invite3pid& pod)
+ template <> struct JsonObjectConverter<CreateRoomJob::Invite3pid>
{
- QJsonObject jo;
- addParam<>(jo, QStringLiteral("id_server"), pod.idServer);
- addParam<>(jo, QStringLiteral("medium"), pod.medium);
- addParam<>(jo, QStringLiteral("address"), pod.address);
- return jo;
- }
+ static void dumpTo(QJsonObject& jo, const CreateRoomJob::Invite3pid& pod)
+ {
+ addParam<>(jo, QStringLiteral("id_server"), pod.idServer);
+ addParam<>(jo, QStringLiteral("medium"), pod.medium);
+ addParam<>(jo, QStringLiteral("address"), pod.address);
+ }
+ };
- QJsonObject toJson(const CreateRoomJob::StateEvent& pod)
+ template <> struct JsonObjectConverter<CreateRoomJob::StateEvent>
{
- QJsonObject jo;
- addParam<>(jo, QStringLiteral("type"), pod.type);
- addParam<IfNotEmpty>(jo, QStringLiteral("state_key"), pod.stateKey);
- addParam<>(jo, QStringLiteral("content"), pod.content);
- return jo;
- }
+ static void dumpTo(QJsonObject& jo, const CreateRoomJob::StateEvent& pod)
+ {
+ addParam<>(jo, QStringLiteral("type"), pod.type);
+ addParam<IfNotEmpty>(jo, QStringLiteral("state_key"), pod.stateKey);
+ addParam<>(jo, QStringLiteral("content"), pod.content);
+ }
+ };
} // namespace QMatrixClient
class CreateRoomJob::Private
@@ -43,7 +45,7 @@ class CreateRoomJob::Private
static const auto CreateRoomJobName = QStringLiteral("CreateRoomJob");
-CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, const QVector<Invite3pid>& invite3pid, const QString& roomVersion, const QJsonObject& creationContent, const QVector<StateEvent>& initialState, const QString& preset, bool isDirect, const QJsonObject& powerLevelContentOverride)
+CreateRoomJob::CreateRoomJob(const QString& visibility, const QString& roomAliasName, const QString& name, const QString& topic, const QStringList& invite, const QVector<Invite3pid>& invite3pid, const QString& roomVersion, const QJsonObject& creationContent, const QVector<StateEvent>& initialState, const QString& preset, Omittable<bool> isDirect, const QJsonObject& powerLevelContentOverride)
: BaseJob(HttpVerb::Post, CreateRoomJobName,
basePath % "/createRoom")
, d(new Private)
@@ -77,7 +79,7 @@ BaseJob::Status CreateRoomJob::parseJson(const QJsonDocument& data)
if (!json.contains("room_id"_ls))
return { JsonParseError,
"The key 'room_id' not found in the response" };
- d->roomId = fromJson<QString>(json.value("room_id"_ls));
+ fromJson(json.value("room_id"_ls), d->roomId);
return Success;
}