Method

GLibVariantlookup

since: 2.28

Declaration

gboolean
g_variant_lookup (
  GVariant* dictionary,
  const gchar* key,
  const gchar* format_string,
  ...
)

Description

Looks up a value in a dictionary GVariant.

This function is a wrapper around g_variant_lookup_value() and g_variant_get(). In the case that NULL would have been returned, this function returns FALSE. Otherwise, it unpacks the returned value and returns TRUE.

format_string determines the C types that are used for unpacking the values and also determines if the values are copied or borrowed, see the section on [GVariant format strings][gvariant-format-strings-pointers].

This function is currently implemented with a linear scan. If you plan to do many lookups then GVariantDict may be more efficient.

Available since: 2.28

This method is not directly available to language bindings.

Parameters

key

Type: const gchar*

The key to look up in the dictionary.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
format_string

Type: const gchar*

A GVariant format string.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
...

Type: 

The arguments to unpack the value into.

Return value

Type: gboolean

TRUE if a value was unpacked.