Skip to content
Commit 84603774 authored by José Alburquerque's avatar José Alburquerque
Browse files

Variant: Allow containing complex types in arrays and in variants.

	* glib/src/variant.hg (Variant< Variant<T> >): Add a new class capable
	of containing any Variant<>.  The class is just like
	Variant<VariantBase> except that with it, it is now possible to store
	and handle complex variant types in a variant easily in a C++ way.
	The modified test below exemplifies.
	(Variant< std::vector<T> >::create): Create a Variant<> for each of
	the members in the vector and then use g_variant_builder_add_value()
	to add the underlying GVariant of the wrapped elements in the builder
	instead of using the variadic g_variant_builder_add() function which
	causes problems when dealing with types that are more complex than
	basic ones.
	(Variant< std::vector<T> >::get_child): Rewritten to get the child as
	a GVariant, wrap the GVariant in a Variant<> and then get its value
	instead of assuming that the array in the variant is a fixed array of
	basic types so that complex types are supported in arrays.
	(Variant< std::vector<T> >::get): Rewritten as get_child() above so
	that the elements in the array are gotten as a GVariant, wrapped in a
	Variant<> and then retrieved and placed in the resulting vector,
	again, to ensure that a vector of complex types can be stored in a
	variant.
	* tests/glibmm_variant/main.cc: Modify the test to ensure that any
	type other than basic ones are supported.
parent fea3c218
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment