[libgda/LIBGDA_4.2] GObject introspection: added non vararg functions and skip vararg ones, for bug #639472



commit 1607029d077a34ae825acc04d55d81a5bce9da4f
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Apr 20 17:04:44 2011 +0200

    GObject introspection: added non vararg functions and skip vararg ones, for bug #639472

 doc/C/libgda-sections.txt     |    6 ++
 libgda/gda-data-model-array.c |   33 ++++++++-
 libgda/gda-data-model-array.h |    1 +
 libgda/gda-meta-store.c       |  163 +++++++++++++++++++++++++++++++++++++----
 libgda/gda-meta-store.h       |   13 +++-
 libgda/gda-server-operation.c |  149 ++++++++++++++++++++++++++++++--------
 libgda/gda-server-operation.h |    9 ++-
 libgda/gda-util.c             |  101 +++++++++++++++++++-------
 libgda/gda-util.h             |    2 +
 libgda/libgda.symbols         |    7 ++
 10 files changed, 409 insertions(+), 75 deletions(-)
---
diff --git a/doc/C/libgda-sections.txt b/doc/C/libgda-sections.txt
index b683493..b920d57 100644
--- a/doc/C/libgda-sections.txt
+++ b/doc/C/libgda-sections.txt
@@ -185,6 +185,7 @@ GdaDataModelArrayClass
 GdaDataModelArrayPrivate
 gda_data_model_array_new
 gda_data_model_array_new_with_g_types
+gda_data_model_array_new_with_g_types_v
 gda_data_model_array_copy_model
 gda_data_model_array_get_row
 gda_data_model_array_set_n_columns
@@ -454,8 +455,11 @@ gda_server_operation_op_type_to_string
 gda_server_operation_string_to_op_type
 <SUBSECTION>
 gda_server_operation_get_value_at
+gda_server_operation_get_value_at_path
 gda_server_operation_get_sql_identifier_at
+gda_server_operation_get_sql_identifier_at_path
 gda_server_operation_set_value_at
+gda_server_operation_set_value_at_path
 gda_server_operation_save_data_to_xml
 gda_server_operation_load_data_from_xml
 gda_server_operation_is_valid
@@ -1344,6 +1348,7 @@ gda_meta_store_new_with_file
 gda_meta_store_get_version
 gda_meta_store_sql_identifier_quote
 gda_meta_store_extract
+gda_meta_store_extract_v
 gda_meta_store_schema_get_structure
 gda_meta_store_get_attribute_value
 gda_meta_store_set_attribute_value
@@ -1514,6 +1519,7 @@ gda_connection_internal_reset_transaction_status
 gda_connection_open_sqlite
 <SUBSECTION>
 gda_meta_store_modify
+gda_meta_store_modify_v
 gda_meta_store_modify_with_context
 GdaSqlIdentifierStyle
 gda_meta_store_set_identifiers_style
diff --git a/libgda/gda-data-model-array.c b/libgda/gda-data-model-array.c
index b0a2df8..278d89a 100644
--- a/libgda/gda-data-model-array.c
+++ b/libgda/gda-data-model-array.c
@@ -1,9 +1,10 @@
-/* GDA library
- * Copyright (C) 1998 - 2010 The GNOME Foundation.
+/*
+ * Copyright (C) 1998 - 2011 The GNOME Foundation.
  *
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
  *      Vivien Malerba <malerba gnome-db org>
+ *      Daniel Espinosa <esodan gmail com>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -317,6 +318,34 @@ gda_data_model_array_new_with_g_types (gint cols, ...)
 }
 
 /**
+ * gda_data_model_array_new_with_g_types_v:
+ * @cols: number of columns for rows in this data model.
+ * @types: array of types of the columns of the model to create as #GType, as many as indicated by @cols
+ *
+ * Creates a new #GdaDataModel object with the column types as
+ * specified.
+ *
+ * Returns: (transfer full): a pointer to the newly created #GdaDataModel.
+ *
+ * Since: 4.2.6
+ */
+GdaDataModel *
+gda_data_model_array_new_with_g_types_v (gint cols, GType *types)
+{
+	GdaDataModel *model;
+	gint i;
+
+	model = gda_data_model_array_new (cols);
+	i = 0;
+	while (i < cols) {
+		GType type = types [i];
+		gda_column_set_g_type (gda_data_model_describe_column (model, i), type);
+		i++;
+	}
+	return model;
+}
+
+/**
  * gda_data_model_array_copy_model:
  * @src: a #GdaDataModel to copy data from
  * @error: a place to store errors, or %NULL
diff --git a/libgda/gda-data-model-array.h b/libgda/gda-data-model-array.h
index 38f0a79..e9555c3 100644
--- a/libgda/gda-data-model-array.h
+++ b/libgda/gda-data-model-array.h
@@ -56,6 +56,7 @@ struct _GdaDataModelArrayClass {
 
 GType              gda_data_model_array_get_type          (void) G_GNUC_CONST;
 GdaDataModel      *gda_data_model_array_new_with_g_types  (gint cols, ...);
+GdaDataModel      *gda_data_model_array_new_with_g_types_v (gint cols, GType *types);
 GdaDataModel      *gda_data_model_array_new               (gint cols);
 GdaDataModelArray *gda_data_model_array_copy_model        (GdaDataModel *src, GError **error);
 
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 57e269a..e90fdc3 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -1,5 +1,9 @@
 /*
- * Copyright (C) 2008 - 2011 Vivien Malerba
+ * Copyright (C) 2008 - 2011 The GNOME Foundation.
+ *
+ * AUTHORS:
+ *      Vivien Malerba <malerba gnome-db org>
+ *      Daniel Espinosa <esodan gmail com>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -2416,16 +2420,127 @@ gda_meta_store_extract (GdaMetaStore *store, const gchar *select_sql, GError **e
 	return model;
 }
 
+/**
+ * gda_meta_store_extract_v: (Rename to: gda_meta_store_extract)
+ * @store: a #GdaMetaStore object
+ * @select_sql: a SELECT statement
+ * @vars: (allow-none): a hash table with all variables names as keys and GValue* as value, representing values for all the
+ * variables mentioned in @select_sql. If there is no variable then this part can be omitted.
+ * @error: (allow-none): a place to store errors, or %NULL
+ *
+ * Extracts some data stored in @store using a custom SELECT query. If the @select_sql filter involves
+ * SQL identifiers (such as table or column names), then the values should have been adapted using
+ * gda_meta_store_sql_identifier_quote().
+ *
+ * For more information about
+ * SQL identifiers are represented in @store, see the
+ * <link linkend="information_schema:sql_identifiers">meta data section about SQL identifiers</link>.
+ *
+ * Returns: (transfer full): a new #GdaDataModel, or %NULL if an error occurred
+ *
+ * Since: 4.2.6
+ */
+GdaDataModel *
+gda_meta_store_extract_v (GdaMetaStore *store, const gchar *select_sql, GHashTable *vars, GError **error)
+{
+	GdaStatement *stmt = NULL;
+	GdaDataModel *model;
+	GdaSet *params = NULL;
+
+	g_return_val_if_fail (GDA_IS_META_STORE (store), NULL);
+	g_return_val_if_fail (select_sql, NULL);
+
+	if (store->priv->init_error) {
+		g_propagate_error (error, g_error_copy (store->priv->init_error));
+		return NULL;
+	}		
+
+	gda_mutex_lock (store->priv->mutex);
+
+	if ((store->priv->max_extract_stmt > 0) && !store->priv->extract_stmt_hash)
+		store->priv->extract_stmt_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+
+	/* statement creation */
+	if (store->priv->extract_stmt_hash)
+		stmt = g_hash_table_lookup (store->priv->extract_stmt_hash, select_sql);
+	if (stmt) 
+		g_object_ref (stmt);
+	else {
+		GdaMetaStoreClass *klass;
+		const gchar *remain;
+
+		klass = (GdaMetaStoreClass *) G_OBJECT_GET_CLASS (store);
+		stmt = gda_sql_parser_parse_string (klass->cpriv->parser, select_sql, &remain, error);
+		if (!stmt) {
+			gda_mutex_unlock (store->priv->mutex);
+			return NULL;
+		}
+		if (remain) {
+			g_set_error (error, GDA_META_STORE_ERROR, GDA_META_STORE_EXTRACT_SQL_ERROR,
+				     "%s", _("More than one SQL statement"));
+			g_object_unref (stmt);
+			gda_mutex_unlock (store->priv->mutex);
+			return NULL;
+		}
+
+		if (store->priv->current_extract_stmt < store->priv->max_extract_stmt) {
+			g_hash_table_insert (store->priv->extract_stmt_hash, g_strdup (select_sql), g_object_ref (stmt));
+			store->priv->current_extract_stmt++;
+		}
+	}
+	
+	/* parameters */
+	if (!gda_statement_get_parameters (stmt, &params, error)) {
+		g_object_unref (stmt);
+		gda_mutex_unlock (store->priv->mutex);
+		return NULL;
+	}
+	if (params) {
+		GSList *list, *params_set = NULL;
+		gchar *pname;
+		GValue *value;
+		GHashTableIter iter;
+		g_hash_table_iter_init (&iter, vars);
+		while (g_hash_table_iter_next (&iter, &pname, &value)) {
+			GdaHolder *h;
+			h = gda_set_get_holder (params, pname);
+			if (!h)
+				g_warning (_("Parameter '%s' is not present in statement"), pname);
+			else {
+				if (!gda_holder_set_value (h, value, error)) {
+					g_object_unref (stmt);
+					g_object_unref (params);
+					gda_mutex_unlock (store->priv->mutex);
+					return NULL;
+				}
+				params_set = g_slist_prepend (params_set, h);
+			}
+		}
+		
+		for (list = params->holders; list; list = list->next) {
+			if (!g_slist_find (params_set, list->data))
+				g_warning (_("No value set for parameter '%s'"), 
+					   gda_holder_get_id (GDA_HOLDER (list->data)));
+		}
+		g_slist_free (params_set);
+	}
+
+	/* execution */
+	model = gda_connection_statement_execute_select (store->priv->cnc, stmt, params, error);
+	g_object_unref (stmt);
+	if (params)
+		g_object_unref (params);
+
+	gda_mutex_unlock (store->priv->mutex);
+	return model;
+} 
+
 static gboolean prepare_tables_infos (GdaMetaStore *store, TableInfo **out_table_infos, 
 				      TableConditionInfo **out_cond_infos, gboolean *out_with_key,
 				      const gchar *table_name, const gchar *condition, GError **error, 
 				      gint nvalues, const gchar **value_names, const GValue **values);
 static gint find_row_in_model (GdaDataModel *find_in, GdaDataModel *data, gint row,
 			       gint *pk_cols, gint pk_cols_nb, gboolean *out_has_changed, GError **error);
-static gboolean gda_meta_store_modify_v (GdaMetaStore *store, const gchar *table_name, 
-					 GdaDataModel *new_data, const gchar *condition, GError **error, 
-					 gint nvalues, const gchar **value_names, const GValue **values);
-
 /**
  * gda_meta_store_modify: (skip)
  * @store: a #GdaMetaStore object
@@ -2486,8 +2601,8 @@ gda_meta_store_modify (GdaMetaStore *store, const gchar *table_name,
 		values [n_values] = v;
 	}
 	va_end (ap);
-	retval = gda_meta_store_modify_v (store, table_name, new_data, condition, error,
-					  n_values, value_names, values);
+	retval = gda_meta_store_modify_v (store, table_name, new_data, condition, 
+					  n_values, value_names, values, error);
 	g_free (value_names);
 	g_free (values);
 	return retval;
@@ -2531,20 +2646,40 @@ gda_meta_store_modify_with_context (GdaMetaStore *store, GdaMetaContext *context
 		return FALSE;
 	}
 
-	retval = gda_meta_store_modify_v (store, context->table_name, new_data, cond ? cond->str : NULL, error,
+	retval = gda_meta_store_modify_v (store, context->table_name, new_data, cond ? cond->str : NULL,
 					  context->size, 
 					  (const gchar **) context->column_names,
-					  (const GValue **)context->column_values);
+					  (const GValue **)context->column_values, error);
 	if (cond)
 		g_string_free (cond, TRUE);
 	return retval;
 }
 
 /*#define DEBUG_STORE_MODIFY*/
-static gboolean
+/**
+ * gda_meta_store_modify_v:
+ * @store: a #GdaMetaStore object
+ * @table_name: the name of the table to modify within @store
+ * @new_data: (allow-none): a #GdaDataModel containing the new data to set in @table_name, or %NULL (treated as a data model
+ * with no row at all)
+ * @condition: (allow-none): SQL expression (which may contain variables) defining the rows which are being obsoleted by @new_data, or %NULL
+ * @nvalues: number of values in @value_names and @values
+ * @value_names: (array length=nvalues): names of values
+ * @values: (array length=nvalues): values
+ * @error: (allow-none): a place to store errors, or %NULL
+ *
+ * Propagates an update to @store, the update's contents is represented by @new_data, this function is
+ * primarily reserved to database providers.
+ *
+ * Returns: %TRUE if no error occurred
+ *
+ * Since: 4.2.6
+ */
+gboolean
 gda_meta_store_modify_v (GdaMetaStore *store, const gchar *table_name, 
-			 GdaDataModel *new_data, const gchar *condition, GError **error, 
-			 gint nvalues, const gchar **value_names, const GValue **values)
+			 GdaDataModel *new_data, const gchar *condition,  
+			 gint nvalues, const gchar **value_names, const GValue **values,
+			 GError **error)
 {
 	TableInfo *schema_set;
 	TableConditionInfo *custom_set;
@@ -2880,8 +3015,8 @@ gda_meta_store_modify_v (GdaMetaStore *store, const gchar *table_name,
 						}
 					}
 					if (!gda_meta_store_modify_v (store, tfk->table_info->obj_name, NULL,
-								      tfk->fk_fields_cond, error, 
-								      tfk->cols_nb, (const gchar **) tfk->fk_names_array, values)) {
+								      tfk->fk_fields_cond,
+								      tfk->cols_nb, (const gchar **) tfk->fk_names_array, values, error)) {
 						retval = FALSE;
 						g_free (values);
 						goto out;
diff --git a/libgda/gda-meta-store.h b/libgda/gda-meta-store.h
index 8523e48..100fecd 100644
--- a/libgda/gda-meta-store.h
+++ b/libgda/gda-meta-store.h
@@ -1,6 +1,9 @@
-/* gda-meta-store.h
+/*
+ * Copyright (C) 2008 - 2011 The GNOME Foundation.
  *
- * Copyright (C) 2008 - 2011 Vivien Malerba
+ * AUTHORS:
+ *      Vivien Malerba <malerba gnome-db org>
+ *      Daniel Espinosa <esodan gmail com>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -111,8 +114,14 @@ gint              gda_meta_store_get_version              (GdaMetaStore *store);
 GdaConnection    *gda_meta_store_get_internal_connection  (GdaMetaStore *store);
 gchar            *gda_meta_store_sql_identifier_quote     (const gchar *id, GdaConnection *cnc);
 GdaDataModel     *gda_meta_store_extract                  (GdaMetaStore *store, const gchar *select_sql, GError **error, ...);
+GdaDataModel     *gda_meta_store_extract_v                (GdaMetaStore *store, const gchar *select_sql, GHashTable *vars, 
+							   GError **error);
 gboolean          gda_meta_store_modify                   (GdaMetaStore *store, const gchar *table_name, 
 							   GdaDataModel *new_data, const gchar *condition, GError **error, ...);
+gboolean          gda_meta_store_modify_v                 (GdaMetaStore *store, const gchar *table_name, 
+			 				   GdaDataModel *new_data, const gchar *condition,
+							   gint nvalues, const gchar **value_names,
+							   const GValue **values, GError **error);
 gboolean          gda_meta_store_modify_with_context      (GdaMetaStore *store, GdaMetaContext *context, 
 							   GdaDataModel *new_data, GError **error);
 GdaDataModel     *gda_meta_store_create_modify_data_model (GdaMetaStore *store, const gchar *table_name);
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index 997eaba..63a6c6b 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -1,8 +1,9 @@
-/* GDA library
+/*
  * Copyright (C) 2006 - 2010 The GNOME Foundation.
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
+ *      Daniel Espinosa <esodan gmail com>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -907,9 +908,12 @@ load_xml_spec (GdaServerOperation *op, xmlNodePtr specnode, const gchar *root, G
 			
 			prop = xmlGetProp(node, (xmlChar*)"minitems");
 			if (prop) {
-				opnode->d.seq.min_items = atoi ((gchar*)prop); /* Flawfinder: ignore */
-				if (opnode->d.seq.min_items < 0)
+				gint tmp;
+				tmp = atoi ((gchar*)prop); /* Flawfinder: ignore */
+				if (tmp < 0)
 					opnode->d.seq.min_items = 0;
+				else
+					opnode->d.seq.min_items = tmp;
 				xmlFree (prop);
 			}
 
@@ -1973,18 +1977,19 @@ gda_server_operation_del_item_from_sequence (GdaServerOperation *op, const gchar
 	return FALSE;
 }
 
-/*
- * real_gda_server_operation_get_value_at
+/**
+ * gda_server_operation_get_value_at_path:
  * @op: a #GdaServerOperation object
  * @path: a complete path to a node (starting with "/")
  *
  * Get the value for the node at the @path path
  *
- * Returns: a constant #GValue if a value has been defined, or %NULL if the value is undefined or
- * if the @path is not defined or @path does not hold any value.
+ * Returns: (transfer none): a constant #GValue if a value has been defined, or %NULL if the value is undefined or if the @path is not defined or @path does not hold any value.
+ *
+ * Since: 4.2.6
  */
-static const GValue *
-real_gda_server_operation_get_value_at (GdaServerOperation *op, const gchar *path)
+const GValue *
+gda_server_operation_get_value_at_path (GdaServerOperation *op, const gchar *path)
 {
 	const GValue *value = NULL;
 	GdaServerOperationNode *node_info;
@@ -2064,7 +2069,7 @@ gda_server_operation_get_value_at (GdaServerOperation *op, const gchar *path_for
 	path = g_strdup_vprintf (path_format, args);
 	va_end (args);
 
-	value = real_gda_server_operation_get_value_at (op, path);
+	value = gda_server_operation_get_value_at_path (op, path);
 	g_free (path);
 
 	return value;
@@ -2093,11 +2098,9 @@ gchar *
 gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnection *cnc, GdaServerProvider *prov,
 					    const gchar *path_format, ...)
 {
-	const GValue *value = NULL;
-	gchar *path;
+	gchar *path, *ret;
 	va_list args;
-	GdaConnectionOptions cncoptions = 0;
-
+	
 	g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), NULL);
 
 	/* build path */
@@ -2105,9 +2108,41 @@ gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnectio
 	path = g_strdup_vprintf (path_format, args);
 	va_end (args);
 
-	value = real_gda_server_operation_get_value_at (op, path);
+	ret = gda_server_operation_get_sql_identifier_at_path (op, cnc, prov, path);
 	g_free (path);
 
+	return ret;
+}
+
+/**
+ * gda_server_operation_get_sql_identifier_at_path:
+ * @op: a #GdaServerOperation object
+ * @cnc: a #GdaConnection, or %NULL
+ * @prov: a #GdaServerProvider, or %NULL
+ * @path: a complete path to a node (starting with "/")
+ *
+ * This method is similar to gda_server_operation_get_value_at(), but for SQL identifiers: a new string
+ * is returned instead of a #GValue. Also the returned string is assumed to represents an SQL identifier
+ * and will correctly be quoted to be used with @cnc, or @prov if @cnc is %NULL (a generic quoting rule
+ * will be applied if both are %NULL).
+ *
+ * Returns: (transfer full): a new string, or %NULL if the value is undefined or
+ * if the @path is not defined or @path does not hold any value, or if the value held is not a string
+ * (in that last case a warning is shown).
+ *
+ * Since: 4.2.6
+ */
+gchar *
+gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op, GdaConnection *cnc, GdaServerProvider *prov,
+						 const gchar *path)
+{
+	const GValue *value = NULL;
+	GdaConnectionOptions cncoptions = 0;
+
+	g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), NULL);
+
+	value = gda_server_operation_get_value_at_path (op, path);
+	
 	if (!value || (G_VALUE_TYPE (value) == GDA_TYPE_NULL))
 		return NULL;
 	g_return_val_if_fail (G_VALUE_TYPE (value) == G_TYPE_STRING, NULL);
@@ -2119,12 +2154,11 @@ gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnectio
 }
 
 /**
- * gda_server_operation_set_value_at: (skip)
+ * gda_server_operation_set_value_at_path:
  * @op: a #GdaServerOperation object
  * @value: a string
  * @error: a place to store errors or %NULL
- * @path_format: a complete path to a node (starting with "/")
- * @...: arguments to use with @path_format to make a complete path
+ * @path: a complete path to a node (starting with "/")
  *
  * Set the value for the node at the path formed using @path_format and the ... ellipse (the rules are the same as
  * for g_strdup_printf()). 
@@ -2157,14 +2191,13 @@ gda_server_operation_get_sql_identifier_at (GdaServerOperation *op, GdaConnectio
  * </itemizedlist>
  *
  * Returns: %TRUE if no error occurred
+ *
+ * Since: 4.2.6
  */
 gboolean
-gda_server_operation_set_value_at (GdaServerOperation *op, const gchar *value, GError **error,
-				   const gchar *path_format, ...)
+gda_server_operation_set_value_at_path (GdaServerOperation *op, const gchar *value, 
+					const gchar *path, GError **error)
 {
-	gchar *path;
-	va_list args;
-
 	Node *opnode;
 	gchar *extension = NULL;
 	gchar *colname = NULL;
@@ -2173,11 +2206,6 @@ gda_server_operation_set_value_at (GdaServerOperation *op, const gchar *value, G
 	g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), FALSE);
 	g_return_val_if_fail (op->priv, FALSE);
 
-	/* build path */
-	va_start (args, path_format);
-	path = g_strdup_vprintf (path_format, args);
-	va_end (args);
-
 	/* set the value */
 	opnode = node_find_or_create (op, path);
 	if (!opnode) {
@@ -2302,11 +2330,72 @@ gda_server_operation_set_value_at (GdaServerOperation *op, const gchar *value, G
 
 	g_free (extension);
 	g_free (colname);
-	g_free (path);
 	return allok;
 }
 
 /**
+ * gda_server_operation_set_value_at: (skip)
+ * @op: a #GdaServerOperation object
+ * @value: a string
+ * @error: a place to store errors or %NULL
+ * @path_format: a complete path to a node (starting with "/")
+ * @...: arguments to use with @path_format to make a complete path
+ *
+ * Set the value for the node at the path formed using @path_format and the ... ellipse (the rules are the same as
+ * for g_strdup_printf()). 
+ *
+ * Note that trying to set a value for a path which is not used by the current
+ * provider, such as "/TABLE_OPTIONS_P/TABLE_ENGINE" for a PostgreSQL connection (this option is only supported for MySQL), 
+ * will <emphasis>not</emphasis> generate
+ * any error; this allows one to give values to a superset of the parameters and thus use the same code for several providers.
+ *
+ * Here are the possible formats of @path_format:
+ * <itemizedlist>
+ *  <listitem><para>If the path corresponds to a #GdaHolder, then the parameter is set to <![CDATA["@value"]]></para></listitem>
+ *  <listitem><para>If the path corresponds to a sequence item like for example "/SEQUENCE_NAME/5/NAME" for
+ *     the "NAME" value of the 6th item of the "SEQUENCE_NAME" sequence then:
+ *     <itemizedlist>
+ *        <listitem><para>if the sequence already has 6 or more items, then the value is just set to the corresponding 
+ *           value in the 6th item of the sequence</para></listitem>
+ *        <listitem><para>if the sequence has less then 6 items, then items are added up to the 6th one before setting
+ *           the value to the corresponding in the 6th item of the sequence</para></listitem>
+ *     </itemizedlist>
+ *  </para></listitem>
+ *  <listitem><para>If the path corresponds to a #GdaDataModel, like for example "/ARRAY/@@COLUMN/5" for the value at the
+ *     6th row of the "COLUMN" column of the "ARRAY" data model, then:
+ *     <itemizedlist>
+ *        <listitem><para>if the data model already contains 6 or more rows, then the value is just set</para></listitem>
+ *        <listitem><para>if the data model has less than 6 rows, then rows are added up to the 6th one before setting
+ *           the value</para></listitem>
+ *     </itemizedlist>
+ *  </para></listitem>
+ * </itemizedlist>
+ *
+ * Returns: %TRUE if no error occurred
+ */
+gboolean
+gda_server_operation_set_value_at (GdaServerOperation *op, const gchar *value, GError **error,
+				   const gchar *path_format, ...)
+{
+	gchar *path;
+	va_list args;
+	gboolean ret;
+
+	g_return_val_if_fail (GDA_IS_SERVER_OPERATION (op), FALSE);
+	g_return_val_if_fail (op->priv, FALSE);
+
+	/* build path */
+	va_start (args, path_format);
+	path = g_strdup_vprintf (path_format, args);
+	va_end (args);
+
+	ret = gda_server_operation_set_value_at_path (op, value, path, error);
+	g_free (path);
+
+	return ret;
+}
+
+/**
  * gda_server_operation_is_valid:
  * @op: a #GdaServerOperation widget
  * @xml_file: an XML specification file (see gda_server_operation_new())
@@ -2526,7 +2615,7 @@ gda_server_operation_perform_drop_database (GdaServerOperation *op, const gchar
 }
 
 /**
- * gda_server_operation_prepare_create_table: (skip)
+ * gda_server_operation_prepare_create_table:
  * @cnc: an opened connection
  * @table_name: name of the table to create
  * @error: a place to store errors, or %NULL
diff --git a/libgda/gda-server-operation.h b/libgda/gda-server-operation.h
index 934b5b5..3241aaf 100644
--- a/libgda/gda-server-operation.h
+++ b/libgda/gda-server-operation.h
@@ -3,6 +3,7 @@
  *
  * AUTHORS:
  *      Vivien Malerba <malerba gnome-db org>
+ *      Daniel Espinosa <esodan gmail com>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -142,11 +143,17 @@ GdaServerOperationType     gda_server_operation_string_to_op_type       (const g
 GdaServerOperationNode    *gda_server_operation_get_node_info           (GdaServerOperation *op, const gchar *path_format, ...);
 
 const GValue              *gda_server_operation_get_value_at            (GdaServerOperation *op, const gchar *path_format, ...);
+const GValue              *gda_server_operation_get_value_at_path       (GdaServerOperation *op, const gchar *path);
 gchar                     *gda_server_operation_get_sql_identifier_at   (GdaServerOperation *op,
 									 GdaConnection *cnc, GdaServerProvider *prov,
-									 const gchar *path_format, ...);
+									 const gchar *path_format, ...);    
+gchar                     *gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op, 
+									    GdaConnection *cnc, GdaServerProvider *prov,
+									    const gchar *path);
 gboolean                   gda_server_operation_set_value_at            (GdaServerOperation *op, const gchar *value, 
 									 GError **error, const gchar *path_format, ...);
+gboolean                   gda_server_operation_set_value_at_path       (GdaServerOperation *op, const gchar *value, 
+									 const gchar *path, GError **error);
 
 xmlNodePtr                 gda_server_operation_save_data_to_xml        (GdaServerOperation *op, GError **error);
 gboolean                   gda_server_operation_load_data_from_xml      (GdaServerOperation *op, 
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index 500b64b..4a2118a 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -55,7 +55,7 @@ extern GdaAttributesManager *gda_holder_attributes_manager;
 #define PROV_CLASS(provider) (GDA_SERVER_PROVIDER_CLASS (G_OBJECT_GET_CLASS (provider)))
 
 /**
- * gda_g_type_to_string
+ * gda_g_type_to_string:
  * @type: Type to convert from.
  *
  * Converts a GType to its string representation (use gda_g_type_from_string() for the
@@ -94,7 +94,7 @@ gda_g_type_to_string (GType type)
 }
 
 /**
- * gda_g_type_from_string
+ * gda_g_type_from_string:
  * @str: the name of a #GType, as returned by gda_g_type_to_string().
  *
  * Converts a named type to ts GType type (also see the gda_g_type_to_string() function).
@@ -150,7 +150,7 @@ gda_g_type_from_string (const gchar *str)
 }
 
 /**
- * gda_default_escape_string
+ * gda_default_escape_string:
  * @string: string to escape
  *
  * Escapes @string to make it understandable by a DBMS. The escape method is very common and replaces any
@@ -204,7 +204,7 @@ gda_default_escape_string (const gchar *string)
 }
 
 /**
- * gda_default_unescape_string
+ * gda_default_unescape_string:
  * @string: string to unescape
  *
  * Do the reverse of gda_default_escape_string(): transforms any "''" into "'", any
@@ -265,6 +265,55 @@ gda_default_unescape_string (const gchar *string)
 }
 
 /**
+ * gda_utility_check_data_model_v:
+ * @model: a #GdaDataModel object
+ * @nbcols: the minimum requested number of columns
+ * @types: (array length=nbcols): array with @nbcols length of type GType or null (if any data type is accepted)
+ *
+ * Check the column types of a GdaDataModel.
+ *
+ * Returns: %TRUE if the data model's columns match the provided data types and number
+ *
+ * Since: 4.2.6
+ */
+gboolean
+gda_utility_check_data_model_v (GdaDataModel *model, gint nbcols, GType* types)
+{
+	gboolean retval = TRUE;
+	gint i;
+
+	g_return_val_if_fail (model && GDA_IS_DATA_MODEL (model), FALSE);
+
+	/* number of columns */
+	if (gda_data_model_get_n_columns (model) < nbcols)
+		return FALSE;
+
+	/* type of each column */
+	if (nbcols > 0) {
+		GdaColumn *att;
+		GType mtype, rtype;
+		i = 0;
+		while ((i<nbcols) && retval) {
+			att = gda_data_model_describe_column (model, i);
+			mtype = gda_column_get_g_type (att);
+
+			rtype = types [i];
+			if (mtype != rtype) {
+				retval = FALSE;
+#ifdef GDA_DEBUG_NO
+				g_print ("Column %d: Expected %s, got %s\n",
+					 i, gda_g_type_to_string (rtype), gda_g_type_to_string (mtype));
+#endif
+			}
+			i++;
+		}
+	}
+
+	return retval;
+}
+
+
+/**
  * gda_utility_check_data_model: (skip)
  * @model: a #GdaDataModel object
  * @nbcols: the minimum requested number of columns
@@ -272,7 +321,7 @@ gda_default_unescape_string (const gchar *string)
  *
  * Check the column types of a GdaDataModel.
  *
- * Returns: TRUE if the data model's columns match the provided data types and number
+ * Returns: %TRUE if the data model's columns match the provided data types and number
  */
 gboolean
 gda_utility_check_data_model (GdaDataModel *model, gint nbcols, ...)
@@ -321,7 +370,7 @@ gda_utility_check_data_model (GdaDataModel *model, gint nbcols, ...)
 }
 
 /**
- * gda_utility_data_model_dump_data_to_xml
+ * gda_utility_data_model_dump_data_to_xml:
  * @model: a #GdaDataModel
  * @parent: the parent XML node
  * @cols: an array containing which columns of @model will be exported, or %NULL for all columns
@@ -337,7 +386,7 @@ gda_utility_check_data_model (GdaDataModel *model, gint nbcols, ...)
  * to access data in @model previously to calling this method, and this iterator will be moved (point to
  * another row).
  *
- * Returns: TRUE if no error occurred
+ * Returns: %TRUE if no error occurred
  */
 gboolean
 gda_utility_data_model_dump_data_to_xml (GdaDataModel *model, xmlNodePtr parent, 
@@ -477,7 +526,7 @@ gda_utility_data_model_dump_data_to_xml (GdaDataModel *model, xmlNodePtr parent,
 
 
 /**
- * gda_utility_data_model_find_column_description
+ * gda_utility_data_model_find_column_description:
  * @model: a #GdaDataSelect data model
  * @field_name: field name
  *
@@ -531,7 +580,7 @@ gda_utility_data_model_find_column_description (GdaDataSelect *model, const gcha
 }
 
 /**
- * gda_utility_holder_load_attributes
+ * gda_utility_holder_load_attributes:
  * @holder: a #GdaHolder
  * @node: an xmlNodePtr with a &lt;parameter&gt; tag
  * @sources: a list of #GdaDataModel
@@ -705,7 +754,7 @@ gda_utility_holder_load_attributes (GdaHolder *holder, xmlNodePtr node, GSList *
 
 #define GDA_PARAM_ENCODE_TOKEN "__gda"
 /**
- * gda_text_to_alphanum
+ * gda_text_to_alphanum:
  * @text: the text to convert
  *
  * The "encoding" consists in replacing non
@@ -740,7 +789,7 @@ gda_text_to_alphanum (const gchar *text)
 }
 
 /**
- * gda_alphanum_to_text
+ * gda_alphanum_to_text:
  * @text: a string
  *
  * Does the opposite of gda_text_to_alphanum(), in the same string 
@@ -830,7 +879,7 @@ dml_statements_check_select_structure (GdaConnection *cnc, GdaSqlStatement *sel_
 }
 
 /**
- * gda_compute_unique_table_row_condition_with_cnc
+ * gda_compute_unique_table_row_condition_with_cnc:
  * @cnc: a #GdaConnection, or %NULL
  * @stsel: a #GdaSqlSelectStatement
  * @mtable: a #GdaMetaTable
@@ -944,7 +993,7 @@ gda_compute_unique_table_row_condition_with_cnc (GdaConnection *cnc, GdaSqlState
 }
 
 /**
- * gda_compute_unique_table_row_condition
+ * gda_compute_unique_table_row_condition:
  * @stsel: a #GdaSqlSelectStatement
  * @mtable: a #GdaMetaTable
  * @require_pk: set to TRUE if a primary key ir required
@@ -962,7 +1011,7 @@ gda_compute_unique_table_row_condition (GdaSqlStatementSelect *stsel, GdaMetaTab
 }
 
 /**
- * gda_compute_dml_statements
+ * gda_compute_dml_statements:
  * @cnc: a #GdaConnection
  * @select_stmt: a SELECT #GdaStatement (compound statements not handled)
  * @require_pk: TRUE if the created statement have to use a primary key
@@ -1175,7 +1224,7 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
 }
 
 /**
- * gda_compute_select_statement_from_update
+ * gda_compute_select_statement_from_update:
  * @update_stmt: an UPDATE statement
  * @error: a place to store errors, or %NULL
  *
@@ -1235,7 +1284,7 @@ static gboolean stmt_rewrite_update_default_keyword (GdaSqlStatementUpdate *upd,
 
 
 /**
- * gda_statement_rewrite_for_default_values
+ * gda_statement_rewrite_for_default_values:
  * @stmt: a #GdaStatement object
  * @params: a #GdaSet containing the variable's values to be bound when executing @stmt
  * @remove: set to %TRUE if DEFAULT fields are removed, of %FALSE if the "DEFAULT" keyword is used
@@ -1459,7 +1508,7 @@ stmt_rewrite_update_default_keyword (GdaSqlStatementUpdate *upd, GdaSet *params,
 }
 
 /**
- * gda_identifier_hash
+ * gda_identifier_hash:
  * @id: an identifier string
  *
  * computes a hash string from @id, to be used in hash tables as a #GHashFunc
@@ -1491,7 +1540,7 @@ gda_identifier_hash (const gchar *id)
 }
 
 /**
- * gda_identifier_equal
+ * gda_identifier_equal:
  * @id1: an identifier string
  * @id2: an identifier string
  *
@@ -1897,7 +1946,7 @@ gda_sql_identifier_split (const gchar *id)
 static gboolean _sql_identifier_needs_quotes (const gchar *str);
 
 /**
- * gda_sql_identifier_quote
+ * gda_sql_identifier_quote:
  * @id: an SQL identifier
  * @cnc: a #GdaConnection object, or %NULL
  * @prov: a #GdaServerProvider object, or %NULL
@@ -2221,7 +2270,7 @@ static char rfc1738_reserved_chars[] =
 };
 
 /**
- * gda_rfc1738_encode
+ * gda_rfc1738_encode:
  * @string: a string to encode 
  *
  * Encodes @string using the RFC 1738 recommendations: the
@@ -2291,7 +2340,7 @@ gda_rfc1738_encode (const gchar *string)
 }
 
 /**
- * gda_rfc1738_decode
+ * gda_rfc1738_decode:
  * @string: a string to decode
  *
  * Decodes @string using the RFC 1738 recommendations: the
@@ -2359,7 +2408,7 @@ gda_rfc1738_decode (gchar *string)
 
 
 /**
- * gda_dsn_split
+ * gda_dsn_split:
  * @string: a string in the "[&lt;username&gt;[:&lt;password&gt;] ]&lt;DSN&gt;" form
  * @out_dsn: a place to store the new string containing the &lt;DSN&gt; part
  * @out_username: a place to store the new string containing the &lt;username&gt; part
@@ -2407,7 +2456,7 @@ gda_dsn_split (const gchar *string, gchar **out_dsn, gchar **out_username, gchar
 }
 
 /**
- * gda_connection_string_split
+ * gda_connection_string_split:
  * @string: a string in the "[&lt;provider&gt;://][&lt;username&gt;[:&lt;password&gt;] ]&lt;connection_params&gt;" form
  * @out_cnc_params: a place to store the new string containing the &lt;connection_params&gt; part
  * @out_provider: a place to store the new string containing the &lt;provider&gt; part
@@ -2593,7 +2642,7 @@ _parse_iso8601_date (GDate *gdate, const gchar *value, char **out_endptr)
 }
 
 /**
- * gda_parse_iso8601_date
+ * gda_parse_iso8601_date:
  * @gdate: a pointer to a #GDate structure which will be filled
  * @value: a string
  *
@@ -2690,7 +2739,7 @@ _parse_iso8601_time (GdaTime *timegda, const gchar *value, char **out_endptr)
 }
 
 /**
- * gda_parse_iso8601_time
+ * gda_parse_iso8601_time:
  * @timegda: a pointer to a #GdaTime structure which will be filled
  * @value: a string
  *
@@ -2717,7 +2766,7 @@ gda_parse_iso8601_time (GdaTime *timegda, const gchar *value)
 }
 
 /**
- * gda_parse_iso8601_timestamp
+ * gda_parse_iso8601_timestamp:
  * @timestamp: a pointer to a #GdaTimeStamp structure which will be filled
  * @value: a string
  *
diff --git a/libgda/gda-util.h b/libgda/gda-util.h
index cd4fec1..3e35f04 100644
--- a/libgda/gda-util.h
+++ b/libgda/gda-util.h
@@ -4,6 +4,7 @@
  * AUTHORS:
  *	Rodrigo Moya <rodrigo gnome-db org>
  *      Vivien Malerba <malerba gnome-db org>
+ *      Daniel Espinosa <esodan gmail com>
  *
  * This Library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public License as
@@ -55,6 +56,7 @@ gchar       *gda_sql_identifier_quote (const gchar *id, GdaConnection *cnc, GdaS
  * Param & model utilities
  */
 gboolean     gda_utility_check_data_model (GdaDataModel *model, gint nbcols, ...);
+gboolean     gda_utility_check_data_model_v (GdaDataModel *model, gint nbcols, GType* types);
 gboolean     gda_utility_data_model_dump_data_to_xml (GdaDataModel *model, xmlNodePtr parent, 
 					      const gint *cols, gint nb_cols, const gint *rows, gint nb_rows,
 					      gboolean use_col_ids);
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 6d177d3..05242ca 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -207,6 +207,7 @@
 	gda_data_model_array_get_type
 	gda_data_model_array_new
 	gda_data_model_array_new_with_g_types
+	gda_data_model_array_new_with_g_types_v
 	gda_data_model_array_set_n_columns
 #ifdef HAVE_BDB
 	gda_data_model_bdb_clean_errors
@@ -423,11 +424,13 @@
 	gda_meta_store_error_get_type
 	gda_meta_store_error_quark
 	gda_meta_store_extract
+	gda_meta_store_extract_v
 	gda_meta_store_get_attribute_value
 	gda_meta_store_get_internal_connection
 	gda_meta_store_get_type
 	gda_meta_store_get_version
 	gda_meta_store_modify
+	gda_meta_store_modify_v
 	gda_meta_store_modify_with_context
 	gda_meta_store_new
 	gda_meta_store_new_with_file
@@ -527,8 +530,10 @@
 	gda_server_operation_get_sequence_name
 	gda_server_operation_get_sequence_size
 	gda_server_operation_get_sql_identifier_at
+	gda_server_operation_get_sql_identifier_at_path
 	gda_server_operation_get_type
 	gda_server_operation_get_value_at
+	gda_server_operation_get_value_at_path
 	gda_server_operation_is_valid
 	gda_server_operation_load_data_from_xml
 	gda_server_operation_new
@@ -545,6 +550,7 @@
 	gda_server_operation_prepare_drop_table
 	gda_server_operation_save_data_to_xml
 	gda_server_operation_set_value_at
+	gda_server_operation_set_value_at_path
 	gda_server_operation_string_to_op_type
 	gda_server_operation_type_get_type
 	gda_server_provider_create_operation
@@ -882,6 +888,7 @@
 	gda_update_row_in_table_v
 	gda_ushort_get_type
 	gda_utility_check_data_model
+	gda_utility_check_data_model_v
 	gda_utility_data_model_dump_data_to_xml
 	gda_utility_data_model_find_column_description
 	gda_utility_holder_load_attributes



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]