Method

GLibVariantlookup

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

Parameters

key const gchar*
 

The key to look up in the dictionary.

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

A GVariant format string.

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

The arguments to unpack the value into.

Return value

Returns: gboolean
 

TRUE if a value was unpacked.