aboutsummaryrefslogtreecommitdiff
path: root/gtad/operation.h.mustache
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /gtad/operation.h.mustache
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'gtad/operation.h.mustache')
-rw-r--r--gtad/operation.h.mustache125
1 files changed, 125 insertions, 0 deletions
diff --git a/gtad/operation.h.mustache b/gtad/operation.h.mustache
new file mode 100644
index 00000000..36963b9a
--- /dev/null
+++ b/gtad/operation.h.mustache
@@ -0,0 +1,125 @@
+{{>preamble}}
+#pragma once
+
+#include "jobs/basejob.h"
+{{#imports}}
+#include {{_}}{{/imports}}
+{{#operations.producesNonJson?}}
+#include <QtNetwork/QNetworkReply>{{/operations.producesNonJson?}}
+
+namespace Quotient {
+{{#operations.operation}}
+
+/*!{{>docCommentSummary}}{{#description}}
+ * {{_}}{{/description}}
+ */
+class {{camelCaseOperationId}}Job : public BaseJob {
+public:
+ {{#models}}
+ // Inner data structures
+ {{#model}}
+
+ {{>docCommentShort}}
+ struct {{name}}{{#parents?}} :
+ {{#parents}}{{name}}{{>cjoin}}{{/parents}}{{/parents?}}
+ {
+ {{#vars}}
+ {{>docCommentShort}}
+ {{>maybeOmittableType}} {{nameCamelCase}};
+ {{/vars}}
+ {{#propertyMap}}
+ {{>docCommentShort}}
+ {{>maybeOmittableType}} {{nameCamelCase}};
+ {{/propertyMap}}
+ };
+ {{/model}}
+
+ // Construction/destruction
+
+ {{/models}}
+ {{#allParams?}}
+ /*!{{>docCommentSummary}}
+ {{#allParams}}
+ * \param {{nameCamelCase}}{{#description}}
+ * {{_}}{{/description}}{{#_join}}
+ * {{/_join}}
+ {{/allParams}}
+ */
+ {{/allParams?}}{{^allParams?}}
+ {{#summary}}
+ /// {{summary}}
+ {{/summary}}
+ {{/allParams?}}
+ explicit {{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDecl}}{{/allParams}});
+ {{^hasBody?}}
+
+ /*! \brief Construct a URL without creating a full-fledged job object
+ *
+ * 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?}});
+ {{/hasBody?}}
+ {{#responses}}{{#normalResponse?}}{{#allProperties?}}
+
+ // Result properties
+ {{#headers}}
+
+ {{>nonInlineResponseSignature}}
+ {
+ return reply()->rawHeader("{{baseName}}");
+ }
+ {{/headers}}{{#inlineResponse}}
+
+ {{>docCommentShort}}
+ {{dataType.name}} {{paramName}}()
+ {{^moveOnly}}{{^producesNonJson?}} const{{/producesNonJson?}}{{/moveOnly}}
+ {
+ return {{#producesNonJson?}}reply(){{/producesNonJson?}}
+ {{^producesNonJson?
+ }}fromJson<{{dataType.name}}>(jsonData()){{/producesNonJson?
+ }};
+ }
+ {{/inlineResponse}}{{#properties}}
+
+ {{!there's nothing in #properties if the response is inline}}
+ {{>nonInlineResponseSignature}}
+ {
+ return {{>takeOrLoad}}FromJson<{{>maybeOmittableType}}>("{{baseName}}"_ls);
+ }
+ {{/properties}}
+ {{/allProperties?}}{{/normalResponse?}}{{/responses}}
+};
+ {{#models.model}}
+
+template <> struct JsonObjectConverter<{{qualifiedName}}> {
+ {{#in?}}
+ static void dumpTo(QJsonObject& jo, const {{qualifiedName}}& pod)
+ { {{#propertyMap}}
+ fillJson(jo, pod.{{nameCamelCase}});
+ {{/propertyMap}}{{#parents}}
+ fillJson<{{name}}>(jo, pod);
+ {{/parents}}{{#vars}}
+ addParam<{{^required?}}IfNotEmpty{{/required?}}>(jo,
+ QStringLiteral("{{baseName}}"), pod.{{nameCamelCase}});
+ {{/vars}}
+ }
+ {{/in?}}
+ {{#out?}}
+ static void fillFrom({{>maybeCrefJsonObject}} jo, {{qualifiedName}}& result)
+ { {{#parents}}
+ fillFromJson<{{name}}{{!of the parent!}}>(jo, result);
+ {{/parents}}{{#vars}}
+ fromJson(jo.{{>takeOrValue}}("{{baseName}}"_ls),
+ result.{{nameCamelCase}});
+ {{/vars}}{{#propertyMap}}
+ fromJson(jo, result.{{nameCamelCase}});
+ {{/propertyMap}}
+ }
+ {{/out?}}
+};
+ {{/models.model}}
+{{/operations.operation}}
+
+} // namespace Quotient