aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-08-16 14:17:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-08-16 14:17:31 +0200
commit4753ee4a133e1e6b23b86b6f1b61e3e4e840417f (patch)
treeb3ddd69c7c33e0afea482841d61321d50175447b
parenteeb35e7debc2eb04a91d712fbdb088eab9bdc33a (diff)
Cosmetic changes
-rw-r--r--odb/mysql/statement.cxx80
-rw-r--r--odb/mysql/statement.hxx133
2 files changed, 107 insertions, 106 deletions
diff --git a/odb/mysql/statement.cxx b/odb/mysql/statement.cxx
index 009e3f1..9c99c8f 100644
--- a/odb/mysql/statement.cxx
+++ b/odb/mysql/statement.cxx
@@ -56,7 +56,7 @@ namespace odb
query_statement::
query_statement (connection& conn,
- const string& query,
+ const string& s,
binding& image,
MYSQL_BIND* parameters)
: statement (conn),
@@ -64,7 +64,7 @@ namespace odb
image_version_ (0),
parameters_ (parameters)
{
- if (mysql_stmt_prepare (stmt_, query.c_str (), query.size ()) != 0)
+ if (mysql_stmt_prepare (stmt_, s.c_str (), s.size ()) != 0)
throw database_exception (stmt_);
}
@@ -158,25 +158,23 @@ namespace odb
free_result ();
}
- // insert_statement
+ // persist_statement
//
- insert_statement::
- ~insert_statement ()
+ persist_statement::
+ ~persist_statement ()
{
}
- insert_statement::
- insert_statement (connection& conn,
- const string& query,
- binding& image)
+ persist_statement::
+ persist_statement (connection& conn, const string& s, binding& image)
: statement (conn), image_ (image), version_ (0)
{
- if (mysql_stmt_prepare (stmt_, query.c_str (), query.size ()) != 0)
+ if (mysql_stmt_prepare (stmt_, s.c_str (), s.size ()) != 0)
throw database_exception (stmt_);
}
- void insert_statement::
+ void persist_statement::
execute ()
{
if (statement* a = conn_.active ())
@@ -211,11 +209,11 @@ namespace odb
*/
}
- // select_statement
+ // find_statement
//
- select_statement::
- ~select_statement ()
+ find_statement::
+ ~find_statement ()
{
if (conn_.active () == this)
{
@@ -229,22 +227,22 @@ namespace odb
}
}
- select_statement::
- select_statement (connection& conn,
- const string& query,
- binding& id,
- binding& image)
+ find_statement::
+ find_statement (connection& conn,
+ const string& s,
+ binding& id,
+ binding& image)
: statement (conn),
id_ (id),
id_version_ (0),
image_ (image),
image_version_ (0)
{
- if (mysql_stmt_prepare (stmt_, query.c_str (), query.size ()) != 0)
+ if (mysql_stmt_prepare (stmt_, s.c_str (), s.size ()) != 0)
throw database_exception (stmt_);
}
- select_statement::result select_statement::
+ find_statement::result find_statement::
execute ()
{
if (statement* a = conn_.active ())
@@ -298,7 +296,7 @@ namespace odb
}
}
- void select_statement::
+ void find_statement::
refetch ()
{
// Re-fetch columns that were truncated.
@@ -316,7 +314,7 @@ namespace odb
}
}
- void select_statement::
+ void find_statement::
free_result ()
{
if (mysql_stmt_free_result (stmt_))
@@ -325,7 +323,7 @@ namespace odb
conn_.active (0);
}
- void select_statement::
+ void find_statement::
cancel ()
{
free_result ();
@@ -335,27 +333,27 @@ namespace odb
// update_statement
//
- update_statement::
- ~update_statement ()
+ store_statement::
+ ~store_statement ()
{
}
- update_statement::
- update_statement (connection& conn,
- const string& query,
- binding& id,
- binding& image)
+ store_statement::
+ store_statement (connection& conn,
+ const string& s,
+ binding& id,
+ binding& image)
: statement (conn),
id_ (id),
id_version_ (0),
image_ (image),
image_version_ (0)
{
- if (mysql_stmt_prepare (stmt_, query.c_str (), query.size ()) != 0)
+ if (mysql_stmt_prepare (stmt_, s.c_str (), s.size ()) != 0)
throw database_exception (stmt_);
}
- void update_statement::
+ void store_statement::
execute ()
{
if (statement* a = conn_.active ())
@@ -390,25 +388,23 @@ namespace odb
throw database_exception (stmt_);
}
- // delete_statement
+ // erase_statement
//
- delete_statement::
- ~delete_statement ()
+ erase_statement::
+ ~erase_statement ()
{
}
- delete_statement::
- delete_statement (connection& conn,
- const string& query,
- binding& id)
+ erase_statement::
+ erase_statement (connection& conn, const string& s, binding& id)
: statement (conn), id_ (id), version_ (0)
{
- if (mysql_stmt_prepare (stmt_, query.c_str (), query.size ()) != 0)
+ if (mysql_stmt_prepare (stmt_, s.c_str (), s.size ()) != 0)
throw database_exception (stmt_);
}
- void delete_statement::
+ void erase_statement::
execute ()
{
if (statement* a = conn_.active ())
diff --git a/odb/mysql/statement.hxx b/odb/mysql/statement.hxx
index ec79b67..3dd4c28 100644
--- a/odb/mysql/statement.hxx
+++ b/odb/mysql/statement.hxx
@@ -69,7 +69,7 @@ namespace odb
~query_statement ();
query_statement (connection& conn,
- const std::string& query,
+ const std::string& statement,
binding& image,
MYSQL_BIND* parameters);
enum result
@@ -105,38 +105,38 @@ namespace odb
MYSQL_BIND* parameters_;
};
- class insert_statement: public statement
+ class persist_statement: public statement
{
public:
virtual
- ~insert_statement ();
+ ~persist_statement ();
- insert_statement (connection& conn,
- const std::string& query,
- binding& image);
+ persist_statement (connection& conn,
+ const std::string& statement,
+ binding& image);
void
execute ();
private:
- insert_statement (const insert_statement&);
- insert_statement& operator= (const insert_statement&);
+ persist_statement (const persist_statement&);
+ persist_statement& operator= (const persist_statement&);
private:
binding& image_;
std::size_t version_;
};
- class select_statement: public statement
+ class find_statement: public statement
{
public:
virtual
- ~select_statement ();
+ ~find_statement ();
- select_statement (connection& conn,
- const std::string& query,
- binding& id,
- binding& image);
+ find_statement (connection& conn,
+ const std::string& statement,
+ binding& id,
+ binding& image);
enum result
{
success,
@@ -160,8 +160,8 @@ namespace odb
cancel ();
private:
- select_statement (const select_statement&);
- select_statement& operator= (const select_statement&);
+ find_statement (const find_statement&);
+ find_statement& operator= (const find_statement&);
private:
binding& id_;
@@ -171,22 +171,22 @@ namespace odb
std::size_t image_version_;
};
- class update_statement: public statement
+ class store_statement: public statement
{
public:
virtual
- ~update_statement ();
+ ~store_statement ();
- update_statement (connection& conn,
- const std::string& query,
- binding& id,
- binding& image);
+ store_statement (connection& conn,
+ const std::string& statement,
+ binding& id,
+ binding& image);
void
execute ();
private:
- update_statement (const update_statement&);
- update_statement& operator= (const update_statement&);
+ store_statement (const store_statement&);
+ store_statement& operator= (const store_statement&);
private:
binding& id_;
@@ -196,22 +196,22 @@ namespace odb
std::size_t image_version_;
};
- class delete_statement: public statement
+ class erase_statement: public statement
{
public:
virtual
- ~delete_statement ();
+ ~erase_statement ();
- delete_statement (connection& conn,
- const std::string& query,
- binding& id);
+ erase_statement (connection& conn,
+ const std::string& statement,
+ binding& id);
void
execute ();
private:
- delete_statement (const delete_statement&);
- delete_statement& operator= (const delete_statement&);
+ erase_statement (const erase_statement&);
+ erase_statement& operator= (const erase_statement&);
private:
binding& id_;
@@ -245,6 +245,11 @@ namespace odb
typedef typename object_traits::image_type image_type;
typedef typename object_traits::id_image_type id_image_type;
+ typedef mysql::persist_statement persist_statement_type;
+ typedef mysql::find_statement find_statement_type;
+ typedef mysql::store_statement store_statement_type;
+ typedef mysql::erase_statement erase_statement_type;
+
object_statements (connection&);
image_type&
@@ -277,56 +282,56 @@ namespace odb
return id_image_binding_;
}
- insert_statement&
- insert ()
+ persist_statement_type&
+ persist_statement ()
{
- if (insert_ == 0)
- insert_.reset (
- new (shared) insert_statement (
- conn_, object_traits::insert_query, image_binding_));
+ if (persist_ == 0)
+ persist_.reset (
+ new (shared) persist_statement_type (
+ conn_, object_traits::persist_statement, image_binding_));
- return *insert_;
+ return *persist_;
}
- select_statement&
- select ()
+ find_statement_type&
+ find_statement ()
{
- if (select_ == 0)
- select_.reset (
- new (shared) select_statement (
+ if (find_ == 0)
+ find_.reset (
+ new (shared) find_statement_type (
conn_,
- object_traits::select_query,
+ object_traits::find_statement,
id_image_binding_,
image_binding_));
- return *select_;
+ return *find_;
}
- update_statement&
- update ()
+ store_statement_type&
+ store_statement ()
{
- if (update_ == 0)
- update_.reset (
- new (shared) update_statement (
+ if (store_ == 0)
+ store_.reset (
+ new (shared) store_statement_type (
conn_,
- object_traits::update_query,
+ object_traits::store_statement,
id_image_binding_,
image_binding_));
- return *update_;
+ return *store_;
}
- delete_statement&
- delete_ ()
+ erase_statement_type&
+ erase_statement ()
{
- if (del_ == 0)
- del_.reset (
- new (shared) delete_statement (
+ if (erase_ == 0)
+ erase_.reset (
+ new (shared) erase_statement_type (
conn_,
- object_traits::delete_query,
+ object_traits::erase_statement,
id_image_binding_));
- return *del_;
+ return *erase_;
}
private:
@@ -334,7 +339,7 @@ namespace odb
object_statements& operator= (const object_statements&);
private:
- // The last element is the id parameter. The update statement
+ // The last element is the id parameter. The store statement
// depends on this being one contiguous arrays.
//
MYSQL_BIND image_bind_[object_traits::column_count + 1];
@@ -346,10 +351,10 @@ namespace odb
id_image_type id_image_;
binding id_image_binding_;
- odb::shared_ptr<insert_statement> insert_;
- odb::shared_ptr<select_statement> select_;
- odb::shared_ptr<update_statement> update_;
- odb::shared_ptr<delete_statement> del_;
+ odb::shared_ptr<persist_statement_type> persist_;
+ odb::shared_ptr<find_statement_type> find_;
+ odb::shared_ptr<store_statement_type> store_;
+ odb::shared_ptr<erase_statement_type> erase_;
};
struct type_info_comparator