diff options
Diffstat (limited to 'jobs/{{base}}.cpp.mustache')
-rw-r--r-- | jobs/{{base}}.cpp.mustache | 63 |
1 files changed, 25 insertions, 38 deletions
diff --git a/jobs/{{base}}.cpp.mustache b/jobs/{{base}}.cpp.mustache index c9b0eb5e..0d01e6dd 100644 --- a/jobs/{{base}}.cpp.mustache +++ b/jobs/{{base}}.cpp.mustache @@ -1,76 +1,63 @@ {{#@filePartial}}preamble{{/@filePartial}} #include "{{filenameBase}}.h" - {{#operations}} #include "../converters.h" #include <QtCore/QStringBuilder> using namespace QMatrixClient; - - {{#returns?}} +{{# returns?}} class {{#@cap}}{{operationId}}{{/@cap}}Job::Private { public: - {{#returns}} - {{type}} {{name}}; - {{/returns}} + {{#returns}}{{type}} {{name}};{{/returns}} }; - {{/returns?}} - +{{/ returns?}} static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); - - {{#operation}} -{{#@cap}}{{operationId}}{{/@cap}}Job::{{#@cap}}{{operationId}}{{/@cap}}Job(const ConnectionData* connection{{#allParams}}, {{!}} - {{#avoidCopy?}}const {{dataType}}&{{/avoidCopy?}}{{^avoidCopy?}}{{dataType}}{{/avoidCopy?}} {{paramName}} - {{/allParams}}) - : BaseJob(connection, HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{#@cap}}{{operationId}}{{/@cap}}Job" - , basePath{{#pathParts}} % {{part}}{{/pathParts}} - , Query { {{#queryParams}} - { "{{baseName}}", toJson({{paramName}}).toString() }{{#hasMore}}, {{/hasMore}} - {{/queryParams}} } - , Data { {{#bodyParams}} - { "{{baseName}}", toJson({{paramName}}) }{{#hasMore}}, {{/hasMore}} - {{/bodyParams}} } - {{#skipAuth}}, false{{/skipAuth}} +{{# operation}} +{{#@cap}}{{operationId}}{{/@cap}}Job::{{#@cap}}{{operationId}}{{/@cap}}Job({{#allParams}}{{#avoidCopy?}}const {{dataType}}&{{/avoidCopy?}}{{^avoidCopy?}}{{dataType}}{{/avoidCopy?}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + : BaseJob(HttpVerb::{{#@cap}}{{#@tolower}}{{httpMethod}}{{/@tolower}}{{/@cap}}, "{{#@cap}}{{operationId}}{{/@cap}}Job", + basePath{{#pathParts}} % {{part}}{{/pathParts}}, + Query {{^queryParams}}{ }{{/queryParams}}{{#queryParams?}}{ + {{#queryParams}}{ "{{baseName}}", toJson({{paramName}}).toString() }{{#hasMore}}, + {{/hasMore}}{{/queryParams}} + }{{/queryParams?}}, + Data {{^bodyParams}}{ }{{/bodyParams}}{{#bodyParams?}}{ + {{#bodyParams}}{ "{{baseName}}", toJson({{paramName}}) }{{#hasMore}}, + {{/hasMore}}{{/bodyParams}} + }{{/bodyParams?}}{{#skipAuth}}, false{{/skipAuth}} ){{#returns?}}, d(new Private){{/returns?}} { } - {{/operation}} - - {{#returns?}} +{{/ operation}} +{{# returns?}} {{className}}Job::~{{className}}Job() { delete d; } - - {{#returns}} +{{# returns}} {{type}} {{className}}Job::{{name}}() const { return d->{{name}}; } - {{/returns}} - - {{#returnFile?}} +{{/ returns}} +{{# returnFile?}} BaseJob::Status {{className}}Job::parseReply(QByteArray data) { {{#returns}}{{name}}{{/returns}} = data; return Success; } - {{/returnFile?}} - {{^returnFile?}} +{{/ returnFile?}}{{^returnFile?}} BaseJob::Status {{className}}Job::parseJson(const QJsonDocument& data) { auto json = data.object(); {{#returns}} - {{#required?}} - if (!json.contains("{{name}}") - return { JsonParseError, "{{name}} not found in the response" }; - {{/required?}} + {{#required?}}if (!json.contains("{{name}}") + return { JsonParseError, "{{name}} not found in the response" };{{/required?}} d->{{name}} = fromJson<{{type}}>(json.value("{{name}}")); {{/returns}} return Success; } - {{/returnFile?}} - {{/returns?}} +{{/ returnFile?}} +{{/ returns?}} {{/operations}} |