On Fri, 2011-10-07 at 15:05 -0400, José Alburquerque wrote: > On Fri, 2011-10-07 at 14:54 -0400, José Alburquerque wrote: > > On Fri, 2011-10-07 at 12:54 +0200, Murray Cumming wrote: > > > On Fri, 2011-10-07 at 09:29 +0200, Markus Elfring wrote: > > > > By which (member) function can such a variable be marked to contain an > > > > unknown > > > > value? > > > > (Do I overlook a programming interface once more?) > > > > http://developer.gnome.org/glibmm/2.30/classGlib_1_1VariantBase.html > > > > > > It looks like we don't have any API yet to create a "maybe" > > > Glib::Variant. The C API is g_variant_new_maybe() but we don't seem to > > > use that yet. I don't know how we would support this in a template > > > specialization. > > > > One possible way might be to add a create_maybe() method to > > Glib::VariantContainerBase that could use the > > Glib::VariantBase::get_type() method of its children to create the maybe > > type, but I'm not sure it would work. I guess I can try and add it for > > glibmm-2.32 and see if it works. > > Though as you point out, Murray, it isn't as easy as it sounds because a > create method should ideally return the type of the derived class. I'll > try to give it a little thought and see if something is possible for > 2.32.
Last clarification: A create_maybe() as described above in Glib::VariantContainerBase should suffice. The method declaration might look something like: VariantContainerBase create_maybe(const Glib::VariantBase& child); It could use the Glib::VariantBase::get_type() method of the child to call g_variant_new_maybe() like so: GVariant* g_variant = g_variant_new_maybe(child.get_type().gobj(), const_cast<GVariant*>(child.gobj())); And then return a VariantContainerBase from the g_variant. I don't know why I was thinking the new method return type should be the type of one of the derived classes of VariantContainerBase. > > > > > > > > > Note that GVariant generally doesn't have set functions. It's meant to > > > be an invariant type. That probably makes it unsuitable for general use > > > anyway. > > > > > > -- José _______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
