diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-06 21:19:55 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-12-07 12:53:00 +0900 |
commit | f7e210bc04bdb45b05f3c75237001b8e51198242 (patch) | |
tree | c97f3bf7655c508b74aeb391ec02dbd2d18da61f /jobs | |
parent | e74de57832f684244d7da82fa743b63d459bf488 (diff) | |
download | libquotient-f7e210bc04bdb45b05f3c75237001b8e51198242.tar.gz libquotient-f7e210bc04bdb45b05f3c75237001b8e51198242.zip |
Use new GTAD features: avoid copying of custom schemas; inline body where appropriate
Body inlining is needed in content-repo cases and also cases with freeform JSON in the body (such as the one of upcoming PostReceiptJob).
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/gtad.yaml | 2 | ||||
-rw-r--r-- | jobs/{{base}}.cpp.mustache | 9 | ||||
-rw-r--r-- | jobs/{{base}}.h.mustache | 4 |
3 files changed, 9 insertions, 6 deletions
diff --git a/jobs/gtad.yaml b/jobs/gtad.yaml index 5f370ac5..a19415a6 100644 --- a/jobs/gtad.yaml +++ b/jobs/gtad.yaml @@ -56,6 +56,8 @@ types: avoidCopy?: true imports: <QtCore/QVector> - //: { type: QJsonArray, "avoidCopy?": true, imports: <QtCore/QJsonArray> } + schema: + avoidCopy?: true #operations: diff --git a/jobs/{{base}}.cpp.mustache b/jobs/{{base}}.cpp.mustache index 84bb2bea..b303c053 100644 --- a/jobs/{{base}}.cpp.mustache +++ b/jobs/{{base}}.cpp.mustache @@ -28,7 +28,7 @@ using namespace QMatrixClient; {{/trivial?}}{{/models.model}}{{#operations}} static const auto basePath = QStringLiteral("{{basePathWithoutHost}}"); {{# operation}}{{#models.model}}{{^trivial?}} -{{qualifiedName}}::operator QJsonValue() const +{{qualifiedName}}::operator QJsonObject() const { QJsonObject o; {{#vars}}o.insert("{{baseName}}", toJson({{nameCamelCase}})); @@ -49,7 +49,7 @@ namespace QMatrixClient return result; } }; -} +} // namespace QMatrixClient {{/ trivial?}}{{/models.model}}{{#responses}}{{#normalResponse?}}{{#properties?}} class {{camelCaseOperationId}}Job::Private { @@ -67,10 +67,11 @@ class {{camelCaseOperationId}}Job::Private }{{/queryParams?}}{{#skipAuth}}, Data { }, false{{/skipAuth}} ){{#responses}}{{#normalResponse?}}{{#properties?}}, d(new Private){{/properties?}}{{/normalResponse?}}{{/responses}} {{#bodyParams?}}{ - Data _data;{{#bodyParams}} +{{#inlineBody}} setRequestData(Data({{paramName}}));{{/inlineBody}}{{! +}}{{^inlineBody}} QJsonObject _data;{{#bodyParams}} {{^required?}}{{#string?}} if (!{{paramName}}.isEmpty()) {{/string?}}{{/required?}} _data.insert("{{baseName}}", toJson({{paramName}}));{{/bodyParams}} - setRequestData(_data); + setRequestData(_data);{{/inlineBody}} }{{/bodyParams?}}{{^bodyParams?}}{ }{{/bodyParams?}} {{# responses}}{{#normalResponse?}}{{#properties?}} {{camelCaseOperationId}}Job::~{{camelCaseOperationId}}Job() diff --git a/jobs/{{base}}.h.mustache b/jobs/{{base}}.h.mustache index f7124f97..76ae4f51 100644 --- a/jobs/{{base}}.h.mustache +++ b/jobs/{{base}}.h.mustache @@ -18,7 +18,7 @@ namespace QMatrixClient { {{#vars}}{{dataType.name}} {{nameCamelCase}}; {{/vars}} - operator QJsonValue() const; + operator QJsonObject() const; }; template <> struct FromJson<{{name}}> @@ -39,7 +39,7 @@ namespace QMatrixClient { {{#vars}}{{dataType.name}} {{nameCamelCase}}; {{/vars}} - operator QJsonValue() const; + operator QJsonObject() const; }; {{/ trivial?}}{{/model}} // End of inner data structures |