summaryrefslogtreecommitdiff
path: root/src/gdbusxx/gdbus-cxx-bridge.h
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2014-01-31 11:13:46 +0100
committerPatrick Ohly <patrick.ohly@intel.com>2014-04-01 16:45:09 +0200
commitd7b7f6dc35854f685f628275bf0742f0d8364704 (patch)
treeb6146f5c2ace97f29b200af9117f740d137180cb /src/gdbusxx/gdbus-cxx-bridge.h
parent940f1ba7d800daa553972ae93e42b35a85a55faa (diff)
D-Bus GIO + libdbus: support structs with base struct
Allow (de)serialization of "struct foo : public bar" kind of structures.
Diffstat (limited to 'src/gdbusxx/gdbus-cxx-bridge.h')
-rw-r--r--src/gdbusxx/gdbus-cxx-bridge.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/gdbusxx/gdbus-cxx-bridge.h b/src/gdbusxx/gdbus-cxx-bridge.h
index 302ad6f7..a4e9abf4 100644
--- a/src/gdbusxx/gdbus-cxx-bridge.h
+++ b/src/gdbusxx/gdbus-cxx-bridge.h
@@ -2373,6 +2373,32 @@ template<class K, class V, V K::*m, class M> struct dbus_member
};
/**
+ * The base class of type V of a struct K, followed by another dbus_member
+ * or dbus_member_single to end the chain
+ */
+template<class K, class V, class M> struct dbus_base
+{
+ static std::string getType()
+ {
+ return dbus_traits<V>::getType() + M::getType();
+ }
+ typedef V host_type;
+
+ static void get(ExtractArgs &context,
+ GVariantIter &iter, K &val)
+ {
+ dbus_traits<V>::get(context, iter, val);
+ M::get(context, iter, val);
+ }
+
+ static void append(GVariantBuilder &builder, const K &val)
+ {
+ dbus_traits<V>::append(builder, val);
+ M::append(builder, val);
+ }
+};
+
+/**
* a helper class which implements dbus_traits for
* a class, use with:
* struct foo { int a; std::string b; };