use unpack syntax
Rather than defining a variable and then reading it from a message,
we also supports directly unpack-ing from the message. Use this
syntax instead as it is more efficient and succinct.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I2ce2aa3e6a43d8866ba9b3920dd3165b7b6b9f6e
diff --git a/example/asio-example.cpp b/example/asio-example.cpp
index 22ae70b..bc6249b 100644
--- a/example/asio-example.cpp
+++ b/example/asio-example.cpp
@@ -315,8 +315,8 @@
std::cerr << "error with async_send\n";
return;
}
- GetSubTreeType data;
- ret.read(data);
+ auto data = ret.unpack<GetSubTreeType>();
+
for (auto& item : data)
{
std::cout << item.first << "\n";
diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 1a900b3..15ac339 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -336,8 +336,8 @@
{}
SetPropertyReturnValue operator()(message_t& m)
{
- PropertyType input;
- m.read(input);
+ auto input = m.unpack<PropertyType>();
+
PropertyType oldValue = *value_;
if (!func_(input, *value_))
{
diff --git a/test/message/call.cpp b/test/message/call.cpp
index 4cd82ac..376d128 100644
--- a/test/message/call.cpp
+++ b/test/message/call.cpp
@@ -28,8 +28,8 @@
std::string syncBusId(bus_t& b)
{
- std::string ret;
- newBusIdReq(b).call().read(ret);
+ auto ret = newBusIdReq(b).call().unpack<std::string>();
+
return ret;
}