gnomemm r1861 - in libgdamm/trunk: . libgda/src



Author: murrayc
Date: Mon Dec 15 12:58:37 2008
New Revision: 1861
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1861&view=rev

Log:
2008-12-15  Murray Cumming  <murrayc murrayc com>

Re-committed this, calling the C function directly to avoid a non-NULL 
col_types parameter:

* libgda/src/connection.ccg:
* libgda/src/connection.hg: statement_execute_select(): Add a 
StatementModelUsage parameter, with a default value, so we can 
specify a cursor model.
statement_execute_select_full(): Rename to statement_execute_select().

Modified:
   libgdamm/trunk/ChangeLog
   libgdamm/trunk/libgda/src/config.hg
   libgdamm/trunk/libgda/src/connection.ccg
   libgdamm/trunk/libgda/src/connection.hg
   libgdamm/trunk/libgda/src/datamodelarray.hg
   libgdamm/trunk/libgda/src/statement.hg

Modified: libgdamm/trunk/libgda/src/config.hg
==============================================================================
--- libgdamm/trunk/libgda/src/config.hg	(original)
+++ libgdamm/trunk/libgda/src/config.hg	Mon Dec 15 12:58:37 2008
@@ -46,16 +46,20 @@
   _WRAP_METHOD(static Glib::RefPtr<Config> get(), gda_config_get, refreturn)
   
   _WRAP_METHOD_DOCS_ONLY(gda_config_get_dsn_info)
-  static GdaDsnInfo* get_dsn_info (const Glib::ustring& dsn_name);
+  static GdaDsnInfo* get_dsn_info(const Glib::ustring& dsn_name);
     
   _WRAP_METHOD_DOCS_ONLY(gda_config_dsn_needs_authentication)
   static bool dsn_needs_authentication(const Glib::ustring& dsn_name);
+
   _WRAP_METHOD_DOCS_ONLY(gda_config_list_dsn)
   static Glib::RefPtr<DataModel> list_dsn();
+
   _WRAP_METHOD_DOCS_ONLY(gda_config_list_providers)
   static Glib::RefPtr<DataModel> list_providers();
+
   _WRAP_METHOD_DOCS_ONLY(gda_config_get_nb_dsn)
   static int get_nb_dsn();
+
   _WRAP_METHOD_DOCS_ONLY(gda_config_can_modify_system_config)
   static bool can_modify_system_config();
   
@@ -65,8 +69,8 @@
   _WRAP_SIGNAL(void dsn_removed(GdaDsnInfo* info), "dsn-removed", no_default_handler)
   _WRAP_SIGNAL(void dsn_to_be_removed(GdaDsnInfo* info), "dsn-to-be-removed", no_default_handler)
 
-  _WRAP_PROPERTY("system-filename", Glib::ustring);
-  _WRAP_PROPERTY("user-filename", Glib::ustring);
+  _WRAP_PROPERTY("system-filename", Glib::ustring)
+  _WRAP_PROPERTY("user-filename", Glib::ustring)
 };
 
 } // namespace Gda

Modified: libgdamm/trunk/libgda/src/connection.ccg
==============================================================================
--- libgdamm/trunk/libgda/src/connection.ccg	(original)
+++ libgdamm/trunk/libgda/src/connection.ccg	Mon Dec 15 12:58:37 2008
@@ -45,12 +45,12 @@
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::RefPtr<Connection> Connection::open_from_string (const Glib::ustring& provider_name,
+Glib::RefPtr<Connection> Connection::open_from_string(const Glib::ustring& provider_name,
                                                        const Glib::ustring& cnc_string,
                                                        const Glib::ustring& auth_string,
                                                        ConnectionOptions options)
 #else
-Glib::RefPtr<Connection> Connection::open_from_string (const Glib::ustring& provider_name,
+Glib::RefPtr<Connection> Connection::open_from_string(const Glib::ustring& provider_name,
                                                        const Glib::ustring& cnc_string,
                                                        const Glib::ustring& auth_string,
                                                        ConnectionOptions options,
@@ -58,7 +58,7 @@
 #endif
 {
   GError* gerror = 0;
-  Glib::RefPtr<Connection> retval = Glib::wrap(gda_connection_open_from_string (provider_name.c_str(),
+  Glib::RefPtr<Connection> retval = Glib::wrap(gda_connection_open_from_string(provider_name.c_str(),
                                                                                 cnc_string.c_str(),
                                                                                 auth_string.c_str(),
                                                                                 (GdaConnectionOptions)options,
@@ -91,6 +91,7 @@
   GdaSet* lir = 0;
   Glib::RefPtr<Glib::Object> retval = Glib::wrap(
     gda_connection_statement_execute(gobj(), cmd->gobj(), Glib::unwrap(params), (GdaStatementModelUsage)model_usage, &lir, &gerror));
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -98,10 +99,10 @@
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
-  if (lir)
-  {
+
+  if(lir)
     last_inserted_row = Glib::wrap(lir);
-  }
+
   return retval;
 }
 
@@ -114,6 +115,7 @@
   GError* gerror = 0;
   Glib::RefPtr<Glib::Object> retval = Glib::wrap(
     gda_connection_statement_execute(gobj(), Glib::unwrap(stmt), 0, (GdaStatementModelUsage)model_usage, 0, &gerror));
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -121,6 +123,7 @@
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
+
   return retval;
 }
 
@@ -130,23 +133,29 @@
 Glib::RefPtr<Glib::Object> Connection::statement_execute(const Glib::ustring& sql, StatementModelUsage model_usage, std::auto_ptr<Glib::Error>& error)
 #endif // GLIBMM_EXCEPTIONS_ENABLED
 {
+  Glib::RefPtr<Statement> stmt;
   Glib::RefPtr<SqlParser> parser = create_parser();
-  if (parser)
+  if(parser)
   {
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-    Glib::RefPtr<Statement> stmt = parser->parse_string(sql);
-    if (!stmt)
-      return Glib::RefPtr<Object>(0);
-    return statement_execute (stmt, model_usage);
-#else
-    Glib::RefPtr<Statement> stmt = parser->parse_string(sql, error);
-    if (error || !stmt)
-      return Glib::RefPtr<Object>(0);
-    return statement_execute (stmt, model_usage, error);
+    stmt = parser->parse_string(sql);
+#else
+    stmt = parser->parse_string(sql, error);
+    if(error)
+      return Glib::RefPtr<Glib::Object>();
 #endif
   }
-  std::cerr << "Gda::Connection::statement_execute(): Couldn't create parser" << std::endl;
-  return Glib::RefPtr<Object>(0);
+  else
+    std::cerr << "Gda::Connection::statement_execute(): Couldn't create parser" << std::endl;
+
+  if(!stmt)
+    return Glib::RefPtr<Glib::Object>();
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+    return statement_execute(stmt, model_usage);
+#else
+    return statement_execute(stmt, model_usage, error);
+#endif
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -157,7 +166,8 @@
 {
   GError* gerror = 0;
   GdaSet* lir = 0;
-  int retval = gda_connection_statement_execute_non_select(gobj(), Glib::unwrap(cmd), Glib::unwrap(params), &lir, &gerror);
+  const int retval = gda_connection_statement_execute_non_select(gobj(), Glib::unwrap(cmd), Glib::unwrap(params), &lir, &gerror);
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -165,10 +175,10 @@
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
-  if (lir)
-  {
+
+  if(lir)
     last_inserted_row = Glib::wrap(lir);
-  }
+
   return retval;
 }
 
@@ -187,6 +197,7 @@
   if(gerror)
     error = ::Glib::Error::throw_exception(gerror);
 #endif //GLIBMM_EXCEPTIONS_ENABLED
+
   return retval;
 }
 
@@ -198,7 +209,8 @@
 {
   GError* gerror = 0;
   GSList* params_usedc = NULL;
-  Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(gda_connection_statement_to_sql(gobj(), Glib::unwrap(statement), Glib::unwrap(params), ((GdaStatementSqlFlag)(flags)), &params_usedc, &(gerror)));
+  const Glib::ustring retvalue = Glib::convert_return_gchar_ptr_to_ustring(gda_connection_statement_to_sql(gobj(), Glib::unwrap(statement), Glib::unwrap(params), ((GdaStatementSqlFlag)(flags)), &params_usedc, &(gerror)));
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);
@@ -219,44 +231,60 @@
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::RefPtr<Statement>& stmt)
+Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage)
 #else
-Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::RefPtr<Statement>& stmt, std::auto_ptr<Glib::Error>& error)
+Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage. std::auto_ptr<Glib::Error>& error)
 #endif
 {
-  Glib::RefPtr<Set> set;
+  GError* gerror = 0;
+  Glib::RefPtr<DataModel> retvalue = Glib::wrap(gda_connection_statement_execute_select_full(gobj(), Glib::unwrap(stmt), NULL /* params */, ((GdaStatementModelUsage)(model_usage)), NULL /* col_types */, &(gerror)));
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  return statement_execute_select (stmt, set);
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
 #else
-  return statement_execute_select (stmt, set, error);
-#endif
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
 }
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::ustring& sql)
+Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::ustring& sql, StatementModelUsage model_usage)
 #else
-Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error)
+Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::ustring& sql, StatementModelUsage model_usage, std::auto_ptr<Glib::Error>& error)
 #endif // GLIBMM_EXCEPTIONS_ENABLED
 {
+  Glib::RefPtr<Statement> stmt;
   Glib::RefPtr<SqlParser> parser = create_parser();
-  if (parser)
+  if(parser)
   {
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-    Glib::RefPtr<Statement> stmt = parser->parse_string(sql);
-    if (!stmt)
-      return Glib::RefPtr<DataModel>(0);
-    return statement_execute_select (stmt);
-#else
-    Glib::RefPtr<Statement> stmt = parser->parse_string(sql, error);
-    if (error || !stmt)
-      return Glib::RefPtr<DataModel>(0);
-    return statement_execute_select (stmt, error);
+    stmt = parser->parse_string(sql);
+#else
+    stmt = parser->parse_string(sql, error);
+    if(error
+      return Glib::RefPtr<DataModel>();
 #endif
   }
-  std::cerr << "Gda::Connection::statement_execute(): Couldn't create parser" << std::endl;
-  return Glib::RefPtr<DataModel>(0);
+
+  if(!stmt)
+    return Glib::RefPtr<DataModel>();
+
+  GError* gerror = 0;
+  Glib::RefPtr<DataModel> retvalue = Glib::wrap(gda_connection_statement_execute_select_full(gobj(), Glib::unwrap(stmt), NULL /* params */, ((GdaStatementModelUsage)(model_usage)), NULL /* col_types */, &(gerror)));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
 }
 
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
 bool Connection::update_meta_store()
 #else
@@ -264,7 +292,7 @@
 #endif
 {
   GError* gerror = 0;
-  bool retvalue = gda_connection_update_meta_store(gobj(), 0, &gerror);
+  const bool retvalue = gda_connection_update_meta_store(gobj(), 0, &gerror);
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(gerror)
     ::Glib::Error::throw_exception(gerror);

Modified: libgdamm/trunk/libgda/src/connection.hg
==============================================================================
--- libgdamm/trunk/libgda/src/connection.hg	(original)
+++ libgdamm/trunk/libgda/src/connection.hg	Mon Dec 15 12:58:37 2008
@@ -131,15 +131,15 @@
   _WRAP_METHOD(Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params), gda_connection_statement_execute_select, errthrow)
 
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
-  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt);
-  Glib::RefPtr<DataModel> statement_execute_select(const Glib::ustring& sql);
+  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
+  Glib::RefPtr<DataModel> statement_execute_select(const Glib::ustring& sql, StatementModelUsage model_usage = STATEMENT_MODEL_RANDOM_ACCESS);
 #else
-  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt, std::auto_ptr<Glib::Error>& error);
+  Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage, std::auto_ptr<Glib::Error>& error);
   Glib::RefPtr<DataModel> statement_execute_select(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error);
-#endif  
+#endif
 
   #m4 _CONVERSION(`const Glib::ArrayHandle<GType>&', `GType*', `const_cast<GType*>(($3).data())')
-  _WRAP_METHOD(Glib::RefPtr<DataModel> statement_execute_select_full(const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, StatementModelUsage model_usage, const Glib::ArrayHandle<GType>& col_types), gda_connection_statement_execute_select_full, errthrow)
+  _WRAP_METHOD(Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, StatementModelUsage model_usage, const Glib::ArrayHandle<GType>& col_types), gda_connection_statement_execute_select_full, errthrow)
   _IGNORE(gda_connection_statement_execute_select_fullv)
   
   _WRAP_METHOD_DOCS_ONLY(gda_connection_statement_execute_non_select)
@@ -154,8 +154,9 @@
   int statement_execute_non_select(const Glib::RefPtr<Statement>& stmt);
 #else
   int statement_execute_non_select(const Glib::RefPtr<Statement>& stmt, std::auto_ptr<Glib::Error>& error);
-#endif //GLIBMM_EXCEPTIONS_ENABLED  
-  _WRAP_METHOD(int statement_execute_non_select(const Glib::ustring& sql), gda_execute_non_select_command, errthrow);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  _WRAP_METHOD(int statement_execute_non_select(const Glib::ustring& sql), gda_execute_non_select_command, 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)

Modified: libgdamm/trunk/libgda/src/datamodelarray.hg
==============================================================================
--- libgdamm/trunk/libgda/src/datamodelarray.hg	(original)
+++ libgdamm/trunk/libgda/src/datamodelarray.hg	Mon Dec 15 12:58:37 2008
@@ -59,7 +59,7 @@
   _WRAP_METHOD(Glib::RefPtr<Row> get_row(int row), gda_data_model_array_get_row, errthrow)
   _WRAP_METHOD(Glib::RefPtr<const Row> get_row(int row) const, gda_data_model_array_get_row, errthrow)
     
-  _WRAP_PROPERTY("n-columns", guint);
+  _WRAP_PROPERTY("n-columns", guint)
 };
 
 } // namespace Gda

Modified: libgdamm/trunk/libgda/src/statement.hg
==============================================================================
--- libgdamm/trunk/libgda/src/statement.hg	(original)
+++ libgdamm/trunk/libgda/src/statement.hg	Mon Dec 15 12:58:37 2008
@@ -34,9 +34,9 @@
 
 class Connection;
 
-_WRAP_ENUM (SqlStatementType, GdaSqlStatementType)
-_WRAP_ENUM (StatementModelUsage, GdaStatementModelUsage)
-_WRAP_ENUM (StatementSqlFlag, GdaStatementSqlFlag)
+_WRAP_ENUM(SqlStatementType, GdaSqlStatementType)
+_WRAP_ENUM(StatementModelUsage, GdaStatementModelUsage)
+_WRAP_ENUM(StatementSqlFlag, GdaStatementSqlFlag)
 
 /** Single SQL statement.
  *



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