From ea5cd86a9deacc9a6b57f1c432ad6e51e92de428 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 5 Jan 2018 19:47:45 +0900 Subject: jobs/generated: Convert numbers to string in a way that actually works Plus a bit of fooling around with linebreaks. --- jobs/gtad.yaml | 1 + jobs/{{base}}.cpp.mustache | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/jobs/gtad.yaml b/jobs/gtad.yaml index ad8dc80f..54f70cdb 100644 --- a/jobs/gtad.yaml +++ b/jobs/gtad.yaml @@ -73,6 +73,7 @@ env: maybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.name}}{{#avoidCopy?}}&{{/avoidCopy?}}" qualifiedMaybeCrefType: "{{#avoidCopy?}}const {{/avoidCopy?}}{{dataType.qualifiedName}}{{#avoidCopy?}}&{{/avoidCopy?}}" initializeDefaultValue: "{{#defaultValue}}{{>initializer}}{{/defaultValue}}{{^defaultValue}}{}{{/defaultValue}}" + paramToString: '{{#string?}}{{nameCamelCase}}{{/string?}}{{^string?}}QString("%1").arg({{nameCamelCase}}){{/string?}}' # preamble: preamble.mustache copyrightName: Kitsune Ral copyrightEmail: diff --git a/jobs/{{base}}.cpp.mustache b/jobs/{{base}}.cpp.mustache index 1461dec5..0726d523 100644 --- a/jobs/{{base}}.cpp.mustache +++ b/jobs/{{base}}.cpp.mustache @@ -59,23 +59,24 @@ class {{camelCaseOperationId}}Job::Private {{/ allProperties?}}{{/normalResponse?}}{{/responses}} {{camelCaseOperationId}}Job::{{camelCaseOperationId}}Job({{#allParams}}{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}{{/allParams}}) : BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{camelCaseOperationId}}Job", - basePath{{#pathParts}} % {{_}}{{/pathParts}}, - Query {{^queryParams}}{ }{{/queryParams}}{{#queryParams?}}{ - {{#queryParams}}{ "{{baseName}}", toJson({{paramName}}).toString() }{{#@join}}, - {{/@join}}{{/queryParams}} - }{{/queryParams?}}{{#skipAuth}}, Data { }, false{{/skipAuth}} - ){{#responses}}{{#normalResponse?}}{{#allProperties?}}, d(new Private){{/allProperties?}}{{/normalResponse?}}{{/responses}} -{{#bodyParams?}}{ + basePath{{#pathParts}} % {{_}}{{/pathParts}}{{#skipAuth}}, false{{/skipAuth}}){{#responses}}{{#normalResponse?}}{{#allProperties?}} + , d(new Private){{/allProperties?}}{{/normalResponse?}}{{/responses}} +{ {{#headerParams?}}{{#headerParams}} setRequestHeader("{{baseName}}", {{paramName}}.toLatin1()); {{/headerParams}} -{{/headerParams?}}{{#inlineBody}} setRequestData(Data({{paramName}}));{{/inlineBody}}{{! +{{/headerParams?}}{{! +}}{{#queryParams?}} QUrlQuery _q;{{#queryParams}} +{{^required?}}{{#string?}} if (!{{nameCamelCase}}.isEmpty()) + {{/string?}}{{/required?}} _q.addQueryItem("{{baseName}}", {{>paramToString}});{{/queryParams}} + setRequestQuery(_q); +{{/queryParams?}}{{#bodyParams?}}{{! +}}{{#inlineBody}} setRequestData(Data({{nameCamelCase}}));{{/inlineBody}}{{! }}{{^inlineBody}} QJsonObject _data;{{#bodyParams}} {{^required?}}{{#string?}} if (!{{paramName}}.isEmpty()) {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}} - setRequestData(_data);{{/inlineBody}}{{#produces?}} -{{#produces}} - addExpectedContentType("{{_}}");{{/produces}}{{/produces?}} -}{{/bodyParams?}}{{^bodyParams?}}{ }{{/bodyParams?}} + setRequestData(_data);{{/inlineBody}} +{{/bodyParams?}}{{#producesNotJson?}} setExpectedContentTypes({ {{#produces}}"{{_}}"{{#@join}}, {{/@join}}{{/produces}} }); +{{/producesNotJson?}}}{{!<- mind the actual brace}} {{# responses}}{{#normalResponse?}}{{#allProperties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() = default; {{# allProperties}} -- cgit v1.2.3