Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cpp-qt-client] pass QString by const reference instead of by value #16793

Merged
merged 8 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,5 @@ modules/openapi-generator-gradle-plugin/**/* @jimschubert
modules/openapi-generator-maven-plugin/**/* @jimschubert

# Martin Delille
/Users/martin/dev/clone/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtClientCodegen.java @martindelille
/Users/martin/dev/clone/openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppQtAbstractCodegen.java @martindelille
/Users/martin/dev/clone/openapi-generator/modules/openapi-generator/src/main/resources/cpp-qt-client @martindelille
/Users/martin/dev/clone/openapi-generator/samples/client/petstore/cpp-qt @martindelille
modules/openapi-generator/src/main/resources/cpp-qt-client/**/* @martindelille
samples/client/petstore/cpp-qt/**/* @martindelille
8 changes: 3 additions & 5 deletions .github/workflows/samples-cpp-qt-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ jobs:
matrix:
qt-version:
- '5.15.2'
- '6.4.2'
- '6.5.3'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
include:
- os: windows-latest
tools: 'tools_openssl_x64'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: jurplel/install-qt-action@v4
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
tools: ${{ matrix.tools }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,34 @@ void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) {
emit _passwordFlow.authenticationNeeded();
{{/isPassword}}{{/isOAuth}}{{/authMethods}}
} else {

#if defined(_MSC_VER)
// For MSVC
#pragma warning(push)
#pragma warning(disable : 4996)
#elif defined(__clang__)
// For Clang
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
// For GCC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

emit {{nickname}}SignalE({{#returnType}}output, {{/returnType}}error_type, error_str);
emit {{nickname}}SignalEFull(worker, error_type, error_str);

#if defined(_MSC_VER)
#pragma warning(pop)
#elif defined(__clang__)
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

emit {{nickname}}SignalError({{#returnType}}output, {{/returnType}}error_type, error_str);
emit {{nickname}}SignalErrorFull(worker, error_type, error_str);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,19 @@ signals:
{{#operations}}{{#operation}}
void {{nickname}}SignalFull({{prefix}}HttpRequestWorker *worker{{#returnType}}, {{{.}}} summary{{/returnType}});{{/operation}}{{/operations}}
{{#operations}}{{#operation}}
void {{nickname}}SignalE({{#returnType}}{{{.}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString error_str);{{/operation}}{{/operations}}
Q_DECL_DEPRECATED_X("Use {{nickname}}SignalError() instead")
void {{nickname}}SignalE({{#returnType}}{{{.}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, QString error_str);
void {{nickname}}SignalError({{#returnType}}{{{.}}} summary, {{/returnType}}QNetworkReply::NetworkError error_type, const QString &error_str);{{/operation}}{{/operations}}
{{#operations}}{{#operation}}
void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);{{/operation}}{{/operations}}
Q_DECL_DEPRECATED_X("Use {{nickname}}SignalErrorFull() instead")
void {{nickname}}SignalEFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, QString error_str);
void {{nickname}}SignalErrorFull({{prefix}}HttpRequestWorker *worker, QNetworkReply::NetworkError error_type, const QString &error_str);{{/operation}}{{/operations}}

void abortRequestsSignal();
void allPendingRequestsCompleted();

public slots:
void tokenAvailable();

};

{{#cppNamespaceDeclarations}}
Expand Down
22 changes: 11 additions & 11 deletions samples/client/petstore/cpp-qt/PetStore/PetApiTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void PetApiTests::findPetsByStatusTest() {
}
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::findPetsByStatusSignalE, [&](QList<PFXPet>, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::findPetsByStatusSignalError, [&](QList<PFXPet>, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -47,7 +47,7 @@ void PetApiTests::createAndGetPetTest() {
petCreated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::addPetSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -69,7 +69,7 @@ void PetApiTests::createAndGetPetTest() {
// QVERIFY(pet.getStatus().compare("freaky") == 0);
petFetched = true;
});
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::getPetByIdSignalError, [&](PFXPet, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -92,7 +92,7 @@ void PetApiTests::updatePetTest() {
petAdded = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::addPetSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -110,7 +110,7 @@ void PetApiTests::updatePetTest() {
petToCheck = pet;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::getPetByIdSignalE, this, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::getPetByIdSignalError, this, [&](PFXPet, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -126,7 +126,7 @@ void PetApiTests::updatePetTest() {
petUpdated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::updatePetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::updatePetSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -146,7 +146,7 @@ void PetApiTests::updatePetTest() {
QVERIFY(pet.getStatus().compare(petToCheck.getStatus()) == 0);
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::getPetByIdSignalError, [&](PFXPet, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -170,7 +170,7 @@ void PetApiTests::updatePetWithFormTest() {
petAdded = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::addPetSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -187,7 +187,7 @@ void PetApiTests::updatePetWithFormTest() {
petToCheck = pet;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::getPetByIdSignalError, [&](PFXPet, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -203,7 +203,7 @@ void PetApiTests::updatePetWithFormTest() {
petUpdated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::updatePetWithFormSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::updatePetWithFormSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -222,7 +222,7 @@ void PetApiTests::updatePetWithFormTest() {
// QVERIFY(pet.getName().compare(QString("gorilla")) == 0);
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXPetApi::getPetByIdSignalError, [&](PFXPet, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/cpp-qt/PetStore/StoreApiTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void StoreApiTests::placeOrderTest() {
qDebug() << order.getShipDate();
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXStoreApi::placeOrderSignalE, [&](PFXOrder, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXStoreApi::placeOrderSignalError, [&](PFXOrder, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand Down Expand Up @@ -49,7 +49,7 @@ void StoreApiTests::getOrderByIdTest() {
qDebug() << order.getShipDate();
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXStoreApi::getOrderByIdSignalE, [&](PFXOrder, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXStoreApi::getOrderByIdSignalError, [&](PFXOrder, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -73,7 +73,7 @@ void StoreApiTests::getInventoryTest() {
}
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXStoreApi::getInventorySignalE, [&](QMap<QString, qint32>, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXStoreApi::getInventorySignalError, [&](QMap<QString, qint32>, QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand Down
16 changes: 8 additions & 8 deletions samples/client/petstore/cpp-qt/PetStore/UserApiTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void UserApiTests::createUserTest() {
userCreated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::createUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::createUserSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -46,7 +46,7 @@ void UserApiTests::createUsersWithArrayInputTest() {
usersCreated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::createUsersWithArrayInputSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::createUsersWithArrayInputSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -70,7 +70,7 @@ void UserApiTests::createUsersWithListInputTest() {
usersCreated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::createUsersWithListInputSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::createUsersWithListInputSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand Down Expand Up @@ -98,7 +98,7 @@ void UserApiTests::deleteUserTest() {
userDeleted = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::deleteUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::deleteUserSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
userDeleted = true;
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
Expand All @@ -121,7 +121,7 @@ void UserApiTests::getUserByNameTest() {
// QVERIFY(summary.getUsername() == "johndoe");
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::getUserByNameSignalE, [&](PFXUser, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::getUserByNameSignalError, [&](PFXUser, QNetworkReply::NetworkError, const QString &error_str) {
userFetched = true;
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
Expand All @@ -143,7 +143,7 @@ void UserApiTests::loginUserTest() {
qDebug() << summary;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::loginUserSignalE, [&](QString, QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::loginUserSignalError, [&](QString, QNetworkReply::NetworkError, const QString &error_str) {
userLogged = true;
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
Expand All @@ -164,7 +164,7 @@ void UserApiTests::logoutUserTest() {
userLoggedOut = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::logoutUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::logoutUserSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand All @@ -184,7 +184,7 @@ void UserApiTests::updateUserTest() {
userUpdated = true;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
connect(&api, &PFXUserApi::updateUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
connect(&api, &PFXUserApi::updateUserSignalError, [&](QNetworkReply::NetworkError, const QString &error_str) {
qDebug() << "Error happened while issuing request : " << error_str;
QTimer::singleShot(0, &loop, &QEventLoop::quit);
});
Expand Down
Loading
Loading