From 744c7d904a0d56a9554adf51f46b8b59f3efca6c Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 14 Nov 2017 23:28:06 +0800 Subject: [PATCH] remove spaces, empty lines from qt5cpp client (#6956) --- .../main/resources/qt5cpp/model-body.mustache | 51 ++++++++++++++----- .../resources/qt5cpp/model-header.mustache | 3 +- .../src/main/resources/qt5cpp/model.mustache | 8 +-- .../petstore/qt5cpp/client/SWGApiResponse.cpp | 5 -- .../petstore/qt5cpp/client/SWGApiResponse.h | 1 - .../petstore/qt5cpp/client/SWGCategory.cpp | 3 -- .../petstore/qt5cpp/client/SWGCategory.h | 1 - .../petstore/qt5cpp/client/SWGOrder.cpp | 8 --- .../client/petstore/qt5cpp/client/SWGOrder.h | 1 - .../client/petstore/qt5cpp/client/SWGPet.cpp | 15 ------ .../client/petstore/qt5cpp/client/SWGPet.h | 1 - .../client/petstore/qt5cpp/client/SWGTag.cpp | 3 -- .../client/petstore/qt5cpp/client/SWGTag.h | 1 - .../client/petstore/qt5cpp/client/SWGUser.cpp | 14 ----- .../client/petstore/qt5cpp/client/SWGUser.h | 1 - 15 files changed, 46 insertions(+), 70 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache index 7fa52b6bde1..896c53a75ed 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model-body.mustache @@ -35,7 +35,8 @@ void void {{classname}}::cleanup() { - {{#vars}}{{#complexType}} + {{#vars}} + {{#complexType}} if({{name}} != nullptr) { {{#isContainer}}{{#isListContainer}}QList<{{complexType}}*>* arr = {{name}};{{/isListContainer}}{{#isMapContainer}}QMap* arr = {{name}};{{/isMapContainer}} foreach({{complexType}}* o, *arr) { @@ -58,10 +59,16 @@ void void {{classname}}::fromJsonObject(QJsonObject &pJson) { {{#vars}} - {{^isContainer}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/isContainer}} + {{^isContainer}} + ::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}"); + {{/isContainer}} {{#isListContainer}} - {{#complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}");{{/complexType}} - {{^complexType}}::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}");{{/complexType}} + {{#complexType}} + ::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{complexType}}"); + {{/complexType}} + {{^complexType}} + ::{{cppNamespace}}::setValue(&{{name}}, pJson["{{baseName}}"], "{{baseType}}", "{{items.baseType}}"); + {{/complexType}} {{/isListContainer}} {{#isMapContainer}} if( pJson["{{baseName}}"].isObject()){ @@ -95,32 +102,52 @@ QString QJsonObject* {{classname}}::asJsonObject() { QJsonObject* obj = new QJsonObject(); - {{#vars}}{{#complexType}}{{^isContainer}}{{#complexType}} - toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}"));{{/complexType}}{{^complexType}} + {{#vars}} + {{#complexType}} + {{^isContainer}} + {{#complexType}} + toJsonValue(QString("{{baseName}}"), {{name}}, obj, QString("{{complexType}}")); + {{/complexType}} + {{^complexType}} if({{name}} != nullptr && *{{name}} != nullptr) { obj->insert("{{name}}", QJsonValue(*{{name}})); - }{{/complexType}}{{/isContainer}}{{#isListContainer}} + } + {{/complexType}} + {{/isContainer}} + {{#isListContainer}} QJsonArray {{name}}JsonArray; toJsonArray((QList*){{name}}, &{{name}}JsonArray, "{{name}}", "{{complexType}}"); - obj->insert("{{baseName}}", {{name}}JsonArray);{{/isListContainer}}{{#isMapContainer}} + obj->insert("{{baseName}}", {{name}}JsonArray); + {{/isListContainer}} + {{#isMapContainer}} QJsonArray {{name}}JsonArray; for(auto keyval : {{name}}->keys()){ QJsonObject {{name}}_jobj; toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{complexType}}"); {{name}}JsonArray.append({{name}}_jobj); } - obj->insert("{{baseName}}", {{name}}JsonArray);{{/isMapContainer}}{{/complexType}}{{^complexType}}{{^isContainer}} - obj->insert("{{baseName}}", QJsonValue({{name}}));{{/isContainer}}{{#isListContainer}} + obj->insert("{{baseName}}", {{name}}JsonArray); + {{/isMapContainer}} + {{/complexType}} + {{^complexType}} + {{^isContainer}} + obj->insert("{{baseName}}", QJsonValue({{name}})); + {{/isContainer}} + {{#isListContainer}} QJsonArray {{name}}JsonArray; toJsonArray((QList*){{name}}, &{{name}}JsonArray, "{{name}}", "{{items.baseType}}"); - obj->insert("{{baseName}}", {{name}}JsonArray);{{/isListContainer}}{{#isMapContainer}} + obj->insert("{{baseName}}", {{name}}JsonArray); + {{/isListContainer}} + {{#isMapContainer}} QJsonArray {{name}}JsonArray; for(auto keyval : {{name}}->keys()){ QJsonObject {{name}}_jobj; toJsonValue(keyval, ((*{{name}})[keyval]), &{{name}}_jobj, "{{items.baseType}}"); {{name}}JsonArray.append(portsobj); } - obj->insert("{{baseName}}", {{name}}JsonArray);{{/isMapContainer}}{{/complexType}} + obj->insert("{{baseName}}", {{name}}JsonArray); + {{/isMapContainer}} + {{/complexType}} {{/vars}} return obj; diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache index 0a55f3aab24..d2866f60e57 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model-header.mustache @@ -16,7 +16,8 @@ #include "SWGObject.h" -{{#models}}{{#model}} +{{#models}} +{{#model}} {{#cppNamespaceDeclarations}} namespace {{this}} { {{/cppNamespaceDeclarations}} diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache index 4d3590b8afe..80bf2842537 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/model.mustache @@ -21,7 +21,8 @@ using namespace Tizen::Web::Json; {{#imports}}{{{import}}} {{/imports}} -{{#models}}{{#model}} +{{#models}} +{{#model}} {{#cppNamespaceDeclarations}} namespace {{this}} { @@ -47,11 +48,12 @@ public: {{#vars}} {{datatype}} {{getter}}(); - void {{setter}}({{datatype}} {{name}}); + void {{setter}}({{{datatype}}} {{name}}); {{/vars}} private: - {{#vars}}{{datatype}} {{name}}; + {{#vars}} + {{{datatype}}} {{name}}; {{/vars}} }; diff --git a/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp b/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp index 8beb7e8187b..8835d53325b 100644 --- a/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGApiResponse.cpp @@ -44,12 +44,10 @@ SWGApiResponse::init() { void SWGApiResponse::cleanup() { - if(type != nullptr) { delete type; } - if(message != nullptr) { delete message; } @@ -84,11 +82,8 @@ SWGApiResponse::asJson () QJsonObject* SWGApiResponse::asJsonObject() { QJsonObject* obj = new QJsonObject(); - obj->insert("code", QJsonValue(code)); - toJsonValue(QString("type"), type, obj, QString("QString")); - toJsonValue(QString("message"), message, obj, QString("QString")); return obj; diff --git a/samples/client/petstore/qt5cpp/client/SWGApiResponse.h b/samples/client/petstore/qt5cpp/client/SWGApiResponse.h index 745c1fd6565..864cf964353 100644 --- a/samples/client/petstore/qt5cpp/client/SWGApiResponse.h +++ b/samples/client/petstore/qt5cpp/client/SWGApiResponse.h @@ -26,7 +26,6 @@ #include "SWGObject.h" - namespace Swagger { class SWGApiResponse: public SWGObject { diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp index 9e5c3ed75c3..916492f2f51 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.cpp @@ -43,7 +43,6 @@ SWGCategory::init() { void SWGCategory::cleanup() { - if(name != nullptr) { delete name; @@ -78,9 +77,7 @@ SWGCategory::asJson () QJsonObject* SWGCategory::asJsonObject() { QJsonObject* obj = new QJsonObject(); - obj->insert("id", QJsonValue(id)); - toJsonValue(QString("name"), name, obj, QString("QString")); return obj; diff --git a/samples/client/petstore/qt5cpp/client/SWGCategory.h b/samples/client/petstore/qt5cpp/client/SWGCategory.h index 229669eff8c..6b9fcb34773 100644 --- a/samples/client/petstore/qt5cpp/client/SWGCategory.h +++ b/samples/client/petstore/qt5cpp/client/SWGCategory.h @@ -26,7 +26,6 @@ #include "SWGObject.h" - namespace Swagger { class SWGCategory: public SWGObject { diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp index bf4f09d4647..8092e3cf428 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.cpp @@ -47,14 +47,12 @@ SWGOrder::init() { void SWGOrder::cleanup() { - if(ship_date != nullptr) { delete ship_date; } - if(status != nullptr) { delete status; } @@ -93,17 +91,11 @@ SWGOrder::asJson () QJsonObject* SWGOrder::asJsonObject() { QJsonObject* obj = new QJsonObject(); - obj->insert("id", QJsonValue(id)); - obj->insert("petId", QJsonValue(pet_id)); - obj->insert("quantity", QJsonValue(quantity)); - toJsonValue(QString("shipDate"), ship_date, obj, QString("QDateTime")); - toJsonValue(QString("status"), status, obj, QString("QString")); - obj->insert("complete", QJsonValue(complete)); return obj; diff --git a/samples/client/petstore/qt5cpp/client/SWGOrder.h b/samples/client/petstore/qt5cpp/client/SWGOrder.h index 13f1b205f0b..ef061bffe2e 100644 --- a/samples/client/petstore/qt5cpp/client/SWGOrder.h +++ b/samples/client/petstore/qt5cpp/client/SWGOrder.h @@ -27,7 +27,6 @@ #include "SWGObject.h" - namespace Swagger { class SWGOrder: public SWGObject { diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.cpp b/samples/client/petstore/qt5cpp/client/SWGPet.cpp index be6f08fbd4f..6c377a057b0 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGPet.cpp @@ -47,16 +47,13 @@ SWGPet::init() { void SWGPet::cleanup() { - if(category != nullptr) { delete category; } - if(name != nullptr) { delete name; } - if(photo_urls != nullptr) { QList* arr = photo_urls; foreach(QString* o, *arr) { @@ -64,7 +61,6 @@ SWGPet::cleanup() { } delete photo_urls; } - if(tags != nullptr) { QList* arr = tags; foreach(SWGTag* o, *arr) { @@ -72,7 +68,6 @@ SWGPet::cleanup() { } delete tags; } - if(status != nullptr) { delete status; } @@ -92,12 +87,8 @@ SWGPet::fromJsonObject(QJsonObject &pJson) { ::Swagger::setValue(&id, pJson["id"], "qint64", ""); ::Swagger::setValue(&category, pJson["category"], "SWGCategory", "SWGCategory"); ::Swagger::setValue(&name, pJson["name"], "QString", "QString"); - ::Swagger::setValue(&photo_urls, pJson["photoUrls"], "QList", "QString"); - - ::Swagger::setValue(&tags, pJson["tags"], "QList", "SWGTag"); - ::Swagger::setValue(&status, pJson["status"], "QString", "QString"); } @@ -114,21 +105,15 @@ SWGPet::asJson () QJsonObject* SWGPet::asJsonObject() { QJsonObject* obj = new QJsonObject(); - obj->insert("id", QJsonValue(id)); - toJsonValue(QString("category"), category, obj, QString("SWGCategory")); - toJsonValue(QString("name"), name, obj, QString("QString")); - QJsonArray photo_urlsJsonArray; toJsonArray((QList*)photo_urls, &photo_urlsJsonArray, "photo_urls", "QString"); obj->insert("photoUrls", photo_urlsJsonArray); - QJsonArray tagsJsonArray; toJsonArray((QList*)tags, &tagsJsonArray, "tags", "SWGTag"); obj->insert("tags", tagsJsonArray); - toJsonValue(QString("status"), status, obj, QString("QString")); return obj; diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.h b/samples/client/petstore/qt5cpp/client/SWGPet.h index 55142740d96..a3b58bceaf6 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.h +++ b/samples/client/petstore/qt5cpp/client/SWGPet.h @@ -29,7 +29,6 @@ #include "SWGObject.h" - namespace Swagger { class SWGPet: public SWGObject { diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.cpp b/samples/client/petstore/qt5cpp/client/SWGTag.cpp index 7a622a68be1..febee3a6a76 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGTag.cpp @@ -43,7 +43,6 @@ SWGTag::init() { void SWGTag::cleanup() { - if(name != nullptr) { delete name; @@ -78,9 +77,7 @@ SWGTag::asJson () QJsonObject* SWGTag::asJsonObject() { QJsonObject* obj = new QJsonObject(); - obj->insert("id", QJsonValue(id)); - toJsonValue(QString("name"), name, obj, QString("QString")); return obj; diff --git a/samples/client/petstore/qt5cpp/client/SWGTag.h b/samples/client/petstore/qt5cpp/client/SWGTag.h index d192718670d..ee562bc8665 100644 --- a/samples/client/petstore/qt5cpp/client/SWGTag.h +++ b/samples/client/petstore/qt5cpp/client/SWGTag.h @@ -26,7 +26,6 @@ #include "SWGObject.h" - namespace Swagger { class SWGTag: public SWGObject { diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.cpp b/samples/client/petstore/qt5cpp/client/SWGUser.cpp index 372ca77bf75..e915cd05a4a 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGUser.cpp @@ -49,28 +49,22 @@ SWGUser::init() { void SWGUser::cleanup() { - if(username != nullptr) { delete username; } - if(first_name != nullptr) { delete first_name; } - if(last_name != nullptr) { delete last_name; } - if(email != nullptr) { delete email; } - if(password != nullptr) { delete password; } - if(phone != nullptr) { delete phone; } @@ -111,21 +105,13 @@ SWGUser::asJson () QJsonObject* SWGUser::asJsonObject() { QJsonObject* obj = new QJsonObject(); - obj->insert("id", QJsonValue(id)); - toJsonValue(QString("username"), username, obj, QString("QString")); - toJsonValue(QString("firstName"), first_name, obj, QString("QString")); - toJsonValue(QString("lastName"), last_name, obj, QString("QString")); - toJsonValue(QString("email"), email, obj, QString("QString")); - toJsonValue(QString("password"), password, obj, QString("QString")); - toJsonValue(QString("phone"), phone, obj, QString("QString")); - obj->insert("userStatus", QJsonValue(user_status)); return obj; diff --git a/samples/client/petstore/qt5cpp/client/SWGUser.h b/samples/client/petstore/qt5cpp/client/SWGUser.h index 30a9ca5271b..bdd4e77a56a 100644 --- a/samples/client/petstore/qt5cpp/client/SWGUser.h +++ b/samples/client/petstore/qt5cpp/client/SWGUser.h @@ -26,7 +26,6 @@ #include "SWGObject.h" - namespace Swagger { class SWGUser: public SWGObject {