gvalue_to_gvariant


Description:

[ Version ( since = "2.30" ) ]
public Variant gvalue_to_gvariant (Value gvalue, VariantType type)

Converts a Value to a Variant of the type indicated by the type parameter.

The conversion is using the following rules:

This can fail if e.g. gvalue is of type STRING and type is ['i'][G-VARIANT-TYPE-INT32:CAPS]. It will also fail for any Type (including e.g. OBJECT and BOXED derived-types) not in the table above.

Note that if gvalue is of type VARIANT and its value is null, the empty Variant instance (never null) for type is returned (e.g. 0 for scalar types, the empty string for string types, '/' for object path types, the empty array for any array type and so on).

See the gvariant_to_gvalue function for how to convert a Variant to a Value.

Parameters:

gvalue

A Value to convert to a Variant

type

A VariantType

Returns:

A Variant (never floating) of VariantType type holding the data from gvalue or null in case of failure. Free with g_variant_unref.


Namespace: GLib.DBus
Package: gio-2.0