[libgdamm] Connection: Add some methods.



commit 03f8607e60679a70a4c10d9767613e7e67becbe5
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Mar 30 10:24:39 2011 +0200

    Connection: Add some methods.
    
    * libgda/src/connection.[hg|ccg]: parse_sql_string(),
    async_statement_execute(), async_fetch_result() and async_cancel().

 ChangeLog                 |    7 +++++++
 libgda/src/connection.ccg |   38 ++++++++++++++++++++++++--------------
 libgda/src/connection.hg  |   15 +++++++++++++++
 3 files changed, 46 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 62e9bbf..4034fa3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-03-30  Murray Cumming  <murrayc murrayc com>
 
+	Connection: Add some methods.
+
+	* libgda/src/connection.[hg|ccg]: parse_sql_string(),
+	async_statement_execute(), async_fetch_result() and async_cancel().
+
+2011-03-30  Murray Cumming  <murrayc murrayc com>
+
 	Avoid a tarball dependency on mm-common.
 
 	* configure.ac: Require the latest version of mm-common.
diff --git a/libgda/src/connection.ccg b/libgda/src/connection.ccg
index e782ee1..180df04 100644
--- a/libgda/src/connection.ccg
+++ b/libgda/src/connection.ccg
@@ -1,8 +1,8 @@
 /* $Id: connection.ccg,v 1.18 2006/11/30 06:58:55 murrayc Exp $ */
-// -*- C++ -*- // 
+// -*- C++ -*- //
 
 /* connection.cc
- * 
+ *
  * Copyright 2003 libgdamm Development Team
  *
  * This library is free software; you can redistribute it and/or
@@ -297,7 +297,7 @@ Glib::ustring Connection::statement_to_sql(const Glib::RefPtr<const Statement>&
   {
     params_used.push_back(*i);
   }
-  
+
   return retvalue;
 }
 
@@ -477,8 +477,8 @@ bool Connection::update_meta_store(std::auto_ptr<Glib::Error>& error)
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
-  
-  return retvalue;  
+
+  return retvalue;
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -497,8 +497,8 @@ bool Connection::update_meta_store(const Glib::ustring& id, std::auto_ptr<Glib::
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
-  
-  return retvalue;  
+
+  return retvalue;
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -526,12 +526,12 @@ bool Connection::update_meta_store_table(const Glib::ustring& table_name, const
 bool Connection::update_meta_store_table(const Glib::ustring& table_name, const Glib::ustring& schema_name, std::auto_ptr<Glib::Error>& error)
 #endif
 {
-  // This function is needed to make sure that 
-  // the GdaMetaStore really gets the meta data for the table we specified, even if 
+  // This function is needed to make sure that
+  // the GdaMetaStore really gets the meta data for the table we specified, even if
   // the table name contains upper-case characters or spaces. murrayc.
   gchar* table_name_quoted = gda_meta_store_sql_identifier_quote (table_name.c_str(), gobj());
   //std::cout << "Connection::update_meta_store_table(): table_name_quoted=" << table_name_quoted << std::endl;
-  
+
   GValue table_name_value = { 0 };
   g_value_init(&table_name_value, G_TYPE_STRING);
   g_value_set_static_string(&table_name_value, table_name_quoted);
@@ -549,7 +549,7 @@ bool Connection::update_meta_store_table(const Glib::ustring& table_name, const
 
   g_value_unset(&table_name_value);
   g_value_unset(&table_schema_value);
-  
+
   g_free(table_name_quoted);
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -589,7 +589,7 @@ bool Connection::update_meta_store_table_names(const Glib::ustring& schema_name,
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
-  
+
   return retval;
 }
 
@@ -602,7 +602,7 @@ bool Connection::update_meta_store_data_types(std::auto_ptr<Glib::Error>& error)
   GdaMetaContext mcontext = {(gchar*)"_builtin_data_types", 0, 0, 0 };
   GError* gerror = 0;
   const bool retval = gda_connection_update_meta_store(gobj(), &mcontext, &gerror);
-  
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -610,10 +610,20 @@ bool Connection::update_meta_store_data_types(std::auto_ptr<Glib::Error>& error)
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
-  
+
   return retval;
 }
 
+Glib::RefPtr<Statement> Connection::parse_sql_string(const Glib::ustring& sql)
+{
+  GError* gerror = 0;
+  Glib::RefPtr<Statement> retvalue = Glib::wrap(gda_connection_parse_sql_string(gobj(), sql.c_str(), 0 /* see C docs */, &(gerror)));
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+
+  return retvalue;
+}
+
 } //namespace Gda
 
 } //namespace Gnome
diff --git a/libgda/src/connection.hg b/libgda/src/connection.hg
index 6f5714d..1eacdfa 100644
--- a/libgda/src/connection.hg
+++ b/libgda/src/connection.hg
@@ -219,6 +219,14 @@ public:
   int statement_execute_non_select_builder(const Glib::RefPtr<const SqlBuilder>& builder, const Glib::RefPtr<const Set>& params, std::auto_ptr<Glib::Error>& error);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
 
+  _WRAP_METHOD(guint async_statement_execute(const Glib::RefPtr<const Statement>& stmt, const Glib::RefPtr<const Set>& params, StatementModelUsage model_usage, const std::vector<GType>& col_types, bool need_last_insert_row = false), gda_connection_async_statement_execute, errthrow)
+
+  //TODO: Wrap the last_insert_row parameter properly and add an overload without it:
+  _WRAP_METHOD(Glib::RefPtr<Glib::Object> async_fetch_result(guint task_id, GdaSet **last_insert_row), gda_connection_async_fetch_result, errthrow)
+  _WRAP_METHOD(bool async_cancel(guint task_id), gda_connection_async_cancel, errthrow)
+
+//TODO: #m4 _CONVERSION(`GSList*',`std::vector<Glib::Object>',`$2(Glib::SListHandler<Glib::RefPtr<const Statement> >::slist_to_vector((GSList*)$3, Glib::OWNERSHIP_DEEP))')
+//  _WRAP_METHOD(std::vector<Glib::Object> repetitive_statement_execute(GdaRepetitiveStatement *rstmt, StatementModelUsage model_usage, const std::vector<GType>& col_types, gboolean stop_on_error = true), gda_connection_repetitive_statement_execute, errthrow)
 
   //Note that we do not add a non-const version of this because the documentation says that it should not be modified:
   _WRAP_METHOD(Glib::RefPtr<const TransactionStatus> get_transaction_status() const, gda_connection_get_transaction_status, errthrow, refreturn)
@@ -247,6 +255,13 @@ public:
   _WRAP_METHOD(bool supports_feature(ConnectionFeature feature) const, gda_connection_supports_feature)
 
   _WRAP_METHOD(Glib::ustring get_authentication() const, gda_connection_get_authentication)
+
+  //TODO: Wrap the GdaSet** output parameter:
+  //_WRAP_METHOD(Glib::RefPtr<Statement> parse_sql_string(const Glib::ustring& sql, GdaSet** params), gda_connection_parse_sql_string, errthrow)
+
+  //TODO: Documentation:
+  Glib::RefPtr<Statement> parse_sql_string(const Glib::ustring& sql);
+
   _WRAP_METHOD(Glib::RefPtr<SqlParser> create_parser(), gda_connection_create_parser)
 
   _WRAP_METHOD(Glib::ustring get_provider_name() const, gda_connection_get_provider_name)



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