[libgda/LIBGDA_4.0] Fixed GdaMetaStore test program
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Subject: [libgda/LIBGDA_4.0] Fixed GdaMetaStore test program
- Date: Tue, 23 Jun 2009 15:20:31 -0400 (EDT)
commit ae7134a9de8545ba81f807114aaa83b55a10c664
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Jun 17 22:57:40 2009 +0200
Fixed GdaMetaStore test program
tests/meta-store/common.c | 37 ++++++++++++++++++++++++++++++-------
1 files changed, 30 insertions(+), 7 deletions(-)
---
diff --git a/tests/meta-store/common.c b/tests/meta-store/common.c
index da2c34a..3edb52e 100644
--- a/tests/meta-store/common.c
+++ b/tests/meta-store/common.c
@@ -27,20 +27,34 @@ common_declare_meta_store (GdaMetaStore *store)
g_signal_connect (store, "suggest-update", G_CALLBACK (suggest_update_cb), NULL);
}
+typedef struct {
+ const gchar *key;
+ const GValue *value;
+} HData;
+
+static gint
+hd_compare_func (const HData *v1, const HData *v2)
+{
+ return strcmp (v1->key, v2->key);
+}
+
static void
-change_key_func (const gchar *key, const GValue *value, GString *string)
+change_key_func (const gchar *key, const GValue *value, GSList **list)
{
- gchar *str = gda_value_stringify (value);
- g_string_append_printf (string, "\t%s => %s\n", key, str);
- g_free (str);
+ HData *hd;
+ hd = g_new (HData, 1);
+ hd->key = key;
+ hd->value = value;
+ *list = g_slist_insert_sorted (*list, hd, (GCompareFunc) hd_compare_func);
}
static gchar *
stringify_a_change (GdaMetaStoreChange *ac)
{
- GString *string;
+ GSList *hlist = NULL; /* will be a list of HData pointers */
gchar *str;
-
+ GString *string;
+
string = g_string_new (ac->table_name);
if (ac->c_type == GDA_META_STORE_ADD)
g_string_append (string, " (ADD)");
@@ -49,8 +63,17 @@ stringify_a_change (GdaMetaStoreChange *ac)
else
g_string_append (string, " (DEL)");
g_string_append_c (string, '\n');
- g_hash_table_foreach (ac->keys, (GHFunc) change_key_func, string);
+ g_hash_table_foreach (ac->keys, (GHFunc) change_key_func, &hlist);
+ GSList *list;
+ for (list = hlist; list; list = list->next) {
+ HData *hd = (HData*) list->data;
+ gchar *str = gda_value_stringify (hd->value);
+ g_string_append_printf (string, "\t%s => %s\n", hd->key, str);
+ g_free (str);
+ g_free (hd);
+ }
+
str = string->str;
g_string_free (string, FALSE);
return str;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]