[telepathy-glib/master] tp_asv_dump() -- dumps the map to the debugging console

Davyd Madeley davyd at madeley.id.au
Mon Mar 30 18:53:19 PDT 2009


---
 telepathy-glib/dbus.c |   27 +++++++++++++++++++++++++++
 telepathy-glib/dbus.h |    1 +
 tests/asv.c           |    2 ++
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/telepathy-glib/dbus.c b/telepathy-glib/dbus.c
index 20b03ce..3ff84a9 100644
--- a/telepathy-glib/dbus.c
+++ b/telepathy-glib/dbus.c
@@ -2358,3 +2358,30 @@ tp_asv_lookup (const GHashTable *asv,
 
   return g_hash_table_lookup ((GHashTable *) asv, key);
 }
+
+/**
+ * tp_asv_dump:
+ * @asv: a #GHashTable created with tp_asv_new()
+ *
+ * Dumps the a{sv} map to the debugging console.
+ *
+ * The purpose of this function is give the programmer the ability to easily
+ * inspect the contents of an a{sv} map for debugging purposes.
+ */
+void
+tp_asv_dump (GHashTable *asv)
+{
+  GHashTableIter iter;
+  char *key;
+  GValue *value;
+
+  g_return_if_fail (asv != NULL);
+
+  g_hash_table_iter_init (&iter, asv);
+  while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
+  {
+    char *str = g_strdup_value_contents (value);
+    g_debug ("'%s' : %s", key, str);
+    g_free (str);
+  }
+}
diff --git a/telepathy-glib/dbus.h b/telepathy-glib/dbus.h
index 7f0c398..8b7096e 100644
--- a/telepathy-glib/dbus.h
+++ b/telepathy-glib/dbus.h
@@ -140,6 +140,7 @@ const gchar * const *
 /* this comment stops gtkdoc denying that this function exists */
 tp_asv_get_strv (const GHashTable *asv, const gchar *key);
 void tp_asv_set_strv (GHashTable *asv, const gchar *key, char **value);
+void tp_asv_dump (GHashTable *asv);
 
 G_END_DECLS
 
diff --git a/tests/asv.c b/tests/asv.c
index e9a9339..a982bbf 100644
--- a/tests/asv.c
+++ b/tests/asv.c
@@ -91,6 +91,8 @@ int main (int argc, char **argv)
   g_hash_table_insert (hash, "as0",
       tp_g_value_slice_new_boxed (G_TYPE_STRV, strv + 2));
 
+  tp_asv_dump (hash);
+
   /* Tests: tp_asv_get_boolean */
 
   valid = (gboolean) 123;
-- 
1.5.6.5




More information about the telepathy-commits mailing list