From 0cef7116e8ceb5aa4863b528bb1473a60294d07d Mon Sep 17 00:00:00 2001 From: Lars Mikkelsen Date: Mon, 7 Dec 2015 16:38:37 -0500 Subject: [PATCH] Replace #import with #include in the Qt5 generator The SWGHelpers.cpp file uses non-standard #import statements. This causes the following error when built using Visual Studio 2013: SWGHelpers.cpp(4): fatal error C1083: Cannot open type library file: 'c:\qt\qt5.5.1\5.5\msvc2013_64\include\qtcore\qdebug': Error loading type library/DLL. --- .../resources/qt5cpp/helpers-body.mustache | 6 ++-- .../petstore/qt5cpp/client/SWGHelpers.cpp | 32 +++++++++++++++++-- .../client/petstore/qt5cpp/client/SWGPet.h | 6 ++-- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache index 7bd9b3f46cc..6b439996724 100644 --- a/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache +++ b/modules/swagger-codegen/src/main/resources/qt5cpp/helpers-body.mustache @@ -1,9 +1,9 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" -#import -#import -#import +#include +#include +#include namespace Swagger { diff --git a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp index 7f4d748c2dc..6b439996724 100644 --- a/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp +++ b/samples/client/petstore/qt5cpp/client/SWGHelpers.cpp @@ -1,9 +1,9 @@ #include "SWGHelpers.h" #include "SWGModelFactory.h" #include "SWGObject.h" -#import -#import -#import +#include +#include +#include namespace Swagger { @@ -25,6 +25,14 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { qint64 *val = static_cast(value); *val = obj.toVariant().toLongLong(); } + else if(QStringLiteral("float").compare(type) == 0) { + float *val = static_cast(value); + *val = obj.toDouble(); + } + else if(QStringLiteral("double").compare(type) == 0) { + double *val = static_cast(value); + *val = obj.toDouble(); + } else if (QStringLiteral("QString").compare(type) == 0) { QString **val = static_cast(value); @@ -86,6 +94,16 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) { setValue(&val, jval, QStringLiteral("bool"), QStringLiteral("")); output->append((void*)&val); } + else if(QStringLiteral("float").compare(complexType) == 0) { + float val; + setValue(&val, jval, QStringLiteral("float"), QStringLiteral("")); + output->append((void*)&val); + } + else if(QStringLiteral("double").compare(complexType) == 0) { + double val; + setValue(&val, jval, QStringLiteral("double"), QStringLiteral("")); + output->append((void*)&val); + } } } QList **val = static_cast**>(value); @@ -131,6 +149,14 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) { bool* str = static_cast(value); output->insert(name, QJsonValue(*str)); } + else if(QStringLiteral("float").compare(type) == 0) { + float* str = static_cast(value); + output->insert(name, QJsonValue((double)*str)); + } + else if(QStringLiteral("double").compare(type) == 0) { + double* str = static_cast(value); + output->insert(name, QJsonValue(*str)); + } } void diff --git a/samples/client/petstore/qt5cpp/client/SWGPet.h b/samples/client/petstore/qt5cpp/client/SWGPet.h index e9cb4d08233..3f9320f1507 100644 --- a/samples/client/petstore/qt5cpp/client/SWGPet.h +++ b/samples/client/petstore/qt5cpp/client/SWGPet.h @@ -10,10 +10,10 @@ #include -#include "SWGTag.h" -#include -#include "SWGCategory.h" #include +#include "SWGCategory.h" +#include +#include "SWGTag.h" #include "SWGObject.h"