Skip to content

Commit

Permalink
[cpp-qt-client] Replace AnyType with QJsonValue (#12642)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrenninghoff committed Jun 25, 2022
1 parent 22ea4a6 commit c1b8780
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/generators/cpp-qt-client.md
Expand Up @@ -38,6 +38,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Type/Alias | Imports |
| ---------- | ------- |
|OAIHttpFileElement|#include "OAIHttpFileElement.h"|
|QJsonValue|#include <QJsonValue>|


## INSTANTIATION TYPES
Expand Down
Expand Up @@ -108,7 +108,9 @@ public CppQtClientCodegen() {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, "client.pri"));
}
typeMapping.put("file", PREFIX + "HttpFileElement");
typeMapping.put("AnyType", "QJsonValue");
importMapping.put(PREFIX + "HttpFileElement", "#include \"" + PREFIX + "HttpFileElement.h\"");
importMapping.put("QJsonValue", "#include <QJsonValue>");
}

@Override
Expand Down Expand Up @@ -140,7 +142,9 @@ public void processOpts() {


typeMapping.put("file", modelNamePrefix + "HttpFileElement");
typeMapping.put("AnyType", "QJsonValue");
importMapping.put(modelNamePrefix + "HttpFileElement", "#include \"" + modelNamePrefix + "HttpFileElement.h\"");
importMapping.put("QJsonValue", "#include <QJsonValue>");
if (optionalProjectFileFlag) {
supportingFiles.add(new SupportingFile("Project.mustache", sourceFolder, modelNamePrefix + "client.pri"));
}
Expand Down
Expand Up @@ -186,6 +186,10 @@ QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value) {
return value.asJsonValue();
}

QJsonValue toJsonValue(const QJsonValue &value) {
return value;
}

bool fromStringValue(const QString &inStr, QString &value) {
value.clear();
value.append(inStr);
Expand Down Expand Up @@ -415,6 +419,11 @@ bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval) {
return value.fromJsonValue(jval);
}

bool fromJsonValue(QJsonValue &value, const QJsonValue &jval) {
value = jval;
return true;
}

{{#cppNamespaceDeclarations}}
} // namespace {{this}}
{{/cppNamespaceDeclarations}}
Expand Up @@ -127,6 +127,7 @@ QJsonValue toJsonValue(const double &value);
QJsonValue toJsonValue(const {{prefix}}Object &value);
QJsonValue toJsonValue(const {{prefix}}Enum &value);
QJsonValue toJsonValue(const {{prefix}}HttpFileElement &value);
QJsonValue toJsonValue(const QJsonValue &value);

template <typename T>
QJsonValue toJsonValue(const QList<T> &val) {
Expand Down Expand Up @@ -213,6 +214,7 @@ bool fromJsonValue(double &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Object &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}Enum &value, const QJsonValue &jval);
bool fromJsonValue({{prefix}}HttpFileElement &value, const QJsonValue &jval);
bool fromJsonValue(QJsonValue &value, const QJsonValue &jval);

template <typename T>
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
Expand Down
9 changes: 9 additions & 0 deletions samples/client/petstore/cpp-qt/client/PFXHelpers.cpp
Expand Up @@ -194,6 +194,10 @@ QJsonValue toJsonValue(const PFXHttpFileElement &value) {
return value.asJsonValue();
}

QJsonValue toJsonValue(const QJsonValue &value) {
return value;
}

bool fromStringValue(const QString &inStr, QString &value) {
value.clear();
value.append(inStr);
Expand Down Expand Up @@ -423,4 +427,9 @@ bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval) {
return value.fromJsonValue(jval);
}

bool fromJsonValue(QJsonValue &value, const QJsonValue &jval) {
value = jval;
return true;
}

} // namespace test_namespace
2 changes: 2 additions & 0 deletions samples/client/petstore/cpp-qt/client/PFXHelpers.h
Expand Up @@ -135,6 +135,7 @@ QJsonValue toJsonValue(const double &value);
QJsonValue toJsonValue(const PFXObject &value);
QJsonValue toJsonValue(const PFXEnum &value);
QJsonValue toJsonValue(const PFXHttpFileElement &value);
QJsonValue toJsonValue(const QJsonValue &value);

template <typename T>
QJsonValue toJsonValue(const QList<T> &val) {
Expand Down Expand Up @@ -221,6 +222,7 @@ bool fromJsonValue(double &value, const QJsonValue &jval);
bool fromJsonValue(PFXObject &value, const QJsonValue &jval);
bool fromJsonValue(PFXEnum &value, const QJsonValue &jval);
bool fromJsonValue(PFXHttpFileElement &value, const QJsonValue &jval);
bool fromJsonValue(QJsonValue &value, const QJsonValue &jval);

template <typename T>
bool fromJsonValue(QList<T> &val, const QJsonValue &jval) {
Expand Down

0 comments on commit c1b8780

Please sign in to comment.