GValueArray utilities

GValueArray utilities — Functions to manipulate GValueArray as used in dbus-glib, despite its deprecation in GLib

Functions

Object Hierarchy


Includes

#include <telepathy-glib/telepathy-glib-dbus.h>

Description

dbus-glib uses GValueArray to represent a D-Bus struct/tuple, even though it's now deprecated in GLib. These utility functions pack/unpack GValueArray structures and avoid some of the deprecation warnings.

Functions

tp_value_array_build ()

GValueArray *
tp_value_array_build (gsize length,
                      GType type,
                      ...);

Creates a new GValueArray for use with structs, containing the values passed in as parameters. The values are copied or reffed as appropriate for their type.

Example 2.  using tp_value_array_build

1
2
3
4
GValueArray *array = tp_value_array_build (2,
   G_TYPE_STRING, host,
   G_TYPE_UINT, port,
   G_TYPE_INVALID);

Parameters

length

The number of elements that should be in the array

 

type

The type of the first argument.

 

...

The value of the first item in the struct followed by a list of type, value pairs terminated by G_TYPE_INVALID.

 

Returns

a newly created GValueArray, free with tp_value_array_free()

Since 0.9.2


tp_value_array_unpack ()

void
tp_value_array_unpack (GValueArray *array,
                       gsize len,
                       ...);

Unpacks a GValueArray into separate variables.

The contents of the values aren't copied into the variables, and so become invalid when array is freed.

Example 3. using tp_value_array_unpack

1
2
3
4
5
6
const gchar *host;
guint port;

tp_value_array_unpack (array, 2,
   &host,
   &port);

Parameters

array

the array to unpack

 

len

The number of elements that should be in the array

 

...

a list of correctly typed pointers to store the values in

 

Since 0.11.0


tp_value_array_free ()

void
tp_value_array_free (GValueArray *va);

Free va . This is exactly the same as g_value_array_free(), but does not provoke deprecation warnings from GLib when used in conjunction with tp_value_array_build() and tp_value_array_unpack().

Parameters

va

a GValueArray

 

Since 0.23.0

Types and Values