diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-03 20:14:19 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-05-03 21:22:37 +0900 |
commit | 37700bbf2df8b96c82a193c25764d9020b1140e9 (patch) | |
tree | 640701e5485dd83d43324d03d0f66f9c68e71242 /lib/jobs/{{base}}.cpp.mustache | |
parent | 1e42eca5c3d864750609eacd4996794c901c6c37 (diff) | |
download | libquotient-37700bbf2df8b96c82a193c25764d9020b1140e9.tar.gz libquotient-37700bbf2df8b96c82a193c25764d9020b1140e9.zip |
GTAD: Use QMatrixClient::Event-derived classes in generated jobs + Mustache cleanup
This should make generated jobs buildable across the whole CS API (sync.yaml is disabled as the manual implementation is still considerably better).
Diffstat (limited to 'lib/jobs/{{base}}.cpp.mustache')
-rw-r--r-- | lib/jobs/{{base}}.cpp.mustache | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/jobs/{{base}}.cpp.mustache b/lib/jobs/{{base}}.cpp.mustache index 1ca23799..d3726f1e 100644 --- a/lib/jobs/{{base}}.cpp.mustache +++ b/lib/jobs/{{base}}.cpp.mustache @@ -7,18 +7,15 @@ {{/producesNonJson?}}#include <QtCore/QStringBuilder> {{/operations}} using namespace QMatrixClient; -{{#models.model}}{{^trivial?}} -namespace QMatrixClient +{{#models.model}}{{#in?}} +QJsonObject QMatrixClient::toJson(const {{qualifiedName}}& pod) { - QJsonObject toJson(const {{qualifiedName}}& pod) - { - QJsonObject o; - {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); - {{/vars}} - return o; - } + QJsonObject o; +{{#vars}} o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); +{{/vars}} + return o; } - +{{/in?}}{{#out?}} {{qualifiedName}} FromJson<{{qualifiedName}}>::operator()(const QJsonValue& jv) { const auto& o = jv.toObject(); @@ -28,33 +25,35 @@ namespace QMatrixClient {{/vars}} return result; } -{{/trivial?}}{{/models.model}}{{#operations}} +{{/out?}}{{/models.model}}{{#operations}} static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); -{{# operation}}{{#models.model}}{{^trivial?}} +{{# operation}}{{#models}} namespace QMatrixClient { + // Converters +{{#model}}{{#in?}} QJsonObject toJson(const {{qualifiedName}}& pod) { QJsonObject o; - {{#vars}}o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); - {{/vars}} +{{#vars}} o.insert("{{baseName}}", toJson(pod.{{nameCamelCase}})); +{{/vars}} return o; } - +{{/in?}}{{#out?}} template <> struct FromJson<{{qualifiedName}}> { {{qualifiedName}} operator()(const QJsonValue& jv) { const auto& o = jv.toObject(); {{qualifiedName}} result; - {{#vars}}result.{{nameCamelCase}} = +{{#vars}} result.{{nameCamelCase}} = fromJson<{{dataType.qualifiedName}}>(o.value("{{baseName}}")); - {{/vars}} +{{/vars}} return result; } }; -} // namespace QMatrixClient -{{/ trivial?}}{{/models.model}}{{#responses}}{{#normalResponse?}}{{#allProperties?}} +{{/out?}}{{/model}}} // namespace QMatrixClient +{{/ models}}{{#responses}}{{#normalResponse?}}{{#allProperties?}} class {{camelCaseOperationId}}Job::Private { public:{{#allProperties}} @@ -99,9 +98,9 @@ QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{ {{# responses}}{{#normalResponse?}}{{#allProperties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default; {{# allProperties}} -{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}() const +{{>qualifiedMaybeCrefType}} {{camelCaseOperationId}}Job::{{paramName}}(){{^noCopy?}} const{{/noCopy?}} { - return d->{{paramName}}; + return {{#noCopy?}}std::move({{/noCopy?}}d->{{paramName}}{{#noCopy?}}){{/noCopy?}}; } {{/ allProperties}}{{#producesNonJson?}} BaseJob::Status {{camelCaseOperationId}}Job::parseReply(QNetworkReply* reply) |