From 8f6a22e833b2dcb69534aa7c137dcae1e2b4a651 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 10 Mar 2014 14:44:29 +0100 Subject: [PATCH] refs #140 , macro to enable enums in CValueObject classes for DBus marshalling, and hence to be used woth tupels. --- src/blackmisc/blackmiscfreefunctions.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/blackmisc/blackmiscfreefunctions.h b/src/blackmisc/blackmiscfreefunctions.h index 45f568661..5c4d3f3b2 100644 --- a/src/blackmisc/blackmiscfreefunctions.h +++ b/src/blackmisc/blackmiscfreefunctions.h @@ -198,4 +198,23 @@ namespace BlackMisc } // BlackMisc +/*! + * \brief Macro to make a ENUMs DBus streamable. + * \details Put this macro outside of any namespace, in the same header as the class defining the enumeration. + * \param ENUM The fully qualified name of the enumeration. + * \hideinitializer + * \ingroup Tuples + */ +#define BLACK_DBUS_ENUM_MARSHALLING(ENUM) \ + namespace BlackMisc \ + { \ + inline const QDBusArgument &operator >>(const QDBusArgument &arg, ENUM &enumType) \ + { \ + uint e; \ + arg >> e; \ + enumType = static_cast(e); \ + return arg; \ + }; \ + } + #endif // guard