C++ Variant type for DBus object path
- From: Andrejs Hanins <andrejs hanins ubnt com>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: C++ Variant type for DBus object path
- Date: Tue, 31 Mar 2015 14:43:43 +0300
Hi,
Currently in Glibmm GDBus it seems no straightforward way to dynamically cast VariantBase containing
some signature with object paths (o) into strictly typed Variant container. I faced the problem when
interpreting (casting) the result of standard DBus org.freedesktop.DBus.ObjectManager.GetManagedObjects()
method call which return signature is a{oa{sa{sv}}} (note 'o'). Typed Variant in my code is defined like this:
Glib::Variant<std::map<Glib::ustring, std::map<Glib::ustring, std::map<Glib::ustring,
Glib::VariantBase>>>>
but the Glib::VariantBase::cast_dynamic fails with bad_cast, because the type signature of the typed Variant
is a{sa{sa{sv}}}, thats is, object 'o' is replaced with just 's'.
My question - is there some ready-to-use type which can be used as a parameter of Variant<> template
to specify that the Variant holds an object path, not just ordinary string?
Of course, it is possible to create such a class in the client code like this (pseudo code):
class obj_path_t : public Glib::ustring;
template<>
class Variant<obj_path_t> : public Variant<Glib::ustring>
{
static const VariantType& variant_type() { return VARIANT_TYPE_OBJECT_PATH; }
};
so that typed Variant looks like this:
Glib::Variant<std::map<obj_path_t, std::map<Glib::ustring, std::map<Glib::ustring,
Glib::VariantBase>>>>
and it actually works for me (cast_dynamic is OK), but IMO it should be provided by the Glibmm itself. Did I
overlook something? Or this is just a missing feature?
BR, Andrey
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]