From: Andrea Zagli Date: Sun, 25 Dec 2011 09:29:45 +0000 (+0100) Subject: Added functions GdaEx::data_model_columns_to_hashtable_from_sql X-Git-Tag: 0.5.0~11 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=a1e0a280b9859d9aeadf84b5ce0e78bab5238834;p=libgdaex Added functions GdaEx::data_model_columns_to_hashtable_from_sql and GdaEx::data_model_row_to_hashtable_from_sql (closes #278)." --- diff --git a/.anjuta/session/anjuta.session b/.anjuta/session/anjuta.session index 1282bd7..08753d5 100644 --- a/.anjuta/session/anjuta.session +++ b/.anjuta/session/anjuta.session @@ -8,7 +8,7 @@ Shortcut=libgdaex//libgdaex//src//libgdaex.la%%%libgdaex//libgdaex//tests//fill_ Expand=libgdaex.la%%%libgdaex [File Loader] -Files=file:///home/andreaz/files/c/libgdaex/src/queryeditor.c#1710 +Files=file:///home/andreaz/files/c/libgdaex/src/queryeditor.c#1259 [Document Manager] bookmarks=\n\n diff --git a/.anjuta/session/dock-layout.xml b/.anjuta/session/dock-layout.xml index c70c788..e55f84a 100644 --- a/.anjuta/session/dock-layout.xml +++ b/.anjuta/session/dock-layout.xml @@ -1,2 +1,2 @@ - + diff --git a/.anjuta_sym_db.db b/.anjuta_sym_db.db index b8cbbc5..fe2c126 100644 Binary files a/.anjuta_sym_db.db and b/.anjuta_sym_db.db differ diff --git a/src/gdaex.c b/src/gdaex.c index b7ee9d0..a977d21 100644 --- a/src/gdaex.c +++ b/src/gdaex.c @@ -2318,6 +2318,52 @@ GHashTable return ret; } +/** + * gdaex_data_model_columns_to_hashtable_from_sql: + * @gdaex: a #GdaEx object. + * @sql: an SQL statement. + * + * Returns: a #GHashTable with keys as the columns names from @sql, + * and values as columns numbers. + */ +GHashTable +*gdaex_data_model_columns_to_hashtable_from_sql (GdaEx *gdaex, gchar *sql) +{ + GHashTable *ret; + GdaDataModel *dm; + + g_return_val_if_fail (IS_GDAEX (gdaex), NULL); + + dm = gdaex_query (gdaex, sql); + ret = gdaex_data_model_columns_to_hashtable (dm); + + return ret; +} + +/** + * gdaex_data_modelrow_to_hashtable_from_sql: + * @gdaex: a #GdaEx object. + * @sql: an SQL statement. + * @row: row number. + * + * Returns: a #GHashTable with keys as the columns names from @sql, + * and values as #GValue. + */ +GHashTable +*gdaex_data_model_row_to_hashtable_from_sql (GdaEx *gdaex, gchar *sql, guint row) +{ + GHashTable *ret; + GdaDataModel *dm; + + g_return_val_if_fail (IS_GDAEX (gdaex), NULL); + g_return_val_if_fail (sql != NULL, NULL); + + dm = gdaex_query (gdaex, sql); + ret = gdaex_data_model_row_to_hashtable (dm, row); + + return ret; +} + /** * gdaex_data_model_to_gtkliststore: * @dm: a #GdaDataModel object. diff --git a/src/gdaex.h b/src/gdaex.h index 8740a05..d2bd54b 100644 --- a/src/gdaex.h +++ b/src/gdaex.h @@ -178,6 +178,9 @@ struct tm *gdaex_data_model_iter_get_value_tm_at (GdaDataModelIter *iter, GHashTable *gdaex_data_model_columns_to_hashtable (GdaDataModel *dm); GHashTable *gdaex_data_model_row_to_hashtable (GdaDataModel *dm, guint row); +GHashTable *gdaex_data_model_columns_to_hashtable_from_sql (GdaEx *gdaex, gchar *sql); +GHashTable *gdaex_data_model_row_to_hashtable_from_sql (GdaEx *gdaex, gchar *sql, guint row); + GtkListStore *gdaex_data_model_to_gtkliststore (GdaDataModel *dm, gboolean only_schema);