auto-handle.hxx   auto-handle.hxx 
// file : odb/sqlite/auto-handle.hxx // file : odb/sqlite/auto-handle.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_AUTO_HANDLE_HXX #ifndef ODB_SQLITE_AUTO_HANDLE_HXX
#define ODB_SQLITE_AUTO_HANDLE_HXX #define ODB_SQLITE_AUTO_HANDLE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cassert> #include <cassert>
#include <sqlite3.h> #include <sqlite3.h>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 binding.hxx   binding.hxx 
// file : odb/sqlite/binding.hxx // file : odb/sqlite/binding.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_BINDING_HXX #ifndef ODB_SQLITE_BINDING_HXX
#define ODB_SQLITE_BINDING_HXX #define ODB_SQLITE_BINDING_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 config.h   config.h 
/* odb/sqlite/details/config.h. Generated from config.h.in by configure. */ /* odb/sqlite/details/config.h. Generated from config.h.in by configure. */
/* file : odb/sqlite/details/config.h.in /* file : odb/sqlite/details/config.h.in
* copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC * copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
* license : GNU GPL v2; see accompanying LICENSE file * license : GNU GPL v2; see accompanying LICENSE file
*/ */
/* This file is automatically processed by configure. */ /* This file is automatically processed by configure. */
#ifndef ODB_SQLITE_DETAILS_CONFIG_H #ifndef ODB_SQLITE_DETAILS_CONFIG_H
#define ODB_SQLITE_DETAILS_CONFIG_H #define ODB_SQLITE_DETAILS_CONFIG_H
/* #undef LIBODB_SQLITE_STATIC_LIB */ /* #undef LIBODB_SQLITE_STATIC_LIB */
/* #undef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY */ /* #undef LIBODB_SQLITE_HAVE_UNLOCK_NOTIFY */
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 config.hxx   config.hxx 
// file : odb/sqlite/details/config.hxx // file : odb/sqlite/details/config.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_DETAILS_CONFIG_HXX #ifndef ODB_SQLITE_DETAILS_CONFIG_HXX
#define ODB_SQLITE_DETAILS_CONFIG_HXX #define ODB_SQLITE_DETAILS_CONFIG_HXX
// no pre // no pre
#ifdef _MSC_VER #ifdef _MSC_VER
#elif defined(ODB_COMPILER) #elif defined(ODB_COMPILER)
# error libodb-sqlite header included in odb-compiled header # error libodb-sqlite header included in odb-compiled header
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 connection-factory.hxx   connection-factory.hxx 
// file : odb/sqlite/connection-factory.hxx // file : odb/sqlite/connection-factory.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX #ifndef ODB_SQLITE_CONNECTION_FACTORY_HXX
#define ODB_SQLITE_CONNECTION_FACTORY_HXX #define ODB_SQLITE_CONNECTION_FACTORY_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <vector> #include <vector>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <cassert>
#include <odb/details/mutex.hxx> #include <odb/details/mutex.hxx>
#include <odb/details/condition.hxx> #include <odb/details/condition.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> #include <odb/sqlite/forward.hxx>
#include <odb/sqlite/connection.hxx> #include <odb/sqlite/connection.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
skipping to change at line 161 skipping to change at line 162
connection_pool_factory (std::size_t max_connections = 0, connection_pool_factory (std::size_t max_connections = 0,
std::size_t min_connections = 0) std::size_t min_connections = 0)
: max_ (max_connections), : max_ (max_connections),
min_ (min_connections), min_ (min_connections),
extra_flags_ (0), extra_flags_ (0),
in_use_ (0), in_use_ (0),
waiters_ (0), waiters_ (0),
db_ (0), db_ (0),
cond_ (mutex_) cond_ (mutex_)
{ {
// @@ check min_ <= max_ // max_connections == 0 means unlimited.
//
assert (max_connections == 0 || max_connections >= min_connections)
;
} }
virtual connection_ptr virtual connection_ptr
connect (); connect ();
virtual void virtual void
database (database_type&); database (database_type&);
virtual virtual
~connection_pool_factory (); ~connection_pool_factory ();
 End of changes. 3 change blocks. 
2 lines changed or deleted 6 lines changed or added


 connection.hxx   connection.hxx 
// file : odb/sqlite/connection.hxx // file : odb/sqlite/connection.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_CONNECTION_HXX #ifndef ODB_SQLITE_CONNECTION_HXX
#define ODB_SQLITE_CONNECTION_HXX #define ODB_SQLITE_CONNECTION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <sqlite3.h> #include <sqlite3.h>
#include <odb/forward.hxx>
#include <odb/connection.hxx> #include <odb/connection.hxx>
#include <odb/details/mutex.hxx> #include <odb/details/mutex.hxx>
#include <odb/details/condition.hxx> #include <odb/details/condition.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/details/unique-ptr.hxx> #include <odb/details/unique-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> #include <odb/sqlite/forward.hxx>
#include <odb/sqlite/query.hxx>
#include <odb/sqlite/tracer.hxx> #include <odb/sqlite/tracer.hxx>
#include <odb/sqlite/transaction-impl.hxx> #include <odb/sqlite/transaction-impl.hxx>
#include <odb/sqlite/auto-handle.hxx> #include <odb/sqlite/auto-handle.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
skipping to change at line 71 skipping to change at line 71
transaction_impl* transaction_impl*
begin_exclusive (); begin_exclusive ();
public: public:
using odb::connection::execute; using odb::connection::execute;
virtual unsigned long long virtual unsigned long long
execute (const char* statement, std::size_t length); execute (const char* statement, std::size_t length);
// Query preparation.
//
public:
template <typename T>
prepared_query<T>
prepare_query (const char* name, const char*);
template <typename T>
prepared_query<T>
prepare_query (const char* name, const std::string&);
template <typename T>
prepared_query<T>
prepare_query (const char* name, const sqlite::query_base&);
template <typename T>
prepared_query<T>
prepare_query (const char* name, const odb::query_base&);
// SQL statement tracing. // SQL statement tracing.
// //
public: public:
typedef sqlite::tracer tracer_type; typedef sqlite::tracer tracer_type;
void void
tracer (tracer_type& t) tracer (tracer_type& t)
{ {
odb::connection::tracer (t); odb::connection::tracer (t);
} }
skipping to change at line 110 skipping to change at line 129
return *statement_cache_; return *statement_cache_;
} }
// Wait for the locks to be released via unlock notification. Can // Wait for the locks to be released via unlock notification. Can
// be called after getting SQLITE_LOCKED_SHAREDCACHE. // be called after getting SQLITE_LOCKED_SHAREDCACHE.
// //
void void
wait (); wait ();
public: public:
// Reset active and finalize uncached statements. // Reset active statements.
// //
void void
clear (); clear ();
private: private:
connection (const connection&); connection (const connection&);
connection& operator= (const connection&); connection& operator= (const connection&);
private: private:
void void
skipping to change at line 146 skipping to change at line 165
// Unlock notification machinery. // Unlock notification machinery.
// //
private: private:
bool unlocked_; bool unlocked_;
details::mutex unlock_mutex_; details::mutex unlock_mutex_;
details::condition unlock_cond_; details::condition unlock_cond_;
friend void friend void
connection_unlock_callback (void**, int); connection_unlock_callback (void**, int);
// Linked list of active and uncached statements currently associated private:
friend class transaction_impl; // invalidate_results()
// Linked list of active statements currently associated
// with this connection. // with this connection.
// //
private: private:
friend class statement; friend class statement;
statement* statements_; statement* statements_;
}; };
} }
} }
#include <odb/sqlite/connection.ixx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_CONNECTION_HXX #endif // ODB_SQLITE_CONNECTION_HXX
 End of changes. 7 change blocks. 
4 lines changed or deleted 28 lines changed or added


 container-statements.hxx   container-statements.hxx 
// file : odb/sqlite/container-statements.hxx // file : odb/sqlite/container-statements.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX #ifndef ODB_SQLITE_CONTAINER_STATEMENTS_HXX
#define ODB_SQLITE_CONTAINER_STATEMENTS_HXX #define ODB_SQLITE_CONTAINER_STATEMENTS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx>
skipping to change at line 36 skipping to change at line 36
// Template argument is the generated abstract container traits type. // Template argument is the generated abstract container traits type.
// That is, it doesn't need to provide column counts and statements. // That is, it doesn't need to provide column counts and statements.
// //
template <typename T> template <typename T>
class container_statements class container_statements
{ {
public: public:
typedef T traits; typedef T traits;
typedef typename traits::data_image_type data_image_type; typedef typename traits::data_image_type data_image_type;
typedef typename traits::cond_image_type cond_image_type;
typedef typename traits::functions_type functions_type; typedef typename traits::functions_type functions_type;
typedef sqlite::insert_statement insert_statement_type; typedef sqlite::insert_statement insert_statement_type;
typedef sqlite::select_statement select_statement_type; typedef sqlite::select_statement select_statement_type;
typedef sqlite::delete_statement delete_statement_type; typedef sqlite::delete_statement delete_statement_type;
typedef sqlite::connection connection_type; typedef sqlite::connection connection_type;
container_statements (connection_type&); container_statements (connection_type&, binding& id_binding);
connection_type& connection_type&
connection () connection ()
{ {
return conn_; return conn_;
} }
// Functions. // Functions.
// //
functions_type& functions_type&
functions () functions ()
{ {
return functions_; return functions_;
} }
// Id image binding (external). // Id image binding (external).
// //
const binding& const binding&
id_binding () id_binding ()
{ {
return *id_binding_; return id_binding_;
} }
void // Data image. The image is split into the id (that comes as a
id_binding (const binding& b) // binding) and index/key plus value which are in data_image_type.
// The select binding is a subset of the full binding (no id).
//
data_image_type&
data_image ()
{ {
id_binding_ = &b; return data_image_;
} }
// Condition image. bind*
// data_bind ()
cond_image_type&
cond_image ()
{ {
return cond_image_; return insert_image_binding_.bind;
} }
std::size_t bool
cond_image_version () const data_binding_test_version () const
{ {
return cond_image_version_; return data_id_binding_version_ != id_binding_.version ||
data_image_version_ != data_image_.version ||
insert_image_binding_.version == 0;
} }
void void
cond_image_version (std::size_t v) data_binding_update_version ()
{ {
cond_image_version_ = v; data_id_binding_version_ = id_binding_.version;
data_image_version_ = data_image_.version;
insert_image_binding_.version++;
select_image_binding_.version++;
} }
std::size_t bool*
cond_id_binding_version () const select_image_truncated ()
{ {
return cond_id_binding_version_; return select_image_truncated_;
} }
void //
cond_id_binding_version (std::size_t v) // Statements.
//
insert_statement_type&
insert_statement ()
{ {
cond_id_binding_version_ = v; if (insert_ == 0)
insert_.reset (
new (details::shared) insert_statement_type (
conn_, insert_text_, insert_image_binding_));
return *insert_;
} }
binding& select_statement_type&
cond_image_binding () select_statement ()
{ {
return cond_image_binding_; if (select_ == 0)
select_.reset (
new (details::shared) select_statement_type (
conn_,
select_text_,
id_binding_,
select_image_binding_));
return *select_;
} }
// Data image. delete_statement_type&
// delete_statement ()
data_image_type&
data_image ()
{ {
return data_image_; if (delete_ == 0)
delete_.reset (
new (details::shared) delete_statement_type (
conn_, delete_text_, id_binding_));
return *delete_;
} }
std::size_t private:
data_image_version () const container_statements (const container_statements&);
container_statements& operator= (const container_statements&);
protected:
connection_type& conn_;
binding& id_binding_;
functions_type functions_;
data_image_type data_image_;
std::size_t data_image_version_;
std::size_t data_id_binding_version_;
binding insert_image_binding_;
binding select_image_binding_;
bool* select_image_truncated_;
const char* insert_text_;
const char* select_text_;
const char* delete_text_;
details::shared_ptr<insert_statement_type> insert_;
details::shared_ptr<select_statement_type> select_;
details::shared_ptr<delete_statement_type> delete_;
};
template <typename T>
class smart_container_statements: public container_statements<T>
{
public:
typedef T traits;
typedef typename traits::cond_image_type cond_image_type;
typedef sqlite::update_statement update_statement_type;
typedef sqlite::delete_statement delete_statement_type;
typedef sqlite::connection connection_type;
smart_container_statements (connection_type&, binding& id_binding);
// Condition image. The image is split into the id (that comes as
// a binding) and index/key/value which is in cond_image_type.
//
cond_image_type&
cond_image ()
{ {
return data_image_version_; return cond_image_;
} }
void bind*
data_image_version (std::size_t v) cond_bind ()
{ {
data_image_version_ = v; return cond_image_binding_.bind;
} }
std::size_t bool
data_id_binding_version () const cond_binding_test_version () const
{ {
return data_id_binding_version_; return cond_id_binding_version_ != this->id_binding_.version ||
cond_image_version_ != cond_image_.version ||
cond_image_binding_.version == 0;
} }
void void
data_id_binding_version (std::size_t v) cond_binding_update_version ()
{ {
data_id_binding_version_ = v; cond_id_binding_version_ = this->id_binding_.version;
cond_image_version_ = cond_image_.version;
cond_image_binding_.version++;
} }
binding& // Update image. The image is split as follows: value comes
data_image_binding () // from the data image, id comes as binding, and index/key
// comes from the condition image.
//
bind*
update_bind ()
{ {
return data_image_binding_; return update_image_binding_.bind;
} }
binding& bool
select_image_binding () update_binding_test_version () const
{ {
return select_image_binding_; return update_id_binding_version_ != this->id_binding_.version ||
update_cond_image_version_ != cond_image_.version ||
update_data_image_version_ != this->data_image_.version ||
update_image_binding_.version == 0;
} }
bool* void
select_image_truncated () update_binding_update_version ()
{ {
return select_image_truncated_; update_id_binding_version_ = this->id_binding_.version;
update_cond_image_version_ = cond_image_.version;
update_data_image_version_ = this->data_image_.version;
update_image_binding_.version++;
} }
// //
// Statements. // Statements.
// //
insert_statement_type& delete_statement_type&
insert_one_statement () delete_statement ()
{ {
if (insert_one_ == 0) if (this->delete_ == 0)
{ this->delete_.reset (
insert_one_.reset ( new (details::shared) delete_statement_type (
new (details::shared) insert_statement_type ( this->conn_,
conn_, insert_one_text_, data_image_binding_)); this->delete_text_,
this->cond_image_binding_));
insert_one_->cached (true);
}
return *insert_one_; return *this->delete_;
} }
select_statement_type& update_statement_type&
select_all_statement () update_statement ()
{ {
if (select_all_ == 0) if (update_ == 0)
{ update_.reset (
select_all_.reset ( new (details::shared) update_statement_type (
new (details::shared) select_statement_type ( this->conn_,
conn_, update_text_,
select_all_text_, update_image_binding_));
cond_image_binding_,
select_image_binding_));
select_all_->cached (true);
}
return *select_all_; return *update_;
} }
delete_statement_type&
delete_all_statement ()
{
if (delete_all_ == 0)
{
delete_all_.reset (
new (details::shared) delete_statement_type (
conn_, delete_all_text_, cond_image_binding_));
delete_all_->cached (true);
}
return *delete_all_;
}
private:
container_statements (const container_statements&);
container_statements& operator= (const container_statements&);
protected: protected:
connection_type& conn_;
functions_type functions_;
const binding* id_binding_;
cond_image_type cond_image_; cond_image_type cond_image_;
std::size_t cond_image_version_; std::size_t cond_image_version_;
std::size_t cond_id_binding_version_; std::size_t cond_id_binding_version_;
binding cond_image_binding_; binding cond_image_binding_;
data_image_type data_image_; std::size_t update_id_binding_version_;
std::size_t data_image_version_; std::size_t update_cond_image_version_;
std::size_t data_id_binding_version_; std::size_t update_data_image_version_;
binding update_image_binding_;
binding data_image_binding_; const char* update_text_;
// Skips the id from data_image_binding. details::shared_ptr<update_statement_type> update_;
//
binding select_image_binding_;
bool* select_image_truncated_;
const char* insert_one_text_;
const char* select_all_text_;
const char* delete_all_text_;
details::shared_ptr<insert_statement_type> insert_one_;
details::shared_ptr<select_statement_type> select_all_;
details::shared_ptr<delete_statement_type> delete_all_;
}; };
// Template argument is the generated concrete container traits type. // Template argument is the generated concrete container traits type.
// //
template <typename T> template <typename T>
class container_statements_impl: public T::statements_type class container_statements_impl: public T::statements_type
{ {
public: public:
typedef T traits; typedef T traits;
typedef typename T::statements_type base; typedef typename T::statements_type base;
typedef sqlite::connection connection_type; typedef sqlite::connection connection_type;
container_statements_impl (connection_type&); container_statements_impl (connection_type&, binding&);
private: private:
container_statements_impl (const container_statements_impl&); container_statements_impl (const container_statements_impl&);
container_statements_impl& operator= (const container_statements_impl &); container_statements_impl& operator= (const container_statements_impl &);
private: private:
bind cond_image_bind_[traits::cond_column_count];
bind data_image_bind_[traits::data_column_count]; bind data_image_bind_[traits::data_column_count];
bool select_image_truncated_array_[traits::data_column_count- bool select_image_truncated_array_[traits::data_column_count -
traits::id_column_count]; traits::id_column_count];
}; };
template <typename T>
class smart_container_statements_impl: public container_statements_impl
<T>
{
public:
typedef T traits;
typedef sqlite::connection connection_type;
smart_container_statements_impl (connection_type&, binding&);
private:
bind cond_image_bind_[traits::cond_column_count];
bind update_image_bind_[traits::value_column_count +
traits::cond_column_count];
};
} }
} }
#include <odb/sqlite/container-statements.txx> #include <odb/sqlite/container-statements.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_CONTAINER_STATEMENTS_HXX #endif // ODB_SQLITE_CONTAINER_STATEMENTS_HXX
 End of changes. 49 change blocks. 
120 lines changed or deleted 178 lines changed or added


 container-statements.txx   container-statements.txx 
// file : odb/sqlite/container-statements.txx // file : odb/sqlite/container-statements.txx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <cstring> // std::memset #include <cstring> // std::memset
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
// container_statements // container_statements
// //
template <typename T> template <typename T>
container_statements<T>:: container_statements<T>::
container_statements (connection_type& conn) container_statements (connection_type& conn, binding& id)
: conn_ (conn), : conn_ (conn),
functions_ (this, id_binding_ (id),
&traits::insert_one, functions_ (this),
&traits::load_all, insert_image_binding_ (0, 0), // Initialized by impl.
&traits::delete_all), select_image_binding_ (0, 0) // Initialized by impl.
id_binding_ (0), {
functions_.insert_ = &traits::insert;
functions_.select_ = &traits::select;
functions_.delete__ = &traits::delete_;
data_image_.version = 0;
data_image_version_ = 0;
data_id_binding_version_ = 0;
}
// smart_container_statements
//
template <typename T>
smart_container_statements<T>::
smart_container_statements (connection_type& conn, binding& id)
: container_statements<T> (conn, id),
cond_image_binding_ (0, 0), // Initialized by impl. cond_image_binding_ (0, 0), // Initialized by impl.
data_image_binding_ (0, 0), // Initialized by impl. update_image_binding_ (0, 0) // Initialized by impl.
select_image_binding_ (0, 0) // Initialized by impl.
{ {
this->functions_.update_ = &traits::update;
cond_image_.version = 0; cond_image_.version = 0;
cond_image_version_ = 0; cond_image_version_ = 0;
cond_id_binding_version_ = 0; cond_id_binding_version_ = 0;
data_image_.version = 0; update_id_binding_version_ = 0;
data_image_version_ = 0; update_cond_image_version_ = 0;
data_id_binding_version_ = 0; update_data_image_version_ = 0;
} }
// container_statements_impl
//
template <typename T> template <typename T>
container_statements_impl<T>:: container_statements_impl<T>::
container_statements_impl (connection_type& conn) container_statements_impl (connection_type& conn, binding& id)
: base (conn) : base (conn, id)
{ {
this->select_image_truncated_ = select_image_truncated_array_; this->select_image_truncated_ = select_image_truncated_array_;
this->cond_image_binding_.bind = cond_image_bind_; this->insert_image_binding_.bind = data_image_bind_;
this->cond_image_binding_.count = traits::cond_column_count; this->insert_image_binding_.count = traits::data_column_count;
this->data_image_binding_.bind = data_image_bind_;
this->data_image_binding_.count = traits::data_column_count;
this->select_image_binding_.bind = data_image_bind_ + this->select_image_binding_.bind = data_image_bind_ +
traits::id_column_count; traits::id_column_count;
this->select_image_binding_.count = traits::data_column_count - this->select_image_binding_.count = traits::data_column_count -
traits::id_column_count; traits::id_column_count;
std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_));
std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); std::memset (data_image_bind_, 0, sizeof (data_image_bind_));
std::memset (select_image_truncated_array_, std::memset (select_image_truncated_array_,
0, 0,
sizeof (select_image_truncated_array_)); sizeof (select_image_truncated_array_));
for (std::size_t i (0); for (std::size_t i (0);
i < traits::data_column_count - traits::id_column_count; i < traits::data_column_count - traits::id_column_count;
++i) ++i)
data_image_bind_[i + traits::id_column_count].truncated = data_image_bind_[i + traits::id_column_count].truncated =
select_image_truncated_array_ + i; select_image_truncated_array_ + i;
this->insert_one_text_ = traits::insert_one_statement; this->insert_text_ = traits::insert_statement;
this->select_all_text_ = traits::select_all_statement; this->select_text_ = traits::select_statement;
this->delete_all_text_ = traits::delete_all_statement; this->delete_text_ = traits::delete_statement;
}
// smart_container_statements_impl
//
template <typename T>
smart_container_statements_impl<T>::
smart_container_statements_impl (connection_type& conn, binding& id)
: container_statements_impl<T> (conn, id)
{
this->cond_image_binding_.bind = cond_image_bind_;
this->cond_image_binding_.count = traits::cond_column_count;
this->update_image_binding_.bind = update_image_bind_;
this->update_image_binding_.count = traits::value_column_count +
traits::cond_column_count;
std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_));
std::memset (update_image_bind_, 0, sizeof (update_image_bind_));
this->update_text_ = traits::update_statement;
} }
} }
} }
 End of changes. 12 change blocks. 
24 lines changed or deleted 57 lines changed or added


 conversion.hxx   conversion.hxx 
// file : odb/sqlite/details/conversion.hxx // file : odb/sqlite/details/conversion.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX #ifndef ODB_SQLITE_DETAILS_CONVERSION_HXX
#define ODB_SQLITE_DETAILS_CONVERSION_HXX #define ODB_SQLITE_DETAILS_CONVERSION_HXX
#include <odb/sqlite/traits.hxx> #include <odb/sqlite/traits.hxx>
#include <odb/details/meta/answer.hxx> #include <odb/details/meta/answer.hxx>
namespace odb namespace odb
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 database.hxx   database.hxx 
// file : odb/sqlite/database.hxx // file : odb/sqlite/database.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_DATABASE_HXX #ifndef ODB_SQLITE_DATABASE_HXX
#define ODB_SQLITE_DATABASE_HXX #define ODB_SQLITE_DATABASE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <sqlite3.h> #include <sqlite3.h>
#include <string> #include <string>
#include <memory> // std::auto_ptr, std::unique_ptr #include <memory> // std::auto_ptr, std::unique_ptr
#include <iosfwd> // std::ostream #include <iosfwd> // std::ostream
#include <odb/database.hxx> #include <odb/database.hxx>
#include <odb/details/unique-ptr.hxx> #include <odb/details/unique-ptr.hxx>
#include <odb/details/transfer-ptr.hxx> #include <odb/details/transfer-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> #include <odb/sqlite/forward.hxx>
#include <odb/sqlite/query.hxx>
#include <odb/sqlite/tracer.hxx> #include <odb/sqlite/tracer.hxx>
#include <odb/sqlite/connection.hxx> #include <odb/sqlite/connection.hxx>
#include <odb/sqlite/connection-factory.hxx> #include <odb/sqlite/connection-factory.hxx>
#include <odb/sqlite/transaction-impl.hxx> #include <odb/sqlite/transaction-impl.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
skipping to change at line 105 skipping to change at line 106
{ {
return foreign_keys_; return foreign_keys_;
} }
const std::string& const std::string&
vfs () const vfs () const
{ {
return vfs_; return vfs_;
} }
// Object persistence API.
//
public:
// Make the object persistent.
//
template <typename T>
typename object_traits<T>::id_type
persist (T& object);
template <typename T>
typename object_traits<T>::id_type
persist (T* obj_ptr);
template <typename T, template <typename> class P>
typename object_traits<T>::id_type
persist (const P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
typename object_traits<T>::id_type
persist (const P<T, A1>& obj_ptr);
template <typename T, template <typename> class P>
typename object_traits<T>::id_type
persist (P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
typename object_traits<T>::id_type
persist (P<T, A1>& obj_ptr);
template <typename T>
typename object_traits<T>::id_type
persist (const typename object_traits<T>::pointer_type& obj_ptr);
// Load an object. Throw object_not_persistent if not found.
//
template <typename T>
typename object_traits<T>::pointer_type
load (const typename object_traits<T>::id_type& id);
template <typename T>
void
load (const typename object_traits<T>::id_type& id, T& object);
// Reload an object.
//
template <typename T>
void
reload (T& object);
template <typename T>
void
reload (T* obj_ptr);
template <typename T, template <typename> class P>
void
reload (const P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
void
reload (const P<T, A1>& obj_ptr);
template <typename T, template <typename> class P>
void
reload (P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
void
reload (P<T, A1>& obj_ptr);
template <typename T>
void
reload (const typename object_traits<T>::pointer_type& obj_ptr);
// Loan an object if found. Return NULL/false if not found.
//
template <typename T>
typename object_traits<T>::pointer_type
find (const typename object_traits<T>::id_type& id);
template <typename T>
bool
find (const typename object_traits<T>::id_type& id, T& object);
// Update the state of a modified objects.
//
template <typename T>
void
update (T& object);
template <typename T>
void
update (T* obj_ptr);
template <typename T, template <typename> class P>
void
update (const P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
void
update (const P<T, A1>& obj_ptr);
template <typename T, template <typename> class P>
void
update (P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
void
update (P<T, A1>& obj_ptr);
template <typename T>
void
update (const typename object_traits<T>::pointer_type& obj_ptr);
// Make the object transient. Throw object_not_persistent if not
// found.
//
template <typename T>
void
erase (const typename object_traits<T>::id_type& id);
template <typename T>
void
erase (T& object);
template <typename T>
void
erase (T* obj_ptr);
template <typename T, template <typename> class P>
void
erase (const P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
void
erase (const P<T, A1>& obj_ptr);
template <typename T, template <typename> class P>
void
erase (P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> clas
s P>
void
erase (P<T, A1>& obj_ptr);
template <typename T>
void
erase (const typename object_traits<T>::pointer_type& obj_ptr);
// Erase multiple objects matching a query predicate.
//
template <typename T>
unsigned long long
erase_query ();
template <typename T>
unsigned long long
erase_query (const char*);
template <typename T>
unsigned long long
erase_query (const std::string&);
template <typename T>
unsigned long long
erase_query (const sqlite::query_base&);
template <typename T>
unsigned long long
erase_query (const odb::query_base&);
// Query API.
//
template <typename T>
result<T>
query ();
template <typename T>
result<T>
query (const char*);
template <typename T>
result<T>
query (const std::string&);
template <typename T>
result<T>
query (const sqlite::query_base&);
template <typename T>
result<T>
query (const odb::query_base&);
// Query preparation.
//
template <typename T>
prepared_query<T>
prepare_query (const char* name, const char*);
template <typename T>
prepared_query<T>
prepare_query (const char* name, const std::string&);
template <typename T>
prepared_query<T>
prepare_query (const char* name, const sqlite::query_base&);
template <typename T>
prepared_query<T>
prepare_query (const char* name, const odb::query_base&);
// Transactions. // Transactions.
// //
public: public:
virtual transaction_impl* virtual transaction_impl*
begin (); begin ();
transaction_impl* transaction_impl*
begin_immediate (); begin_immediate ();
transaction_impl* transaction_impl*
skipping to change at line 141 skipping to change at line 353
void void
tracer (tracer_type* t) tracer (tracer_type* t)
{ {
odb::database::tracer (t); odb::database::tracer (t);
} }
using odb::database::tracer; using odb::database::tracer;
public: public:
// Database id constant (useful for meta-programming).
//
static const odb::database_id database_id = id_sqlite;
public:
virtual virtual
~database (); ~database ();
protected: protected:
virtual odb::connection* virtual odb::connection*
connection_ (); connection_ ();
private: private:
std::string name_; std::string name_;
int flags_; int flags_;
 End of changes. 4 change blocks. 
1 lines changed or deleted 226 lines changed or added


 database.ixx   database.ixx 
// file : odb/sqlite/database.ixx // file : odb/sqlite/database.ixx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <odb/sqlite/transaction.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
inline connection_ptr database:: inline connection_ptr database::
connection () connection ()
{ {
// Go through the virtual connection_() function instead of // Go through the virtual connection_() function instead of
// directly to allow overriding. // directly to allow overriding.
// //
return connection_ptr ( return connection_ptr (
static_cast<sqlite::connection*> (connection_ ())); static_cast<sqlite::connection*> (connection_ ()));
} }
template <typename T>
inline typename object_traits<T>::id_type database::
persist (T& obj)
{
return persist_<T, id_sqlite> (obj);
}
template <typename T>
inline typename object_traits<T>::id_type database::
persist (T* p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
return persist_<T, id_sqlite> (pobj);
}
template <typename T, template <typename> class P>
inline typename object_traits<T>::id_type database::
persist (const P<T>& p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
return persist_<T, id_sqlite> (pobj);
}
template <typename T, typename A1, template <typename, typename> class
P>
inline typename object_traits<T>::id_type database::
persist (const P<T, A1>& p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
return persist_<T, id_sqlite> (pobj);
}
template <typename T, template <typename> class P>
inline typename object_traits<T>::id_type database::
persist (P<T>& p)
{
const P<T>& cr (p);
return persist<T, P> (cr);
}
template <typename T, typename A1, template <typename, typename> class
P>
inline typename object_traits<T>::id_type database::
persist (P<T, A1>& p)
{
const P<T, A1>& cr (p);
return persist<T, A1, P> (cr);
}
template <typename T>
inline typename object_traits<T>::id_type database::
persist (const typename object_traits<T>::pointer_type& pobj)
{
return persist_<T, id_sqlite> (pobj);
}
template <typename T>
inline typename object_traits<T>::pointer_type database::
load (const typename object_traits<T>::id_type& id)
{
return load_<T, id_sqlite> (id);
}
template <typename T>
inline void database::
load (const typename object_traits<T>::id_type& id, T& obj)
{
return load_<T, id_sqlite> (id, obj);
}
template <typename T>
inline typename object_traits<T>::pointer_type database::
find (const typename object_traits<T>::id_type& id)
{
return find_<T, id_sqlite> (id);
}
template <typename T>
inline bool database::
find (const typename object_traits<T>::id_type& id, T& obj)
{
return find_<T, id_sqlite> (id, obj);
}
template <typename T>
inline void database::
reload (T& obj)
{
reload_<T, id_sqlite> (obj);
}
template <typename T>
inline void database::
reload (T* p)
{
reload<T> (*p);
}
template <typename T, template <typename> class P>
inline void database::
reload (const P<T>& p)
{
reload (odb::pointer_traits< P<T> >::get_ref (p));
}
template <typename T, typename A1, template <typename, typename> class
P>
inline void database::
reload (const P<T, A1>& p)
{
reload (odb::pointer_traits< P<T, A1> >::get_ref (p));
}
template <typename T, template <typename> class P>
inline void database::
reload (P<T>& p)
{
reload (odb::pointer_traits< P<T> >::get_ref (p));
}
template <typename T, typename A1, template <typename, typename> class
P>
inline void database::
reload (P<T, A1>& p)
{
reload (odb::pointer_traits< P<T, A1> >::get_ref (p));
}
template <typename T>
inline void database::
reload (const typename object_traits<T>::pointer_type& pobj)
{
typedef typename object_traits<T>::pointer_type pointer_type;
reload (odb::pointer_traits<pointer_type>::get_ref (pobj));
}
template <typename T>
inline void database::
update (T& obj)
{
update_<T, id_sqlite> (obj);
}
template <typename T>
inline void database::
update (T* p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
update_<T, id_sqlite> (pobj);
}
template <typename T, template <typename> class P>
inline void database::
update (const P<T>& p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
update_<T, id_sqlite> (pobj);
}
template <typename T, typename A1, template <typename, typename> class
P>
inline void database::
update (const P<T, A1>& p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
update_<T, id_sqlite> (pobj);
}
template <typename T, template <typename> class P>
inline void database::
update (P<T>& p)
{
const P<T>& cr (p);
update<T, P> (cr);
}
template <typename T, typename A1, template <typename, typename> class
P>
inline void database::
update (P<T, A1>& p)
{
const P<T, A1>& cr (p);
update<T, A1, P> (cr);
}
template <typename T>
inline void database::
update (const typename object_traits<T>::pointer_type& pobj)
{
update_<T, id_sqlite> (pobj);
}
template <typename T>
inline void database::
erase (const typename object_traits<T>::id_type& id)
{
return erase_<T, id_sqlite> (id);
}
template <typename T>
inline void database::
erase (T& obj)
{
return erase_<T, id_sqlite> (obj);
}
template <typename T>
inline void database::
erase (T* p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
erase_<T, id_sqlite> (pobj);
}
template <typename T, template <typename> class P>
inline void database::
erase (const P<T>& p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
erase_<T, id_sqlite> (pobj);
}
template <typename T, typename A1, template <typename, typename> class
P>
inline void database::
erase (const P<T, A1>& p)
{
typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object.
//
const object_pointer& pobj (p);
erase_<T, id_sqlite> (pobj);
}
template <typename T, template <typename> class P>
inline void database::
erase (P<T>& p)
{
const P<T>& cr (p);
erase<T, P> (cr);
}
template <typename T, typename A1, template <typename, typename> class
P>
inline void database::
erase (P<T, A1>& p)
{
const P<T, A1>& cr (p);
erase<T, A1, P> (cr);
}
template <typename T>
inline void database::
erase (const typename object_traits<T>::pointer_type& pobj)
{
erase_<T, id_sqlite> (pobj);
}
template <typename T>
inline unsigned long long database::
erase_query ()
{
// T is always object_type.
//
return erase_query<T> (sqlite::query_base ());
}
template <typename T>
inline unsigned long long database::
erase_query (const char* q)
{
// T is always object_type.
//
return erase_query<T> (sqlite::query_base (q));
}
template <typename T>
inline unsigned long long database::
erase_query (const std::string& q)
{
// T is always object_type.
//
return erase_query<T> (sqlite::query_base (q));
}
template <typename T>
inline unsigned long long database::
erase_query (const sqlite::query_base& q)
{
// T is always object_type.
//
return object_traits_impl<T, id_sqlite>::erase_query (*this, q);
}
template <typename T>
inline unsigned long long database::
erase_query (const odb::query_base& q)
{
// Translate to native query.
//
return erase_query<T> (sqlite::query_base (q));
}
template <typename T>
inline result<T> database::
query ()
{
return query<T> (sqlite::query_base ());
}
template <typename T>
inline result<T> database::
query (const char* q)
{
return query<T> (sqlite::query_base (q));
}
template <typename T>
inline result<T> database::
query (const std::string& q)
{
return query<T> (sqlite::query_base (q));
}
template <typename T>
inline result<T> database::
query (const sqlite::query_base& q)
{
// T is always object_type. We also don't need to check for transacti
on
// here; object_traits::query () does this.
//
return query_<T, id_sqlite>::call (*this, q);
}
template <typename T>
inline result<T> database::
query (const odb::query_base& q)
{
// Translate to native query.
//
return query<T> (sqlite::query_base (q));
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const char* q)
{
return prepare_query<T> (n, sqlite::query_base (q));
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const std::string& q)
{
return prepare_query<T> (n, sqlite::query_base (q));
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const sqlite::query_base& q)
{
// Throws if not in transaction.
//
sqlite::connection& c (transaction::current ().connection ());
return c.prepare_query<T> (n, q);
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const odb::query_base& q)
{
// Translate to native query.
//
return prepare_query<T> (n, sqlite::query_base (q));
}
} }
} }
 End of changes. 3 change blocks. 
1 lines changed or deleted 441 lines changed or added


 error.hxx   error.hxx 
// file : odb/sqlite/error.hxx // file : odb/sqlite/error.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_ERROR_HXX #ifndef ODB_SQLITE_ERROR_HXX
#define ODB_SQLITE_ERROR_HXX #define ODB_SQLITE_ERROR_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 exceptions.hxx   exceptions.hxx 
// file : odb/sqlite/exceptions.hxx // file : odb/sqlite/exceptions.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_EXCEPTIONS_HXX #ifndef ODB_SQLITE_EXCEPTIONS_HXX
#define ODB_SQLITE_EXCEPTIONS_HXX #define ODB_SQLITE_EXCEPTIONS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <string> #include <string>
#include <odb/exceptions.hxx> #include <odb/exceptions.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception struct LIBODB_SQLITE_EXPORT database_exception: odb::database_exception
{ {
database_exception (int error, database_exception (int error,
int extended_error, int extended_error,
skipping to change at line 68 skipping to change at line 69
{ {
cli_exception (const std::string& what); cli_exception (const std::string& what);
~cli_exception () throw (); ~cli_exception () throw ();
virtual const char* virtual const char*
what () const throw (); what () const throw ();
private: private:
std::string what_; std::string what_;
}; };
namespace core
{
using sqlite::database_exception;
using sqlite::cli_exception;
}
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_EXCEPTIONS_HXX #endif // ODB_SQLITE_EXCEPTIONS_HXX
 End of changes. 3 change blocks. 
1 lines changed or deleted 8 lines changed or added


 export.hxx   export.hxx 
// file : odb/sqlite/details/export.hxx // file : odb/sqlite/details/export.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_DETAILS_EXPORT_HXX #ifndef ODB_SQLITE_DETAILS_EXPORT_HXX
#define ODB_SQLITE_DETAILS_EXPORT_HXX #define ODB_SQLITE_DETAILS_EXPORT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/sqlite/details/config.hxx> #include <odb/sqlite/details/config.hxx>
#ifdef LIBODB_SQLITE_STATIC_LIB #ifdef LIBODB_SQLITE_STATIC_LIB
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 forward.hxx   forward.hxx 
// file : odb/sqlite/forward.hxx // file : odb/sqlite/forward.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_FORWARD_HXX #ifndef ODB_SQLITE_FORWARD_HXX
#define ODB_SQLITE_FORWARD_HXX #define ODB_SQLITE_FORWARD_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
namespace core
{
using namespace odb::common;
}
//
//
class database; class database;
class connection; class connection;
typedef details::shared_ptr<connection> connection_ptr; typedef details::shared_ptr<connection> connection_ptr;
class connection_factory; class connection_factory;
class statement; class statement;
class transaction; class transaction;
class tracer; class tracer;
class query;
namespace core
{
using sqlite::database;
using sqlite::connection;
using sqlite::connection_ptr;
using sqlite::transaction;
using sqlite::statement;
}
// Implementation details. // Implementation details.
// //
enum statement_kind enum statement_kind
{ {
statement_select, statement_select,
statement_insert, statement_insert,
statement_update statement_update
}; };
skipping to change at line 55 skipping to change at line 70
template <typename T> template <typename T>
class no_id_object_statements; class no_id_object_statements;
template <typename T> template <typename T>
class view_statements; class view_statements;
template <typename T> template <typename T>
class container_statements; class container_statements;
template <typename T>
class smart_container_statements;
class query_base;
class query_params; class query_params;
} }
namespace details namespace details
{ {
template <> template <>
struct counter_type<sqlite::connection> struct counter_type<sqlite::connection>
{ {
typedef shared_base counter; typedef shared_base counter;
}; };
 End of changes. 4 change blocks. 
2 lines changed or deleted 21 lines changed or added


 no-id-object-result.hxx   no-id-object-result.hxx 
// file : odb/sqlite/no-id-object-result.hxx // file : odb/sqlite/no-id-object-result.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX #ifndef ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX
#define ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX #define ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/no-id-object-result.hxx> #include <odb/no-id-object-result.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> // query #include <odb/sqlite/forward.hxx> // query_base, query_params
#include <odb/sqlite/result.hxx>
#include <odb/sqlite/statement.hxx> #include <odb/sqlite/statement.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
class no_id_object_result_impl: public odb::no_id_object_result_impl<T> class no_id_object_result_impl: public odb::no_id_object_result_impl<T>
,
public result_impl_base
{ {
public: public:
typedef odb::no_id_object_result_impl<T> base_type; typedef odb::no_id_object_result_impl<T> base_type;
typedef typename base_type::object_traits object_traits;
typedef typename base_type::object_type object_type; typedef typename base_type::object_type object_type;
typedef typename base_type::pointer_type pointer_type; typedef typename base_type::pointer_type pointer_type;
typedef object_traits_impl<object_type, id_sqlite> object_traits;
typedef typename base_type::pointer_traits pointer_traits; typedef typename base_type::pointer_traits pointer_traits;
typedef typename object_traits::statements_type statements_type; typedef typename object_traits::statements_type statements_type;
virtual virtual
~no_id_object_result_impl (); ~no_id_object_result_impl ();
no_id_object_result_impl (const query&, no_id_object_result_impl (const query_base&,
details::shared_ptr<select_statement>, const details::shared_ptr<select_statement>
&,
statements_type&); statements_type&);
virtual void virtual void
load (object_type&); load (object_type&);
virtual void virtual void
next (); next ();
virtual void virtual void
cache (); cache ();
virtual std::size_t virtual std::size_t
size (); size ();
virtual void
invalidate ();
using base_type::current; using base_type::current;
private: private:
// We need to hold on to the query parameters because SQLite uses
// the parameter buffers to find each next row.
//
details::shared_ptr<query_params> params_;
details::shared_ptr<select_statement> statement_;
statements_type& statements_; statements_type& statements_;
}; };
} }
} }
#include <odb/sqlite/no-id-object-result.txx> #include <odb/sqlite/no-id-object-result.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX #endif // ODB_SQLITE_NO_ID_OBJECT_RESULT_HXX
 End of changes. 9 change blocks. 
10 lines changed or deleted 16 lines changed or added


 no-id-object-result.txx   no-id-object-result.txx 
// file : odb/sqlite/no-id-object-result.txx // file : odb/sqlite/no-id-object-result.txx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <odb/callback.hxx> #include <odb/callback.hxx>
#include <odb/exceptions.hxx> // result_not_cached #include <odb/exceptions.hxx> // result_not_cached
#include <odb/sqlite/no-id-object-statements.hxx> #include <odb/sqlite/no-id-object-statements.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
no_id_object_result_impl<T>:: no_id_object_result_impl<T>::
~no_id_object_result_impl () ~no_id_object_result_impl ()
{ {
if (!this->end_) if (!this->end_)
statement_->free_result (); statement_->free_result ();
} }
template <typename T> template <typename T>
void no_id_object_result_impl<T>::
invalidate ()
{
if (!this->end_)
{
statement_->free_result ();
this->end_ = true;
}
params_.reset ();
statement_.reset ();
}
template <typename T>
no_id_object_result_impl<T>:: no_id_object_result_impl<T>::
no_id_object_result_impl (const query& q, no_id_object_result_impl (const query_base& q,
details::shared_ptr<select_statement> stateme const details::shared_ptr<select_statement>&
nt, s,
statements_type& statements) statements_type& sts)
: base_type (statements.connection ().database ()), : base_type (sts.connection ()),
result_impl_base (q, statement), params_ (q.parameters ()),
statements_ (statements) statement_ (s),
statements_ (sts)
{ {
} }
template <typename T> template <typename T>
void no_id_object_result_impl<T>:: void no_id_object_result_impl<T>::
load (object_type& obj) load (object_type& obj)
{ {
// The image can grow between calls to load() as a result of other // The image can grow between calls to load() as a result of other
// statements execution. // statements execution.
// //
skipping to change at line 67 skipping to change at line 82
if (im.version != statements_.select_image_version ()) if (im.version != statements_.select_image_version ())
{ {
binding& b (statements_.select_image_binding ()); binding& b (statements_.select_image_binding ());
object_traits::bind (b.bind, im, statement_select); object_traits::bind (b.bind, im, statement_select);
statements_.select_image_version (im.version); statements_.select_image_version (im.version);
b.version++; b.version++;
statement_->reload (); statement_->reload ();
} }
} }
odb::database& db (this->database ()); object_traits::callback (this->db_, obj, callback_event::pre_load);
object_traits::init (obj, im, &this->db_);
object_traits::callback (db, obj, callback_event::pre_load); object_traits::callback (this->db_, obj, callback_event::post_load);
object_traits::init (obj, im, &db);
object_traits::callback (db, obj, callback_event::post_load);
} }
template <typename T> template <typename T>
void no_id_object_result_impl<T>:: void no_id_object_result_impl<T>::
next () next ()
{ {
this->current (pointer_type ()); this->current (pointer_type ());
if (!statement_->next ()) if (!statement_->next ())
{ {
 End of changes. 4 change blocks. 
13 lines changed or deleted 26 lines changed or added


 no-id-object-statements.hxx   no-id-object-statements.hxx 
// file : odb/sqlite/no-id-object-statements.hxx // file : odb/sqlite/no-id-object-statements.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX #ifndef ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX
#define ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX #define ODB_SQLITE_NO_ID_OBJECT_STATEMENTS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx>
skipping to change at line 37 skipping to change at line 37
{ {
// //
// Implementation for objects without object id. // Implementation for objects without object id.
// //
template <typename T> template <typename T>
class no_id_object_statements: public statements_base class no_id_object_statements: public statements_base
{ {
public: public:
typedef T object_type; typedef T object_type;
typedef odb::object_traits<object_type> object_traits; typedef object_traits_impl<object_type, id_sqlite> object_traits;
typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::pointer_type pointer_type;
typedef typename object_traits::image_type image_type; typedef typename object_traits::image_type image_type;
typedef sqlite::insert_statement insert_statement_type; typedef sqlite::insert_statement insert_statement_type;
public: public:
no_id_object_statements (connection_type&); no_id_object_statements (connection_type&);
virtual virtual
~no_id_object_statements (); ~no_id_object_statements ();
skipping to change at line 91 skipping to change at line 91
insert_statement_type& insert_statement_type&
persist_statement () persist_statement ()
{ {
if (persist_ == 0) if (persist_ == 0)
{ {
persist_.reset ( persist_.reset (
new (details::shared) insert_statement_type ( new (details::shared) insert_statement_type (
conn_, conn_,
object_traits::persist_statement, object_traits::persist_statement,
insert_image_binding_)); insert_image_binding_));
persist_->cached (true);
} }
return *persist_; return *persist_;
} }
public: public:
// select = total // select = total
// insert = total - inverse; inverse == 0 for object without id // insert = total - inverse; inverse == 0 for object without id
// //
static const std::size_t insert_column_count = static const std::size_t insert_column_count =
 End of changes. 3 change blocks. 
4 lines changed or deleted 2 lines changed or added


 no-id-object-statements.txx   no-id-object-statements.txx 
// file : odb/sqlite/no-id-object-statements.txx // file : odb/sqlite/no-id-object-statements.txx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset #include <cstring> // std::memset
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
no_id_object_statements<T>:: no_id_object_statements<T>::
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 polymorphic-object-result.hxx   polymorphic-object-result.hxx 
// file : odb/sqlite/polymorphic-object-result.hxx // file : odb/sqlite/polymorphic-object-result.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX
#define ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX #define ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/polymorphic-object-result.hxx> #include <odb/polymorphic-object-result.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> // query #include <odb/sqlite/forward.hxx> // query_base, query_params
#include <odb/sqlite/result.hxx>
#include <odb/sqlite/statement.hxx> #include <odb/sqlite/statement.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
class polymorphic_object_result_impl: class polymorphic_object_result_impl:
public odb::polymorphic_object_result_impl<T>, public odb::polymorphic_object_result_impl<T>
public result_impl_base
{ {
public: public:
typedef odb::polymorphic_object_result_impl<T> base_type; typedef odb::polymorphic_object_result_impl<T> base_type;
typedef typename base_type::object_type object_type;
typedef typename base_type::object_traits object_traits;
typedef typename base_type::id_type id_type; typedef typename base_type::id_type id_type;
typedef typename base_type::object_type object_type;
typedef typename base_type::pointer_type pointer_type; typedef typename base_type::pointer_type pointer_type;
typedef object_traits_impl<object_type, id_sqlite> object_traits;
typedef typename base_type::pointer_traits pointer_traits; typedef typename base_type::pointer_traits pointer_traits;
typedef typename base_type::root_type root_type; typedef typename base_type::root_type root_type;
typedef typename base_type::root_traits root_traits;
typedef typename base_type::discriminator_type discriminator_type; typedef typename base_type::discriminator_type discriminator_type;
typedef object_traits_impl<root_type, id_sqlite> root_traits;
typedef typename object_traits::statements_type statements_type; typedef typename object_traits::statements_type statements_type;
virtual virtual
~polymorphic_object_result_impl (); ~polymorphic_object_result_impl ();
polymorphic_object_result_impl (const query&, polymorphic_object_result_impl (
details::shared_ptr<select_statement> const query_base&,
, const details::shared_ptr<select_statement>&,
statements_type&); statements_type&);
virtual void virtual void
load (object_type*, bool fetch); load (object_type*, bool fetch);
virtual id_type virtual id_type
load_id (); load_id ();
virtual discriminator_type virtual discriminator_type
load_discriminator (); load_discriminator ();
virtual void virtual void
next (); next ();
virtual void virtual void
cache (); cache ();
virtual std::size_t virtual std::size_t
size (); size ();
virtual void
invalidate ();
using base_type::current; using base_type::current;
private: private:
void void
load_image (); load_image ();
private: private:
// We need to hold on to the query parameters because SQLite uses
// the parameter buffers to find each next row.
//
details::shared_ptr<query_params> params_;
details::shared_ptr<select_statement> statement_;
statements_type& statements_; statements_type& statements_;
}; };
} }
} }
#include <odb/sqlite/polymorphic-object-result.txx> #include <odb/sqlite/polymorphic-object-result.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX #endif // ODB_SQLITE_POLYMORPHIC_OBJECT_RESULT_HXX
 End of changes. 11 change blocks. 
13 lines changed or deleted 20 lines changed or added


 polymorphic-object-result.txx   polymorphic-object-result.txx 
// file : odb/sqlite/polymorphic-object-result.txx // file : odb/sqlite/polymorphic-object-result.txx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cassert> #include <cassert>
#include <odb/callback.hxx> #include <odb/callback.hxx>
#include <odb/exceptions.hxx> // result_not_cached #include <odb/exceptions.hxx> // result_not_cached
#include <odb/sqlite/polymorphic-object-statements.hxx> #include <odb/sqlite/polymorphic-object-statements.hxx>
namespace odb namespace odb
skipping to change at line 25 skipping to change at line 25
{ {
template <typename T> template <typename T>
polymorphic_object_result_impl<T>:: polymorphic_object_result_impl<T>::
~polymorphic_object_result_impl () ~polymorphic_object_result_impl ()
{ {
if (!this->end_) if (!this->end_)
statement_->free_result (); statement_->free_result ();
} }
template <typename T> template <typename T>
void polymorphic_object_result_impl<T>::
invalidate ()
{
if (!this->end_)
{
statement_->free_result ();
this->end_ = true;
}
params_.reset ();
statement_.reset ();
}
template <typename T>
polymorphic_object_result_impl<T>:: polymorphic_object_result_impl<T>::
polymorphic_object_result_impl (const query& q, polymorphic_object_result_impl (
details::shared_ptr<select_statement> s const query_base& q,
t, const details::shared_ptr<select_statement>& s,
statements_type& sts) statements_type& sts)
: base_type (sts.connection ().database ()), : base_type (sts.connection ()),
result_impl_base (q, st), params_ (q.parameters ()),
statement_ (s),
statements_ (sts) statements_ (sts)
{ {
} }
template <typename T> template <typename T>
void polymorphic_object_result_impl<T>:: void polymorphic_object_result_impl<T>::
load (object_type* pobj, bool fetch) load (object_type* pobj, bool fetch)
{ {
if (fetch) if (fetch)
load_image (); load_image ();
typename statements_type::root_statements_type& rsts ( typename statements_type::root_statements_type& rsts (
statements_.root_statements ()); statements_.root_statements ());
// This is a top-level call so the statements cannot be locked. // This is a top-level call so the statements cannot be locked.
// //
assert (!rsts.locked ()); assert (!rsts.locked ());
typename statements_type::auto_lock l (rsts); typename statements_type::auto_lock l (rsts);
odb::database& db (this->database ());
typename object_traits::image_type& i (statements_.image ()); typename object_traits::image_type& i (statements_.image ());
typename root_traits::image_type& ri (rsts.image ()); typename root_traits::image_type& ri (rsts.image ());
id_type id (root_traits::id (ri)); id_type id (root_traits::id (ri));
// Determine this object's dynamic type. // Determine this object's dynamic type.
// //
typedef typename root_traits::info_type info_type; typedef typename root_traits::info_type info_type;
discriminator_type d (root_traits::discriminator (ri)); discriminator_type d (root_traits::discriminator (ri));
discriminator_type disc (d); discriminator_type disc (d);
skipping to change at line 87 skipping to change at line 102
{ {
// Need to create a new instance of the dynamic type. // Need to create a new instance of the dynamic type.
// //
root_pointer_type rp (pi.create ()); root_pointer_type rp (pi.create ());
pointer_type p ( pointer_type p (
root_pointer_traits::template static_pointer_cast<object_type> (r p)); root_pointer_traits::template static_pointer_cast<object_type> (r p));
// Insert it as a root pointer (for non-unique pointers, rp should // Insert it as a root pointer (for non-unique pointers, rp should
// still be valid and for unique pointers this is a no-op). // still be valid and for unique pointers this is a no-op).
// //
ig.reset (object_traits::pointer_cache_traits::insert (db, id, rp)) ig.reset (
; object_traits::pointer_cache_traits::insert (this->db_, id, rp));
pobj = &pointer_traits::get_ref (p); pobj = &pointer_traits::get_ref (p);
current (p); current (p);
} }
else else
{ {
// We are loading into an existing instance. If the static and // We are loading into an existing instance. If the static and
// dynamic types differ, then make sure the instance is at least // dynamic types differ, then make sure the instance is at least
// of the dynamic type. // of the dynamic type.
// //
if (&pi != &object_traits::info) if (&pi != &object_traits::info)
{ {
const info_type& dpi (root_traits::map->find (typeid (*pobj))); const info_type& dpi (root_traits::map->find (typeid (*pobj)));
if (&dpi != &pi && dpi.derived (pi)) if (&dpi != &pi && dpi.derived (pi))
throw object_not_persistent (); // @@ type_mismatch ? throw object_not_persistent (); // @@ type_mismatch ?
} }
} }
callback_event ce (callback_event::pre_load); callback_event ce (callback_event::pre_load);
pi.dispatch (info_type::call_callback, db, pobj, &ce); pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
object_traits::init (*pobj, i, &db); object_traits::init (*pobj, i, &this->db_);
// Initialize the id image and binding and load the rest of the objec t // Initialize the id image and binding and load the rest of the objec t
// (containers, dynamic part, etc). // (containers, dynamic part, etc).
// //
typename object_traits::id_image_type& idi (statements_.id_image ()); typename object_traits::id_image_type& idi (statements_.id_image ());
root_traits::init (idi, id); root_traits::init (idi, id);
binding& idb (statements_.id_image_binding ()); binding& idb (statements_.id_image_binding ());
if (idi.version != statements_.id_image_version () || idb.version == 0) if (idi.version != statements_.id_image_version () || idb.version == 0)
{ {
skipping to change at line 134 skipping to change at line 150
} }
object_traits::load_ (statements_, *pobj); object_traits::load_ (statements_, *pobj);
// Load the dynamic part of the object unless static and dynamic // Load the dynamic part of the object unless static and dynamic
// types are the same. // types are the same.
// //
if (&pi != &object_traits::info) if (&pi != &object_traits::info)
{ {
std::size_t d (object_traits::depth); std::size_t d (object_traits::depth);
pi.dispatch (info_type::call_load, db, pobj, &d); pi.dispatch (info_type::call_load, this->db_, pobj, &d);
}; };
rsts.load_delayed (); rsts.load_delayed ();
l.unlock (); l.unlock ();
ce = callback_event::post_load; ce = callback_event::post_load;
pi.dispatch (info_type::call_callback, db, pobj, &ce); pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
object_traits::pointer_cache_traits::load (ig.position ());
ig.release (); ig.release ();
} }
template <typename T> template <typename T>
typename polymorphic_object_result_impl<T>::id_type typename polymorphic_object_result_impl<T>::id_type
polymorphic_object_result_impl<T>:: polymorphic_object_result_impl<T>::
load_id () load_id ()
{ {
load_image (); load_image ();
return root_traits::id (statements_.root_statements ().image ()); return root_traits::id (statements_.root_statements ().image ());
skipping to change at line 182 skipping to change at line 199
statement_->free_result (); statement_->free_result ();
this->end_ = true; this->end_ = true;
} }
} }
template <typename T, typename R> template <typename T, typename R>
struct polymorphic_image_rebind struct polymorphic_image_rebind
{ {
// Derived type version. // Derived type version.
// //
typedef object_traits<T> traits; typedef object_traits_impl<T, id_sqlite> traits;
static bool static bool
rebind (typename traits::statements_type& sts) rebind (typename traits::statements_type& sts)
{ {
typename traits::image_type& im (sts.image ()); typename traits::image_type& im (sts.image ());
if (traits::check_version (sts.select_image_versions (), im)) if (traits::check_version (sts.select_image_versions (), im))
{ {
binding& b (sts.select_image_binding (traits::depth)); binding& b (sts.select_image_binding (traits::depth));
traits::bind (b.bind, 0, 0, im, statement_select); traits::bind (b.bind, 0, 0, im, statement_select);
skipping to change at line 207 skipping to change at line 224
return false; return false;
} }
}; };
template <typename R> template <typename R>
struct polymorphic_image_rebind<R, R> struct polymorphic_image_rebind<R, R>
{ {
// Root type version. // Root type version.
// //
typedef object_traits<R> traits; typedef object_traits_impl<R, id_sqlite> traits;
static bool static bool
rebind (typename traits::statements_type& sts) rebind (typename traits::statements_type& sts)
{ {
typename traits::image_type& im (sts.image ()); typename traits::image_type& im (sts.image ());
if (im.version != sts.select_image_version ()) if (im.version != sts.select_image_version ())
{ {
binding& b (sts.select_image_binding ()); binding& b (sts.select_image_binding ());
traits::bind (b.bind, im, statement_select); traits::bind (b.bind, im, statement_select);
 End of changes. 11 change blocks. 
16 lines changed or deleted 31 lines changed or added


 polymorphic-object-statements.hxx   polymorphic-object-statements.hxx 
// file : odb/sqlite/polymorphic-object-statements.hxx // file : odb/sqlite/polymorphic-object-statements.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX #ifndef ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX
#define ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX #define ODB_SQLITE_POLYMORPHIC_OBJECT_STATEMENTS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx>
skipping to change at line 110 skipping to change at line 110
find_discriminator_statement () find_discriminator_statement ()
{ {
if (find_discriminator_ == 0) if (find_discriminator_ == 0)
{ {
find_discriminator_.reset ( find_discriminator_.reset (
new (details::shared) select_statement_type ( new (details::shared) select_statement_type (
this->conn_, this->conn_,
object_traits::find_discriminator_statement, object_traits::find_discriminator_statement,
discriminator_id_image_binding_, discriminator_id_image_binding_,
discriminator_image_binding_)); discriminator_image_binding_));
find_discriminator_->cached (true);
} }
return *find_discriminator_; return *find_discriminator_;
} }
public: public:
polymorphic_root_object_statements (connection_type&); polymorphic_root_object_statements (connection_type&);
virtual virtual
~polymorphic_root_object_statements (); ~polymorphic_root_object_statements ();
skipping to change at line 159 skipping to change at line 157
bind discriminator_id_image_bind_[id_column_count]; bind discriminator_id_image_bind_[id_column_count];
details::shared_ptr<select_statement_type> find_discriminator_; details::shared_ptr<select_statement_type> find_discriminator_;
}; };
template <typename T> template <typename T>
class polymorphic_derived_object_statements: public statements_base class polymorphic_derived_object_statements: public statements_base
{ {
public: public:
typedef T object_type; typedef T object_type;
typedef odb::object_traits<object_type> object_traits; typedef object_traits_impl<object_type, id_sqlite> object_traits;
typedef typename object_traits::id_type id_type; typedef typename object_traits::id_type id_type;
typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::pointer_type pointer_type;
typedef typename object_traits::id_image_type id_image_type; typedef typename object_traits::id_image_type id_image_type;
typedef typename object_traits::image_type image_type; typedef typename object_traits::image_type image_type;
typedef typename object_traits::root_type root_type; typedef typename object_traits::root_type root_type;
typedef typedef
polymorphic_root_object_statements<root_type> polymorphic_root_object_statements<root_type>
root_statements_type; root_statements_type;
skipping to change at line 299 skipping to change at line 297
insert_statement_type& insert_statement_type&
persist_statement () persist_statement ()
{ {
if (persist_ == 0) if (persist_ == 0)
{ {
persist_.reset ( persist_.reset (
new (details::shared) insert_statement_type ( new (details::shared) insert_statement_type (
conn_, conn_,
object_traits::persist_statement, object_traits::persist_statement,
insert_image_binding_)); insert_image_binding_));
persist_->cached (true);
} }
return *persist_; return *persist_;
} }
select_statement_type& select_statement_type&
find_statement (std::size_t d) find_statement (std::size_t d)
{ {
std::size_t i (object_traits::depth - d); std::size_t i (object_traits::depth - d);
details::shared_ptr<select_statement_type>& p (find_[i]); details::shared_ptr<select_statement_type>& p (find_[i]);
if (p == 0) if (p == 0)
{ {
p.reset ( p.reset (
new (details::shared) select_statement_type ( new (details::shared) select_statement_type (
conn_, conn_,
object_traits::find_statements[i], object_traits::find_statements[i],
root_statements_.id_image_binding (), root_statements_.id_image_binding (),
select_image_bindings_[i])); select_image_bindings_[i]));
p->cached (true);
} }
return *p; return *p;
} }
update_statement_type& update_statement_type&
update_statement () update_statement ()
{ {
if (update_ == 0) if (update_ == 0)
{ {
update_.reset ( update_.reset (
new (details::shared) update_statement_type ( new (details::shared) update_statement_type (
conn_, conn_,
object_traits::update_statement, object_traits::update_statement,
update_image_binding_)); update_image_binding_));
update_->cached (true);
} }
return *update_; return *update_;
} }
delete_statement_type& delete_statement_type&
erase_statement () erase_statement ()
{ {
if (erase_ == 0) if (erase_ == 0)
{ {
erase_.reset ( erase_.reset (
new (details::shared) delete_statement_type ( new (details::shared) delete_statement_type (
conn_, conn_,
object_traits::erase_statement, object_traits::erase_statement,
root_statements_.id_image_binding ())); root_statements_.id_image_binding ()));
erase_->cached (true);
} }
return *erase_; return *erase_;
} }
// Container statement cache. // Container statement cache.
// //
container_statement_cache_type& container_statement_cache_type&
container_statment_cache () container_statment_cache ()
{ {
return container_statement_cache_.get (conn_); return container_statement_cache_.get (conn_, id_image_binding ());
} }
public: public:
// select = total - id + base::select // select = total - id + base::select
// insert = total - inverse // insert = total - inverse
// update = total - inverse - id - readonly // update = total - inverse - id - readonly
// //
static const std::size_t id_column_count = static const std::size_t id_column_count =
object_traits::id_column_count; object_traits::id_column_count;
 End of changes. 8 change blocks. 
13 lines changed or deleted 3 lines changed or added


 polymorphic-object-statements.txx   polymorphic-object-statements.txx 
// file : odb/sqlite/polymorphic-object-statements.txx // file : odb/sqlite/polymorphic-object-statements.txx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset #include <cstring> // std::memset
#include <odb/callback.hxx> #include <odb/callback.hxx>
#include <odb/exceptions.hxx> #include <odb/exceptions.hxx>
#include <odb/sqlite/connection.hxx> #include <odb/sqlite/connection.hxx>
#include <odb/sqlite/transaction.hxx> #include <odb/sqlite/transaction.hxx>
#include <odb/sqlite/statement-cache.hxx> #include <odb/sqlite/statement-cache.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 query.hxx   query.hxx 
// file : odb/sqlite/query.hxx // file : odb/sqlite/query.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_QUERY_HXX #ifndef ODB_SQLITE_QUERY_HXX
#define ODB_SQLITE_QUERY_HXX #define ODB_SQLITE_QUERY_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <string> #include <string>
#include <vector> #include <vector>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/forward.hxx> // odb::query_column
#include <odb/query.hxx> #include <odb/query.hxx>
#include <odb/details/buffer.hxx> #include <odb/details/buffer.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> #include <odb/sqlite/forward.hxx>
#include <odb/sqlite/traits.hxx> #include <odb/sqlite/traits.hxx>
#include <odb/sqlite/sqlite-types.hxx> #include <odb/sqlite/sqlite-types.hxx>
#include <odb/sqlite/binding.hxx> #include <odb/sqlite/binding.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
#include <odb/sqlite/details/conversion.hxx> #include <odb/sqlite/details/conversion.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
class val_bind struct val_bind
{ {
public: typedef const T& type;
explicit
val_bind (type v): val (v) {}
type val;
};
template <typename T, std::size_t N>
struct val_bind<T[N]>
{
typedef const T* type;
explicit explicit
val_bind (const T& v): val (v) {} val_bind (type v): val (v) {}
const T& val; type val;
}; };
template <typename T> template <typename T>
class ref_bind struct ref_bind
{ {
public: typedef const T& type;
explicit explicit
ref_bind (const T& r): ref (r) {} ref_bind (type r): ref (r) {}
const T& ref; const void*
ptr () const {return &ref;}
type ref;
};
template <typename T, std::size_t N>
struct ref_bind<T[N]>
{
typedef const T* type;
explicit
ref_bind (type r): ref (r) {}
// Allow implicit conversion from decayed ref_bind's.
//
ref_bind (ref_bind<T*> r): ref (r.ref) {}
ref_bind (ref_bind<const T*> r): ref (r.ref) {}
const void*
ptr () const {return ref;}
type ref;
};
template <typename T, database_type_id ID>
struct val_bind_typed: val_bind<T>
{
explicit
val_bind_typed (typename val_bind<T>::type v): val_bind<T> (v) {}
};
template <typename T, database_type_id ID>
struct ref_bind_typed: ref_bind<T>
{
explicit
ref_bind_typed (typename ref_bind<T>::type r): ref_bind<T> (r) {}
}; };
struct LIBODB_SQLITE_EXPORT query_param: details::shared_base struct LIBODB_SQLITE_EXPORT query_param: details::shared_base
{ {
virtual virtual
~query_param (); ~query_param ();
bool bool
reference () const reference () const
{ {
skipping to change at line 78 skipping to change at line 128
protected: protected:
query_param (const void* value) query_param (const void* value)
: value_ (value) : value_ (value)
{ {
} }
protected: protected:
const void* value_; const void* value_;
}; };
class query; class query_base;
class LIBODB_SQLITE_EXPORT query_params: public details::shared_base class LIBODB_SQLITE_EXPORT query_params: public details::shared_base
{ {
public: public:
typedef sqlite::binding binding_type; typedef sqlite::binding binding_type;
void
init ();
binding_type& binding_type&
binding (); binding () {return binding_;}
private: private:
friend class query; friend class query_base;
query_params (): binding_ (0, 0) {} query_params (): binding_ (0, 0) {}
query_params (const query_params&); query_params (const query_params&);
query_params& query_params&
operator= (const query_params&); operator= (const query_params&);
query_params& query_params&
operator+= (const query_params&); operator+= (const query_params&);
skipping to change at line 116 skipping to change at line 169
params params_; params params_;
std::vector<sqlite::bind> bind_; std::vector<sqlite::bind> bind_;
binding_type binding_; binding_type binding_;
}; };
// //
// //
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
struct query_column; struct query_column;
class LIBODB_SQLITE_EXPORT query class LIBODB_SQLITE_EXPORT query_base
{ {
public: public:
struct clause_part struct clause_part
{ {
enum kind_type enum kind_type
{ {
column, kind_column,
param, kind_param,
native, kind_native,
boolean kind_bool
}; };
clause_part (kind_type k): kind (k) {} clause_part (kind_type k): kind (k) {}
clause_part (kind_type k, const std::string& p): kind (k), part (p) {} clause_part (kind_type k, const std::string& p): kind (k), part (p) {}
clause_part (bool p): kind (boolean), bool_part (p) {} clause_part (bool p): kind (kind_bool), bool_part (p) {}
kind_type kind; kind_type kind;
std::string part; // If kind is param, then part is conversion expr . std::string part; // If kind is param, then part is conversion expr .
bool bool_part; bool bool_part;
}; };
query () query_base ()
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
} }
// True or false literal. // True or false literal.
// //
explicit explicit
query (bool v) query_base (bool v)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
clause_.push_back (clause_part (v)); append (v);
} }
explicit explicit
query (const char* native) query_base (const char* native)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
clause_.push_back (clause_part (clause_part::native, native)); clause_.push_back (clause_part (clause_part::kind_native, native));
} }
explicit explicit
query (const std::string& native) query_base (const std::string& native)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
clause_.push_back (clause_part (clause_part::native, native)); clause_.push_back (clause_part (clause_part::kind_native, native));
} }
query (const char* table, const char* column) query_base (const char* table, const char* column)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
append (table, column); append (table, column);
} }
template <typename T> template <typename T>
explicit explicit
query (val_bind<T> v) query_base (val_bind<T> v)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
append<T, type_traits<T>::db_type_id> ( *this += v;
v, details::conversion<T>::to ()); }
template <typename T, database_type_id ID>
explicit
query_base (val_bind_typed<T, ID> v)
: parameters_ (new (details::shared) query_params)
{
*this += v;
} }
template <typename T> template <typename T>
explicit explicit
query (ref_bind<T> r) query_base (ref_bind<T> r)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
append<T, type_traits<T>::db_type_id> ( *this += r;
r, details::conversion<T>::to ()); }
template <typename T, database_type_id ID>
explicit
query_base (ref_bind_typed<T, ID> r)
: parameters_ (new (details::shared) query_params)
{
*this += r;
} }
template <database_type_id ID> template <database_type_id ID>
query (const query_column<bool, ID>&); query_base (const query_column<bool, ID>&);
// Translate common query representation to SQLite native. Defined
// in query-dynamic.cxx
//
query_base (const odb::query_base&);
query (const query&); // Copy c-tor and assignment.
//
query_base (const query_base&);
query& query_base&
operator= (const query&); operator= (const query_base&);
public: public:
std::string std::string
clause () const; clause () const;
const char* const char*
clause_prefix () const; clause_prefix () const;
// Initialize the by-reference parameters from bound variables.
//
void
init_parameters () const;
binding& binding&
parameters_binding () const; parameters_binding () const;
details::shared_ptr<query_params>; const details::shared_ptr<query_params>&;
parameters () const; parameters () const;
public: public:
bool bool
empty () const empty () const
{ {
return clause_.empty (); return clause_.empty ();
} }
static const query true_expr; static const query_base true_expr;
bool bool
const_true () const const_true () const
{ {
return clause_.size () == 1 && return clause_.size () == 1 &&
clause_.front ().kind == clause_part::boolean && clause_.front ().kind == clause_part::kind_bool &&
clause_.front ().bool_part; clause_.front ().bool_part;
} }
void void
optimize (); optimize ();
public: public:
template <typename T> template <typename T>
static val_bind<T> static val_bind<T>
_val (const T& x) _val (const T& x)
{ {
return val_bind<T> (x); return val_bind<T> (x);
} }
template <database_type_id ID, typename T>
static val_bind_typed<T, ID>
_val (const T& x)
{
return val_bind_typed<T, ID> (x);
}
template <typename T> template <typename T>
static ref_bind<T> static ref_bind<T>
_ref (const T& x) _ref (const T& x)
{ {
return ref_bind<T> (x); return ref_bind<T> (x);
} }
template <database_type_id ID, typename T>
static ref_bind_typed<T, ID>
_ref (const T& x)
{
return ref_bind_typed<T, ID> (x);
}
// Some compilers (notably VC++), when deducing const T& from const
// array do not strip const from the array type. As a result, in the
// above signatures we get, for example, T = const char[4] instead
// of T = char[4], which is what we want. So to "fix" such compilers,
// we will have to provide the following specializations of the above
// functions.
//
template <typename T, std::size_t N>
static val_bind<T[N]>
_val (const T (&x) [N])
{
return val_bind<T[N]> (x);
}
template <database_type_id ID, typename T, std::size_t N>
static val_bind_typed<T[N], ID>
_val (const T (&x) [N])
{
return val_bind_typed<T[N], ID> (x);
}
template <typename T, std::size_t N>
static ref_bind<T[N]>
_ref (const T (&x) [N])
{
return ref_bind<T[N]> (x);
}
template <database_type_id ID, typename T, std::size_t N>
static ref_bind_typed<T[N], ID>
_ref (const T (&x) [N])
{
return ref_bind_typed<T[N], ID> (x);
}
public: public:
query& query_base&
operator+= (const query&); operator+= (const query_base&);
query& query_base&
operator+= (const std::string& q) operator+= (const std::string& q)
{ {
append (q); append (q);
return *this; return *this;
} }
template <typename T> template <typename T>
query& query_base&
operator+= (val_bind<T> v) operator+= (val_bind<T> v)
{ {
append<T, type_traits<T>::db_type_id> ( append<T, type_traits<T>::db_type_id> (
v, details::conversion<T>::to ()); v, details::conversion<T>::to ());
return *this; return *this;
} }
template <typename T, database_type_id ID>
query_base&
operator+= (val_bind_typed<T, ID> v)
{
// We are not using default type_traits so no default conversion
// either.
//
append<T, ID> (v, 0);
return *this;
}
template <typename T> template <typename T>
query& query_base&
operator+= (ref_bind<T> r) operator+= (ref_bind<T> r)
{ {
append<T, type_traits<T>::db_type_id> ( append<T, type_traits<T>::db_type_id> (
r, details::conversion<T>::to ()); r, details::conversion<T>::to ());
return *this; return *this;
} }
template <typename T, database_type_id ID>
query_base&
operator+= (ref_bind_typed<T, ID> r)
{
// We are not using default type_traits so no default conversion
// either.
//
append<T, ID> (r, 0);
return *this;
}
// Implementation details.
//
public: public:
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
void void
append (val_bind<T>, const char* conv); append (val_bind<T>, const char* conv);
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
void void
append (ref_bind<T>, const char* conv); append (ref_bind<T>, const char* conv);
void void
append (details::shared_ptr<query_param>, const char* conv);
void
append (bool v)
{
clause_.push_back (clause_part (v));
}
void
append (const std::string& native); append (const std::string& native);
void void
append (const char* table, const char* column); append (const char* native) // Clashes with append(bool).
{
append (std::string (native));
}
private:
void void
add (details::shared_ptr<query_param>, const char* conv); append (const char* table, const char* column);
private: private:
typedef std::vector<clause_part> clause_type; typedef std::vector<clause_part> clause_type;
clause_type clause_; clause_type clause_;
details::shared_ptr<query_params> parameters_; details::shared_ptr<query_params> parameters_;
}; };
inline query inline query_base
operator+ (const query& x, const query& y) operator+ (const query_base& x, const query_base& y)
{ {
query r (x); query_base r (x);
r += y; r += y;
return r; return r;
} }
template <typename T> template <typename T>
inline query inline query_base
operator+ (const query& q, val_bind<T> b) operator+ (const query_base& q, val_bind<T> b)
{ {
query r (q); query_base r (q);
r += b; r += b;
return r; return r;
} }
template <typename T> template <typename T>
inline query inline query_base
operator+ (const query& q, ref_bind<T> b) operator+ (val_bind<T> b, const query_base& q)
{ {
query r (q); query_base r;
r += b; r += b;
r += q;
return r; return r;
} }
template <typename T> template <typename T, database_type_id ID>
inline query inline query_base
operator+ (val_bind<T> b, const query& q) operator+ (const query_base& q, val_bind_typed<T, ID> b)
{
query_base r (q);
r += b;
return r;
}
template <typename T, database_type_id ID>
inline query_base
operator+ (val_bind_typed<T, ID> b, const query_base& q)
{ {
query r; query_base r;
r += b; r += b;
r += q; r += q;
return r; return r;
} }
template <typename T> template <typename T>
inline query inline query_base
operator+ (ref_bind<T> b, const query& q) operator+ (const query_base& q, ref_bind<T> b)
{
query_base r (q);
r += b;
return r;
}
template <typename T>
inline query_base
operator+ (ref_bind<T> b, const query_base& q)
{
query_base r;
r += b;
r += q;
return r;
}
template <typename T, database_type_id ID>
inline query_base
operator+ (const query_base& q, ref_bind_typed<T, ID> b)
{
query_base r (q);
r += b;
return r;
}
template <typename T, database_type_id ID>
inline query_base
operator+ (ref_bind_typed<T, ID> b, const query_base& q)
{ {
query r; query_base r;
r += b; r += b;
r += q; r += q;
return r; return r;
} }
inline query inline query_base
operator+ (const query& q, const std::string& s) operator+ (const query_base& q, const std::string& s)
{ {
query r (q); query_base r (q);
r += s; r += s;
return r; return r;
} }
inline query inline query_base
operator+ (const std::string& s, const query& q) operator+ (const std::string& s, const query_base& q)
{ {
query r (s); query_base r (s);
r += q; r += q;
return r; return r;
} }
template <typename T> template <typename T>
inline query inline query_base
operator+ (const std::string& s, val_bind<T> b) operator+ (const std::string& s, val_bind<T> b)
{ {
query r (s); query_base r (s);
r += b; r += b;
return r; return r;
} }
template <typename T> template <typename T>
inline query inline query_base
operator+ (const std::string& s, ref_bind<T> b) operator+ (val_bind<T> b, const std::string& s)
{ {
query r (s); query_base r;
r += b; r += b;
r += s;
return r; return r;
} }
template <typename T> template <typename T, database_type_id ID>
inline query inline query_base
operator+ (val_bind<T> b, const std::string& s) operator+ (const std::string& s, val_bind_typed<T, ID> b)
{ {
query r; query_base r (s);
r += b;
return r;
}
template <typename T, database_type_id ID>
inline query_base
operator+ (val_bind_typed<T, ID> b, const std::string& s)
{
query_base r;
r += b; r += b;
r += s; r += s;
return r; return r;
} }
template <typename T> template <typename T>
inline query inline query_base
operator+ (const std::string& s, ref_bind<T> b)
{
query_base r (s);
r += b;
return r;
}
template <typename T>
inline query_base
operator+ (ref_bind<T> b, const std::string& s) operator+ (ref_bind<T> b, const std::string& s)
{ {
query r; query_base r;
r += b; r += b;
r += s; r += s;
return r; return r;
} }
LIBODB_SQLITE_EXPORT query template <typename T, database_type_id ID>
operator&& (const query&, const query&); inline query_base
operator+ (const std::string& s, ref_bind_typed<T, ID> b)
LIBODB_SQLITE_EXPORT query {
operator|| (const query&, const query&); query_base r (s);
r += b;
LIBODB_SQLITE_EXPORT query return r;
operator! (const query&); }
// query_column
//
template <typename T, typename T2> template <typename T, database_type_id ID>
class copy_bind: public val_bind<T> inline query_base
operator+ (ref_bind_typed<T, ID> b, const std::string& s)
{ {
public: query_base r;
explicit r += b;
copy_bind (const T2& v): val_bind<T> (val), val (v) {} r += s;
return r;
}
const T val; LIBODB_SQLITE_EXPORT query_base
}; operator&& (const query_base&, const query_base&);
template <typename T> LIBODB_SQLITE_EXPORT query_base
const T& operator|| (const query_base&, const query_base&);
type_instance ();
template <typename T, database_type_id ID> LIBODB_SQLITE_EXPORT query_base
struct query_column operator! (const query_base&);
// query_column
//
struct LIBODB_SQLITE_EXPORT query_column_base
{ {
// Note that we keep shallow copies of the table, column, and convers ion // Note that we keep shallow copies of the table, column, and convers ion
// expression. The latter can be NULL. // expression. The latter can be NULL.
// //
query_column (const char* table, const char* column, const char* conv query_column_base (const char* table,
) const char* column,
const char* conv)
: table_ (table), column_ (column), conversion_ (conv) : table_ (table), column_ (column), conversion_ (conv)
{ {
} }
const char* const char*
table () const table () const
{ {
return table_; return table_;
} }
skipping to change at line 458 skipping to change at line 683
} }
// Can be NULL. // Can be NULL.
// //
const char* const char*
conversion () const conversion () const
{ {
return conversion_; return conversion_;
} }
protected:
const char* table_;
const char* column_;
const char* conversion_;
};
template <typename T, database_type_id ID>
struct query_column: query_column_base
{
typedef typename decay_traits<T>::type decayed_type;
// Note that we keep shallow copies of the table, column, and convers
ion
// expression. The latter can be NULL.
//
query_column (const char* table, const char* column, const char* conv
)
: query_column_base (table, column, conv) {}
// Implementation is in query-dynamic.ixx.
//
query_column (odb::query_column<T>&,
const char* table, const char* column, const char* conv
);
// is_null, is_not_null // is_null, is_not_null
// //
public: public:
query query_base
is_null () const is_null () const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IS NULL"; q += "IS NULL";
return q; return q;
} }
query query_base
is_not_null () const is_not_null () const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IS NOT NULL"; q += "IS NOT NULL";
return q; return q;
} }
// in // in
// //
public: public:
query query_base
in (const T&, const T&) const; in (decayed_type, decayed_type) const;
query query_base
in (const T&, const T&, const T&) const; in (decayed_type, decayed_type, decayed_type) const;
query query_base
in (const T&, const T&, const T&, const T&) const; in (decayed_type, decayed_type, decayed_type, decayed_type) const;
query query_base
in (const T&, const T&, const T&, const T&, const T&) const; in (decayed_type, decayed_type, decayed_type, decayed_type,
decayed_type) const;
template <typename I> template <typename I>
query query_base
in_range (I begin, I end) const; in_range (I begin, I end) const;
// = // =
// //
public: public:
query query_base
equal (const T& v) const equal (decayed_type v) const
{ {
return equal (val_bind<T> (v)); return equal (val_bind<T> (v));
} }
query query_base
equal (val_bind<T> v) const equal (val_bind<T> v) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "="; q += "=";
q.append<T, ID> (v, conversion_); q.append<T, ID> (v, conversion_);
return q; return q;
} }
template <typename T2> template <typename T2>
query query_base
equal (val_bind<T2> v) const equal (val_bind<T2> v) const
{ {
copy_bind<T, T2> c (v.val); return equal (val_bind<T> (decayed_type (v.val)));
return equal (c);
} }
query query_base
equal (ref_bind<T> r) const equal (ref_bind<T> r) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "="; q += "=";
q.append<T, ID> (r, conversion_); q.append<T, ID> (r, conversion_);
return q; return q;
} }
friend query friend query_base
operator== (const query_column& c, const T& v) operator== (const query_column& c, decayed_type v)
{ {
return c.equal (v); return c.equal (v);
} }
friend query friend query_base
operator== (const T& v, const query_column& c) operator== (decayed_type v, const query_column& c)
{ {
return c.equal (v); return c.equal (v);
} }
friend query friend query_base
operator== (const query_column& c, val_bind<T> v) operator== (const query_column& c, val_bind<T> v)
{ {
return c.equal (v); return c.equal (v);
} }
friend query friend query_base
operator== (val_bind<T> v, const query_column& c) operator== (val_bind<T> v, const query_column& c)
{ {
return c.equal (v); return c.equal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator== (const query_column& c, val_bind<T2> v) operator== (const query_column& c, val_bind<T2> v)
{ {
return c.equal (v); return c.equal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator== (val_bind<T2> v, const query_column& c) operator== (val_bind<T2> v, const query_column& c)
{ {
return c.equal (v); return c.equal (v);
} }
friend query friend query_base
operator== (const query_column& c, ref_bind<T> r) operator== (const query_column& c, ref_bind<T> r)
{ {
return c.equal (r); return c.equal (r);
} }
friend query friend query_base
operator== (ref_bind<T> r, const query_column& c) operator== (ref_bind<T> r, const query_column& c)
{ {
return c.equal (r); return c.equal (r);
} }
// != // !=
// //
public: public:
query query_base
unequal (const T& v) const unequal (decayed_type v) const
{ {
return unequal (val_bind<T> (v)); return unequal (val_bind<T> (v));
} }
query query_base
unequal (val_bind<T> v) const unequal (val_bind<T> v) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "!="; q += "!=";
q.append<T, ID> (v, conversion_); q.append<T, ID> (v, conversion_);
return q; return q;
} }
template <typename T2> template <typename T2>
query query_base
unequal (val_bind<T2> v) const unequal (val_bind<T2> v) const
{ {
copy_bind<T, T2> c (v.val); return unequal (val_bind<T> (decayed_type (v.val)));
return unequal (c);
} }
query query_base
unequal (ref_bind<T> r) const unequal (ref_bind<T> r) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "!="; q += "!=";
q.append<T, ID> (r, conversion_); q.append<T, ID> (r, conversion_);
return q; return q;
} }
friend query friend query_base
operator!= (const query_column& c, const T& v) operator!= (const query_column& c, decayed_type v)
{ {
return c.unequal (v); return c.unequal (v);
} }
friend query friend query_base
operator!= (const T& v, const query_column& c) operator!= (decayed_type v, const query_column& c)
{ {
return c.unequal (v); return c.unequal (v);
} }
friend query friend query_base
operator!= (const query_column& c, val_bind<T> v) operator!= (const query_column& c, val_bind<T> v)
{ {
return c.unequal (v); return c.unequal (v);
} }
friend query friend query_base
operator!= (val_bind<T> v, const query_column& c) operator!= (val_bind<T> v, const query_column& c)
{ {
return c.unequal (v); return c.unequal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator!= (const query_column& c, val_bind<T2> v) operator!= (const query_column& c, val_bind<T2> v)
{ {
return c.unequal (v); return c.unequal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator!= (val_bind<T2> v, const query_column& c) operator!= (val_bind<T2> v, const query_column& c)
{ {
return c.unequal (v); return c.unequal (v);
} }
friend query friend query_base
operator!= (const query_column& c, ref_bind<T> r) operator!= (const query_column& c, ref_bind<T> r)
{ {
return c.unequal (r); return c.unequal (r);
} }
friend query friend query_base
operator!= (ref_bind<T> r, const query_column& c) operator!= (ref_bind<T> r, const query_column& c)
{ {
return c.unequal (r); return c.unequal (r);
} }
// < // <
// //
public: public:
query query_base
less (const T& v) const less (decayed_type v) const
{ {
return less (val_bind<T> (v)); return less (val_bind<T> (v));
} }
query query_base
less (val_bind<T> v) const less (val_bind<T> v) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "<"; q += "<";
q.append<T, ID> (v, conversion_); q.append<T, ID> (v, conversion_);
return q; return q;
} }
template <typename T2> template <typename T2>
query query_base
less (val_bind<T2> v) const less (val_bind<T2> v) const
{ {
copy_bind<T, T2> c (v.val); return less (val_bind<T> (decayed_type (v.val)));
return less (c);
} }
query query_base
less (ref_bind<T> r) const less (ref_bind<T> r) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "<"; q += "<";
q.append<T, ID> (r, conversion_); q.append<T, ID> (r, conversion_);
return q; return q;
} }
friend query friend query_base
operator< (const query_column& c, const T& v) operator< (const query_column& c, decayed_type v)
{ {
return c.less (v); return c.less (v);
} }
friend query friend query_base
operator< (const T& v, const query_column& c) operator< (decayed_type v, const query_column& c)
{ {
return c.greater (v); return c.greater (v);
} }
friend query friend query_base
operator< (const query_column& c, val_bind<T> v) operator< (const query_column& c, val_bind<T> v)
{ {
return c.less (v); return c.less (v);
} }
friend query friend query_base
operator< (val_bind<T> v, const query_column& c) operator< (val_bind<T> v, const query_column& c)
{ {
return c.greater (v); return c.greater (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator< (const query_column& c, val_bind<T2> v) operator< (const query_column& c, val_bind<T2> v)
{ {
return c.less (v); return c.less (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator< (val_bind<T2> v, const query_column& c) operator< (val_bind<T2> v, const query_column& c)
{ {
return c.greater (v); return c.greater (v);
} }
friend query friend query_base
operator< (const query_column& c, ref_bind<T> r) operator< (const query_column& c, ref_bind<T> r)
{ {
return c.less (r); return c.less (r);
} }
friend query friend query_base
operator< (ref_bind<T> r, const query_column& c) operator< (ref_bind<T> r, const query_column& c)
{ {
return c.greater (r); return c.greater (r);
} }
// > // >
// //
public: public:
query query_base
greater (const T& v) const greater (decayed_type v) const
{ {
return greater (val_bind<T> (v)); return greater (val_bind<T> (v));
} }
query query_base
greater (val_bind<T> v) const greater (val_bind<T> v) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += ">"; q += ">";
q.append<T, ID> (v, conversion_); q.append<T, ID> (v, conversion_);
return q; return q;
} }
template <typename T2> template <typename T2>
query query_base
greater (val_bind<T2> v) const greater (val_bind<T2> v) const
{ {
copy_bind<T, T2> c (v.val); return greater (val_bind<T> (decayed_type (v.val)));
return greater (c);
} }
query query_base
greater (ref_bind<T> r) const greater (ref_bind<T> r) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += ">"; q += ">";
q.append<T, ID> (r, conversion_); q.append<T, ID> (r, conversion_);
return q; return q;
} }
friend query friend query_base
operator> (const query_column& c, const T& v) operator> (const query_column& c, decayed_type v)
{ {
return c.greater (v); return c.greater (v);
} }
friend query friend query_base
operator> (const T& v, const query_column& c) operator> (decayed_type v, const query_column& c)
{ {
return c.less (v); return c.less (v);
} }
friend query friend query_base
operator> (const query_column& c, val_bind<T> v) operator> (const query_column& c, val_bind<T> v)
{ {
return c.greater (v); return c.greater (v);
} }
friend query friend query_base
operator> (val_bind<T> v, const query_column& c) operator> (val_bind<T> v, const query_column& c)
{ {
return c.less (v); return c.less (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator> (const query_column& c, val_bind<T2> v) operator> (const query_column& c, val_bind<T2> v)
{ {
return c.greater (v); return c.greater (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator> (val_bind<T2> v, const query_column& c) operator> (val_bind<T2> v, const query_column& c)
{ {
return c.less (v); return c.less (v);
} }
friend query friend query_base
operator> (const query_column& c, ref_bind<T> r) operator> (const query_column& c, ref_bind<T> r)
{ {
return c.greater (r); return c.greater (r);
} }
friend query friend query_base
operator> (ref_bind<T> r, const query_column& c) operator> (ref_bind<T> r, const query_column& c)
{ {
return c.less (r); return c.less (r);
} }
// <= // <=
// //
public: public:
query query_base
less_equal (const T& v) const less_equal (decayed_type v) const
{ {
return less_equal (val_bind<T> (v)); return less_equal (val_bind<T> (v));
} }
query query_base
less_equal (val_bind<T> v) const less_equal (val_bind<T> v) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "<="; q += "<=";
q.append<T, ID> (v, conversion_); q.append<T, ID> (v, conversion_);
return q; return q;
} }
template <typename T2> template <typename T2>
query query_base
less_equal (val_bind<T2> v) const less_equal (val_bind<T2> v) const
{ {
copy_bind<T, T2> c (v.val); return less_equal (val_bind<T> (decayed_type (v.val)));
return less_equal (c);
} }
query query_base
less_equal (ref_bind<T> r) const less_equal (ref_bind<T> r) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "<="; q += "<=";
q.append<T, ID> (r, conversion_); q.append<T, ID> (r, conversion_);
return q; return q;
} }
friend query friend query_base
operator<= (const query_column& c, const T& v) operator<= (const query_column& c, decayed_type v)
{ {
return c.less_equal (v); return c.less_equal (v);
} }
friend query friend query_base
operator<= (const T& v, const query_column& c) operator<= (decayed_type v, const query_column& c)
{ {
return c.greater_equal (v); return c.greater_equal (v);
} }
friend query friend query_base
operator<= (const query_column& c, val_bind<T> v) operator<= (const query_column& c, val_bind<T> v)
{ {
return c.less_equal (v); return c.less_equal (v);
} }
friend query friend query_base
operator<= (val_bind<T> v, const query_column& c) operator<= (val_bind<T> v, const query_column& c)
{ {
return c.greater_equal (v); return c.greater_equal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator<= (const query_column& c, val_bind<T2> v) operator<= (const query_column& c, val_bind<T2> v)
{ {
return c.less_equal (v); return c.less_equal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator<= (val_bind<T2> v, const query_column& c) operator<= (val_bind<T2> v, const query_column& c)
{ {
return c.greater_equal (v); return c.greater_equal (v);
} }
friend query friend query_base
operator<= (const query_column& c, ref_bind<T> r) operator<= (const query_column& c, ref_bind<T> r)
{ {
return c.less_equal (r); return c.less_equal (r);
} }
friend query friend query_base
operator<= (ref_bind<T> r, const query_column& c) operator<= (ref_bind<T> r, const query_column& c)
{ {
return c.greater_equal (r); return c.greater_equal (r);
} }
// >= // >=
// //
public: public:
query query_base
greater_equal (const T& v) const greater_equal (decayed_type v) const
{ {
return greater_equal (val_bind<T> (v)); return greater_equal (val_bind<T> (v));
} }
query query_base
greater_equal (val_bind<T> v) const greater_equal (val_bind<T> v) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += ">="; q += ">=";
q.append<T, ID> (v, conversion_); q.append<T, ID> (v, conversion_);
return q; return q;
} }
template <typename T2> template <typename T2>
query query_base
greater_equal (val_bind<T2> v) const greater_equal (val_bind<T2> v) const
{ {
copy_bind<T, T2> c (v.val); return greater_equal (val_bind<T> (decayed_type (v.val)));
return greater_equal (c);
} }
query query_base
greater_equal (ref_bind<T> r) const greater_equal (ref_bind<T> r) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += ">="; q += ">=";
q.append<T, ID> (r, conversion_); q.append<T, ID> (r, conversion_);
return q; return q;
} }
friend query friend query_base
operator>= (const query_column& c, const T& v) operator>= (const query_column& c, decayed_type v)
{ {
return c.greater_equal (v); return c.greater_equal (v);
} }
friend query friend query_base
operator>= (const T& v, const query_column& c) operator>= (decayed_type v, const query_column& c)
{ {
return c.less_equal (v); return c.less_equal (v);
} }
friend query friend query_base
operator>= (const query_column& c, val_bind<T> v) operator>= (const query_column& c, val_bind<T> v)
{ {
return c.greater_equal (v); return c.greater_equal (v);
} }
friend query friend query_base
operator>= (val_bind<T> v, const query_column& c) operator>= (val_bind<T> v, const query_column& c)
{ {
return c.less_equal (v); return c.less_equal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator>= (const query_column& c, val_bind<T2> v) operator>= (const query_column& c, val_bind<T2> v)
{ {
return c.greater_equal (v); return c.greater_equal (v);
} }
template <typename T2> template <typename T2>
friend query friend query_base
operator>= (val_bind<T2> v, const query_column& c) operator>= (val_bind<T2> v, const query_column& c)
{ {
return c.less_equal (v); return c.less_equal (v);
} }
friend query friend query_base
operator>= (const query_column& c, ref_bind<T> r) operator>= (const query_column& c, ref_bind<T> r)
{ {
return c.greater_equal (r); return c.greater_equal (r);
} }
friend query friend query_base
operator>= (ref_bind<T> r, const query_column& c) operator>= (ref_bind<T> r, const query_column& c)
{ {
return c.less_equal (r); return c.less_equal (r);
} }
// Column comparison. // Column comparison.
// //
public: public:
template <typename T2, database_type_id ID2> template <typename T2, database_type_id ID2>
query query_base
operator== (const query_column<T2, ID2>& c) const operator== (const query_column<T2, ID2>& c) const
{ {
// We can compare columns only if we can compare their C++ types. // We can compare columns only if we can compare their C++ types.
// //
(void) (sizeof (type_instance<T> () == type_instance<T2> ())); (void) (sizeof (decay_traits<T>::instance () ==
decay_traits<T2>::instance ()));
query q (table_, column_); query_base q (table_, column_);
q += "="; q += "=";
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
template <typename T2, database_type_id ID2> template <typename T2, database_type_id ID2>
query query_base
operator!= (const query_column<T2, ID2>& c) const operator!= (const query_column<T2, ID2>& c) const
{ {
// We can compare columns only if we can compare their C++ types. // We can compare columns only if we can compare their C++ types.
// //
(void) (sizeof (type_instance<T> () != type_instance<T2> ())); (void) (sizeof (decay_traits<T>::instance () !=
decay_traits<T2>::instance ()));
query q (table_, column_); query_base q (table_, column_);
q += "!="; q += "!=";
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
template <typename T2, database_type_id ID2> template <typename T2, database_type_id ID2>
query query_base
operator< (const query_column<T2, ID2>& c) const operator< (const query_column<T2, ID2>& c) const
{ {
// We can compare columns only if we can compare their C++ types. // We can compare columns only if we can compare their C++ types.
// //
(void) (sizeof (type_instance<T> () < type_instance<T2> ())); (void) (sizeof (decay_traits<T>::instance () <
decay_traits<T2>::instance ()));
query q (table_, column_); query_base q (table_, column_);
q += "<"; q += "<";
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
template <typename T2, database_type_id ID2> template <typename T2, database_type_id ID2>
query query_base
operator> (const query_column<T2, ID2>& c) const operator> (const query_column<T2, ID2>& c) const
{ {
// We can compare columns only if we can compare their C++ types. // We can compare columns only if we can compare their C++ types.
// //
(void) (sizeof (type_instance<T> () > type_instance<T2> ())); (void) (sizeof (decay_traits<T>::instance () >
decay_traits<T2>::instance ()));
query q (table_, column_); query_base q (table_, column_);
q += ">"; q += ">";
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
template <typename T2, database_type_id ID2> template <typename T2, database_type_id ID2>
query query_base
operator<= (const query_column<T2, ID2>& c) const operator<= (const query_column<T2, ID2>& c) const
{ {
// We can compare columns only if we can compare their C++ types. // We can compare columns only if we can compare their C++ types.
// //
(void) (sizeof (type_instance<T> () <= type_instance<T2> ())); (void) (sizeof (decay_traits<T>::instance () <=
decay_traits<T2>::instance ()));
query q (table_, column_); query_base q (table_, column_);
q += "<="; q += "<=";
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
template <typename T2, database_type_id ID2> template <typename T2, database_type_id ID2>
query query_base
operator>= (const query_column<T2, ID2>& c) const operator>= (const query_column<T2, ID2>& c) const
{ {
// We can compare columns only if we can compare their C++ types. // We can compare columns only if we can compare their C++ types.
// //
(void) (sizeof (type_instance<T> () >= type_instance<T2> ())); (void) (sizeof (decay_traits<T>::instance () >=
decay_traits<T2>::instance ()));
query q (table_, column_); query_base q (table_, column_);
q += ">="; q += ">=";
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
private:
const char* table_;
const char* column_;
const char* conversion_;
}; };
// Provide operator+() for using columns to construct native // Provide operator+() for using columns to construct native
// query fragments (e.g., ORDER BY). // query fragments (e.g., ORDER BY).
// //
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
inline query inline query_base
operator+ (const query_column<T, ID>& c, const std::string& s) operator+ (const query_column<T, ID>& c, const std::string& s)
{ {
query q (c.table (), c.column ()); query_base q (c.table (), c.column ());
q += s; q += s;
return q; return q;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
inline query inline query_base
operator+ (const std::string& s, const query_column<T, ID>& c) operator+ (const std::string& s, const query_column<T, ID>& c)
{ {
query q (s); query_base q (s);
q.append (c.table (), c.column ()); q.append (c.table (), c.column ());
return q; return q;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
inline query inline query_base
operator+ (const query_column<T, ID>& c, const query& q) operator+ (const query_column<T, ID>& c, const query_base& q)
{ {
query r (c.table (), c.column ()); query_base r (c.table (), c.column ());
r += q; r += q;
return r; return r;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
inline query inline query_base
operator+ (const query& q, const query_column<T, ID>& c) operator+ (const query_base& q, const query_column<T, ID>& c)
{ {
query r (q); query_base r (q);
r.append (c.table (), c.column ()); r.append (c.table (), c.column ());
return r; return r;
} }
// //
// //
template <typename T, database_type_id> template <typename T, database_type_id>
struct query_param_impl; struct query_param_impl;
// INTEGER // INTEGER
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_integer>: query_param struct query_param_impl<T, id_integer>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool virtual bool
init () init ()
{ {
init (*static_cast<const T*> (value_)); init (*static_cast<const T*> (value_));
return false; return false;
} }
virtual void virtual void
bind (sqlite::bind* b) bind (sqlite::bind* b)
{ {
b->type = sqlite::bind::integer; b->type = sqlite::bind::integer;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (typename decay_traits<T>::type v)
{ {
bool is_null (false); // Can't be NULL. bool is_null (false); // Can't be NULL.
value_traits<T, id_integer>::set_image (image_, is_null, v); value_traits<T, id_integer>::set_image (image_, is_null, v);
} }
private: private:
long long image_; long long image_;
}; };
// REAL // REAL
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_real>: query_param struct query_param_impl<T, id_real>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool virtual bool
init () init ()
{ {
init (*static_cast<const T*> (value_)); init (*static_cast<const T*> (value_));
return false; return false;
} }
virtual void virtual void
bind (sqlite::bind* b) bind (sqlite::bind* b)
{ {
b->type = sqlite::bind::real; b->type = sqlite::bind::real;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (typename decay_traits<T>::type v)
{ {
bool is_null (false); // Can't be NULL. bool is_null (false); // Can't be NULL.
value_traits<T, id_real>::set_image (image_, is_null, v); value_traits<T, id_real>::set_image (image_, is_null, v);
} }
private: private:
double image_; double image_;
}; };
// TEXT // TEXT
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_text>: query_param struct query_param_impl<T, id_text>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool virtual bool
init () init ()
{ {
return init (*static_cast<const T*> (value_)); return init (*static_cast<const T*> (value_));
} }
virtual void virtual void
bind (sqlite::bind* b) bind (sqlite::bind* b)
{ {
b->type = image_traits<T, id_text>::bind_value; b->type = image_traits<T, id_text>::bind_value;
b->buffer = buffer_.data (); b->buffer = buffer_.data ();
b->size = &size_; b->size = &size_;
} }
private: private:
bool bool
init (const T& v) init (typename decay_traits<T>::type v)
{ {
bool is_null (false); // Can't be NULL. bool is_null (false); // Can't be NULL.
std::size_t cap (buffer_.capacity ()); std::size_t cap (buffer_.capacity ());
value_traits<T, id_text>::set_image (buffer_, size_, is_null, v); value_traits<T, id_text>::set_image (buffer_, size_, is_null, v);
return cap != buffer_.capacity (); return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; details::buffer buffer_;
std::size_t size_; std::size_t size_;
}; };
// BLOB // BLOB
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_blob>: query_param struct query_param_impl<T, id_blob>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (r.ptr ()) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool virtual bool
init () init ()
{ {
return init (*static_cast<const T*> (value_)); return init (*static_cast<const T*> (value_));
} }
virtual void virtual void
bind (sqlite::bind* b) bind (sqlite::bind* b)
{ {
b->type = sqlite::bind::blob; b->type = sqlite::bind::blob;
b->buffer = buffer_.data (); b->buffer = buffer_.data ();
b->size = &size_; b->size = &size_;
} }
private: private:
bool bool
init (const T& v) init (typename decay_traits<T>::type v)
{ {
bool is_null (false); // Can't be NULL. bool is_null (false); // Can't be NULL.
std::size_t cap (buffer_.capacity ()); std::size_t cap (buffer_.capacity ());
value_traits<T, id_blob>::set_image (buffer_, size_, is_null, v); value_traits<T, id_blob>::set_image (buffer_, size_, is_null, v);
return cap != buffer_.capacity (); return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; details::buffer buffer_;
std::size_t size_; std::size_t size_;
}; };
} }
} }
// odb::query specialization for SQLite. // odb::sqlite::query and odb::query specialization for SQLite.
// //
namespace odb namespace odb
{ {
namespace sqlite
{
template <typename T>
class query: public query_base,
public query_selector<T, id_sqlite>::columns_type
{
public:
// We don't define any typedefs here since they may clash with
// column names defined by our base type.
//
query ()
{
}
explicit
query (bool v)
: query_base (v)
{
}
explicit
query (const char* q)
: query_base (q)
{
}
explicit
query (const std::string& q)
: query_base (q)
{
}
template <typename T2>
explicit
query (val_bind<T2> v)
: query_base (v)
{
}
template <typename T2>
explicit
query (ref_bind<T2> r)
: query_base (r)
{
}
query (const query_base& q)
: query_base (q)
{
}
template <database_type_id ID>
query (const query_column<bool, ID>& qc)
: query_base (qc)
{
}
query (const odb::query_base& q)
: query_base (q)
{
}
};
namespace core
{
using sqlite::query;
}
}
// Derive odb::query from odb::sqlite::query so that it can be
// implicitly converted in sqlite::database::query() calls.
//
template <typename T> template <typename T>
class query<T, sqlite::query>: public sqlite::query, class query<T, sqlite::query_base>: public sqlite::query<T>
public query_selector<T>::columns_type
{ {
public: public:
// We don't define any typedefs here since they may clash with // We don't define any typedefs here since they may clash with
// column names defined by our base type. // column names defined by our base type.
// //
query () query ()
{ {
} }
explicit explicit
query (bool v) query (bool v)
: sqlite::query (v) : sqlite::query<T> (v)
{ {
} }
explicit explicit
query (const char* q) query (const char* q)
: sqlite::query (q) : sqlite::query<T> (q)
{ {
} }
explicit explicit
query (const std::string& q) query (const std::string& q)
: sqlite::query (q) : sqlite::query<T> (q)
{ {
} }
template <typename T2> template <typename T2>
explicit explicit
query (sqlite::val_bind<T2> v) query (sqlite::val_bind<T2> v)
: sqlite::query (sqlite::query (v)) : sqlite::query<T> (v)
{ {
} }
template <typename T2> template <typename T2>
explicit explicit
query (sqlite::ref_bind<T2> r) query (sqlite::ref_bind<T2> r)
: sqlite::query (sqlite::query (r)) : sqlite::query<T> (r)
{ {
} }
query (const sqlite::query& q) query (const sqlite::query_base& q)
: sqlite::query (q) : sqlite::query<T> (q)
{ {
} }
template <sqlite::database_type_id ID> template <sqlite::database_type_id ID>
query (const sqlite::query_column<bool, ID>& qc) query (const sqlite::query_column<bool, ID>& qc)
: sqlite::query (qc) : sqlite::query<T> (qc)
{ {
} }
}; };
} }
#include <odb/sqlite/query.ixx> #include <odb/sqlite/query.ixx>
#include <odb/sqlite/query.txx> #include <odb/sqlite/query.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
 End of changes. 224 change blocks. 
284 lines changed or deleted 601 lines changed or added


 query.ixx   query.ixx 
// file : odb/sqlite/query.ixx // file : odb/sqlite/query.ixx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
inline binding& query:: inline void query_base::
init_parameters () const
{
return parameters_->init ();
}
inline binding& query_base::
parameters_binding () const parameters_binding () const
{ {
return parameters_->binding (); return parameters_->binding ();
} }
inline details::shared_ptr<query_params> query:: inline const details::shared_ptr<query_params>& query_base::
parameters () const parameters () const
{ {
return parameters_; return parameters_;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
inline void query:: inline void query_base::
append (val_bind<T> v, const char* conv) append (val_bind<T> v, const char* conv)
{ {
add ( append (
details::shared_ptr<query_param> ( details::shared_ptr<query_param> (
new (details::shared) query_param_impl<T, ID> (v)), new (details::shared) query_param_impl<T, ID> (v)),
conv); conv);
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
inline void query:: inline void query_base::
append (ref_bind<T> r, const char* conv) append (ref_bind<T> r, const char* conv)
{ {
add ( append (
details::shared_ptr<query_param> ( details::shared_ptr<query_param> (
new (details::shared) query_param_impl<T, ID> (r)), new (details::shared) query_param_impl<T, ID> (r)),
conv); conv);
} }
} }
} }
 End of changes. 7 change blocks. 
7 lines changed or deleted 13 lines changed or added


 query.txx   query.txx 
// file : odb/sqlite/query.txx // file : odb/sqlite/query.txx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
// query // query_base
// //
template <database_type_id ID> template <database_type_id ID>
query:: query_base::
query (const query_column<bool, ID>& c) query_base (const query_column<bool, ID>& c)
: parameters_ (new (details::shared) query_params) : parameters_ (new (details::shared) query_params)
{ {
// Cannot use IS TRUE here since database type can be a non- // Cannot use IS TRUE here since database type can be a non-
// integral type. // integral type.
// //
append (c.table (), c.column ()); append (c.table (), c.column ());
append ("="); append ("=");
append<bool, ID> (val_bind<bool> (true), c.conversion ()); append<bool, ID> (val_bind<bool> (true), c.conversion ());
} }
// query_column // query_column
// //
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
query query_column<T, ID>:: query_base query_column<T, ID>::
in (const T& v1, const T& v2) const in (decayed_type v1, decayed_type v2) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IN ("; q += "IN (";
q.append<T, ID> (val_bind<T> (v1), conversion_); q.append<T, ID> (val_bind<T> (v1), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v2), conversion_); q.append<T, ID> (val_bind<T> (v2), conversion_);
q += ")"; q += ")";
return q; return q;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
query query_column<T, ID>:: query_base query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3) const in (decayed_type v1, decayed_type v2, decayed_type v3) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IN ("; q += "IN (";
q.append<T, ID> (val_bind<T> (v1), conversion_); q.append<T, ID> (val_bind<T> (v1), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v2), conversion_); q.append<T, ID> (val_bind<T> (v2), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v3), conversion_); q.append<T, ID> (val_bind<T> (v3), conversion_);
q += ")"; q += ")";
return q; return q;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
query query_column<T, ID>:: query_base query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3, const T& v4) const in (decayed_type v1, decayed_type v2, decayed_type v3,
decayed_type v4) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IN ("; q += "IN (";
q.append<T, ID> (val_bind<T> (v1), conversion_); q.append<T, ID> (val_bind<T> (v1), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v2), conversion_); q.append<T, ID> (val_bind<T> (v2), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v3), conversion_); q.append<T, ID> (val_bind<T> (v3), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v4), conversion_); q.append<T, ID> (val_bind<T> (v4), conversion_);
q += ")"; q += ")";
return q; return q;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
query query_column<T, ID>:: query_base query_column<T, ID>::
in (const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) co in (decayed_type v1, decayed_type v2, decayed_type v3, decayed_type v4,
nst decayed_type v5) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IN ("; q += "IN (";
q.append<T, ID> (val_bind<T> (v1), conversion_); q.append<T, ID> (val_bind<T> (v1), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v2), conversion_); q.append<T, ID> (val_bind<T> (v2), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v3), conversion_); q.append<T, ID> (val_bind<T> (v3), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v4), conversion_); q.append<T, ID> (val_bind<T> (v4), conversion_);
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (v5), conversion_); q.append<T, ID> (val_bind<T> (v5), conversion_);
q += ")"; q += ")";
return q; return q;
} }
template <typename T, database_type_id ID> template <typename T, database_type_id ID>
template <typename I> template <typename I>
query query_column<T, ID>:: query_base query_column<T, ID>::
in_range (I begin, I end) const in_range (I begin, I end) const
{ {
query q (table_, column_); query_base q (table_, column_);
q += "IN ("; q += "IN (";
for (I i (begin); i != end; ++i) for (I i (begin); i != end; ++i)
{ {
if (i != begin) if (i != begin)
q += ","; q += ",";
q.append<T, ID> (val_bind<T> (*i), conversion_); q.append<T, ID> (val_bind<T> (*i), conversion_);
} }
q += ")"; q += ")";
return q; return q;
} }
} }
} }
 End of changes. 14 change blocks. 
19 lines changed or deleted 21 lines changed or added


 simple-object-result.hxx   simple-object-result.hxx 
// file : odb/sqlite/simple-object-result.hxx // file : odb/sqlite/simple-object-result.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX #ifndef ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX
#define ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX #define ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/simple-object-result.hxx> #include <odb/simple-object-result.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> // query #include <odb/sqlite/forward.hxx> // query_base, query_params
#include <odb/sqlite/result.hxx>
#include <odb/sqlite/statement.hxx> #include <odb/sqlite/statement.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
class object_result_impl: public odb::object_result_impl<T>, class object_result_impl: public odb::object_result_impl<T>
public result_impl_base
{ {
public: public:
typedef odb::object_result_impl<T> base_type; typedef odb::object_result_impl<T> base_type;
typedef typename base_type::object_traits object_traits;
typedef typename base_type::object_type object_type;
typedef typename base_type::id_type id_type; typedef typename base_type::id_type id_type;
typedef typename base_type::object_type object_type;
typedef typename base_type::pointer_type pointer_type; typedef typename base_type::pointer_type pointer_type;
typedef object_traits_impl<object_type, id_sqlite> object_traits;
typedef typename base_type::pointer_traits pointer_traits; typedef typename base_type::pointer_traits pointer_traits;
typedef typename object_traits::statements_type statements_type; typedef typename object_traits::statements_type statements_type;
virtual virtual
~object_result_impl (); ~object_result_impl ();
object_result_impl (const query&, object_result_impl (const query_base&,
details::shared_ptr<select_statement>, const details::shared_ptr<select_statement>&,
statements_type&); statements_type&);
virtual void virtual void
load (object_type&, bool fetch); load (object_type&, bool fetch);
virtual id_type virtual id_type
load_id (); load_id ();
virtual void virtual void
next (); next ();
virtual void virtual void
cache (); cache ();
virtual std::size_t virtual std::size_t
size (); size ();
virtual void
invalidate ();
using base_type::current; using base_type::current;
private: private:
void void
load_image (); load_image ();
private: private:
// We need to hold on to the query parameters because SQLite uses
// the parameter buffers to find each next row.
//
details::shared_ptr<query_params> params_;
details::shared_ptr<select_statement> statement_;
statements_type& statements_; statements_type& statements_;
}; };
} }
} }
#include <odb/sqlite/simple-object-result.txx> #include <odb/sqlite/simple-object-result.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX #endif // ODB_SQLITE_SIMPLE_OBJECT_RESULT_HXX
 End of changes. 9 change blocks. 
10 lines changed or deleted 16 lines changed or added


 simple-object-result.txx   simple-object-result.txx 
// file : odb/sqlite/simple-object-result.txx // file : odb/sqlite/simple-object-result.txx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cassert> #include <cassert>
#include <odb/callback.hxx> #include <odb/callback.hxx>
#include <odb/exceptions.hxx> // result_not_cached #include <odb/exceptions.hxx> // result_not_cached
#include <odb/sqlite/simple-object-statements.hxx> #include <odb/sqlite/simple-object-statements.hxx>
namespace odb namespace odb
skipping to change at line 25 skipping to change at line 25
{ {
template <typename T> template <typename T>
object_result_impl<T>:: object_result_impl<T>::
~object_result_impl () ~object_result_impl ()
{ {
if (!this->end_) if (!this->end_)
statement_->free_result (); statement_->free_result ();
} }
template <typename T> template <typename T>
void object_result_impl<T>::
invalidate ()
{
if (!this->end_)
{
statement_->free_result ();
this->end_ = true;
}
params_.reset ();
statement_.reset ();
}
template <typename T>
object_result_impl<T>:: object_result_impl<T>::
object_result_impl (const query& q, object_result_impl (const query_base& q,
details::shared_ptr<select_statement> statement, const details::shared_ptr<select_statement>& s,
statements_type& statements) statements_type& sts)
: base_type (statements.connection ().database ()), : base_type (sts.connection ()),
result_impl_base (q, statement), params_ (q.parameters ()),
statements_ (statements) statement_ (s),
statements_ (sts)
{ {
} }
template <typename T> template <typename T>
void object_result_impl<T>:: void object_result_impl<T>::
load (object_type& obj, bool fetch) load (object_type& obj, bool fetch)
{ {
if (fetch) if (fetch)
load_image (); load_image ();
// This is a top-level call so the statements cannot be locked. // This is a top-level call so the statements cannot be locked.
// //
assert (!statements_.locked ()); assert (!statements_.locked ());
typename statements_type::auto_lock l (statements_); typename statements_type::auto_lock l (statements_);
odb::database& db (this->database ()); object_traits::callback (this->db_, obj, callback_event::pre_load);
object_traits::callback (db, obj, callback_event::pre_load);
typename object_traits::image_type& i (statements_.image ()); typename object_traits::image_type& i (statements_.image ());
object_traits::init (obj, i, &db); object_traits::init (obj, i, &this->db_);
// Initialize the id image and binding and load the rest of the objec t // Initialize the id image and binding and load the rest of the objec t
// (containers, etc). // (containers, etc).
// //
typename object_traits::id_image_type& idi (statements_.id_image ()); typename object_traits::id_image_type& idi (statements_.id_image ());
object_traits::init (idi, object_traits::id (i)); object_traits::init (idi, object_traits::id (i));
binding& idb (statements_.id_image_binding ()); binding& idb (statements_.id_image_binding ());
if (idi.version != statements_.id_image_version () || idb.version == 0) if (idi.version != statements_.id_image_version () || idb.version == 0)
{ {
object_traits::bind (idb.bind, idi); object_traits::bind (idb.bind, idi);
statements_.id_image_version (idi.version); statements_.id_image_version (idi.version);
idb.version++; idb.version++;
} }
object_traits::load_ (statements_, obj); object_traits::load_ (statements_, obj);
statements_.load_delayed (); statements_.load_delayed ();
l.unlock (); l.unlock ();
object_traits::callback (db, obj, callback_event::post_load); object_traits::callback (this->db_, obj, callback_event::post_load);
} }
template <typename T> template <typename T>
typename object_result_impl<T>::id_type typename object_result_impl<T>::id_type
object_result_impl<T>:: object_result_impl<T>::
load_id () load_id ()
{ {
load_image (); load_image ();
return object_traits::id (statements_.image ()); return object_traits::id (statements_.image ());
} }
 End of changes. 6 change blocks. 
11 lines changed or deleted 25 lines changed or added


 simple-object-statements.hxx   simple-object-statements.hxx 
// file : odb/sqlite/simple-object-statements.hxx // file : odb/sqlite/simple-object-statements.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX #ifndef ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX
#define ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX #define ODB_SQLITE_SIMPLE_OBJECT_STATEMENTS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <vector> #include <vector>
#include <cassert> #include <cassert>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
skipping to change at line 48 skipping to change at line 48
// and when needed. We will also need to store a pointer to the // and when needed. We will also need to store a pointer to the
// deleter function which will be initialized during allocation // deleter function which will be initialized during allocation
// (at that point we know that the cache class is defined). // (at that point we know that the cache class is defined).
// //
template <typename T> template <typename T>
struct container_statement_cache_ptr struct container_statement_cache_ptr
{ {
typedef sqlite::connection connection_type; typedef sqlite::connection connection_type;
container_statement_cache_ptr (): p_ (0) {} container_statement_cache_ptr (): p_ (0) {}
~container_statement_cache_ptr () {if (p_ != 0) (this->*deleter_) (0) ~container_statement_cache_ptr ()
;} {
if (p_ != 0)
(this->*deleter_) (0, 0);
}
T& T&
get (connection_type& c) get (connection_type& c, binding& id)
{ {
if (p_ == 0) if (p_ == 0)
allocate (&c); allocate (&c, &id);
return *p_; return *p_;
} }
private: private:
void void
allocate (connection_type*); allocate (connection_type*, binding*);
private: private:
T* p_; T* p_;
void (container_statement_cache_ptr::*deleter_) (connection_type*); void (container_statement_cache_ptr::*deleter_) (
connection_type*, binding*);
}; };
template <typename T> template <typename T>
void container_statement_cache_ptr<T>:: void container_statement_cache_ptr<T>::
allocate (connection_type* c) allocate (connection_type* c, binding* id)
{ {
// To reduce object code size, this function acts as both allocator // To reduce object code size, this function acts as both allocator
// and deleter. // and deleter.
// //
if (p_ == 0) if (p_ == 0)
{ {
p_ = new T (*c); p_ = new T (*c, *id);
deleter_ = &container_statement_cache_ptr<T>::allocate; deleter_ = &container_statement_cache_ptr<T>::allocate;
} }
else else
delete p_; delete p_;
} }
// //
// Implementation for objects with object id. // Implementation for objects with object id.
// //
skipping to change at line 150 skipping to change at line 155
bool locked_; bool locked_;
}; };
template <typename T, bool optimistic> template <typename T, bool optimistic>
struct optimistic_data; struct optimistic_data;
template <typename T> template <typename T>
struct optimistic_data<T, true> struct optimistic_data<T, true>
{ {
typedef T object_type; typedef T object_type;
typedef odb::object_traits<object_type> object_traits; typedef object_traits_impl<object_type, id_sqlite> object_traits;
optimistic_data (bind*); optimistic_data (bind*);
// The id + optimistic column binding. // The id + optimistic column binding.
// //
std::size_t id_image_version_; std::size_t id_image_version_;
binding id_image_binding_; binding id_image_binding_;
details::shared_ptr<delete_statement> erase_; details::shared_ptr<delete_statement> erase_;
}; };
skipping to change at line 173 skipping to change at line 178
struct optimistic_data<T, false> struct optimistic_data<T, false>
{ {
optimistic_data (bind*) {} optimistic_data (bind*) {}
}; };
template <typename T> template <typename T>
class object_statements: public object_statements_base class object_statements: public object_statements_base
{ {
public: public:
typedef T object_type; typedef T object_type;
typedef odb::object_traits<object_type> object_traits; typedef object_traits_impl<object_type, id_sqlite> object_traits;
typedef typename object_traits::id_type id_type; typedef typename object_traits::id_type id_type;
typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::pointer_type pointer_type;
typedef typename object_traits::image_type image_type; typedef typename object_traits::image_type image_type;
typedef typename object_traits::id_image_type id_image_type; typedef typename object_traits::id_image_type id_image_type;
typedef typedef
typename object_traits::pointer_cache_traits typename object_traits::pointer_cache_traits
pointer_cache_traits; pointer_cache_traits;
typedef typedef
skipping to change at line 347 skipping to change at line 352
insert_statement_type& insert_statement_type&
persist_statement () persist_statement ()
{ {
if (persist_ == 0) if (persist_ == 0)
{ {
persist_.reset ( persist_.reset (
new (details::shared) insert_statement_type ( new (details::shared) insert_statement_type (
conn_, conn_,
object_traits::persist_statement, object_traits::persist_statement,
insert_image_binding_)); insert_image_binding_));
persist_->cached (true);
} }
return *persist_; return *persist_;
} }
select_statement_type& select_statement_type&
find_statement () find_statement ()
{ {
if (find_ == 0) if (find_ == 0)
{ {
find_.reset ( find_.reset (
new (details::shared) select_statement_type ( new (details::shared) select_statement_type (
conn_, conn_,
object_traits::find_statement, object_traits::find_statement,
id_image_binding_, id_image_binding_,
select_image_binding_)); select_image_binding_));
find_->cached (true);
} }
return *find_; return *find_;
} }
update_statement_type& update_statement_type&
update_statement () update_statement ()
{ {
if (update_ == 0) if (update_ == 0)
{ {
update_.reset ( update_.reset (
new (details::shared) update_statement_type ( new (details::shared) update_statement_type (
conn_, conn_,
object_traits::update_statement, object_traits::update_statement,
update_image_binding_)); update_image_binding_));
update_->cached (true);
} }
return *update_; return *update_;
} }
delete_statement_type& delete_statement_type&
erase_statement () erase_statement ()
{ {
if (erase_ == 0) if (erase_ == 0)
{ {
erase_.reset ( erase_.reset (
new (details::shared) delete_statement_type ( new (details::shared) delete_statement_type (
conn_, conn_,
object_traits::erase_statement, object_traits::erase_statement,
id_image_binding_)); id_image_binding_));
erase_->cached (true);
} }
return *erase_; return *erase_;
} }
delete_statement_type& delete_statement_type&
optimistic_erase_statement () optimistic_erase_statement ()
{ {
if (od_.erase_ == 0) if (od_.erase_ == 0)
{ {
od_.erase_.reset ( od_.erase_.reset (
new (details::shared) delete_statement_type ( new (details::shared) delete_statement_type (
conn_, conn_,
object_traits::optimistic_erase_statement, object_traits::optimistic_erase_statement,
od_.id_image_binding_)); od_.id_image_binding_));
od_.erase_->cached (true);
} }
return *od_.erase_; return *od_.erase_;
} }
// Container statement cache. // Container statement cache.
// //
container_statement_cache_type& container_statement_cache_type&
container_statment_cache () container_statment_cache ()
{ {
return container_statement_cache_.get (conn_); return container_statement_cache_.get (conn_, id_image_binding_);
} }
public: public:
// select = total // select = total
// insert = total - inverse - managed_optimistic // insert = total - inverse - managed_optimistic
// update = total - inverse - managed_optimistic - id - readonly // update = total - inverse - managed_optimistic - id - readonly
// //
static const std::size_t select_column_count = static const std::size_t select_column_count =
object_traits::column_count; object_traits::column_count;
 End of changes. 16 change blocks. 
22 lines changed or deleted 16 lines changed or added


 simple-object-statements.ixx   simple-object-statements.ixx 
// file : odb/sqlite/simple-object-statements.ixx // file : odb/sqlite/simple-object-statements.ixx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
// //
// auto_unlock // auto_unlock
// //
inline object_statements_base::auto_unlock:: inline object_statements_base::auto_unlock::
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 simple-object-statements.txx   simple-object-statements.txx 
// file : odb/sqlite/simple-object-statements.txx // file : odb/sqlite/simple-object-statements.txx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::memset #include <cstring> // std::memset
#include <odb/callback.hxx> #include <odb/callback.hxx>
#include <odb/exceptions.hxx> #include <odb/exceptions.hxx>
#include <odb/sqlite/connection.hxx> #include <odb/sqlite/connection.hxx>
namespace odb namespace odb
skipping to change at line 85 skipping to change at line 85
load_delayed_ () load_delayed_ ()
{ {
database& db (connection ().database ()); database& db (connection ().database ());
delayed_loads dls; delayed_loads dls;
swap_guard sg (*this, dls); swap_guard sg (*this, dls);
while (!dls.empty ()) while (!dls.empty ())
{ {
delayed_load l (dls.back ()); delayed_load l (dls.back ());
typename pointer_cache_traits::insert_guard g (l.pos); typename pointer_cache_traits::insert_guard ig (l.pos);
dls.pop_back (); dls.pop_back ();
if (l.loader == 0) if (l.loader == 0)
{ {
if (!object_traits::find_ (*this, &l.id)) if (!object_traits::find_ (*this, &l.id))
throw object_not_persistent (); throw object_not_persistent ();
object_traits::callback (db, *l.obj, callback_event::pre_load); object_traits::callback (db, *l.obj, callback_event::pre_load);
// Our calls to init/load below can result in additional delayed // Our calls to init/load below can result in additional delayed
skipping to change at line 121 skipping to change at line 121
// returning). // returning).
// //
{ {
auto_unlock u (*this); auto_unlock u (*this);
object_traits::callback (db, *l.obj, callback_event::post_load) ; object_traits::callback (db, *l.obj, callback_event::post_load) ;
} }
} }
else else
l.loader (db, l.id, *l.obj); l.loader (db, l.id, *l.obj);
g.release (); pointer_cache_traits::load (ig.position ());
ig.release ();
} }
} }
template <typename T> template <typename T>
void object_statements<T>:: void object_statements<T>::
clear_delayed_ () clear_delayed_ ()
{ {
// Remove the objects from the session cache. This is not the most // Remove the objects from the session cache.
// efficient way to do this (cache_traits::erase() will check for
// a session on every iteration), but the delay vector won't be
// empty only if something goes wrong (i.e., we are throwing an
// exception).
// //
for (typename delayed_loads::iterator i (delayed_.begin ()), for (typename delayed_loads::iterator i (delayed_.begin ()),
e (delayed_.end ()); i != e; ++i) e (delayed_.end ()); i != e; ++i)
{ {
pointer_cache_traits::erase (i->pos); pointer_cache_traits::erase (i->pos);
} }
delayed_.clear (); delayed_.clear ();
} }
} }
 End of changes. 4 change blocks. 
8 lines changed or deleted 5 lines changed or added


 sqlite-types.hxx   sqlite-types.hxx 
// file : odb/sqlite/sqlite-types.hxx // file : odb/sqlite/sqlite-types.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_SQLITE_TYPES_HXX #ifndef ODB_SQLITE_SQLITE_TYPES_HXX
#define ODB_SQLITE_SQLITE_TYPES_HXX #define ODB_SQLITE_SQLITE_TYPES_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
namespace odb namespace odb
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 statement-cache.hxx   statement-cache.hxx 
// file : odb/sqlite/statement-cache.hxx // file : odb/sqlite/statement-cache.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_STATEMENT_CACHE_HXX #ifndef ODB_SQLITE_STATEMENT_CACHE_HXX
#define ODB_SQLITE_STATEMENT_CACHE_HXX #define ODB_SQLITE_STATEMENT_CACHE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <map> #include <map>
#include <typeinfo> #include <typeinfo>
skipping to change at line 72 skipping to change at line 72
return *commit_; return *commit_;
} }
generic_statement& generic_statement&
rollback_statement () const rollback_statement () const
{ {
return *rollback_; return *rollback_;
} }
template <typename T> template <typename T>
typename object_traits<T>::statements_type& typename object_traits_impl<T, id_sqlite>::statements_type&
find_object (); find_object ();
template <typename T> template <typename T>
view_statements<T>& view_statements<T>&
find_view (); find_view ();
private: private:
void void
begin_immediate_statement_ () const; begin_immediate_statement_ () const;
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 statement-cache.txx   statement-cache.txx 
// file : odb/sqlite/statement-cache.txx // file : odb/sqlite/statement-cache.txx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
typename object_traits<T>::statements_type& statement_cache:: typename object_traits_impl<T, id_sqlite>::statements_type&
statement_cache::
find_object () find_object ()
{ {
typedef typename object_traits<T>::statements_type statements_type; typedef
typename object_traits_impl<T, id_sqlite>::statements_type
statements_type;
map::iterator i (map_.find (&typeid (T))); map::iterator i (map_.find (&typeid (T)));
if (i != map_.end ()) if (i != map_.end ())
return static_cast<statements_type&> (*i->second); return static_cast<statements_type&> (*i->second);
details::shared_ptr<statements_type> p ( details::shared_ptr<statements_type> p (
new (details::shared) statements_type (conn_)); new (details::shared) statements_type (conn_));
map_.insert (map::value_type (&typeid (T), p)); map_.insert (map::value_type (&typeid (T), p));
 End of changes. 3 change blocks. 
3 lines changed or deleted 6 lines changed or added


 statement.hxx   statement.hxx 
// file : odb/sqlite/statement.hxx // file : odb/sqlite/statement.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_STATEMENT_HXX #ifndef ODB_SQLITE_STATEMENT_HXX
#define ODB_SQLITE_STATEMENT_HXX #define ODB_SQLITE_STATEMENT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <sqlite3.h> #include <sqlite3.h>
#include <string> #include <string>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <cstring> // std::strlen, std::memcpy #include <cstring> // std::strlen, std::memcpy
#include <cassert> #include <cassert>
#include <odb/forward.hxx>
#include <odb/statement.hxx> #include <odb/statement.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx>
#include <odb/sqlite/binding.hxx> #include <odb/sqlite/binding.hxx>
#include <odb/sqlite/connection.hxx> #include <odb/sqlite/connection.hxx>
#include <odb/sqlite/auto-handle.hxx> #include <odb/sqlite/auto-handle.hxx>
#include <odb/sqlite/details/export.hxx> #include <odb/sqlite/details/export.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
class connection; class connection;
class LIBODB_SQLITE_EXPORT statement: public odb::statement class LIBODB_SQLITE_EXPORT statement: public odb::statement
{ {
public: public:
typedef sqlite::connection connection_type;
virtual virtual
~statement () = 0; ~statement () = 0;
sqlite3_stmt* sqlite3_stmt*
handle () const handle () const
{ {
return stmt_; return stmt_;
} }
virtual const char* virtual const char*
text () const; text () const;
// Cached state (public part). virtual connection_type&
// connection ()
public:
bool
cached () const
{
return cached_;
}
void
cached (bool cached)
{ {
assert (cached); return conn_;
if (!cached_)
{
if (!active_)
list_remove ();
cached_ = true;
}
} }
protected: protected:
statement (connection& conn, const std::string& text) statement (connection_type& conn, const std::string& text)
: conn_ (conn) : conn_ (conn)
{ {
init (text.c_str (), text.size ()); init (text.c_str (), text.size ());
} }
statement (connection& conn, const char* text) statement (connection_type& conn, const char* text)
: conn_ (conn) : conn_ (conn)
{ {
init (text, std::strlen (text)); init (text, std::strlen (text));
} }
statement (connection& conn, const char* text, std::size_t text_size) statement (connection_type& conn,
const char* text,
std::size_t text_size)
: conn_ (conn) : conn_ (conn)
{ {
init (text, text_size); init (text, text_size);
} }
protected: protected:
void void
bind_param (const bind*, std::size_t count); bind_param (const bind*, std::size_t count);
// Extract row columns into the bound buffers. If the truncated // Extract row columns into the bound buffers. If the truncated
skipping to change at line 128 skipping to change at line 115
list_add (); list_add ();
active_ = true; active_ = true;
} }
} }
void void
reset () reset ()
{ {
if (active_) if (active_)
{ {
if (stmt_ != 0) sqlite3_reset (stmt_);
sqlite3_reset (stmt_); list_remove ();
if (cached_)
list_remove ();
active_ = false; active_ = false;
} }
} }
// Cached state (protected part).
//
protected:
void
finilize ();
protected: protected:
friend class connection; friend class sqlite::connection;
connection& conn_; connection_type& conn_;
auto_handle<sqlite3_stmt> stmt_; auto_handle<sqlite3_stmt> stmt_;
bool active_; bool active_;
bool cached_;
private: private:
void void
init (const char* text, std::size_t text_size); init (const char* text, std::size_t text_size);
// Doubly-linked list of active/uncached statements. // Doubly-linked list of active statements.
// //
private: private:
void list_add () void
list_add ()
{ {
if (next_ == this) next_ = conn_.statements_;
{ conn_.statements_ = this;
next_ = conn_.statements_;
conn_.statements_ = this;
if (next_ != 0) if (next_ != 0)
next_->prev_ = this; next_->prev_ = this;
}
} }
void list_remove () void
list_remove ()
{ {
if (next_ != this) (prev_ == 0 ? conn_.statements_ : prev_->next_) = next_;
{
if (prev_ == 0)
conn_.statements_ = next_;
else
{
prev_->next_ = next_;
}
if (next_ != 0) if (next_ != 0)
next_->prev_ = prev_; next_->prev_ = prev_;
prev_ = 0; prev_ = 0;
next_ = this; next_ = this;
}
} }
// prev_ == 0 means we are the first element. // prev_ == 0 means we are the first element.
// next_ == 0 means we are the last element. // next_ == 0 means we are the last element.
// next_ == this means we are not on the list (prev_ should be 0). // next_ == this means we are not on the list (prev_ should be 0).
// //
statement* prev_; statement* prev_;
statement* next_; statement* next_;
}; };
class LIBODB_SQLITE_EXPORT generic_statement: public statement class LIBODB_SQLITE_EXPORT generic_statement: public statement
{ {
public: public:
generic_statement (connection&, const std::string& text); generic_statement (connection_type&, const std::string& text);
generic_statement (connection&, const char* text); generic_statement (connection_type&, const char* text);
generic_statement (connection&, const char* text, std::size_t text_si generic_statement (connection_type&,
ze); const char* text,
std::size_t text_size);
unsigned long long unsigned long long
execute (); execute ();
private: private:
generic_statement (const generic_statement&); generic_statement (const generic_statement&);
generic_statement& operator= (const generic_statement&); generic_statement& operator= (const generic_statement&);
private: private:
bool result_set_; bool result_set_;
}; };
class LIBODB_SQLITE_EXPORT select_statement: public statement class LIBODB_SQLITE_EXPORT select_statement: public statement
{ {
public: public:
select_statement (connection& conn, select_statement (connection_type& conn,
const std::string& text, const std::string& text,
binding& param, binding& param,
binding& result); binding& result);
select_statement (connection& conn, select_statement (connection_type& conn,
const char* text, const char* text,
binding& param, binding& param,
binding& result); binding& result);
select_statement (connection& conn, select_statement (connection_type& conn,
const std::string& text, const std::string& text,
binding& result); binding& result);
select_statement (connection& conn, const char* text, binding& result select_statement (connection_type& conn,
); const char* text,
binding& result);
// Common select interface expected by the generated code. // Common select interface expected by the generated code.
// //
public: public:
enum result enum result
{ {
success, success,
no_data, no_data,
truncated truncated
}; };
skipping to change at line 313 skipping to change at line 284
auto_result (const auto_result&); auto_result (const auto_result&);
auto_result& operator= (const auto_result&); auto_result& operator= (const auto_result&);
private: private:
select_statement& s_; select_statement& s_;
}; };
class LIBODB_SQLITE_EXPORT insert_statement: public statement class LIBODB_SQLITE_EXPORT insert_statement: public statement
{ {
public: public:
insert_statement (connection& conn, insert_statement (connection_type& conn,
const std::string& text, const std::string& text,
binding& param); binding& param);
insert_statement (connection& conn, const char* text, binding& param) insert_statement (connection_type& conn,
; const char* text,
binding& param);
// Return true if successful and false if the row is a duplicate. // Return true if successful and false if the row is a duplicate.
// All other errors are reported by throwing exceptions. // All other errors are reported by throwing exceptions.
// //
bool bool
execute (); execute ();
unsigned long long unsigned long long
id (); id ();
skipping to change at line 339 skipping to change at line 312
insert_statement (const insert_statement&); insert_statement (const insert_statement&);
insert_statement& operator= (const insert_statement&); insert_statement& operator= (const insert_statement&);
private: private:
binding& param_; binding& param_;
}; };
class LIBODB_SQLITE_EXPORT update_statement: public statement class LIBODB_SQLITE_EXPORT update_statement: public statement
{ {
public: public:
update_statement (connection& conn, update_statement (connection_type& conn,
const std::string& text, const std::string& text,
binding& param); binding& param);
update_statement (connection& conn, const char* text, binding& param) update_statement (connection_type& conn,
; const char* text,
binding& param);
unsigned long long unsigned long long
execute (); execute ();
private: private:
update_statement (const update_statement&); update_statement (const update_statement&);
update_statement& operator= (const update_statement&); update_statement& operator= (const update_statement&);
private: private:
binding& param_; binding& param_;
}; };
class LIBODB_SQLITE_EXPORT delete_statement: public statement class LIBODB_SQLITE_EXPORT delete_statement: public statement
{ {
public: public:
delete_statement (connection& conn, delete_statement (connection_type& conn,
const std::string& text, const std::string& text,
binding& param); binding& param);
delete_statement (connection& conn, const char* text, binding& param) delete_statement (connection_type& conn,
; const char* text,
binding& param);
unsigned long long unsigned long long
execute (); execute ();
private: private:
delete_statement (const delete_statement&); delete_statement (const delete_statement&);
delete_statement& operator= (const delete_statement&); delete_statement& operator= (const delete_statement&);
private: private:
binding& param_; binding& param_;
 End of changes. 33 change blocks. 
81 lines changed or deleted 53 lines changed or added


 statements-base.hxx   statements-base.hxx 
// file : odb/sqlite/statements-base.hxx // file : odb/sqlite/statements-base.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_STATEMENTS_BASE_HXX #ifndef ODB_SQLITE_STATEMENTS_BASE_HXX
#define ODB_SQLITE_STATEMENTS_BASE_HXX #define ODB_SQLITE_STATEMENTS_BASE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 tracer.hxx   tracer.hxx 
// file : odb/sqlite/tracer.hxx // file : odb/sqlite/tracer.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_TRACER_HXX #ifndef ODB_SQLITE_TRACER_HXX
#define ODB_SQLITE_TRACER_HXX #define ODB_SQLITE_TRACER_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/tracer.hxx> #include <odb/tracer.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 traits.hxx   traits.hxx 
// file : odb/sqlite/traits.hxx // file : odb/sqlite/traits.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_TRAITS_HXX #ifndef ODB_SQLITE_TRAITS_HXX
#define ODB_SQLITE_TRAITS_HXX #define ODB_SQLITE_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
#include <string> #include <string>
skipping to change at line 287 skipping to change at line 287
v.erase (); v.erase ();
} }
static void static void
set_image (details::buffer&, set_image (details::buffer&,
std::size_t& n, std::size_t& n,
bool& is_null, bool& is_null,
const std::string&); const std::string&);
}; };
// const char* specialization // char*/const char* specialization
// //
// Specialization for const char* which only supports initialization // Specialization for const char* which only supports initialization
// of an image from the value but not the other way around. This way // of an image from the value but not the other way around. This way
// we can pass such values to the queries. // we can pass such values to the queries.
// //
struct LIBODB_SQLITE_EXPORT c_string_value_traits struct LIBODB_SQLITE_EXPORT c_string_value_traits
{ {
typedef const char* value_type; typedef const char* value_type;
typedef const char* query_type;
typedef details::buffer image_type; typedef details::buffer image_type;
static void static void
set_image (details::buffer&, set_image (details::buffer&,
std::size_t& n, std::size_t& n,
bool& is_null, bool& is_null,
const char*); const char*);
}; };
template <> template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<char*, id_text>:
c_string_value_traits {};
template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<const char*, id_text>: struct LIBODB_SQLITE_EXPORT default_value_traits<const char*, id_text>:
c_string_value_traits c_string_value_traits {};
// char[N] specialization.
//
struct LIBODB_SQLITE_EXPORT c_array_value_traits_base
{ {
static void
set_value (char* const& v,
const details::buffer& b,
std::size_t n,
bool is_null,
std::size_t N);
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
const char* v,
std::size_t N);
}; };
template <std::size_t N> template <std::size_t N>
struct default_value_traits<char[N], id_text>: c_string_value_traits struct default_value_traits<char[N], id_text>
{ {
typedef char* value_type;
typedef char query_type[N];
typedef details::buffer image_type;
static void
set_value (char* const& v,
const details::buffer& b,
std::size_t n,
bool is_null)
{
c_array_value_traits_base::set_value (v, b, n, is_null, N);
}
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
const char* v)
{
c_array_value_traits_base::set_image (b, n, is_null, v, N);
}
}; };
// std::array<char, N> (string) specialization.
//
#ifdef ODB_CXX11
template <std::size_t N> template <std::size_t N>
struct default_value_traits<const char[N], id_text>: c_string_value_tra its struct default_value_traits<std::array<char, N>, id_text>
{ {
typedef std::array<char, N> value_type;
typedef std::array<char, N> query_type;
typedef details::buffer image_type;
static void
set_value (value_type& v,
const details::buffer& b,
std::size_t n,
bool is_null)
{
c_array_value_traits_base::set_value (v.data (), b, n, is_null, N);
}
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
const value_type& v)
{
c_array_value_traits_base::set_image (b, n, is_null, v.data (), N);
}
};
#endif
// char specialization.
//
template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<char, id_text>
{
typedef char value_type;
typedef char query_type;
typedef details::buffer image_type;
static void
set_value (char& v,
const details::buffer& b,
std::size_t n,
bool is_null)
{
c_array_value_traits_base::set_value (&v, b, n, is_null, 1);
}
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
char v)
{
c_array_value_traits_base::set_image (b, n, is_null, &v, 1);
}
}; };
#ifdef _WIN32 #ifdef _WIN32
// std::wstring specialization. Using UTF-16 binding. // std::wstring specialization. Using UTF-16 binding.
// //
template <> struct wstring_image_traits
struct image_traits<std::wstring, id_text>
{ {
typedef details::buffer image_type; typedef details::buffer image_type;
static const bind::buffer_type bind_value = bind::text16; static const bind::buffer_type bind_value = bind::text16;
}; };
template <> template <>
struct image_traits<std::wstring, id_text>: wstring_image_traits {};
template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<std::wstring, id_text> struct LIBODB_SQLITE_EXPORT default_value_traits<std::wstring, id_text>
{ {
typedef std::wstring value_type; typedef std::wstring value_type;
typedef std::wstring query_type; typedef std::wstring query_type;
typedef details::buffer image_type; typedef details::buffer image_type;
static void static void
set_value (std::wstring& v, set_value (std::wstring& v,
const details::buffer& b, const details::buffer& b,
std::size_t n, std::size_t n,
skipping to change at line 358 skipping to change at line 454
v.erase (); v.erase ();
} }
static void static void
set_image (details::buffer&, set_image (details::buffer&,
std::size_t& n, std::size_t& n,
bool& is_null, bool& is_null,
const std::wstring&); const std::wstring&);
}; };
// const wchar_t* specialization // wchar_t*/const wchar_t* specialization.
// //
struct c_wstring_image_traits
{
typedef details::buffer image_type;
static const bind::buffer_type bind_value = bind::text16;
};
struct LIBODB_SQLITE_EXPORT c_wstring_value_traits struct LIBODB_SQLITE_EXPORT c_wstring_value_traits
{ {
typedef const wchar_t* value_type; typedef const wchar_t* value_type;
typedef const wchar_t* query_type;
typedef details::buffer image_type; typedef details::buffer image_type;
static void static void
set_image (details::buffer&, set_image (details::buffer&,
std::size_t& n, std::size_t& n,
bool& is_null, bool& is_null,
const wchar_t*); const wchar_t*);
}; };
template <> template <>
struct image_traits<const wchar_t*, id_text>: c_wstring_image_traits {} struct image_traits<wchar_t*, id_text>: wstring_image_traits {};
;
template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<wchar_t*, id_text>:
c_wstring_value_traits {};
template <>
struct image_traits<const wchar_t*, id_text>: wstring_image_traits {};
template <> template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<const wchar_t*, id_tex t>: struct LIBODB_SQLITE_EXPORT default_value_traits<const wchar_t*, id_tex t>:
c_wstring_value_traits c_wstring_value_traits {};
// wchar_t[N] specialization.
//
struct LIBODB_SQLITE_EXPORT c_warray_value_traits_base
{ {
static void
set_value (wchar_t* const& v,
const details::buffer& b,
std::size_t n,
bool is_null,
std::size_t N);
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
const wchar_t* v,
std::size_t N);
}; };
template <std::size_t N> template <std::size_t N>
struct image_traits<wchar_t[N], id_text>: c_wstring_image_traits {}; struct image_traits<wchar_t[N], id_text>: wstring_image_traits {};
template <std::size_t N> template <std::size_t N>
struct default_value_traits<wchar_t[N], id_text>: struct default_value_traits<wchar_t[N], id_text>
c_wstring_value_traits
{ {
typedef wchar_t* value_type;
typedef wchar_t query_type[N];
typedef details::buffer image_type;
static void
set_value (wchar_t* const& v,
const details::buffer& b,
std::size_t n,
bool is_null)
{
c_warray_value_traits_base::set_value (v, b, n, is_null, N);
}
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
const wchar_t* v)
{
c_warray_value_traits_base::set_image (b, n, is_null, v, N);
}
}; };
// std::array<wchar_t, N> (string) specialization.
//
#ifdef ODB_CXX11
template <std::size_t N> template <std::size_t N>
struct image_traits<const wchar_t[N], id_text>: c_wstring_image_traits struct image_traits<std::array<wchar_t, N>, id_text>:
{}; wstring_image_traits {};
template <std::size_t N> template <std::size_t N>
struct default_value_traits<const wchar_t[N], id_text>: struct default_value_traits<std::array<wchar_t, N>, id_text>
c_wstring_value_traits {
typedef std::array<wchar_t, N> value_type;
typedef std::array<wchar_t, N> query_type;
typedef details::buffer image_type;
static void
set_value (value_type& v,
const details::buffer& b,
std::size_t n,
bool is_null)
{
c_warray_value_traits_base::set_value (v.data (), b, n, is_null, N)
;
}
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
const value_type& v)
{
c_warray_value_traits_base::set_image (b, n, is_null, v.data (), N)
;
}
};
#endif
// wchar_t specialization.
//
template <>
struct image_traits<wchar_t, id_text>: wstring_image_traits {};
template <>
struct LIBODB_SQLITE_EXPORT default_value_traits<wchar_t, id_text>
{ {
typedef wchar_t value_type;
typedef wchar_t query_type;
typedef details::buffer image_type;
static void
set_value (wchar_t& v,
const details::buffer& b,
std::size_t n,
bool is_null)
{
c_warray_value_traits_base::set_value (&v, b, n, is_null, 1);
}
static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
wchar_t v)
{
c_warray_value_traits_base::set_image (b, n, is_null, &v, 1);
}
}; };
#endif // _WIN32 #endif // _WIN32
// std::vector<char> (buffer) specialization. // std::vector<char> (buffer) specialization.
// //
template <> template <>
struct LIBODB_SQLITE_EXPORT default_value_traits< struct LIBODB_SQLITE_EXPORT default_value_traits<
std::vector<char>, id_blob> std::vector<char>, id_blob>
{ {
public: public:
skipping to change at line 478 skipping to change at line 667
const value_type&); const value_type&);
}; };
// char[N] (buffer) specialization. // char[N] (buffer) specialization.
// //
template <std::size_t N> template <std::size_t N>
struct default_value_traits<char[N], id_blob> struct default_value_traits<char[N], id_blob>
{ {
public: public:
typedef char* value_type; typedef char* value_type;
typedef const char* query_type; typedef char query_type[N];
typedef details::buffer image_type; typedef details::buffer image_type;
static void static void
set_value (char* const& v, set_value (char* const& v,
const details::buffer& b, const details::buffer& b,
std::size_t n, std::size_t n,
bool is_null) bool is_null)
{ {
if (!is_null) if (!is_null)
std::memcpy (v, b.data (), (n < N ? n : N)); std::memcpy (v, b.data (), (n < N ? n : N));
skipping to change at line 516 skipping to change at line 705
} }
}; };
// unsigned char[N] (buffer) specialization. // unsigned char[N] (buffer) specialization.
// //
template <std::size_t N> template <std::size_t N>
struct default_value_traits<unsigned char[N], id_blob> struct default_value_traits<unsigned char[N], id_blob>
{ {
public: public:
typedef unsigned char* value_type; typedef unsigned char* value_type;
typedef const unsigned char* query_type; typedef unsigned char query_type[N];
typedef details::buffer image_type; typedef details::buffer image_type;
static void static void
set_value (unsigned char* const& v, set_value (unsigned char* const& v,
const details::buffer& b, const details::buffer& b,
std::size_t n, std::size_t n,
bool is_null) bool is_null)
{ {
if (!is_null) if (!is_null)
std::memcpy (v, b.data (), (n < N ? n : N)); std::memcpy (v, b.data (), (n < N ? n : N));
skipping to change at line 633 skipping to change at line 822
#endif #endif
// //
// type_traits // type_traits
// //
template <typename T> template <typename T>
struct default_type_traits; struct default_type_traits;
template <typename T> template <typename T>
class type_traits: public default_type_traits<T> class type_traits: public default_type_traits<T> {};
{
};
// Integral types. // Integral types.
// //
template <> template <>
struct default_type_traits<bool> struct default_type_traits<bool>
{ {
static const database_type_id db_type_id = id_integer; static const database_type_id db_type_id = id_integer;
}; };
template <> template <>
skipping to change at line 728 skipping to change at line 915
// String types. // String types.
// //
template <> template <>
struct default_type_traits<std::string> struct default_type_traits<std::string>
{ {
static const database_type_id db_type_id = id_text; static const database_type_id db_type_id = id_text;
}; };
template <> template <>
struct default_type_traits<char*>
{
static const database_type_id db_type_id = id_text;
};
template <>
struct default_type_traits<const char*> struct default_type_traits<const char*>
{ {
static const database_type_id db_type_id = id_text; static const database_type_id db_type_id = id_text;
}; };
template <std::size_t N> template <std::size_t N>
struct default_type_traits<char[N]> struct default_type_traits<char[N]>
{ {
static const database_type_id db_type_id = id_text; static const database_type_id db_type_id = id_text;
}; };
#ifdef ODB_CXX11
template <std::size_t N> template <std::size_t N>
struct default_type_traits<const char[N]> struct default_type_traits<std::array<char, N> >
{
static const database_type_id db_type_id = id_text;
};
#endif
template <>
struct default_type_traits<char>
{ {
static const database_type_id db_type_id = id_text; static const database_type_id db_type_id = id_text;
}; };
// Binary types. // Binary types.
// //
template <> template <std::size_t N>
struct default_type_traits<std::vector<char> > struct default_type_traits<unsigned char[N]>
{ {
static const database_type_id db_type_id = id_blob; static const database_type_id db_type_id = id_blob;
}; };
template <> template <>
struct default_type_traits<std::vector<unsigned char> > struct default_type_traits<std::vector<char> >
{ {
static const database_type_id db_type_id = id_blob; static const database_type_id db_type_id = id_blob;
}; };
#ifdef ODB_CXX11 template <>
template <std::size_t N> struct default_type_traits<std::vector<unsigned char> >
struct default_type_traits<std::array<char, N> >
{ {
static const database_type_id db_type_id = id_blob; static const database_type_id db_type_id = id_blob;
}; };
#ifdef ODB_CXX11
template <std::size_t N> template <std::size_t N>
struct default_type_traits<std::array<unsigned char, N> > struct default_type_traits<std::array<unsigned char, N> >
{ {
static const database_type_id db_type_id = id_blob; static const database_type_id db_type_id = id_blob;
}; };
#endif #endif
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
 End of changes. 36 change blocks. 
38 lines changed or deleted 239 lines changed or added


 transaction-impl.hxx   transaction-impl.hxx 
// file : odb/sqlite/transaction-impl.hxx // file : odb/sqlite/transaction-impl.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX #ifndef ODB_SQLITE_TRANSACTION_IMPL_HXX
#define ODB_SQLITE_TRANSACTION_IMPL_HXX #define ODB_SQLITE_TRANSACTION_IMPL_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/transaction.hxx> #include <odb/transaction.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 transaction-impl.ixx   transaction-impl.ixx 
// file : odb/sqlite/transaction-impl.ixx // file : odb/sqlite/transaction-impl.ixx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
inline transaction_impl::connection_type& transaction_impl:: inline transaction_impl::connection_type& transaction_impl::
connection () connection ()
{ {
return *connection_; return *connection_;
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 transaction.hxx   transaction.hxx 
// file : odb/sqlite/transaction.hxx // file : odb/sqlite/transaction.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_TRANSACTION_HXX #ifndef ODB_SQLITE_TRANSACTION_HXX
#define ODB_SQLITE_TRANSACTION_HXX #define ODB_SQLITE_TRANSACTION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/transaction.hxx> #include <odb/transaction.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 transaction.ixx   transaction.ixx 
// file : odb/sqlite/transaction.ixx // file : odb/sqlite/transaction.ixx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <odb/sqlite/database.hxx> #include <odb/sqlite/database.hxx>
#include <odb/sqlite/transaction-impl.hxx> #include <odb/sqlite/transaction-impl.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
inline transaction:: inline transaction::
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 version.hxx   version.hxx 
// file : odb/sqlite/version.hxx // file : odb/sqlite/version.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_VERSION_HXX #ifndef ODB_SQLITE_VERSION_HXX
#define ODB_SQLITE_VERSION_HXX #define ODB_SQLITE_VERSION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/version.hxx> #include <odb/version.hxx>
// Version format is AABBCCDD where // Version format is AABBCCDD where
skipping to change at line 31 skipping to change at line 31
// Version AABBCCDD // Version AABBCCDD
// 2.0.0 02000000 // 2.0.0 02000000
// 2.1.0 02010000 // 2.1.0 02010000
// 2.1.1 02010100 // 2.1.1 02010100
// 2.2.0.a1 02019901 // 2.2.0.a1 02019901
// 3.0.0.b2 02999952 // 3.0.0.b2 02999952
// //
// Check that we have compatible ODB version. // Check that we have compatible ODB version.
// //
#if ODB_VERSION != 20100 #if ODB_VERSION != 20200
# error incompatible odb interface version detected # error incompatible odb interface version detected
#endif #endif
// libodb-sqlite version: odb interface version plus the bugfix // libodb-sqlite version: odb interface version plus the bugfix
// version. // version.
// //
#define LIBODB_SQLITE_VERSION 2010100 #define LIBODB_SQLITE_VERSION 2020000
#define LIBODB_SQLITE_VERSION_STR "2.1.1" #define LIBODB_SQLITE_VERSION_STR "2.2.0"
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_VERSION_HXX #endif // ODB_SQLITE_VERSION_HXX
 End of changes. 3 change blocks. 
4 lines changed or deleted 4 lines changed or added


 view-result.hxx   view-result.hxx 
// file : odb/sqlite/view-result.hxx // file : odb/sqlite/view-result.hxx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_VIEW_RESULT_HXX #ifndef ODB_SQLITE_VIEW_RESULT_HXX
#define ODB_SQLITE_VIEW_RESULT_HXX #define ODB_SQLITE_VIEW_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/view-result.hxx> #include <odb/view-result.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/sqlite/version.hxx> #include <odb/sqlite/version.hxx>
#include <odb/sqlite/forward.hxx> // query, view_statements #include <odb/sqlite/forward.hxx> // query_base, query_params
#include <odb/sqlite/statement.hxx> #include <odb/sqlite/statement.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
class view_result_impl: public odb::view_result_impl<T>, class view_result_impl: public odb::view_result_impl<T>
public result_impl_base
{ {
public: public:
typedef odb::view_result_impl<T> base_type; typedef odb::view_result_impl<T> base_type;
typedef typename base_type::view_type view_type; typedef typename base_type::view_type view_type;
typedef typename base_type::view_traits view_traits;
typedef typename base_type::pointer_type pointer_type; typedef typename base_type::pointer_type pointer_type;
typedef view_traits_impl<view_type, id_sqlite> view_traits;
typedef typename base_type::pointer_traits pointer_traits; typedef typename base_type::pointer_traits pointer_traits;
typedef view_statements<view_type> statements_type; typedef view_statements<view_type> statements_type;
virtual virtual
~view_result_impl (); ~view_result_impl ();
view_result_impl (const query&, view_result_impl (const query_base&,
details::shared_ptr<select_statement>, const details::shared_ptr<select_statement>&,
statements_type&); statements_type&);
virtual void virtual void
load (view_type&); load (view_type&);
virtual void virtual void
next (); next ();
virtual void virtual void
cache (); cache ();
virtual std::size_t virtual std::size_t
size (); size ();
virtual void
invalidate ();
using base_type::current; using base_type::current;
private: private:
// We need to hold on to the query parameters because SQLite uses
// the parameter buffers to find each next row.
//
details::shared_ptr<query_params> params_;
details::shared_ptr<select_statement> statement_;
statements_type& statements_; statements_type& statements_;
}; };
} }
} }
#include <odb/sqlite/view-result.txx> #include <odb/sqlite/view-result.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SQLITE_VIEW_RESULT_HXX #endif // ODB_SQLITE_VIEW_RESULT_HXX
 End of changes. 8 change blocks. 
8 lines changed or deleted 15 lines changed or added


 view-result.txx   view-result.txx 
// file : odb/sqlite/view-result.txx // file : odb/sqlite/view-result.txx
// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <odb/callback.hxx> #include <odb/callback.hxx>
#include <odb/exceptions.hxx> #include <odb/exceptions.hxx>
#include <odb/sqlite/view-statements.hxx> #include <odb/sqlite/view-statements.hxx>
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
view_result_impl<T>:: view_result_impl<T>::
~view_result_impl () ~view_result_impl ()
{ {
if (!this->end_) if (!this->end_)
statement_->free_result (); statement_->free_result ();
} }
template <typename T> template <typename T>
void view_result_impl<T>::
invalidate ()
{
if (!this->end_)
{
statement_->free_result ();
this->end_ = true;
}
params_.reset ();
statement_.reset ();
}
template <typename T>
view_result_impl<T>:: view_result_impl<T>::
view_result_impl (const query& q, view_result_impl (const query_base& q,
details::shared_ptr<select_statement> statement, const details::shared_ptr<select_statement>& s,
statements_type& statements) statements_type& sts)
: base_type (statements.connection ().database ()), : base_type (sts.connection ()),
result_impl_base (q, statement), params_ (q.parameters ()),
statements_ (statements) statement_ (s),
statements_ (sts)
{ {
} }
template <typename T> template <typename T>
void view_result_impl<T>:: void view_result_impl<T>::
load (view_type& view) load (view_type& view)
{ {
// The image can grow between calls to load() as a result of other // The image can grow between calls to load() as a result of other
// statements execution. // statements execution.
// //
skipping to change at line 67 skipping to change at line 82
if (im.version != statements_.image_version ()) if (im.version != statements_.image_version ())
{ {
binding& b (statements_.image_binding ()); binding& b (statements_.image_binding ());
view_traits::bind (b.bind, im); view_traits::bind (b.bind, im);
statements_.image_version (im.version); statements_.image_version (im.version);
b.version++; b.version++;
statement_->reload (); statement_->reload ();
} }
} }
odb::database& db (this->database ()); view_traits::callback (this->db_, view, callback_event::pre_load);
view_traits::init (view, im, &this->db_);
view_traits::callback (db, view, callback_event::pre_load); view_traits::callback (this->db_, view, callback_event::post_load);
view_traits::init (view, im, &db);
view_traits::callback (db, view, callback_event::post_load);
} }
template <typename T> template <typename T>
void view_result_impl<T>:: void view_result_impl<T>::
next () next ()
{ {
this->current (pointer_type ()); this->current (pointer_type ());
if (!statement_->next ()) if (!statement_->next ())
{ {
 End of changes. 4 change blocks. 
12 lines changed or deleted 25 lines changed or added


 view-statements.hxx   view-statements.hxx 
// file : odb/sqlite/view-statements.hxx // file : odb/sqlite/view-statements.hxx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX #ifndef ODB_SQLITE_VIEW_STATEMENTS_HXX
#define ODB_SQLITE_VIEW_STATEMENTS_HXX #define ODB_SQLITE_VIEW_STATEMENTS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx>
skipping to change at line 29 skipping to change at line 29
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
class view_statements: public statements_base class view_statements: public statements_base
{ {
public: public:
typedef T view_type; typedef T view_type;
typedef odb::view_traits<view_type> view_traits; typedef view_traits_impl<view_type, id_sqlite> view_traits;
typedef typename view_traits::pointer_type pointer_type; typedef typename view_traits::pointer_type pointer_type;
typedef typename view_traits::image_type image_type; typedef typename view_traits::image_type image_type;
public: public:
view_statements (connection_type&); view_statements (connection_type&);
virtual virtual
~view_statements (); ~view_statements ();
// View image. // View image.
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 view-statements.txx   view-statements.txx 
// file : odb/sqlite/view-statements.txx // file : odb/sqlite/view-statements.txx
// copyright : Copyright (c) 2005-2012 Code Synthesis Tools CC // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <cstring> // std::memset #include <cstring> // std::memset
namespace odb namespace odb
{ {
namespace sqlite namespace sqlite
{ {
template <typename T> template <typename T>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/