[gnome-db] Removed GdaRecordset from postgres



	Hi!

	I tried to replace GdaRecordset by GdaDataModel and this is the
	result.

	It works with gda-test (well, changing some GDA_IS_RECORDSET by
	GDA_IS_DATA_MODEL in model.c).

	Only a couple of functions hanging around:
	gda_recordset_get_command_type and _text.

	If the patch is ok, what should i do with these functions?
	If it's not ok, well, it has been funny :-)...

	Cheers.
	
-- 
Gonzalo Paniagua Javier <gonzalo gnome-db org>
http://www.gnome-db.org/~gonzalo/

Index: gda-postgres-provider.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-provider.c,v
retrieving revision 1.27
diff -u -r1.27 gda-postgres-provider.c
--- gda-postgres-provider.c	26 Apr 2002 21:20:31 -0000	1.27
+++ gda-postgres-provider.c	8 May 2002 03:15:10 -0000
@@ -379,7 +379,7 @@
 
 		while (arr[n]) {
 			PGresult *pg_res;
-			GdaRecordset *recset;
+			GdaDataModel *recset;
 			gint status;
 
 			pg_res = PQexec(pconn, arr[n]);
@@ -397,9 +397,10 @@
 			    status == PGRES_TUPLES_OK 			||
 			    status == PGRES_COMMAND_OK) {
 				recset = gda_postgres_recordset_new (cnc, pg_res);
-				if (GDA_IS_RECORDSET (recset)) {
-					gda_recordset_set_command_text (recset, arr[n]);
-					gda_recordset_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
+				if (GDA_IS_DATA_MODEL (recset)) {
+					//FIXME
+					//gda_recordset_set_command_text (recset, arr[n]);
+					//gda_recordset_set_command_type (recset, GDA_COMMAND_TYPE_SQL);
 					reclist = g_list_append (reclist, recset);
 				}
 			}
@@ -545,7 +546,7 @@
 get_postgres_procedures (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -556,17 +557,17 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModel *
 get_postgres_tables (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -579,10 +580,10 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static void
@@ -637,7 +638,7 @@
 get_postgres_views (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -650,17 +651,17 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModel *
 get_postgres_indexes (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -673,17 +674,17 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModel *
 get_postgres_aggregates (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -697,17 +698,17 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModel *
 get_postgres_triggers (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -720,10 +721,10 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModelArray *
@@ -1069,7 +1070,7 @@
 get_postgres_databases (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -1082,17 +1083,17 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModel *
 get_postgres_users (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -1105,17 +1106,17 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 static GdaDataModel *
 get_postgres_sequences (GdaConnection *cnc, GdaParameterList *params)
 {
 	GList *reclist;
-	GdaRecordset *recset;
+	GdaDataModel *recset;
 
 	g_return_val_if_fail (GDA_IS_CONNECTION (cnc), NULL);
 
@@ -1131,10 +1132,10 @@
 	if (!reclist)
 		return NULL;
 
-	recset = GDA_RECORDSET (reclist->data);
+	recset = GDA_DATA_MODEL (reclist->data);
 	g_list_free (reclist);
 
-	return GDA_DATA_MODEL (recset);
+	return recset;
 }
 
 /* get_schema handler for the GdaPostgresProvider class */
Index: gda-postgres-recordset.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-recordset.c,v
retrieving revision 1.14
diff -u -r1.14 gda-postgres-recordset.c
--- gda-postgres-recordset.c	27 Apr 2002 16:13:51 -0000	1.14
+++ gda-postgres-recordset.c	8 May 2002 03:15:10 -0000
@@ -27,11 +27,14 @@
 #include <libgda/gda-intl.h>
 #include <string.h>
 #include "gda-postgres.h"
+#include "gda-postgres-recordset.h"
 
 #define OBJECT_DATA_RECSET_HANDLE "GDA_Postgres_RecsetHandle"
 
 typedef struct {
 	PGresult *pg_res;
+	GdaConnection *gda_conn;
+
 	gint ntypes;
 	GdaPostgresTypeOid *type_data;
 	GHashTable *h_table;
@@ -52,124 +55,155 @@
 	g_free (priv_data);
 }
 
-static GdaRow *
-fetch_func (GdaRecordset *recset, gulong rownum, gpointer user_data)
+static const GdaValue *
+get_value_at_func (GdaDataModel *model, gint col, gint row)
 {
-	GdaPostgresRecordsetPrivate *priv_data = user_data;
-	GdaRow *row;
+	GdaPostgresRecordsetPrivate *priv_data;
 	gint field_count;
 	gint row_count;
-	gint i;
 	PGresult *pg_res;
-
-	g_return_val_if_fail (GDA_IS_RECORDSET (recset), NULL);
-	g_return_val_if_fail (priv_data != NULL, NULL);
+	GdaValue *value;
+	gchar *thevalue;
+	GdaValueType ftype;
+	gboolean isNull;
+
+	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), NULL);
+	priv_data = g_object_get_data (G_OBJECT (model), OBJECT_DATA_RECSET_HANDLE);
+	g_return_val_if_fail (priv_data != NULL, 0);
 
 	pg_res = priv_data->pg_res;
 	if (!pg_res) {
-		gda_connection_add_error_string (
-			gda_recordset_get_connection (recset),
-			_("Invalid PostgreSQL handle"));
+		gda_connection_add_error_string (priv_data->gda_conn,
+						_("Invalid PostgreSQL handle"));
 		return NULL;
 	}
 
 	row_count = PQntuples (pg_res);
 	field_count = PQnfields (pg_res);
 
-	if (rownum == row_count)
+	if (row == row_count)
 		return NULL; // For the last row don't add an error.
 
-	if (rownum < 0 || rownum > row_count) {
-		gda_connection_add_error_string (
-			gda_recordset_get_connection (recset),
-			_("Row number out of range"));
+	if (row < 0 || row > row_count) {
+		gda_connection_add_error_string (priv_data->gda_conn,
+						_("Row number out of range"));
 		return NULL;
 	}
 
-	row = gda_row_new (field_count);
+	if (field_count < 0 || col > field_count) {
+		gda_connection_add_error_string (priv_data->gda_conn,
+						_("Column number out of range"));
+		return NULL;
+	}
 
-	for (i = 0; i < field_count; i++) {
-		GdaField *field;
-		gchar *thevalue;
-		GdaValueType ftype;
-		gboolean isNull;
-
-		field = gda_row_get_field (row, i);
-		thevalue = PQgetvalue(pg_res, rownum, i);
-
-		ftype = gda_postgres_type_oid_to_gda (priv_data->type_data,
-						      priv_data->ntypes, 
-						      PQftype (pg_res, i));
-		isNull = *thevalue != '\0' ? FALSE : PQgetisnull (pg_res, rownum, i);
+	thevalue = PQgetvalue(pg_res, row, col);
 
-		gda_postgres_set_field_data (field, PQfname (pg_res, i), ftype,
-					     thevalue, PQfsize (pg_res, i), isNull);
-	}
+	ftype = gda_postgres_type_oid_to_gda (priv_data->type_data,
+					      priv_data->ntypes, 
+					      PQftype (pg_res, col));
+	isNull = *thevalue != '\0' ? FALSE : PQgetisnull (pg_res, row, col);
+
+	value = gda_value_new_null ();
+	gda_postgres_set_value (value, PQfname (pg_res, col), ftype,
+			 	thevalue, PQfsize (pg_res, col), isNull);
 
-	return row;
+	return value;
 }
 
-static GdaRowAttributes *
-describe_func (GdaRecordset *recset, gpointer user_data)
+static GdaFieldAttributes *
+describe_func (GdaDataModel *model, gint col)
 {
-	GdaPostgresRecordsetPrivate *priv_data = user_data;
+	GdaPostgresRecordsetPrivate *priv_data;
 	PGresult *pg_res;
 	gint field_count;
-	gint i;
-	GdaRowAttributes *attrs;
-
-	g_return_val_if_fail (GDA_IS_RECORDSET (recset), NULL);
-	g_return_val_if_fail (priv_data != NULL, NULL);
+	GdaValueType ftype;
+	gint scale;
+	GdaFieldAttributes *field_attrs;
+
+	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), NULL);
+	priv_data = g_object_get_data (G_OBJECT (model), OBJECT_DATA_RECSET_HANDLE);
+	g_return_val_if_fail (priv_data != NULL, 0);
 
 	pg_res = priv_data->pg_res;
 	if (!pg_res) {
-		gda_connection_add_error_string (
-			gda_recordset_get_connection (recset),
-			_("Invalid PostgreSQL handle"));
+		gda_connection_add_error_string (priv_data->gda_conn,
+						_("Invalid PostgreSQL handle"));
 		return NULL;
 	}
 
-	/* create the GdaRowAttributes to be returned */
 	field_count = PQnfields (pg_res);
-	attrs = gda_row_attributes_new (field_count);
-	
-	for (i = 0; i < field_count; i++) {
-		GdaFieldAttributes *field_attrs;
-		GdaValueType ftype;
-		gint scale;
-
-		field_attrs = gda_row_attributes_get_field (attrs, i);
-		gda_field_attributes_set_name (field_attrs, PQfname (pg_res, i));
-
-		ftype = gda_postgres_type_oid_to_gda (priv_data->type_data,
-						      priv_data->ntypes, 
-						      PQftype (pg_res, i));
-
-		scale = (ftype == GDA_VALUE_TYPE_DOUBLE) ? DBL_DIG :
-			(ftype == GDA_VALUE_TYPE_SINGLE) ? FLT_DIG : 0;
-
-		gda_field_attributes_set_scale (field_attrs, scale);
-		gda_field_attributes_set_gdatype (field_attrs, ftype);
-
-		// PQfsize() == -1 => variable length
-		gda_field_attributes_set_defined_size (field_attrs, 
-							PQfsize (pg_res, i));
-		gda_field_attributes_set_references (field_attrs, "");
-		gda_field_attributes_set_primary_key (field_attrs, FALSE);
-		gda_field_attributes_set_unique_key (field_attrs, FALSE);
+	if (field_count >= col){
+		gda_connection_add_error_string (priv_data->gda_conn,
+						_("Column out of range"));
+		return NULL;
 	}
 
-	return attrs;
+	field_attrs = gda_field_attributes_new ();
+	gda_field_attributes_set_name (field_attrs, PQfname (pg_res, col));
+
+	ftype = gda_postgres_type_oid_to_gda (priv_data->type_data,
+					      priv_data->ntypes, 
+					      PQftype (pg_res, col));
+
+	scale = (ftype == GDA_VALUE_TYPE_DOUBLE) ? DBL_DIG :
+		(ftype == GDA_VALUE_TYPE_SINGLE) ? FLT_DIG : 0;
+
+	gda_field_attributes_set_scale (field_attrs, scale);
+	gda_field_attributes_set_gdatype (field_attrs, ftype);
+
+	// PQfsize() == -1 => variable length
+	gda_field_attributes_set_defined_size (field_attrs, PQfsize (pg_res, col));
+	gda_field_attributes_set_references (field_attrs, "");
+	gda_field_attributes_set_primary_key (field_attrs, FALSE);
+	gda_field_attributes_set_unique_key (field_attrs, FALSE);
+	//FIXME: set_allow_null?
+
+	return field_attrs;
+}
+
+static gint
+get_n_columns_func (GdaDataModel *model)
+{
+	GdaPostgresRecordsetPrivate *priv_data;
+	PGresult *pg_res;
+
+	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), 0);
+	priv_data = g_object_get_data (G_OBJECT (model), OBJECT_DATA_RECSET_HANDLE);
+	g_return_val_if_fail (priv_data != NULL, 0);
+
+	pg_res = priv_data->pg_res;
+	if (!pg_res)
+		return 0;
+
+	return PQnfields (pg_res);
+}
+
+static gint
+get_n_rows_func (GdaDataModel *model)
+{
+	GdaPostgresRecordsetPrivate *priv_data;
+	PGresult *pg_res;
+
+	g_return_val_if_fail (GDA_IS_DATA_MODEL (model), 0);
+	priv_data = g_object_get_data (G_OBJECT (model), OBJECT_DATA_RECSET_HANDLE);
+	g_return_val_if_fail (priv_data != NULL, 0);
+
+	pg_res = priv_data->pg_res;
+	if (!pg_res)
+		return 0;
+
+	return PQntuples (pg_res);
 }
 
 /*
  * Public functions
  */
 
-GdaRecordset *
+GdaDataModel *
 gda_postgres_recordset_new (GdaConnection *cnc, PGresult *pg_res)
 {
-	GdaRecordset *recset;
+	GdaDataModel *model;
+	GdaDataModelClass *klass;
 	GdaPostgresRecordsetPrivate *priv_data;
 	GdaPostgresConnectionData *cnc_priv_data;
 
@@ -180,15 +214,26 @@
 
 	priv_data = g_new (GdaPostgresRecordsetPrivate, 1);
 	priv_data->pg_res = pg_res;
+	priv_data->gda_conn = cnc;
 	priv_data->ntypes = cnc_priv_data->ntypes;
 	priv_data->type_data = cnc_priv_data->type_data;
 	priv_data->h_table = cnc_priv_data->h_table;
 
-	recset = gda_recordset_new (cnc, fetch_func, describe_func, priv_data);
+	model = g_object_new (GDA_TYPE_DATA_MODEL, NULL);
+	klass = GDA_DATA_MODEL_CLASS (G_OBJECT_GET_CLASS (model));
+
+	klass->changed = NULL;
+	klass->begin_edit = NULL;
+	klass->cancel_edit = NULL;
+	klass->end_edit = NULL;
+	klass->get_n_rows = get_n_rows_func;
+	klass->get_n_columns = get_n_columns_func;
+	klass->describe_column = describe_func;
+	klass->get_value_at = get_value_at_func;
 
-	g_object_set_data_full (G_OBJECT (recset), OBJECT_DATA_RECSET_HANDLE,
+	g_object_set_data_full (G_OBJECT (model), OBJECT_DATA_RECSET_HANDLE,
 				priv_data, (GDestroyNotify) free_postgres_res);
 
-	return recset;
+	return model;
 }
 
Index: gda-postgres-recordset.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres-recordset.h,v
retrieving revision 1.3
diff -u -r1.3 gda-postgres-recordset.h
--- gda-postgres-recordset.h	22 Apr 2002 22:01:50 -0000	1.3
+++ gda-postgres-recordset.h	8 May 2002 03:15:10 -0000
@@ -26,12 +26,13 @@
 #if !defined(__gda_postgres_recordset_h__)
 #  define __gda_postgres_recordset_h__
 
-#include <libgda/gda-recordset.h>
+#include <libgda/gda-data-model-array.h>
+#include <libgda/gda-value.h>
 #include <libpq-fe.h>
 
 G_BEGIN_DECLS
 
-GdaRecordset *gda_postgres_recordset_new (GdaConnection *cnc, PGresult *pgres);
+GdaDataModel *gda_postgres_recordset_new (GdaConnection *cnc, PGresult *pgres);
 
 G_END_DECLS
 
Index: gda-postgres.h
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/gda-postgres.h,v
retrieving revision 1.11
diff -u -r1.11 gda-postgres.h
--- gda-postgres.h	26 Apr 2002 21:20:31 -0000	1.11
+++ gda-postgres.h	8 May 2002 03:15:10 -0000
@@ -43,9 +43,9 @@
  */
 
 GdaError *gda_postgres_make_error (PGconn *pconn, PGresult *pg_res);
-void gda_postgres_set_field_data (GdaField *field, const gchar *fname,
-				  GdaValueType type, const gchar *value, 
-				  gint dbsize, gboolean isNull);
+void gda_postgres_set_value (GdaValue *value, const gchar *fname,
+			     GdaValueType type, const gchar *thevalue, 
+			     gint dbsize, gboolean isNull);
 
 GdaValueType gda_postgres_type_oid_to_gda (GdaPostgresTypeOid *type_data, 
 					   gint ntypes, Oid postgres_type);
Index: utils.c
===================================================================
RCS file: /cvs/gnome/libgda/providers/postgres/utils.c,v
retrieving revision 1.21
diff -u -r1.21 utils.c
--- utils.c	22 Apr 2002 22:01:50 -0000	1.21
+++ utils.c	8 May 2002 03:15:10 -0000
@@ -129,10 +129,10 @@
 	timestamp->timezone = atol (value) * 60 * 60;
 }
 
-void 
-gda_postgres_set_field_data (GdaField *field, const gchar *fname,
-			     GdaValueType type, const gchar *value, 
-			     gint dbsize, gboolean isNull)
+void
+gda_postgres_set_value (GdaValue *value, const gchar *fname,
+			GdaValueType type, const gchar *thevalue, 
+			gint dbsize, gboolean isNull)
 {
 	GDate *gdate;
 	GdaDate date;
@@ -140,101 +140,80 @@
 	GdaTimestamp timestamp;
 	GdaGeometricPoint point;
 	GdaNumeric numeric;
-	gint scale;
 
-	g_return_if_fail (field != NULL);
-	g_return_if_fail (fname != NULL);
 	g_return_if_fail (value != NULL);
+	g_return_if_fail (fname != NULL);
+	g_return_if_fail (thevalue != NULL);
 
 	//TODO: What do I do with BLOBs?
 
-	gda_field_set_name (field, fname);
-	// dbsize == -1 => variable length
-	gda_field_set_defined_size (field, dbsize);
-	scale = (type == GDA_VALUE_TYPE_DOUBLE) ? DBL_DIG :
-		(type == GDA_VALUE_TYPE_SINGLE) ? FLT_DIG : 0;
-	gda_field_set_scale (field, scale);
-
-	if (isNull) 
-		type = GDA_VALUE_TYPE_NULL;
+	if (isNull){
+		gda_value_set_null (value);
+		return;
+	}
 
 	switch (type) {
 	case GDA_VALUE_TYPE_BOOLEAN :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_boolean_value (field, 
-				(*value == 't') ? TRUE : FALSE);
+		gda_value_set_boolean (value, (*thevalue == 't') ? TRUE : FALSE);
 		break;
 	case GDA_VALUE_TYPE_STRING :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_string_value (field, value);
+		gda_value_set_string (value, thevalue);
 		break;
 	case GDA_VALUE_TYPE_BIGINT :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_bigint_value (field, atoll (value));
+		gda_value_set_bigint (value, atoll (thevalue));
 		break;
 	case GDA_VALUE_TYPE_INTEGER :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_integer_value (field, atol (value));
+		gda_value_set_integer (value, atol (thevalue));
 		break;
 	case GDA_VALUE_TYPE_SMALLINT :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_smallint_value (field, atoi (value));
+		gda_value_set_smallint (value, atoi (thevalue));
 		break;
 	case GDA_VALUE_TYPE_SINGLE :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_single_value (field, atof (value));
+		gda_value_set_single (value, atof (thevalue));
 		break;
 	case GDA_VALUE_TYPE_DOUBLE :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_double_value (field, atof (value));
+		gda_value_set_double (value, atof (thevalue));
 		break;
 	case GDA_VALUE_TYPE_NUMERIC :
-		numeric.number = g_strdup (value);
+		numeric.number = g_strdup (thevalue);
 		numeric.precision = 0; //FIXME
 		numeric.width = 0; //FIXME
-		gda_field_set_gdatype (field, type);
-		gda_field_set_numeric_value (field, &numeric);
+		gda_value_set_numeric (value, &numeric);
 		g_free (numeric.number);
 		break;
 	case GDA_VALUE_TYPE_DATE :
-		gda_field_set_gdatype (field, type);
 		gdate = g_date_new ();
-		g_date_set_parse (gdate, value);
+		g_date_set_parse (gdate, thevalue);
 		if (!g_date_valid (gdate)) {
 			g_warning ("Could not parse '%s' "
-				"Setting date to 01/01/0001!\n", value);
+				"Setting date to 01/01/0001!\n", thevalue);
 			g_date_clear (gdate, 1);
 			g_date_set_dmy (gdate, 1, 1, 1);
 		}
 		date.day = g_date_get_day (gdate);
 		date.month = g_date_get_month (gdate);
 		date.year = g_date_get_year (gdate);
-		gda_field_set_date_value (field, &date);
+		gda_value_set_date (value, &date);
 		g_date_free (gdate);
 		break;
 	case GDA_VALUE_TYPE_GEOMETRIC_POINT :
-		make_point (&point, value);
-		gda_field_set_geometric_point_value (field, &point);
-		gda_field_set_gdatype (field, type);
+		make_point (&point, thevalue);
+		gda_value_set_geometric_point (value, &point);
 		break;
 	case GDA_VALUE_TYPE_NULL :
-		gda_field_set_gdatype (field, type);
-		gda_field_set_null_value (field);
+		gda_value_set_null (value);
 		break;
 	case GDA_VALUE_TYPE_TIMESTAMP :
-		make_timestamp (&timestamp, value);
-		gda_field_set_timestamp_value (field, &timestamp);
-		gda_field_set_gdatype (field, type);
+		make_timestamp (&timestamp, thevalue);
+		gda_value_set_timestamp (value, &timestamp);
 		break;
 	case GDA_VALUE_TYPE_TIME :
-		make_time (&timegda, value);
-		gda_field_set_time_value (field, &timegda);
-		gda_field_set_gdatype (field, type);
+		make_time (&timegda, thevalue);
+		gda_value_set_time (value, &timegda);
 		break;
 	case GDA_VALUE_TYPE_BINARY : //FIXME
 	default :
-		gda_field_set_string_value (field, value);
-		gda_field_set_gdatype (field, GDA_VALUE_TYPE_STRING);
+		gda_value_set_string (value, thevalue);
 	}
 }
 


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