diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-05 19:47:45 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-01-05 19:55:49 +0900 |
commit | ea5cd86a9deacc9a6b57f1c432ad6e51e92de428 (patch) | |
tree | 0825fafcf811b910f3deeea14f537dc1bf2f1af4 | |
parent | 859a0c70353d9c92fbc02c9d5aa467bf9c28e9e6 (diff) | |
download | libquotient-ea5cd86a9deacc9a6b57f1c432ad6e51e92de428.tar.gz libquotient-ea5cd86a9deacc9a6b57f1c432ad6e51e92de428.zip |
jobs/generated: Convert numbers to string in a way that actually works
Plus a bit of fooling around with linebreaks.
-rw-r--r-- | jobs/gtad.yaml | 1 | ||||
-rw-r--r-- | 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: <kitsune-ral@users.sf.net> 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}} |