Thanks for the tip Kjell. I managed to create a Glib Variant Tuple with Glibmm by implementing a new template for std::tuple.
If I find time I will create a bug report and patch on bugzilla. Alexander Rössler Professional Software Engineer Zühlke Engineering (Austria) GmbH Rivergate, Handelskai 92, 1200 Wien, Österreich Phone +43 1 205 11 6843 alexander.roess...@zuehlke.com<mailto:alexander.roess...@zuehlke.com> This e-mail is for the addressees only. The information it contains is confidential and may be legally privileged. If you are not an addressee you must not distribute, copy, disclose, use or rely on this e-mail or its contents and you must immediately notify the sender you are in receipt of this e-mail and delete all copies from your system. Any unauthorised use may be unlawful. ________________________________ From: Kjell Ahlstedt <kjell.ahlst...@bredband.net> Sent: Tuesday, January 17, 2017 5:23 PM To: Roessler, Alexander Cc: gtkmm-list@gnome.org Subject: Re: Reading a{q(qsb)} into Glib::Variant Den 2017-01-17 kl. 08:56, skrev Roessler, Alexander: Hello Gtkmm developers and users, I am currently using Gtkmm to develop an embedded Linux UI. So far I have been able to find all relevant information in the Gnome and Gtkmm documentation -> good work! However, now I stumbled upon a problem I cannot figure out myself. I am trying to read a DBus property using get_cached_property(). The property variant has the form a{q(qsb)} meaning a dictionary/map with uint16 keys and tuple values. I have tried following to read the variant: Glib::Variant< std::map<guint16, Glib::VariantContainerBase> > driver_map; m_userman->get_cached_property(driver_map, "DriverList"); auto data = driver_map.get(); Throws following error: In file included from /usr/include/glibmm-2.4/glibmm/containerhandle_shared.h:25:0, from /usr/include/glibmm-2.4/glibmm/object.h:34, from /usr/include/giomm-2.4/giomm/dbusconnection.h:29, from dbushandler.h:3, from dbushandler.cpp:1: /usr/include/glibmm-2.4/glibmm/variant.h: In instantiation of ‘std::pair<_T1, _T2> Glib::Variant<std::pair<_T1, _T2> >::get() const [with K = short int; V = Glib::VariantContainerBase]’: /usr/include/glibmm-2.4/glibmm/variant.h:1722:5: required from ‘std::map<K, V> Glib::Variant<std::map<K, V> >::get() const [with K = short int; V = Glib::VariantContainerBase]’ dbushandler.cpp:88:36: required from here /usr/include/glibmm-2.4/glibmm/variant.h:1549:48: error: ‘class Glib::Variant<Glib::VariantContainerBase>’ has no member named ‘get’ std::pair<K, V> result(key.get(), value.get()); ^ /usr/include/glibmm-2.4/glibmm/variant.h: In instantiation of ‘static const Glib::VariantType& Glib::Variant<std::pair<_T1, _T2> >::variant_type() [with K = short int; V = Glib::VariantContainerBase]’: /usr/include/glibmm-2.4/glibmm/variant.h:1643:71: required from ‘static const Glib::VariantType& Glib::Variant<std::map<K, V> >::variant_type() [with K = short int; V = Glib::VariantContainerBase]’ /usr/include/glibmm-2.4/glibmm/variant.h:1731:53: required from ‘Glib::VariantIter Glib::Variant<std::map<K, V> >::get_iter() const [with K = short int; V = Glib::VariantContainerBase]’ /usr/include/glibmm-2.4/glibmm/variant.h:1717:30: required from ‘std::map<K, V> Glib::Variant<std::map<K, V> >::get() const [with K = short int; V = Glib::VariantContainerBase]’ dbushandler.cpp:88:36: required from here /usr/include/glibmm-2.4/glibmm/variant.h:1520:29: error: ‘variant_type’ is not a member of ‘Glib::Variant<Glib::VariantContainerBase>’ Variant<V>::variant_type().gobj())); I also tried this second approach: Glib::Variant< std::map<guint16, Glib::Variant<std::vector<Glib::VariantBase> > > > driver_map; m_userman->get_cached_property(driver_map, "DriverList"); auto data = driver_map.get(); Which throws following error at runtime: (launcher:10778): GLib-CRITICAL **: the GVariant format string 'a{qv}' has a type of 'a{qv}' but the given value has a type of 'a{q(qsb)}' (launcher:10778): GLib-CRITICAL **: g_variant_get: assertion 'valid_format_string (format_string, TRUE, value)' failed (launcher:10778): GLib-CRITICAL **: g_variant_iter_next_value: assertion 'is_valid_iter (iter)' failed Does anyone have an idea how to decode this type of variant in Glibmm? Best regards, Alexander I don't think it's possible. What you would need is Glib::Variant<std::map<gunit16, std::tuple<guint16,Glib::ustring,bool>>> driver_map; There is no specialization of Glib::Variant<T> for std::tuple. Probably because std::tuple is new in C++11, and Glib::Variant was written before C++11 was around. Kjell
_______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtkmm-list