Top |
Manipulating a{sv} mappingsManipulating a{sv} mappings — Functions to manipulate mappings from string to
variant, as represented in GVariant by a |
GHashTable * | tp_asv_from_vardict () |
GVariant * | tp_asv_to_vardict () |
gboolean | tp_vardict_has_key () |
gboolean | tp_vardict_get_boolean () |
gdouble | tp_vardict_get_double () |
gint32 | tp_vardict_get_int32 () |
gint64 | tp_vardict_get_int64 () |
const gchar * | tp_vardict_get_object_path () |
const gchar * | tp_vardict_get_string () |
guint32 | tp_vardict_get_uint32 () |
guint64 | tp_vardict_get_uint64 () |
GHashTable *
tp_asv_from_vardict (GVariant *variant
);
Convert a GVariant of type G_VARIANT_TYPE_VARDICT
to a
TP_HASH_TYPE_STRING_VARIANT_MAP
GVariant *
tp_asv_to_vardict (const GHashTable *asv
);
Convert a TP_HASH_TYPE_STRING_VARIANT_MAP to a GVariant of type
G_VARIANT_TYPE_VARDICT
gboolean tp_vardict_has_key (GVariant *variant
,const gchar *key
);
Check if variant
contains key
.
Since 0.99.8
gboolean tp_vardict_get_boolean (GVariant *variant
,const gchar *key
,gboolean *valid
);
If a value for key
in variant
is present and boolean, return it,
and set *valid
to TRUE
if valid
is not NULL
.
Otherwise return FALSE
, and set *valid
to FALSE
if valid
is not NULL
.
variant |
a GVariant of type |
|
key |
The key to look up |
|
valid |
Either |
[out] |
Since 0.19.10
gdouble tp_vardict_get_double (GVariant *variant
,const gchar *key
,gboolean *valid
);
If a value for key
in variant
is present and has any numeric type used by
GVariant (gint32, guint32, gint64, guint64 or gdouble),
return it as a double, and if valid
is not NULL
, set *valid
to TRUE
.
Otherwise, return 0.0, and if valid
is not NULL
, set *valid
to FALSE
.
variant |
a GVariant of type |
|
key |
The key to look up |
|
valid |
Either |
[out] |
Since 0.19.10
gint32 tp_vardict_get_int32 (GVariant *variant
,const gchar *key
,gboolean *valid
);
If a value for key
in variant
is present, has an integer type used by
GVariant (gint32, guint32, gint64 or guint64) and fits in the
range of a gint32, return it, and if valid
is not NULL
, set *valid
to
TRUE
.
Otherwise, return 0, and if valid
is not NULL
, set *valid
to FALSE
.
variant |
a GVariant of type |
|
key |
The key to look up |
|
valid |
Either |
[out] |
Since 0.19.10
gint64 tp_vardict_get_int64 (GVariant *variant
,const gchar *key
,gboolean *valid
);
If a value for key
in variant
is present, has an integer type used by
GVariant (gint32, guint32, gint64 or guint64) and fits in the
range of a gint64, return it, and if valid
is not NULL
, set *valid
to
TRUE
.
Otherwise, return 0, and if valid
is not NULL
, set *valid
to FALSE
.
variant |
a GVariant of type |
|
key |
The key to look up |
|
valid |
Either |
[out] |
Since 0.19.10
const gchar * tp_vardict_get_object_path (GVariant *variant
,const gchar *key
);
If a value for key
in variant
is present and is an object path, return it.
Otherwise return NULL
.
The returned value is not copied, and is only valid as long as variant
is
kept. Copy it with g_strdup()
if you need to keep it for longer.
Since 0.19.10
const gchar * tp_vardict_get_string (GVariant *variant
,const gchar *key
);
If a value for key
in variant
is present and is a string, return it.
Otherwise return NULL
.
The returned value is not copied, and is only valid as long as variant
is
kept. Copy it with g_strdup()
if you need to keep it for longer.
Since 0.19.10
guint32 tp_vardict_get_uint32 (GVariant *variant
,const gchar *key
,gboolean *valid
);
If a value for key
in variant
is present, has an integer type used by
GVariant (gint32, guint32, gint64 or guint64) and fits in the
range of a guint32, return it, and if valid
is not NULL
, set *valid
to
TRUE
.
Otherwise, return 0, and if valid
is not NULL
, set *valid
to FALSE
.
variant |
a GVariant of type |
|
key |
The key to look up |
|
valid |
Either |
[out] |
Since 0.19.10
guint64 tp_vardict_get_uint64 (GVariant *variant
,const gchar *key
,gboolean *valid
);
If a value for key
in variant
is present, has an integer type used by
GVariant (gint32, guint32, gint64 or guint64) and is non-negative,
return it, and if valid
is not NULL
, set *valid
to TRUE
.
Otherwise, return 0, and if valid
is not NULL
, set *valid
to FALSE
.
variant |
a GVariant of type |
|
key |
The key to look up |
|
valid |
Either |
[out] |
Since 0.19.10