From afdf8eccadd49db755d97cfae829bf27a1a73b0e Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 28 Apr 2015 01:04:27 +0200 Subject: [PATCH] refs #411, MS diff to reduce DBus signature length --- src/blackmisc/tuple_private.h | 12 ++++++++++-- src/blackmisc/valueobject.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/blackmisc/tuple_private.h b/src/blackmisc/tuple_private.h index bb515a75d..5cf3ce03f 100644 --- a/src/blackmisc/tuple_private.h +++ b/src/blackmisc/tuple_private.h @@ -332,17 +332,25 @@ namespace BlackMisc template static void marshallImpl(QDBusArgument &arg, const T &head, const Ts &... tail) { - arg << head; + marshallHelper(arg, head, 0); marshallImpl(arg, tail...); } + template ::value, int>::type = 0> + static void marshallHelper(QDBusArgument &arg, const T &val, int) { static_cast(val).marshallToDbus(arg); } + template + static void marshallHelper(QDBusArgument &arg, const T &val, ...) { arg << val; } static void unmarshallImpl(const QDBusArgument &) {} template static void unmarshallImpl(const QDBusArgument &arg, T &head, Ts &... tail) { - arg >> head; + unmarshallHelper(arg, head, 0); unmarshallImpl(arg, tail...); } + template ::value, int>::type = 0> + static void unmarshallHelper(const QDBusArgument &arg, T &val, int) { static_cast(val).unmarshallFromDbus(arg); } + template + static void unmarshallHelper(const QDBusArgument &arg, T &val, ...) { arg >> val; } static void debugImpl(QDebug) {} template diff --git a/src/blackmisc/valueobject.h b/src/blackmisc/valueobject.h index 2ce9c637a..b959a7fb3 100644 --- a/src/blackmisc/valueobject.h +++ b/src/blackmisc/valueobject.h @@ -427,6 +427,7 @@ namespace BlackMisc return BaseOrDummy::isA(metaTypeId); } + public: //! Marshall to DBus virtual void marshallToDbus(QDBusArgument &argument) const {