[gnome-db] New gda_parse_string convenient function



Please find attached a new gda_parse_string convenient function. I'm using in some code and I think any buddy needs to parse a SQL command string and get its parameters all the time, this function helps on it.


--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)
From 74100753dd1bfe8e1fa4c3a1d2536857802ec714 Mon Sep 17 00:00:00 2001
From: Daniel Espinosa <esodan gmail com>
Date: Wed, 9 Jun 2010 20:18:41 -0500
Subject: [PATCH] Added a new gda_parse_string convenient function

---
 doc/C/tmpl/gda-column.sgml          |    2 --
 doc/C/tmpl/gda-connection.sgml      |    2 --
 doc/C/tmpl/gda-data-proxy.sgml      |    8 --------
 doc/C/tmpl/gda-server-provider.sgml |    4 ++++
 libgda/gda-easy.c                   |   26 ++++++++++++++++++++++++++
 libgda/gda-easy.h                   |    3 ++-
 libgda/libgda.symbols               |    1 +
 7 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/doc/C/tmpl/gda-column.sgml b/doc/C/tmpl/gda-column.sgml
index 5358ffb..13be76a 100644
--- a/doc/C/tmpl/gda-column.sgml
+++ b/doc/C/tmpl/gda-column.sgml
@@ -32,8 +32,6 @@ Management of #GdaDataModel column attributes
 
 </para>
 
-@:
-
 @gdacolumn: the object which received the signal.
 @arg1: 
 @arg2: 
diff --git a/doc/C/tmpl/gda-connection.sgml b/doc/C/tmpl/gda-connection.sgml
index 7ed7a3c..7722371 100644
--- a/doc/C/tmpl/gda-connection.sgml
+++ b/doc/C/tmpl/gda-connection.sgml
@@ -159,7 +159,6 @@ A connection to a database
 @GDA_CONNECTION_OPTIONS_READ_ONLY: 
 @GDA_CONNECTION_OPTIONS_SQL_IDENTIFIERS_CASE_SENSITIVE: 
 @GDA_CONNECTION_OPTIONS_THREAD_SAFE: 
- GDA_CONNECTION_OPTIONS_THREAD_ISOLATED: 
 
 <!-- ##### ENUM GdaConnectionError ##### -->
 <para>
@@ -614,7 +613,6 @@ A connection to a database
 @GDA_CONNECTION_FEATURE_USERS: 
 @GDA_CONNECTION_FEATURE_VIEWS: 
 @GDA_CONNECTION_FEATURE_XA_TRANSACTIONS: 
- GDA_CONNECTION_FEATURE_MULTI_THREADING: 
 @GDA_CONNECTION_FEATURE_LAST: 
 
 <!-- ##### FUNCTION gda_connection_supports_feature ##### -->
diff --git a/doc/C/tmpl/gda-data-proxy.sgml b/doc/C/tmpl/gda-data-proxy.sgml
index e44a0a3..0db259f 100644
--- a/doc/C/tmpl/gda-data-proxy.sgml
+++ b/doc/C/tmpl/gda-data-proxy.sgml
@@ -137,8 +137,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode
 
 </para>
 
-@:
-
 @gdadataproxy: the object which received the signal.
 @arg1: 
 @arg2: 
@@ -148,8 +146,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode
 
 </para>
 
-@:
-
 @gdadataproxy: the object which received the signal.
 @arg1: 
 @arg2: 
@@ -159,8 +155,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode
 
 </para>
 
-@:
-
 @gdadataproxy: the object which received the signal.
 @arg1: 
 @arg2: 
@@ -178,8 +172,6 @@ Proxy to hold modifications for any #GdaDataModel, and provides the #GdaDataMode
 
 </para>
 
-@:
-
 @Returns: 
 @Param2: 
 @Param3: 
diff --git a/doc/C/tmpl/gda-server-provider.sgml b/doc/C/tmpl/gda-server-provider.sgml
index e7a91fe..7328eca 100644
--- a/doc/C/tmpl/gda-server-provider.sgml
+++ b/doc/C/tmpl/gda-server-provider.sgml
@@ -70,6 +70,10 @@ Base class for all the DBMS providers
 @xa_funcs: 
 @identifier_quote: 
 @handle_async: 
+ _gda_reserved3: 
+ _gda_reserved4: 
+ _gda_reserved5: 
+ _gda_reserved6: 
 
 <!-- ##### ENUM GdaServerProviderError ##### -->
 <para>
diff --git a/libgda/gda-easy.c b/libgda/gda-easy.c
index 5879c9d..31b15e0 100644
--- a/libgda/gda-easy.c
+++ b/libgda/gda-easy.c
@@ -1050,3 +1050,29 @@ gda_delete_row_from_table (GdaConnection *cnc, const gchar *table,
 	return retval;
 }
 
+/**
+ * gda_parse_string
+ * @cnc: a #GdaConnection object
+ * @sql: a valid GDA's string representation for a SQL command to parse
+ * @params: (out) (allow-none) (transfer full): a place to store a new #GdaSet, for parameters used in SQL command
+ * @error: a place to store errors
+ *
+ * This function helps to parse a SQL witch use paramenters and store them at @params.
+ *
+ * Returns: a #GdaStatement representing the SQL command
+ */
+GdaStatement*
+gda_parse_string (GdaConnection *cnc, const gchar *sql, GdaSet **params, GError **error)
+{
+	GdaStatement *stm;
+	GdaSqlParser *parser;
+	parser = gda_connection_create_parser (cnc);
+	stm = gda_sql_parser_parse_string (parser, sql, NULL, error);
+	if (!GDA_IS_STATEMENT (stm))
+		return NULL;
+	if (!gda_statement_get_parameters (stm, params, error))
+		return NULL;
+	g_object_unref (parser);
+	
+	return stm;
+}
\ No newline at end of file
diff --git a/libgda/gda-easy.h b/libgda/gda-easy.h
index 22d1e4f..b44f97f 100644
--- a/libgda/gda-easy.h
+++ b/libgda/gda-easy.h
@@ -60,7 +60,8 @@ typedef enum
  * Convenient Functions
  */
 GdaDataHandler     *gda_get_default_handler           (GType for_type);
-
+GdaStatement       *gda_parse_string                  (GdaConnection *cnc, const gchar *sql, GdaSet **params,
+    												   GError **error);
 /*
  * Quick commands execution
  */
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 75b7d4b..084b1d2 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -457,6 +457,7 @@
 	gda_parse_iso8601_date
 	gda_parse_iso8601_time
 	gda_parse_iso8601_timestamp
+	gda_parse_string
 	gda_perform_create_database
 	gda_perform_create_table
 	gda_perform_drop_database
-- 
1.7.0.4



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