match: add string constructors
Change-Id: Ifb6527c5bc686f65fea28679bc653f0509de4aec
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/sdbusplus/bus/match.hpp b/sdbusplus/bus/match.hpp
index 8a048df..20b0bd7 100644
--- a/sdbusplus/bus/match.hpp
+++ b/sdbusplus/bus/match.hpp
@@ -49,6 +49,9 @@
_slot = decltype(_slot){slot};
}
+ match(sdbusplus::bus::bus& bus, const std::string& _match,
+ sd_bus_message_handler_t handler, void* context = nullptr)
+ : match(bus, _match.c_str(), handler, context) {}
using callback_t = std::function<void(sdbusplus::message::message&)>;
@@ -69,6 +72,9 @@
_slot = decltype(_slot){slot};
}
+ match(sdbusplus::bus::bus& bus, const std::string& _match,
+ callback_t callback)
+ : match(bus, _match.c_str(), callback) {}
private:
slot::slot _slot;
diff --git a/test/bus/match.cpp b/test/bus/match.cpp
index 12d2336..c69c76b 100644
--- a/test/bus/match.cpp
+++ b/test/bus/match.cpp
@@ -37,7 +37,7 @@
return 0;
};
- sdbusplus::bus::match_t m{bus, matchRule().c_str(), trigger, &triggered};
+ sdbusplus::bus::match_t m{bus, matchRule(), trigger, &triggered};
auto m2 = std::move(m); // ensure match is move-safe.
waitForIt(triggered);
@@ -57,7 +57,7 @@
triggered = true;
};
- sdbusplus::bus::match_t m{bus, matchRule().c_str(), trigger};
+ sdbusplus::bus::match_t m{bus, matchRule(), trigger};
auto m2 = std::move(m); // ensure match is move-safe.
waitForIt(triggered);
@@ -84,7 +84,7 @@
};
BoolHolder b;
- sdbusplus::bus::match_t m{bus, matchRule().c_str(),
+ sdbusplus::bus::match_t m{bus, matchRule(),
std::bind(std::mem_fn(&BoolHolder::callback),
&b, std::placeholders::_1)};
auto m2 = std::move(m); // ensure match is move-safe.