VariantBuilder


Object Hierarchy:

GLib.VariantBuilder GLib.VariantBuilder GLib.VariantBuilder

Description:

[ Compact ]
[ Version ( since = "2.24" ) ]
[ CCode ( ref_function = "g_variant_builder_ref" , type_id = "G_TYPE_VARIANT_BUILDER" , unref_function = "g_variant_builder_unref" ) ]
public class VariantBuilder

A utility type for constructing container-type Variant instances.

This is an opaque structure and may only be accessed using the following functions.

VariantBuilder is not threadsafe in any way. Do not attempt to access it from more than one thread.

Example: VariantBuilder:

public static int main (string[] args) {
GLib.Variant? val = null;
string? key = null;

VariantBuilder builder = new VariantBuilder (new VariantType ("a{sv}") );
builder.add ("{sv}", "str1", new Variant.string ("str"));
builder.add ("{sv}", "str2", new Variant.int16 (10));
builder.add ("{sv}", "str4", new Variant.int32 (10));
builder.add ("{sv}", "str5", new Variant.int64 (10));

Variant dictionary = builder.end ();

VariantIter iter = dictionary.iterator ();

while (iter.next ("{sv}", out key, out val)) {
print ("Item '%s' has type '%s'\n", key, val.get_type_string ());
}

return 0;
}

valac --pkg glib-2.0 GLib.VariantBuilder.vala


Namespace: GLib
Package: glib-2.0

Content:

Creation methods:

Methods: