[libgdamm] SqlBuilder: Small const and other improvements.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdamm] SqlBuilder: Small const and other improvements.
- Date: Mon, 26 Oct 2009 06:20:56 +0000 (UTC)
commit 8b5054f1000c029de97a1e3d102e5aca673fc45b
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Oct 25 18:26:48 2009 +0100
SqlBuilder: Small const and other improvements.
* libgda/src/sqlbuilder.[hg|ccg]: add_expr(): Use const ref for the Value
parameter. Don't use NULL in C++ code.
add_function(): Use const ref for the ArrayHandle parameter.
get_statement(): Make this const.
add_cond_v(): Rename to add_cond().
select_order_by(): Add default parameter values.
ChangeLog | 11 +++++++++++
libgda/src/sqlbuilder.ccg | 14 +++++++-------
libgda/src/sqlbuilder.hg | 18 ++++++++++--------
3 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e60250e..524a0f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-25 Murray Cumming <murrayc murrayc com>
+
+ SqlBuilder: Small const and other improvements.
+
+ * libgda/src/sqlbuilder.[hg|ccg]: add_expr(): Use const ref for the Value
+ parameter. Don't use NULL in C++ code.
+ add_function(): Use const ref for the ArrayHandle parameter.
+ get_statement(): Make this const.
+ add_cond_v(): Rename to add_cond().
+ select_order_by(): Add default parameter values.
+
2009-10-05 Johannes Schmid <jschmid openismus com>
* libgda/src/sqlbuilder.ccg: add_expr() should use the DataHandler
diff --git a/libgda/src/sqlbuilder.ccg b/libgda/src/sqlbuilder.ccg
index 736b141..fa41720 100644
--- a/libgda/src/sqlbuilder.ccg
+++ b/libgda/src/sqlbuilder.ccg
@@ -41,14 +41,14 @@ guint SqlBuilder::add_id(const Glib::ustring& string)
return gda_sql_builder_add_id(gobj(), 0, string.c_str());
}
-guint SqlBuilder::add_expr(const Glib::RefPtr<DataHandler>& dh, Value value)
+guint SqlBuilder::add_expr(const Glib::RefPtr<DataHandler>& dh, const Value& value)
{
- return gda_sql_builder_add_expr_value(gobj(), 0, dh->gobj(), value.gobj());
+ return gda_sql_builder_add_expr_value(gobj(), 0, dh->gobj(), const_cast<GValue*>(value.gobj()));
}
-guint SqlBuilder::add_expr(Value value)
+guint SqlBuilder::add_expr(const Value& value)
{
- return gda_sql_builder_add_expr_value(gobj(), 0, NULL, value.gobj());
+ return gda_sql_builder_add_expr_value(gobj(), 0, 0, const_cast<GValue*>(value.gobj()));
}
guint SqlBuilder::add_param(const Glib::ustring& param_name, GType type, bool nullok)
@@ -61,12 +61,12 @@ guint SqlBuilder::add_cond(SqlOperatorType op, guint op1, guint op2, guint op3)
return gda_sql_builder_add_cond(gobj(), 0, (GdaSqlOperatorType) op, op1, op2, op3);
}
-guint SqlBuilder::add_cond_v(SqlOperatorType op, Glib::ArrayHandle<uint> op_ids)
+guint SqlBuilder::add_cond(SqlOperatorType op, const Glib::ArrayHandle<uint>& op_ids)
{
return gda_sql_builder_add_cond_v(gobj(), 0, (GdaSqlOperatorType) op, op_ids.data(), op_ids.size());
}
-guint SqlBuilder::add_function(const Glib::ustring& function_name, Glib::ArrayHandle<guint> args)
+guint SqlBuilder::add_function(const Glib::ustring& function_name, const Glib::ArrayHandle<guint>& args)
{
return gda_sql_builder_add_function_v(gobj(), 0, function_name.c_str(), args.data(), args.size());
}
@@ -78,7 +78,7 @@ guint SqlBuilder::select_add_target(guint table_id, const Glib::ustring& alias)
guint SqlBuilder::select_add_target(guint table_id)
{
- return gda_sql_builder_select_add_target(gobj(), 0, table_id, NULL);
+ return gda_sql_builder_select_add_target(gobj(), 0, table_id, 0);
}
guint SqlBuilder::select_join_targets(guint left_target_id, guint right_target_id, SqlSelectJoinType join_type, guint join_expr)
diff --git a/libgda/src/sqlbuilder.hg b/libgda/src/sqlbuilder.hg
index 34c26bb..5c5bc6a 100644
--- a/libgda/src/sqlbuilder.hg
+++ b/libgda/src/sqlbuilder.hg
@@ -45,7 +45,7 @@ protected:
public:
_WRAP_CREATE(SqlStatementType type)
- _WRAP_METHOD(Glib::RefPtr<Statement> get_statement(), gda_sql_builder_get_statement, errthrow)
+ _WRAP_METHOD(Glib::RefPtr<Statement> get_statement() const, gda_sql_builder_get_statement, errthrow)
// TODO: Wrap SqlStatement
//_WRAP_METHOD(Glib::RefPtr<SqlStatement> get_sql_statement(bool copy_it), gda_sql_builder_get_sql_statement, errthrow)
@@ -68,7 +68,7 @@ public:
*
* @return the ID of the new expression, or 0 if there was an error
*/
- guint add_expr(const Glib::RefPtr<DataHandler>& dh, Value value);
+ guint add_expr(const Glib::RefPtr<DataHandler>& dh, const Value& value);
/** Defines an expression in Builder which may be reused to build other parts of a statement.
* @param value: value to set the expression to
*
@@ -76,7 +76,7 @@ public:
*
* @return the ID of the new expression, or 0 if there was an error
*/
- guint add_expr(Value value);
+ guint add_expr(const Value& value);
/** Defines a parameter which may be reused to build other parts of a statement.
* @param: param_name: name of the parameter
@@ -85,7 +85,7 @@ public:
*
* @return the ID of the new expression, or 0 if there was an error
*/
- guint add_param(const Glib::ustring& param_name, GType type, bool nullok);
+ guint add_param(const Glib::ustring& param_name, GType type, bool nullok = false);
/** Builds a new expression which reprenents a condition (or operation).
* @param op: type of condition
@@ -103,17 +103,19 @@ public:
*
* @return the ID of the new expression, or 0 if there was an error
*/
- guint add_cond_v(SqlOperatorType op, Glib::ArrayHandle<guint> op_ids);
+ guint add_cond(SqlOperatorType op, const Glib::ArrayHandle<guint>& op_ids);
_IGNORE(gda_sql_builder_add_function, gda_sql_builder_add_function_v)
_IGNORE(gda_sql_builder_select_add_target, gda_sql_builder_select_join_targets)
- /** add_function
+
+ /** Builds a new expression which represents a function applied to some arguments.
+ *
* @param function_name: the name of the function to embed (e.g. MAX, MIN, ...)
* @param args: list of ids of the arguments to the function
*
* @return the ID of the new target, or 0 if there was an error
*/
- guint add_function(const Glib::ustring& function_name, Glib::ArrayHandle<guint> args);
+ guint add_function(const Glib::ustring& function_name, const Glib::ArrayHandle<guint>& args);
// Statement API
/** Adds a new target to a SELECT statement
@@ -142,7 +144,7 @@ public:
*/
guint select_join_targets(guint left_target_id, guint right_target_id, SqlSelectJoinType join_type, guint join_expr = 0);
_WRAP_METHOD(void join_add_field(guint join_id, const Glib::ustring& field_name), gda_sql_builder_join_add_field)
- _WRAP_METHOD(void select_order_by(guint expr_id, bool asc, const Glib::ustring& collation_name), gda_sql_builder_select_order_by)
+ _WRAP_METHOD(void select_order_by(guint expr_id, bool asc = true, const Glib::ustring& collation_name = Glib::ustring()), gda_sql_builder_select_order_by)
// General Statement API
_WRAP_METHOD(void set_table(const Glib::ustring& table_name), gda_sql_builder_set_table)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]