From ef95b0d6d69c44ee47d6d4107720e7313b46c11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sun, 20 Jun 2021 19:27:57 +0800 Subject: Simplify member functions --- client.cxx | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) (limited to 'client.cxx') diff --git a/client.cxx b/client.cxx index 40aa342..8c84da8 100644 --- a/client.cxx +++ b/client.cxx @@ -16,46 +16,37 @@ namespace QICClient { icclient_cleanup(); } - static void catalogHandler(icclient_response* response) - { - client->emitCatalog(QString{response->data}); - icclient_free_response(response); - } - - static void catalogCallback(struct icclient_catalog* catalog) - { - icclient_free_catalog(catalog); - } - void Client::catalog(QString const& prodGroup) { - icclient_catalog(prodGroup.toLatin1().constData(), catalogHandler, nullptr); + icclient_catalog(prodGroup.toLatin1().constData(), [](icclient_response* response) { + client->emitCatalog(QString{response->data}); + icclient_free_response(response); + }, nullptr); } void Client::allProducts() { - icclient_allproducts(catalogHandler, nullptr); - } - - static void productHandler(icclient_response* response) - { - client->emitProduct(QString{response->data}); - icclient_free_response(response); + catalog("All-Products"); } void Client::product(QString const& sku) { - icclient_product(sku.toLatin1().constData(), productHandler, nullptr); + icclient_product(sku.toLatin1().constData(), [](icclient_response* response) { + client->emitProduct(QString{response->data}); + icclient_free_response(response); + }, nullptr); } void Client::defaultCatalog(QString const& prodGroup) { - icclient_catalog(prodGroup.toLatin1().constData(), nullptr, catalogCallback); + icclient_catalog(prodGroup.toLatin1().constData(), nullptr, [](struct icclient_catalog* catalog) { + icclient_free_catalog(catalog); + }); } void Client::defaultAllProducts() { - icclient_allproducts(nullptr, catalogCallback); + defaultCatalog("All-Products"); } void Client::emitCatalog(QString const& catalog) -- cgit v1.2.3