server-bindings: convertForMessage utility
Some C++ types, such as enumerations, need some conversion
before they can be added to a message. Provide a global
utility which passes a C++ reference unchanged, which can
be used in all server-bindings.
Specific C++ types that need conversion will provide their
own override of this in their own namespace/class.
"Argument dependent lookup" rules will allow the override to
be used where appropriate.
Change-Id: I0e9f64974ea12093c1b67f28847da4696fa85f61
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/sdbusplus/server.hpp b/sdbusplus/server.hpp
index bbea03b..468bd98 100644
--- a/sdbusplus/server.hpp
+++ b/sdbusplus/server.hpp
@@ -7,3 +7,4 @@
#include <sdbusplus/server/manager.hpp>
#include <sdbusplus/server/object.hpp>
#include <sdbusplus/server/match.hpp>
+#include <sdbusplus/server/bindings.hpp>
diff --git a/sdbusplus/server/bindings.hpp b/sdbusplus/server/bindings.hpp
new file mode 100644
index 0000000..88b0610
--- /dev/null
+++ b/sdbusplus/server/bindings.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <utility>
+
+namespace sdbusplus
+{
+namespace server
+{
+namespace binding
+{
+namespace details
+{
+
+/** Utility for converting C++ types prior to 'append'ing to a message.
+ *
+ * Some C++ types require conversion to a native dbus type before they
+ * can be inserted into a message. This template provides a general no-op
+ * implementation for all other types.
+ */
+template <typename T>
+T&& convertForMessage(T&& t)
+{
+ return std::forward<T>(t);
+}
+
+}
+}
+}
+}