aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jobs/gtad.yaml5
-rw-r--r--jobs/{{base}}.cpp.mustache29
-rw-r--r--jobs/{{base}}.h.mustache11
3 files changed, 34 insertions, 11 deletions
diff --git a/jobs/gtad.yaml b/jobs/gtad.yaml
index f79ce9b6..78c879e4 100644
--- a/jobs/gtad.yaml
+++ b/jobs/gtad.yaml
@@ -25,7 +25,7 @@ types:
number:
- float: float
- //: double
- boolean: bool
+ boolean: { type: bool, initializer: false }
string:
- byte: &ByteStream
type: QIODevice*
@@ -70,6 +70,9 @@ env:
maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}"
qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}"
initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}"
+ joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}'
+ joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}'
+ passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}'
paramToString: '{{#string?}}{{nameCamelCase}}{{/string?}}{{^string?}}QString("%1").arg({{nameCamelCase}}){{/string?}}'
# preamble: preamble.mustache
copyrightName: Kitsune Ral
diff --git a/jobs/{{base}}.cpp.mustache b/jobs/{{base}}.cpp.mustache
index 34e7faf3..b8532c51 100644
--- a/jobs/{{base}}.cpp.mustache
+++ b/jobs/{{base}}.cpp.mustache
@@ -56,20 +56,33 @@ class {{camelCaseOperationId}}Job::Private
public:{{#allProperties}}
{{dataType.name}} {{paramName}};{{/allProperties}}
};
-{{/ allProperties?}}{{/normalResponse?}}{{/responses}}
-{{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}{{/allParams}})
+{{/ allProperties?}}{{/normalResponse?}}{{/responses}}{{#queryParams?}}
+BaseJob::Query queryTo{{camelCaseOperationId}}({{#queryParams}}{{>joinedParamDef}}{{/queryParams}})
+{
+ BaseJob::Query _q;{{#queryParams}}
+{{^required?}}{{#string?}} if (!{{nameCamelCase}}.isEmpty())
+ {{/string?}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}}
+ return _q;
+}
+{{/queryParams?}}{{^bodyParams}}
+QUrl {{camelCaseOperationId}}Job::makeRequestUrl(QUrl baseUrl{{#allParams?}}, {{#allParams}}{{>joinedParamDef}}{{/allParams}}{{/allParams?}})
+{
+ return BaseJob::makeRequestUrl(baseUrl,
+ basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}},
+ queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}});
+}
+{{/ bodyParams}}
+{{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{>joinedParamDef}}{{/allParams}})
: BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{camelCaseOperationId}}Job",
- basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#skipAuth}}, false{{/skipAuth}}){{#responses}}{{#normalResponse?}}{{#allProperties?}}
+ basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#queryParams?}},
+ queryTo{{camelCaseOperationId}}({{>passQueryParams}}){{/queryParams?}}{{#skipAuth}}{{#queryParams?}},
+ {}{{/queryParams?}}, false{{/skipAuth}}){{#responses}}{{#normalResponse?}}{{#allProperties?}}
, d(new Private){{/allProperties?}}{{/normalResponse?}}{{/responses}}
{
{{#headerParams?}}{{#headerParams}} setRequestHeader("{{baseName}}", {{paramName}}.toLatin1());
{{/headerParams}}
{{/headerParams?}}{{!
-}}{{#queryParams?}} QUrlQuery _q;{{#queryParams}}
-{{^required?}}{{#string?}} if (!{{nameCamelCase}}.isEmpty())
- {{/string?}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}}
- setRequestQuery(_q);
-{{/queryParams?}}{{#bodyParams?}}{{!
+}}{{#bodyParams?}}{{!
}}{{#inlineBody}} setRequestData(Data({{nameCamelCase}}));{{/inlineBody}}{{!
}}{{^inlineBody}} QJsonObject _data;{{#bodyParams}}
{{^required?}}{{#string?}} if (!{{paramName}}.isEmpty())
diff --git a/jobs/{{base}}.h.mustache b/jobs/{{base}}.h.mustache
index 69e0e6d3..63aa53e7 100644
--- a/jobs/{{base}}.h.mustache
+++ b/jobs/{{base}}.h.mustache
@@ -42,8 +42,15 @@ namespace QMatrixClient
};
{{/ trivial?}}{{/model}}
// End of inner data structures
-{{/models}}
- explicit {{camelCaseOperationId}}Job({{#allParams}}{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}{{/allParams}});{{!skip EOL
+{{/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}}