GLib.Variant.new_parsed
Description: Reference for GLib.Variant.new_parsed

### Function

# GLib Variantnew_parsed

#### Declaration [src]

    GVariant*
    g_variant_new_parsed (
      const gchar* format,
      ...
    )

#### Description [src]

Parses `format` and returns the result.

`format` must be a text format `GVariant` with one extension: at any point that a value may appear in the text, a ‘%’ character followed by a GVariant format string (as per g_variant_new()) may appear. In that case, the same arguments are collected from the argument list as `g_variant_new()` would have collected.

Note that the arguments must be of the correct width for their types specified in `format`. This can be achieved by casting them. See the GVariant varargs documentation.

Consider this simple example:

     g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");

In the example, the variable argument parameters are collected and filled in as if they were part of the original string to produce the result of

    [('one', 1), ('two', 2), ('three', 3)]

This function is intended only to be used with `format` as a string literal. Any parse error is fatal to the calling process. If you want to parse data from untrusted sources, use g_variant_parse().

You may not use this function to return, unmodified, a single `GVariant` pointer from the argument list. ie: `format` may not solely be anything along the lines of “%*”, “%?”, “\%r”, or anything starting with “%@”.

This function is not directly available to language bindings.

#### Parameters

`format`

  Type: `const gchar*`

  A text format `GVariant`.

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

`...`

  Type: ``

  Arguments as per `format`.

#### Return value

Type: `GVariant`

A new floating `GVariant` instance.

The caller of the function takes ownership of the data, and is responsible for freeing it.