Variant.parsed


Description:

public Variant.parsed (string format_string, ...)

Parses format and returns the result.

format must be a text format Variant with one extension: at any point that a value may appear in the text, a '%' character followed by a GVariant format string (as per Variant) may appear. In that case, the same arguments are collected from the argument list as Variant 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 parse.

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

Parameters:

...

arguments as per format

format

a text format Variant

Returns:

a new floating Variant instance