From 4ced9792f27ed3d891c1f7772ae30d9fe452dd79 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 14 Apr 2018 14:12:03 +0900 Subject: jobs/generated: Overload toJson() instead of operator QJsonObject()/QJsonValue() It slightly reduces the header interface and shortcuts the actual call chain (not that it had any performance implications, just easier reasoning). --- lib/jobs/generated/administrative_contact.cpp | 36 ++++++++++++++------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'lib/jobs/generated/administrative_contact.cpp') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index 1af57941..78eb21fe 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -10,16 +10,17 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -GetAccount3PIDsJob::ThirdPartyIdentifier::operator QJsonObject() const -{ - QJsonObject o; - o.insert("medium", toJson(medium)); - o.insert("address", toJson(address)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const GetAccount3PIDsJob::ThirdPartyIdentifier& pod) + { + QJsonObject o; + o.insert("medium", toJson(pod.medium)); + o.insert("address", toJson(pod.address)); + + return o; + } + template <> struct FromJson { GetAccount3PIDsJob::ThirdPartyIdentifier operator()(QJsonValue jv) @@ -69,17 +70,18 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) return Success; } -Post3PIDsJob::ThreePidCredentials::operator QJsonObject() const -{ - QJsonObject o; - o.insert("client_secret", toJson(clientSecret)); - o.insert("id_server", toJson(idServer)); - o.insert("sid", toJson(sid)); - - return o; -} namespace QMatrixClient { + QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) + { + QJsonObject o; + o.insert("client_secret", toJson(pod.clientSecret)); + o.insert("id_server", toJson(pod.idServer)); + o.insert("sid", toJson(pod.sid)); + + return o; + } + template <> struct FromJson { Post3PIDsJob::ThreePidCredentials operator()(QJsonValue jv) -- cgit v1.2.3 From cbb7c2d7eff7ac8724d766ade2c3e659d15d97e2 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Mon, 30 Apr 2018 22:17:04 +0900 Subject: jobs/generated: cleanup C++ --- lib/jobs/generated/administrative_contact.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/jobs/generated/administrative_contact.cpp') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index 78eb21fe..fc75fd85 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -23,14 +23,14 @@ namespace QMatrixClient template <> struct FromJson { - GetAccount3PIDsJob::ThirdPartyIdentifier operator()(QJsonValue jv) + GetAccount3PIDsJob::ThirdPartyIdentifier operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); GetAccount3PIDsJob::ThirdPartyIdentifier result; result.medium = - fromJson(o.value("medium")); + fromJson(o.value("medium")); result.address = - fromJson(o.value("address")); + fromJson(o.value("address")); return result; } @@ -84,16 +84,16 @@ namespace QMatrixClient template <> struct FromJson { - Post3PIDsJob::ThreePidCredentials operator()(QJsonValue jv) + Post3PIDsJob::ThreePidCredentials operator()(const QJsonValue& jv) { - QJsonObject o = jv.toObject(); + const auto& o = jv.toObject(); Post3PIDsJob::ThreePidCredentials result; result.clientSecret = - fromJson(o.value("client_secret")); + fromJson(o.value("client_secret")); result.idServer = - fromJson(o.value("id_server")); + fromJson(o.value("id_server")); result.sid = - fromJson(o.value("sid")); + fromJson(o.value("sid")); return result; } -- cgit v1.2.3 From 38934c2310b426be640988dc10f48de88a3d92bc Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Tue, 1 May 2018 20:04:51 +0900 Subject: jobs/generated: use std::move in baseURL; type updates from the API files The type updates are a matter of pending PR to matrix-doc yet. --- lib/jobs/generated/administrative_contact.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/jobs/generated/administrative_contact.cpp') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index fc75fd85..b003c92d 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -45,7 +45,7 @@ class GetAccount3PIDsJob::Private QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/3pid"); } @@ -112,7 +112,7 @@ Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) QUrl RequestTokenTo3PIDJob::makeRequestUrl(QUrl baseUrl) { - return BaseJob::makeRequestUrl(baseUrl, + return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/account/3pid/email/requestToken"); } -- cgit v1.2.3 From f3927ca0c16a61fcb0933333ecff8095917a5b47 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 20:10:14 +0900 Subject: jobs/generated: Drop unused code --- lib/jobs/generated/administrative_contact.cpp | 32 +++++---------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'lib/jobs/generated/administrative_contact.cpp') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp index b003c92d..ec7c77c3 100644 --- a/lib/jobs/generated/administrative_contact.cpp +++ b/lib/jobs/generated/administrative_contact.cpp @@ -12,14 +12,7 @@ static const auto basePath = QStringLiteral("/_matrix/client/r0"); namespace QMatrixClient { - QJsonObject toJson(const GetAccount3PIDsJob::ThirdPartyIdentifier& pod) - { - QJsonObject o; - o.insert("medium", toJson(pod.medium)); - o.insert("address", toJson(pod.address)); - - return o; - } + // Converters template <> struct FromJson { @@ -31,7 +24,7 @@ namespace QMatrixClient fromJson(o.value("medium")); result.address = fromJson(o.value("address")); - + return result; } }; @@ -72,32 +65,17 @@ BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) namespace QMatrixClient { + // Converters + QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) { QJsonObject o; o.insert("client_secret", toJson(pod.clientSecret)); o.insert("id_server", toJson(pod.idServer)); o.insert("sid", toJson(pod.sid)); - + return o; } - - template <> struct FromJson - { - Post3PIDsJob::ThreePidCredentials operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - Post3PIDsJob::ThreePidCredentials result; - result.clientSecret = - fromJson(o.value("client_secret")); - result.idServer = - fromJson(o.value("id_server")); - result.sid = - fromJson(o.value("sid")); - - return result; - } - }; } // namespace QMatrixClient Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) -- cgit v1.2.3 From 49022915fde72b83d9f18944c268110b01fa3469 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 4 May 2018 23:04:04 +0900 Subject: New home for the generated code - lib/csapi --- lib/jobs/generated/administrative_contact.cpp | 102 -------------------------- 1 file changed, 102 deletions(-) delete mode 100644 lib/jobs/generated/administrative_contact.cpp (limited to 'lib/jobs/generated/administrative_contact.cpp') diff --git a/lib/jobs/generated/administrative_contact.cpp b/lib/jobs/generated/administrative_contact.cpp deleted file mode 100644 index ec7c77c3..00000000 --- a/lib/jobs/generated/administrative_contact.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN - */ - -#include "administrative_contact.h" - -#include - -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson - { - GetAccount3PIDsJob::ThirdPartyIdentifier operator()(const QJsonValue& jv) - { - const auto& o = jv.toObject(); - GetAccount3PIDsJob::ThirdPartyIdentifier result; - result.medium = - fromJson(o.value("medium")); - result.address = - fromJson(o.value("address")); - - return result; - } - }; -} // namespace QMatrixClient - -class GetAccount3PIDsJob::Private -{ - public: - QVector threepids; -}; - -QUrl GetAccount3PIDsJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/3pid"); -} - -GetAccount3PIDsJob::GetAccount3PIDsJob() - : BaseJob(HttpVerb::Get, "GetAccount3PIDsJob", - basePath % "/account/3pid") - , d(new Private) -{ -} - -GetAccount3PIDsJob::~GetAccount3PIDsJob() = default; - -const QVector& GetAccount3PIDsJob::threepids() const -{ - return d->threepids; -} - -BaseJob::Status GetAccount3PIDsJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - d->threepids = fromJson>(json.value("threepids")); - return Success; -} - -namespace QMatrixClient -{ - // Converters - - QJsonObject toJson(const Post3PIDsJob::ThreePidCredentials& pod) - { - QJsonObject o; - o.insert("client_secret", toJson(pod.clientSecret)); - o.insert("id_server", toJson(pod.idServer)); - o.insert("sid", toJson(pod.sid)); - - return o; - } -} // namespace QMatrixClient - -Post3PIDsJob::Post3PIDsJob(const ThreePidCredentials& threePidCreds, bool bind) - : BaseJob(HttpVerb::Post, "Post3PIDsJob", - basePath % "/account/3pid") -{ - QJsonObject _data; - _data.insert("three_pid_creds", toJson(threePidCreds)); - _data.insert("bind", toJson(bind)); - setRequestData(_data); -} - -QUrl RequestTokenTo3PIDJob::makeRequestUrl(QUrl baseUrl) -{ - return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/account/3pid/email/requestToken"); -} - -RequestTokenTo3PIDJob::RequestTokenTo3PIDJob() - : BaseJob(HttpVerb::Post, "RequestTokenTo3PIDJob", - basePath % "/account/3pid/email/requestToken", false) -{ -} - -- cgit v1.2.3