Files
infix/package/sysrepo-cpp/0008-fix-onOperGet-unconsistent-with-C-library.patch
T

91 lines
4.4 KiB
Diff

From 6e9dbd8513ce75e51f2f714df69c08af5b556d1d Mon Sep 17 00:00:00 2001
From: Edoardo Bortolozzo <edoardo.bortolozzo@thinkquantum.com>
Date: Tue, 28 Oct 2025 13:24:13 +0100
Subject: [PATCH 8/9] fix: onOperGet unconsistent with C library.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Wires
Fixes: https://github.com/sysrepo/sysrepo-cpp/issues/29
Change-Id: I5a21069889c59466df8e9457c3a316b58e2571bb
Signed-off-by: Mattias Walström <lazzer@gmail.com>
---
include/sysrepo-cpp/Session.hpp | 2 +-
include/sysrepo-cpp/Subscription.hpp | 2 +-
src/Session.cpp | 4 ++--
src/Subscription.cpp | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/sysrepo-cpp/Session.hpp b/include/sysrepo-cpp/Session.hpp
index aae7068..3af4b10 100644
--- a/include/sysrepo-cpp/Session.hpp
+++ b/include/sysrepo-cpp/Session.hpp
@@ -127,7 +127,7 @@ public:
[[nodiscard]] Subscription onOperGet(
const std::string& moduleName,
OperGetCb cb,
- const std::optional<std::string>& xpath = std::nullopt,
+ const std::string& path,
const SubscribeOptions opts = SubscribeOptions::Default,
ExceptionHandler handler = nullptr,
const std::optional<FDHandling>& callbacks = std::nullopt);
diff --git a/include/sysrepo-cpp/Subscription.hpp b/include/sysrepo-cpp/Subscription.hpp
index c8f3ff8..14ecce4 100644
--- a/include/sysrepo-cpp/Subscription.hpp
+++ b/include/sysrepo-cpp/Subscription.hpp
@@ -32,7 +32,7 @@ public:
Subscription& operator=(Subscription&&) noexcept;
void onModuleChange(const std::string& moduleName, ModuleChangeCb cb, const std::optional<std::string>& xpath = std::nullopt, uint32_t priority = 0, const SubscribeOptions opts = SubscribeOptions::Default);
- void onOperGet(const std::string& moduleName, OperGetCb cb, const std::optional<std::string>& xpath, const SubscribeOptions opts = SubscribeOptions::Default);
+ void onOperGet(const std::string& moduleName, OperGetCb cb, const std::string& path, const SubscribeOptions opts = SubscribeOptions::Default);
void onRPCAction(const std::string& xpath, RpcActionCb cb, uint32_t priority = 0, const SubscribeOptions opts = SubscribeOptions::Default);
void onNotification(
const std::string& moduleName,
diff --git a/src/Session.cpp b/src/Session.cpp
index 95b8f24..6f0327d 100644
--- a/src/Session.cpp
+++ b/src/Session.cpp
@@ -505,14 +505,14 @@ Subscription Session::onModuleChange(
Subscription Session::onOperGet(
const std::string& moduleName,
OperGetCb cb,
- const std::optional<std::string>& xpath,
+ const std::string& path,
const SubscribeOptions opts,
ExceptionHandler handler,
const std::optional<FDHandling>& callbacks)
{
checkNoThreadFlag(opts, callbacks);
auto sub = Subscription{*this, handler, callbacks};
- sub.onOperGet(moduleName, cb, xpath, opts);
+ sub.onOperGet(moduleName, cb, path, opts);
return sub;
}
diff --git a/src/Subscription.cpp b/src/Subscription.cpp
index 5bb724e..dca1176 100644
--- a/src/Subscription.cpp
+++ b/src/Subscription.cpp
@@ -215,14 +215,14 @@ void Subscription::onModuleChange(const std::string& moduleName, ModuleChangeCb
* @param xpath XPath that identifies which data this subscription is able to provide.
* @param opts Options further changing the behavior of this method.
*/
-void Subscription::onOperGet(const std::string& moduleName, OperGetCb cb, const std::optional<std::string>& xpath, const SubscribeOptions opts)
+void Subscription::onOperGet(const std::string& moduleName, OperGetCb cb, const std::string& path, const SubscribeOptions opts)
{
SYSREPO_CPP_SESSION_MTX_OF(m_sess);
checkNoThreadFlag(opts, m_customEventLoopCbs);
auto& privRef = m_operGetCbs.emplace_back(PrivData{cb, m_exceptionHandler.get()});
sr_subscription_ctx_s* ctx = m_sub.get();
- auto res = sr_oper_get_subscribe(m_sess.m_sess.get(), moduleName.c_str(), xpath ? xpath->c_str() : nullptr, operGetItemsCb, reinterpret_cast<void*>(&privRef), toSubscribeOptions(opts), &ctx);
+ auto res = sr_oper_get_subscribe(m_sess.m_sess.get(), moduleName.c_str(), path.c_str(), operGetItemsCb, reinterpret_cast<void*>(&privRef), toSubscribeOptions(opts), &ctx);
throwIfError(res, "Couldn't create operational get items subscription", m_sess.m_sess.get());
saveContext(ctx);
--
2.43.0