[gnome-db] Patch for new data type (Point) and support for it in postgres.
- From: Gonzalo Paniagua Javier <gonzalo gnome-db org>
- To: Gnome-db list <gnome-db-list gnome org>
- Subject: [gnome-db] Patch for new data type (Point) and support for it in postgres.
- Date: Fri, 4 Jan 2002 00:20:36 +0100
Hi all!
Well here goes the patch that adds support for GdaGeometricPoint
to the library and the postgres provider. Already tested and it
works!
Now a little question: why 'cvs diff' gives me differences in
the following files that I have not even looked at?
doc/C/tmpl/gda-report-client.sgml
doc/C/tmpl/gda-report-datasource.sgml
doc/C/tmpl/gda-report-document.sgml
doc/C/tmpl/gda-server-recordset-model.sgml
doc/C/tmpl/gda-util.sgml
Bye!
Index: idl/ChangeLog
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/idl/ChangeLog,v
retrieving revision 1.19
diff -u -r1.19 ChangeLog
--- idl/ChangeLog 30 Dec 2001 12:48:41 -0000 1.19
+++ idl/ChangeLog 3 Jan 2002 23:03:47 -0000
@@ -1,3 +1,7 @@
+2002-01-03 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+ * GNOME_Database.idl: added Point as new data type.
+
2001-12-29 Rodrigo Moya <rodrigo gnome-db org>
* GNOME_Database.idl: added more schemas (VIEWS, PROCEDURES, TYPES)
Index: GNOME_Database.idl
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/idl/GNOME_Database.idl,v
retrieving revision 1.13
diff -u -r1.13 GNOME_Database.idl
--- GNOME_Database.idl 30 Dec 2001 12:48:41 -0000 1.13
+++ GNOME_Database.idl 3 Jan 2002 23:14:17 -0000
@@ -33,10 +33,11 @@
TYPE_SMALLINT,
TYPE_TINYINT,
TYPE_STRING,
+ TYPE_POINT,
TYPE_UNKNOWN
};
- struct Date{
+ struct Date {
short year;
unsigned short month;
unsigned short day;
@@ -54,6 +55,10 @@
unsigned short minute;
unsigned short second;
unsigned long fraction;
+ };
+ struct Point {
+ double x;
+ double y;
};
/*
Index: libgda/ChangeLog
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/ChangeLog,v
retrieving revision 1.57
diff -u -r1.57 ChangeLog
--- libgda/ChangeLog 3 Jan 2002 17:01:09 -0000 1.57
+++ libgda/ChangeLog 3 Jan 2002 23:07:30 -0000
@@ -1,8 +1,10 @@
2002-01-03 Gonzalo Paniagua Javier <gonzalo gnome-db org>
- * gda-server-connection.c (gda_server_connection_free_error_list):
- Test if the error list is NULL to avoid failing assertion in
- gda_error_list_free().
+ * Changelog: fix little mistake.
+
+ * gda-row.[ch]:
+ * gda-value.[ch]:
+ Added support for Point data type.
2002-01-02 Gonzalo Paniagua Javier <gonzalo gnome-db org>
@@ -11,6 +13,7 @@
* Makefile.am: s/IDLFILES/IDL_FILES, so that ORBit-generated files
are regenerated when the IDL files change
+
* gda-server-connection.c (gda_server_connection_free_error_list):
Test if the error list is NULL to avoid failing assertion in
gda_error_list_free().
Index: libgda/gda-row.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-row.c,v
retrieving revision 1.8
diff -u -r1.8 gda-row.c
--- libgda/gda-row.c 30 Dec 2001 16:29:44 -0000 1.8
+++ libgda/gda-row.c 3 Jan 2002 21:02:26 -0000
@@ -632,6 +632,31 @@
}
+/**
+ * gda_field_get_point_value
+ */
+GdaGeometricPoint *
+gda_field_get_point_value (GdaField *field)
+{
+ g_return_val_if_fail (field != NULL, NULL);
+ return gda_value_get_point (&field->value);
+}
+
+/**
+ * gda_field_set_point_value
+ */
+void
+gda_field_set_point_value (GdaField *field, GdaGeometricPoint *value)
+{
+ g_return_if_fail (field != NULL);
+ g_return_if_fail (value != NULL);
+
+ field->attributes.gdaType = GDA_TYPE_POINT;
+ field->actualSize = sizeof (GdaGeometricPoint);
+
+ gda_value_set_point (&field->value, value);
+}
+
/**
* gda_field_stringify
Index: libgda/gda-row.h
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-row.h,v
retrieving revision 1.5
diff -u -r1.5 gda-row.h
--- libgda/gda-row.h 30 Dec 2001 16:29:44 -0000 1.5
+++ libgda/gda-row.h 3 Jan 2002 21:03:15 -0000
@@ -49,6 +49,7 @@
#define GDA_TYPE_SMALLINT GNOME_Database_TYPE_SMALLINT
#define GDA_TYPE_STRING GNOME_Database_TYPE_STRING
#define GDA_TYPE_TINYINT GNOME_Database_TYPE_TINYINT
+#define GDA_TYPE_POINT GNOME_Database_TYPE_POINT
#define GDA_TYPE_UNKNOWN GNOME_Database_TYPE_UNKNOWN
GdaRow *gda_row_new (gint count);
@@ -106,6 +107,10 @@
void gda_field_set_timestamp_value (GdaField *field, time_t value);
gchar gda_field_get_tinyint_value (GdaField *field);
void gda_field_set_tinyint_value (GdaField *field, gchar value);
+GdaGeometricPoint *gda_field_get_point_value (GdaField *field);
+void gda_field_set_point_value (GdaField *field,
+ GdaGeometricPoint *value);
+
gchar *gda_field_stringify (GdaField *field);
G_END_DECLS
Index: libgda/gda-value.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-value.c,v
retrieving revision 1.9
diff -u -r1.9 gda-value.c
--- libgda/gda-value.c 24 Dec 2001 00:32:21 -0000 1.9
+++ libgda/gda-value.c 3 Jan 2002 22:53:14 -0000
@@ -146,6 +146,12 @@
return bonobo_arg_new_from (GDA_VALUE_TYPE_TINYINT, (gconstpointer) &val);
}
+GdaValue *
+gda_value_new_point (GdaGeometricPoint *val)
+{
+ return bonobo_arg_new_from (GDA_VALUE_TYPE_POINT, (gconstpointer) val);
+}
+
/**
* gda_value_free
*/
@@ -557,6 +563,36 @@
}
/**
+ * gda_value_get_point
+ */
+GdaGeometricPoint *
+gda_value_get_point (GdaValue *value)
+{
+ g_return_val_if_fail (value != NULL, NULL);
+
+ return (GdaGeometricPoint *) value->_value;
+}
+
+/**
+ * gda_value_set_point
+ */
+void
+gda_value_set_point (GdaValue *value, GdaGeometricPoint *val)
+{
+ g_return_if_fail (value != NULL);
+ g_return_if_fail (val != NULL);
+
+ if (!gda_value_isa (value, GDA_VALUE_TYPE_POINT)) {
+ clear_value (value);
+ value->_type = ORBit_RootObject_duplicate (GDA_VALUE_TYPE_POINT);
+ }
+ else if (value->_value)
+ CORBA_free (value->_value);
+
+ value->_value = ORBit_copy_value (val, TC_GNOME_Database_Point);
+}
+
+/**
* gda_value_stringify
*/
gchar *
@@ -590,6 +626,12 @@
}
else if (gda_value_isa (value, GDA_VALUE_TYPE_TIMESTAMP)) {
/* FIXME: implement, and add all missing ones */
+ }
+ else if (gda_value_isa (value, GDA_VALUE_TYPE_POINT)) {
+ GdaGeometricPoint *point;
+
+ point = gda_value_get_point (value);
+ retval = g_strdup_printf ("(%f,%f)", point->x, point->y);
}
else if (gda_value_isa (value, GDA_VALUE_TYPE_NULL))
retval = g_strdup ("NULL");
Index: libgda/gda-value.h
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/libgda/gda-value.h,v
retrieving revision 1.4
diff -u -r1.4 gda-value.h
--- libgda/gda-value.h 7 Nov 2001 19:00:42 -0000 1.4
+++ libgda/gda-value.h 3 Jan 2002 21:06:56 -0000
@@ -45,6 +45,9 @@
#define GDA_VALUE_TYPE_TIME TC_GNOME_Database_Time
#define GDA_VALUE_TYPE_TIMESTAMP TC_GNOME_Database_Timestamp
#define GDA_VALUE_TYPE_TINYINT TC_CORBA_char
+#define GDA_VALUE_TYPE_POINT TC_GNOME_Database_Point
+
+typedef GNOME_Database_Point GdaGeometricPoint;
GdaValue *gda_value_new_null (void);
GdaValue *gda_value_new_bigint (long long val);
@@ -59,6 +62,7 @@
GdaValue *gda_value_new_time (GTime val);
GdaValue *gda_value_new_timestamp (time_t val);
GdaValue *gda_value_new_tinyint (gchar val);
+GdaValue *gda_value_new_point (GdaGeometricPoint *val);
void gda_value_free (GdaValue *value);
@@ -89,6 +93,8 @@
void gda_value_set_timestamp (GdaValue *value, time_t val);
gchar gda_value_get_tinyint (GdaValue *value);
void gda_value_set_tinyint (GdaValue *value, gchar val);
+GdaGeometricPoint *gda_value_get_point (GdaValue *value);
+void gda_value_set_point (GdaValue *value, GdaGeometricPoint *val);
gchar *gda_value_stringify (GdaValue *value);
Index: providers/postgres/ChangeLog
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- providers/postgres/ChangeLog 3 Jan 2002 17:01:35 -0000 1.4
+++ providers/postgres/ChangeLog 3 Jan 2002 22:57:36 -0000
@@ -1,3 +1,10 @@
+2002-01-03 Gonzalo Paniagua Javier <gonzalo gnome-db org>
+
+ * utils.c:
+ * gda-postgres-recordset.c:
+ Added support for GdaGeometricPoint.
+
+
2002-01-02 Gonzalo Paniagua Javier <gonzalo gnome-db org>
* gda-postgres-provider.c (process_sql_commands()): don't call
Index: providers/postgres/utils.c
===================================================================
RCS file: /home/gpanjav/gnome-db-2/cvs/libgda/providers/postgres/utils.c,v
retrieving revision 1.4
diff -u -r1.4 utils.c
--- providers/postgres/utils.c 3 Jan 2002 17:01:35 -0000 1.4
+++ providers/postgres/utils.c 3 Jan 2002 23:02:27 -0000
@@ -36,12 +36,12 @@
gda_error_set_description (error, PQerrorMessage(handle));
gda_error_set_number (error, -1);
} else {
- gda_error_set_description (error, "NO DESCRIPTION");
+ gda_error_set_description (error, _("NO DESCRIPTION"));
gda_error_set_number (error, -1);
}
gda_error_set_source (error, "gda-postgres");
- gda_error_set_sqlstate (error, "Not available");
+ gda_error_set_sqlstate (error, _("Not available"));
return error;
}
@@ -80,15 +80,43 @@
return GDA_TYPE_TIME;
case VARBITOID :
return GDA_TYPE_BINARY;
+ case POINTOID :
+ return GDA_TYPE_POINT;
}
return GDA_TYPE_UNKNOWN;
}
+static GdaGeometricPoint *
+make_point (const gchar *value)
+{
+ GdaGeometricPoint *point;
+
+ g_return_val_if_fail (value != NULL, NULL);
+
+ point = g_new (GdaGeometricPoint, 1);
+ value++;
+ point->x = atof (value);
+ value = strchr (value, ',');
+ value++;
+ point->y = atof (value);
+
+ return point;
+}
+
+static void
+delete_point (GdaGeometricPoint *point)
+{
+ g_return_if_fail (point != NULL);
+
+ g_free (point);
+}
+
void
gda_postgres_set_type_value (GdaField *field, GdaType type, const gchar *value)
{
GDate *date;
+ GdaGeometricPoint *point;
switch (type) {
case GDA_TYPE_BOOLEAN :
@@ -132,6 +160,12 @@
gda_field_set_date_value (field, date);
g_date_free (date);
+ break;
+ case GDA_TYPE_POINT :
+ point = make_point (value);
+ gda_field_set_point_value (field, point);
+ gda_field_set_gdatype (field, type);
+ delete_point (point);
break;
case GDA_TYPE_TIMESTAMP : //FIXME
case GDA_TYPE_TIME : //FIXME
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]