From 282a045eb36c347b18d7b11a440c9bb682c550e0 Mon Sep 17 00:00:00 2001 From: DenisBiryukov91 <155981813+DenisBiryukov91@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:58:11 +0100 Subject: [PATCH] fix queryable examples (#320) --- examples/universal/z_queryable.cxx | 2 +- examples/zenohc/z_queryable_shm.cxx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/universal/z_queryable.cxx b/examples/universal/z_queryable.cxx index 39d0455..ac145ee 100644 --- a/examples/universal/z_queryable.cxx +++ b/examples/universal/z_queryable.cxx @@ -54,7 +54,7 @@ int _main(int argc, char **argv) { auto on_query = [payload, keyexpr](const Query &query) { auto params = query.get_parameters(); auto query_payload = query.get_payload(); - std::cout << ">> [Queryable ] Received Query '" << keyexpr << "?" << params; + std::cout << ">> [Queryable ] Received Query '" << query.get_keyexpr().as_string_view() << "?" << params; if (query_payload.has_value()) { std::cout << "' with value = '" << query_payload->get().as_string(); } diff --git a/examples/zenohc/z_queryable_shm.cxx b/examples/zenohc/z_queryable_shm.cxx index 3a1221c..12ee99b 100644 --- a/examples/zenohc/z_queryable_shm.cxx +++ b/examples/zenohc/z_queryable_shm.cxx @@ -49,7 +49,7 @@ int _main(int argc, char **argv) { std::cout << "Preparing SHM Provider...\n"; PosixShmProvider provider(MemoryLayout(65536, AllocAlignment({0}))); - auto on_query = [provider = std::move(provider), payload](const Query &query) { + auto on_query = [provider = std::move(provider), payload, keyexpr](const Query &query) { auto query_payload = query.get_payload(); const char *payload_type = ""; @@ -63,10 +63,9 @@ int _main(int argc, char **argv) { } } - const KeyExpr &keyexpr = query.get_keyexpr(); auto params = query.get_parameters(); - std::cout << ">> [Queryable ] Received Query [" << payload_type << "] '" << keyexpr.as_string_view() << "?" - << params; + std::cout << ">> [Queryable ] Received Query [" << payload_type << "] '" << query.get_keyexpr().as_string_view() + << "?" << params; if (query_payload.has_value()) { std::cout << "' value = '" << query_payload->get().as_string(); } @@ -77,6 +76,7 @@ int _main(int argc, char **argv) { ZShmMut &&buf = std::get(std::move(alloc_result)); memcpy(buf.data(), payload.data(), len); + std::cout << "[Queryable ] Responding ('" << keyexpr << "': '" << payload << "')\n"; query.reply(keyexpr, std::move(buf)); };