aboutsummaryrefslogtreecommitdiff
path: root/lib/jobs/{{base}}.h.mustache
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-13 12:36:03 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-04-13 14:44:04 +0900
commitb68186efc5fcedad6980686c8a07bab3b47a874d (patch)
tree1aaf5de974996279ec7e82af199d65fc5a187a48 /lib/jobs/{{base}}.h.mustache
parent44764f015f25db307811f2969c117b37133fc676 (diff)
parent7ca442a432994a19a86d43c917a1f537bcebb387 (diff)
downloadlibquotient-b68186efc5fcedad6980686c8a07bab3b47a874d.tar.gz
libquotient-b68186efc5fcedad6980686c8a07bab3b47a874d.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'lib/jobs/{{base}}.h.mustache')
-rw-r--r--lib/jobs/{{base}}.h.mustache67
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/jobs/{{base}}.h.mustache b/lib/jobs/{{base}}.h.mustache
new file mode 100644
index 00000000..63aa53e7
--- /dev/null
+++ b/lib/jobs/{{base}}.h.mustache
@@ -0,0 +1,67 @@
+{{#@filePartial}}preamble{{/@filePartial}}
+#pragma once
+
+{{#operations}}#include "../basejob.h"
+{{/operations}}
+{{#imports}}#include {{_}}
+{{/imports}}
+{{#allModels}}#include "converters.h"
+{{/allModels}}
+namespace QMatrixClient
+{
+{{#models}} // Data structures
+{{# model}}{{#trivial?}}
+ using {{name}} = {{parent.name}};
+{{/ trivial?}}{{^trivial?}}
+ struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}{{dataType.name}} {{nameCamelCase}};
+ {{/vars}}
+ operator QJsonObject() const;
+ };
+
+ template <> struct FromJson<{{name}}>
+ {
+ {{name}} operator()(QJsonValue jv);
+ };
+{{/ trivial?}}{{/model}}
+{{/models}}{{#operations}} // Operations
+{{# operation}}
+ class {{camelCaseOperationId}}Job : public BaseJob
+ {
+ public:{{# models}}
+ // Inner data structures
+{{# model}}{{#trivial?}}
+ using {{name}} = {{parent.name}};
+{{/ trivial?}}{{^trivial?}}
+ struct {{name}}{{#parents?}} : {{#parents}}{{name}}{{#@join}}, {{/@join}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}{{dataType.name}} {{nameCamelCase}};
+ {{/vars}}
+ operator QJsonObject() const;
+ };
+{{/ trivial?}}{{/model}}
+ // End of inner data structures
+{{/models}}{{^bodyParams}}
+ /** Construct a URL out of baseUrl and usual parameters passed to
+ * {{camelCaseOperationId}}Job. This function can be used when
+ * a URL for {{camelCaseOperationId}}Job is necessary but the job
+ * itself isn't.
+ */
+ static QUrl makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDecl}}{{/allParams}}{{/allParams?}});
+{{/bodyParams}}
+ explicit {{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDecl}}{{/allParams}});{{!skip EOL
+}}{{# responses}}{{#normalResponse?}}{{#allProperties?}}
+ ~{{camelCaseOperationId}}Job() override;
+{{#allProperties}}
+ {{>maybeCrefType}} {{paramName}}() const;{{/allProperties}}
+
+ protected:
+ Status {{#producesNotJson?}}parseReply(QNetworkReply* reply){{/producesNotJson?}}{{^producesNotJson?}}parseJson(const QJsonDocument& data){{/producesNotJson?}} override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;{{/allProperties?}}{{/normalResponse?}}{{/responses}}
+ };
+{{/operation}}{{/operations}}{{!skip EOL
+}}} // namespace QMatrixClient