gnomemm r1799 - in libgdamm/trunk: . examples/simple libgda/src
- From: jhs svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1799 - in libgdamm/trunk: . examples/simple libgda/src
- Date: Tue, 18 Nov 2008 09:35:55 +0000 (UTC)
Author: jhs
Date: Tue Nov 18 09:35:55 2008
New Revision: 1799
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1799&view=rev
Log:
2008-11-18 Johannes Schmid <jschmid openismus com>
* libgda/src/batch.hg:
* libgda/src/column.hg:
* libgda/src/connection.ccg:
* libgda/src/connection.hg:
* libgda/src/set.hg:
* libgda/src/sqlparser.ccg:
* libgda/src/sqlparser.hg:
Added some custom methods and default arguments to honer the fact
that libgda allows to pass "NULL" for several arguments
* examples/simple/main.cc:
Used new methods.
Modified:
libgdamm/trunk/ChangeLog
libgdamm/trunk/examples/simple/main.cc
libgdamm/trunk/libgda/src/batch.hg
libgdamm/trunk/libgda/src/column.hg
libgdamm/trunk/libgda/src/connection.ccg
libgdamm/trunk/libgda/src/connection.hg
libgdamm/trunk/libgda/src/set.hg
libgdamm/trunk/libgda/src/sqlparser.ccg
libgdamm/trunk/libgda/src/sqlparser.hg
Modified: libgdamm/trunk/examples/simple/main.cc
==============================================================================
--- libgdamm/trunk/examples/simple/main.cc (original)
+++ libgdamm/trunk/examples/simple/main.cc Tue Nov 18 09:35:55 2008
@@ -20,7 +20,6 @@
#include <libgdamm.h>
-#include <libgdamm/config.h>
#include <iostream>
using namespace Gnome;
@@ -49,10 +48,8 @@
int nrows = 0;
try
- {
- Glib::RefPtr<Gda::Set> params;
- Glib::RefPtr<Gda::Set> last_inserted_row;
- nrows = cnc->statement_execute_non_select (stmt, params, last_inserted_row);
+ {
+ nrows = cnc->statement_execute_non_select (stmt);
}
catch(const Glib::Error& err)
{
@@ -94,12 +91,10 @@
std::cerr << "Error: " << err.what() << std::endl;
return;
}
-
- Glib::RefPtr<Gda::Set> params;
Glib::RefPtr<Gda::DataModel> data_model;
try
{
- data_model = cnc->statement_execute_select (stmt, params);
+ data_model = cnc->statement_execute_select (stmt);
}
catch(const Glib::Error& err)
{
Modified: libgdamm/trunk/libgda/src/batch.hg
==============================================================================
--- libgdamm/trunk/libgda/src/batch.hg (original)
+++ libgdamm/trunk/libgda/src/batch.hg Tue Nov 18 09:35:55 2008
@@ -1,6 +1,6 @@
// -*- C++ -*- // this is for the .hg, I realize gensig puts one in
-/* set.h
+/* batch.h
*
* Copyright 2006 libgdamm Development Team
*
Modified: libgdamm/trunk/libgda/src/column.hg
==============================================================================
--- libgdamm/trunk/libgda/src/column.hg (original)
+++ libgdamm/trunk/libgda/src/column.hg Tue Nov 18 09:35:55 2008
@@ -33,6 +33,16 @@
namespace Gda
{
+
+/* possible predefined attribute names for gda_holder_get_attribute() or gda_column_get_attribute() */
+// Keep in sync with libgda
+const std::string ATTRIBUTE_DESCRIPTION = "__gda_attr_descr"; /* G_TYPE_STRING */
+const std::string ATTRIBUTE_NAME = "__gda_attr_name"; /* G_TYPE_STRING */
+const std::string ATTRIBUTE_NUMERIC_PRECISION = "__gda_attr_numeric_precision"; /* G_TYPE_INT */
+const std::string ATTRIBUTE_NUMERIC_SCALE = "__gda_attr_numeric_scale"; /* G_TYPE_INT */
+const std::string ATTRIBUTE_AUTO_INCREMENT = "__gda_attr_autoinc"; /* G_TYPE_BOOLEAN */
+const std::string ATTRIBUTE_IS_DEFAULT = "__gda_attr_is_default"; /* G_TYPE_BOOLEAN */
+
/** Management of DataModel column attributes.
*
* @ingroup DataHandlers
Modified: libgdamm/trunk/libgda/src/connection.ccg
==============================================================================
--- libgdamm/trunk/libgda/src/connection.ccg (original)
+++ libgdamm/trunk/libgda/src/connection.ccg Tue Nov 18 09:35:55 2008
@@ -104,6 +104,24 @@
return retval;
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<Glib::Object> Connection::statement_execute(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage)
+#else
+Glib::RefPtr<Glib::Object> Connection::statement_execute(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage, std::auto_ptr<Glib::Error>& error)
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+{
+ 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);
+#else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+ return retval;
+}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
int Connection::statement_execute_non_select(const Glib::RefPtr<Statement>& cmd, const Glib::RefPtr<Set>& params, Glib::RefPtr<Set>& last_inserted_row)
@@ -129,6 +147,24 @@
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
+int Connection::statement_execute_non_select(const Glib::RefPtr<Statement>& cmd)
+#else
+int Connection::statement_execute_non_select(const Glib::RefPtr<Statement>& cmd, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ int retval = gda_connection_statement_execute_non_select(gobj(), Glib::unwrap(cmd), 0, 0, &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 retval;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::ustring Connection::statement_to_sql(const Glib::RefPtr<Statement>& statement, const Glib::RefPtr<Set>& params, StatementSqlFlag flags, std::list< Glib::RefPtr<Holder> >& params_used)
#else
Glib::ustring Connection::statement_to_sql(const Glib::RefPtr<Statement>& statement, const Glib::RefPtr<Set>& params, StatementSqlFlag flags, std::list< Glib::RefPtr<Holder> >& params_used, std::auto_ptr<Glib::Error>& error)
@@ -156,6 +192,12 @@
}
+Glib::RefPtr<DataModel> Connection::statement_execute_select(const Glib::RefPtr<Statement>& stmt)
+{
+ Glib::RefPtr<Set> set;
+ return statement_execute_select (stmt, set);
+}
+
} //namespace Gda
} //namespace Gnome
Modified: libgdamm/trunk/libgda/src/connection.hg
==============================================================================
--- libgdamm/trunk/libgda/src/connection.hg (original)
+++ libgdamm/trunk/libgda/src/connection.hg Tue Nov 18 09:35:55 2008
@@ -119,9 +119,15 @@
#else
Glib::RefPtr<Glib::Object> statement_execute(const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, StatementModelUsage model_usage, Glib::RefPtr<Set>& last_insert_row, std::auto_ptr<Glib::Error>& error);
#endif // GLIBMM_EXCEPTIONS_ENABLED
-
- _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<Glib::Object> statement_execute(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage);
+#else
+ Glib::RefPtr<Glib::Object> statement_execute(const Glib::RefPtr<Statement>& stmt, StatementModelUsage model_usage, std::auto_ptr<Glib::Error>& error);
+#endif // GLIBMM_EXCEPTIONS_ENABLED
+ _WRAP_METHOD(Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params), gda_connection_statement_execute_select, errthrow)
+ Glib::RefPtr<DataModel> statement_execute_select(const Glib::RefPtr<Statement>& stmt);
+
#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)
_IGNORE (gda_connection_statement_execute_select_fullv)
@@ -132,7 +138,11 @@
#else
int statement_execute_non_select(const Glib::RefPtr<Statement>& stmt, const Glib::RefPtr<Set>& params, Glib::RefPtr<Set>& last_insert_row, std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
-
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ 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
//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/set.hg
==============================================================================
--- libgdamm/trunk/libgda/src/set.hg (original)
+++ libgdamm/trunk/libgda/src/set.hg Tue Nov 18 09:35:55 2008
@@ -55,7 +55,7 @@
_WRAP_CTOR(Set(const HolderSList& holders), gda_set_new)
public:
- _WRAP_CREATE(const HolderSList& holders)
+ _WRAP_CREATE(const HolderSList& holders = std::list< Glib::RefPtr<Holder> >())
_WRAP_METHOD(Glib::RefPtr<Set> copy(), gda_set_copy)
Modified: libgdamm/trunk/libgda/src/sqlparser.ccg
==============================================================================
--- libgdamm/trunk/libgda/src/sqlparser.ccg (original)
+++ libgdamm/trunk/libgda/src/sqlparser.ccg Tue Nov 18 09:35:55 2008
@@ -55,6 +55,25 @@
}
#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<Statement> SqlParser::parse_string(const Glib::ustring& sql)
+#else
+Glib::RefPtr<Statement> SqlParser::parse_string(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<Statement> retvalue = Glib::wrap(gda_sql_parser_parse_string(gobj(), sql.c_str(), 0, &(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
Glib::RefPtr<Batch> SqlParser::parse_string_as_batch(const Glib::ustring& sql, Glib::ustring& remain)
#else
Glib::RefPtr<Batch> SqlParser::parse_string_as_batch(const Glib::ustring& sql, Glib::ustring& remain, std::auto_ptr<Glib::Error>& error)
@@ -79,6 +98,25 @@
return retvalue;
}
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<Batch> SqlParser::parse_string_as_batch(const Glib::ustring& sql)
+#else
+Glib::RefPtr<Batch> SqlParser::parse_string_as_batch(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<Batch> retvalue = Glib::wrap(gda_sql_parser_parse_string_as_batch(gobj(), sql.c_str(), 0, &(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;
+}
+
} /* namespace Gda */
} /* namespace Gnome */
Modified: libgdamm/trunk/libgda/src/sqlparser.hg
==============================================================================
--- libgdamm/trunk/libgda/src/sqlparser.hg (original)
+++ libgdamm/trunk/libgda/src/sqlparser.hg Tue Nov 18 09:35:55 2008
@@ -101,11 +101,29 @@
//TODO: Should these be const?
_WRAP_METHOD_DOCS_ONLY(gda_sql_parser_parse_string)
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<Statement> parse_string(const Glib::ustring& sql, Glib::ustring& remain);
-
+ #else
+ Glib::RefPtr<Statement> parse_string(const Glib::ustring& sql, Glib::ustring& remain, std::auto_ptr<Glib::Error>& error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<Statement> parse_string(const Glib::ustring& sql);
+ #else
+ Glib::RefPtr<Statement> parse_string(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
_WRAP_METHOD_DOCS_ONLY(gda_sql_parser_parse_string_as_batch)
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<Batch> parse_string_as_batch(const Glib::ustring& sql, Glib::ustring& remain);
-
+ #else
+ Glib::RefPtr<Batch> parse_string_as_batch(const Glib::ustring& sql, Glib::ustring& remain, std::auto_ptr<Glib::Error>& error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<Batch> parse_string_as_batch(const Glib::ustring& sql);
+ #else
+ Glib::RefPtr<Batch> parse_string_as_batch(const Glib::ustring& sql, std::auto_ptr<Glib::Error>& error);
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
_WRAP_METHOD(Glib::RefPtr<Batch> parse_file_as_batch(const std::string& filename), gda_sql_parser_parse_file_as_batch, errthrow)
_IGNORE(gda_sql_parser_set_overflow_error, gda_sql_parser_set_syntax_error)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]