Re: Glib::VariantBase usage examples



On Fri, 2011-03-25 at 08:11 +0200, Povietkin Konstantin wrote:
> Hi, all!
> The result of Gio::DBus::call_sync

You mean Gio::DBus::Connection::call_sync(), right?

>  is a Glib::VariantBase instance of
> type "ao", which, in my opinion, is Glib::Variant< std::vector<
> Glib::ustring > >.

Well, I think it should be Glib::VariantContainerBase, which is what we
are using for GVariant tuples generally. Thanks for catching this. I've
improved the API:
http://git.gnome.org/browse/glibmm/commit/?id=19a97d1dec0068421d2c2a1478c53419d26a4132

I guess that the child variants are sometimes strings, and sometimes
not, depending on what the D-Bus server's method actually returns.

> What is the wright way to cast it to Glib::Variant< std::vector<
> Glib::ustring > > with Glib::VariantBase::cast_dynamics?
> 
> I think I miss something, but I don't understand what one. 

You maybe be able to cast the VariantContainerBase to a Variant<
std::vector<Glib::ustring> >, like so, though I don't know if that is
useful.

Variant< std::vector<Glib::ustring> > derived =
VariantBase::cast_dynamic< Variant< std::vector<Glib::ustring> >
>(base);

That syntax is mentioned in the documentation now:
http://library.gnome.org/devel/glibmm/unstable/classGlib_1_1VariantBase.html#a85493035a605ffadbef3264793e3fea2

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]