### Method

# GLib Variant check_format_string

since: 2.34

#### Declaration [src]

    gboolean
    g_variant_check_format_string (
      GVariant* value,
      const gchar* format_string,
      gboolean copy_only
    )

#### Description [src]

Checks if calling `g_variant_get()` with `format_string` on `value` would be valid from a type-compatibility standpoint. `format_string` is assumed to be a valid format string (from a syntactic standpoint).

If `copy_only` is `TRUE` then this function additionally checks that it would be safe to call `g_variant_unref()` on `value` immediately after the call to `g_variant_get()` without invalidating the result. This is only possible if deep copies are made (ie: there are no pointers to the data inside of the soon-to-be-freed `GVariant` instance). If this check fails then a `g_critical()` is printed and `FALSE` is returned.

This function is meant to be used by functions that wish to provide varargs accessors to `GVariant` values of uncertain values (eg: `g_variant_lookup()` or g_menu_model_get_item_attribute()).

Available since: 2.34

#### Parameters

`format_string`

  Type: `const gchar*`

  A valid `GVariant` format string.

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

`copy_only`

  Type: `gboolean`

  `TRUE` to ensure the format string makes deep copies.

#### Return value

Type: `gboolean`

`TRUE` if `format_string` is safe to use.