buffer.hxx   buffer.hxx 
skipping to change at line 25 skipping to change at line 25
namespace odb namespace odb
{ {
namespace details namespace details
{ {
class LIBODB_EXPORT basic_buffer_base class LIBODB_EXPORT basic_buffer_base
{ {
public: public:
~basic_buffer_base () ~basic_buffer_base ()
{ {
if (data_) if (data_ != 0)
operator delete (data_); operator delete (data_);
} }
basic_buffer_base () basic_buffer_base (std::size_t capacity)
: capacity_ (512) : capacity_ (capacity)
{ {
data_ = operator new (capacity_); data_ = capacity_ == 0 ? 0 : operator new (capacity_);
} }
std::size_t std::size_t
capacity () const capacity () const
{ {
return capacity_; return capacity_;
} }
void void
capacity (std::size_t, std::size_t data_size = 0); capacity (std::size_t, std::size_t data_size = 0);
skipping to change at line 54 skipping to change at line 54
protected: protected:
void* data_; void* data_;
std::size_t capacity_; std::size_t capacity_;
}; };
template <typename T> template <typename T>
class basic_buffer: public basic_buffer_base class basic_buffer: public basic_buffer_base
{ {
public: public:
basic_buffer (std::size_t capacity = 256)
: basic_buffer_base (capacity)
{
}
T* T*
data () data ()
{ {
return static_cast<T*> (data_); return static_cast<T*> (data_);
} }
const T* const T*
data () const data () const
{ {
return static_cast<T*> (data_); return static_cast<T*> (data_);
 End of changes. 4 change blocks. 
4 lines changed or deleted 9 lines changed or added


 cache-traits.hxx   cache-traits.hxx 
skipping to change at line 20 skipping to change at line 20
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/session.hxx> #include <odb/session.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
namespace odb namespace odb
{ {
// Caching traits for objects passed by pointer. // Caching traits for objects passed by pointer.
// //
template <typename P, pointer_kind = pointer_traits<P>::kind> template <typename P, typename ID, pointer_kind kind>
struct pointer_cache_traits struct pointer_cache_traits_impl;
template <typename P>
struct pointer_cache_traits: pointer_cache_traits_impl<
P,
typename object_traits<typename pointer_traits<P>::element_type>::id_ty
pe,
pointer_traits<P>::kind>
{
};
template <typename P, typename ID, pointer_kind kind>
struct pointer_cache_traits_impl
{ {
typedef P pointer_type; typedef P pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
typedef typename pointer_traits::element_type element_type; typedef typename pointer_traits::element_type element_type;
// element_type can be const while object_type is always non-const. // element_type can be const while object_type is always non-const.
// //
typedef typename object_traits<element_type>::object_type object_type; typedef typename object_traits<element_type>::object_type object_type;
typedef typename object_traits<element_type>::id_type id_type; typedef typename object_traits<element_type>::id_type id_type;
typedef session::object_position<object_type> position_type; typedef session::object_position<object_type> position_type;
skipping to change at line 48 skipping to change at line 59
position_type position_type
position () const {return pos_;} position () const {return pos_;}
void void
release () {pos_.map_ = 0;} release () {pos_.map_ = 0;}
private: private:
position_type pos_; position_type pos_;
}; };
// We need the insert() overload with explicit id to handle self-
// references. In such cases the object is not yet loaded and the
// id member does not contain the correct id.
//
// Qualify the database type to resolve a phony ambiguity in VC 10. // Qualify the database type to resolve a phony ambiguity in VC 10.
// //
static position_type static position_type
insert (odb::database& db, const id_type& id, const pointer_type& p) insert (odb::database& db, const id_type& id, const pointer_type& p)
{ {
if (session::has_current ()) if (session::has_current ())
{
// Cast away constness if any. // Cast away constness if any.
// //
return session::current ().insert<object_type> ( return session::current ().insert<object_type> (
db, id, pointer_traits::cast (p)); db, id, pointer_traits::cast (p));
}
else else
return position_type (); return position_type ();
} }
static position_type
insert (odb::database& db, const pointer_type& p)
{
const id_type& id (
object_traits<object_type>::id (
pointer_traits::get_ref (p)));
return insert (db, id, p);
}
static pointer_type static pointer_type
find (odb::database& db, const id_type& id) find (odb::database& db, const id_type& id)
{ {
if (session::has_current ()) if (session::has_current ())
return session::current ().find<object_type> (db, id); return session::current ().find<object_type> (db, id);
else else
return pointer_type (); return pointer_type ();
} }
static void static void
skipping to change at line 86 skipping to change at line 113
} }
static void static void
erase (const position_type& p) erase (const position_type& p)
{ {
if (p.map_ != 0) if (p.map_ != 0)
session::current ().erase<object_type> (p); session::current ().erase<object_type> (p);
} }
}; };
template <typename P, pointer_kind kind>
struct pointer_cache_traits_impl<P, void, kind>
{
typedef P pointer_type;
struct position_type {};
static position_type
insert (odb::database&, const pointer_type&)
{
return position_type ();
}
};
// Unique pointers don't work with the object cache. // Unique pointers don't work with the object cache.
// //
template <typename P> template <typename P, typename ID>
struct pointer_cache_traits<P, pk_unique> struct pointer_cache_traits_impl<P, ID, pk_unique>
{ {
typedef P pointer_type; typedef P pointer_type;
typedef typename pointer_traits<pointer_type>::element_type element_typ e; typedef typename pointer_traits<pointer_type>::element_type element_typ e;
typedef typename object_traits<element_type>::id_type id_type; typedef typename object_traits<element_type>::id_type id_type;
struct position_type {}; struct position_type {};
struct insert_guard struct insert_guard
{ {
insert_guard (const position_type&) {} insert_guard (const position_type&) {}
skipping to change at line 113 skipping to change at line 153
void void
release () {} release () {}
}; };
static position_type static position_type
insert (odb::database&, const id_type&, const pointer_type&) insert (odb::database&, const id_type&, const pointer_type&)
{ {
return position_type (); return position_type ();
} }
static position_type
insert (odb::database&, const pointer_type&)
{
return position_type ();
}
static pointer_type static pointer_type
find (odb::database&, const id_type&) { return pointer_type (); } find (odb::database&, const id_type&) { return pointer_type (); }
static void static void
erase (odb::database&, const id_type&) {} erase (odb::database&, const id_type&) {}
static void static void
erase (const position_type&) {} erase (const position_type&) {}
}; };
template <typename P>
struct pointer_cache_traits_impl<P, void, pk_unique>
{
typedef P pointer_type;
struct position_type {};
static position_type
insert (odb::database&, const pointer_type&)
{
return position_type ();
}
};
// Caching traits for objects passed by reference. Only if the object // Caching traits for objects passed by reference. Only if the object
// pointer kind is raw do we add the object to the session. // pointer kind is raw do we add the object to the session.
// //
template <typename T, template <typename T, typename ID, pointer_kind kind>
pointer_kind = struct reference_cache_traits_impl;
pointer_traits<typename object_traits<T>::pointer_type>::kind
> template <typename T>
struct reference_cache_traits struct reference_cache_traits: reference_cache_traits_impl<
T,
typename object_traits<T>::id_type,
pointer_traits<typename object_traits<T>::pointer_type>::kind>
{
};
template <typename T, typename ID, pointer_kind kind>
struct reference_cache_traits_impl
{ {
typedef T element_type; typedef T element_type;
typedef typename object_traits<element_type>::pointer_type pointer_type ; typedef typename object_traits<element_type>::pointer_type pointer_type ;
typedef typename object_traits<element_type>::id_type id_type; typedef typename object_traits<element_type>::id_type id_type;
typedef typedef
typename pointer_cache_traits<pointer_type>::position_type typename pointer_cache_traits<pointer_type>::position_type
position_type; position_type;
struct insert_guard struct insert_guard
skipping to change at line 155 skipping to change at line 223
void void
release () {} release () {}
}; };
static position_type static position_type
insert (odb::database&, const id_type&, element_type&) insert (odb::database&, const id_type&, element_type&)
{ {
return position_type (); return position_type ();
} }
static position_type
insert (odb::database&, element_type&)
{
return position_type ();
}
}; };
template <typename T> template <typename T, pointer_kind kind>
struct reference_cache_traits<T, pk_raw> struct reference_cache_traits_impl<T, void, kind>
{
typedef T element_type;
struct position_type {};
static position_type
insert (odb::database&, element_type&)
{
return position_type ();
}
};
template <typename T, typename ID>
struct reference_cache_traits_impl<T, ID, pk_raw>
{ {
typedef T element_type; typedef T element_type;
typedef typename object_traits<element_type>::pointer_type pointer_type ; typedef typename object_traits<element_type>::pointer_type pointer_type ;
typedef typename object_traits<element_type>::id_type id_type; typedef typename object_traits<element_type>::id_type id_type;
typedef typedef
typename pointer_cache_traits<pointer_type>::position_type typename pointer_cache_traits<pointer_type>::position_type
position_type; position_type;
typedef typedef
typename pointer_cache_traits<pointer_type>::insert_guard typename pointer_cache_traits<pointer_type>::insert_guard
insert_guard; insert_guard;
static position_type static position_type
insert (odb::database& db, const id_type& id, element_type& obj) insert (odb::database& db, const id_type& id, element_type& obj)
{ {
pointer_type p (&obj); pointer_type p (&obj);
return pointer_cache_traits<pointer_type>::insert (db, id, p); return pointer_cache_traits<pointer_type>::insert (db, id, p);
} }
static position_type
insert (odb::database& db, element_type& obj)
{
pointer_type p (&obj);
return pointer_cache_traits<pointer_type>::insert (db, p);
}
};
template <typename T>
struct reference_cache_traits_impl<T, void, pk_raw>
{
typedef T element_type;
struct position_type {};
static position_type
insert (odb::database&, element_type&)
{
return position_type ();
}
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_CACHE_TRAITS_HXX #endif // ODB_CACHE_TRAITS_HXX
 End of changes. 13 change blocks. 
11 lines changed or deleted 118 lines changed or added


 connection.hxx   connection.hxx 
skipping to change at line 54 skipping to change at line 54
public: public:
unsigned long long unsigned long long
execute (const char* statement); execute (const char* statement);
unsigned long long unsigned long long
execute (const std::string& statement); execute (const std::string& statement);
virtual unsigned long long virtual unsigned long long
execute (const char* statement, std::size_t length) = 0; execute (const char* statement, std::size_t length) = 0;
// SQL statement tracing.
//
public:
typedef odb::tracer tracer_type;
void
tracer (tracer_type&);
void
tracer (tracer_type*);
tracer_type*
tracer () const;
public:
// Store the transaction-spacific tracer in the connection. If we
// were to store it in the transaction, then in order to check if
// it was set, we would need to get the transaction instance using
// the current() API. But that requires a TLS lookup, which can be
// slow.
//
tracer_type*
transaction_tracer () const;
public: public:
virtual virtual
~connection (); ~connection ();
protected: protected:
connection (database_type&); connection (database_type&);
private: private:
connection (const connection&); connection (const connection&);
connection& operator= (const connection&); connection& operator= (const connection&);
private: protected:
database_type& database_; database_type& database_;
tracer_type* tracer_;
protected:
friend class transaction;
tracer_type* transaction_tracer_;
}; };
} }
#include <odb/connection.ixx> #include <odb/connection.ixx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_MYSQL_CONNECTION_HXX #endif // ODB_MYSQL_CONNECTION_HXX
 End of changes. 3 change blocks. 
1 lines changed or deleted 30 lines changed or added


 connection.ixx   connection.ixx 
skipping to change at line 12 skipping to change at line 12
// author : Boris Kolpackov <boris@codesynthesis.com> // author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::string #include <cstring> // std::string
namespace odb namespace odb
{ {
inline connection:: inline connection::
connection (database_type& database) connection (database_type& database)
: database_ (database) : database_ (database), tracer_ (0), transaction_tracer_ (0)
{ {
} }
inline connection::database_type& connection:: inline connection::database_type& connection::
database () database ()
{ {
return database_; return database_;
} }
inline unsigned long long connection:: inline unsigned long long connection::
execute (const char* st) execute (const char* st)
{ {
return execute (st, std::strlen (st)); return execute (st, std::strlen (st));
} }
inline unsigned long long connection:: inline unsigned long long connection::
execute (const std::string& st) execute (const std::string& st)
{ {
return execute (st.c_str (), st.size ()); return execute (st.c_str (), st.size ());
} }
inline void connection::
tracer (tracer_type& t)
{
tracer_ = &t;
}
inline void connection::
tracer (tracer_type* t)
{
tracer_ = t;
}
inline connection::tracer_type* connection::
tracer () const
{
return tracer_;
}
inline connection::tracer_type* connection::
transaction_tracer () const
{
return transaction_tracer_;
}
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 25 lines changed or added


 database.hxx   database.hxx 
skipping to change at line 69 skipping to change at line 69
// Throw object_not_persistent if not found. // Throw object_not_persistent if not found.
// //
template <typename T> template <typename T>
typename object_traits<T>::pointer_type typename object_traits<T>::pointer_type
load (const typename object_traits<T>::id_type& id); load (const typename object_traits<T>::id_type& id);
template <typename T> template <typename T>
void void
load (const typename object_traits<T>::id_type& id, T& object); load (const typename object_traits<T>::id_type& id, T& 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, template <typename> class P>
void
reload (P<T>& obj_ptr);
template <typename T>
void
reload (const typename object_traits<T>::pointer_type& obj_ptr);
// Return NULL/false if not found. // Return NULL/false if not found.
// //
template <typename T> template <typename T>
typename object_traits<T>::pointer_type typename object_traits<T>::pointer_type
find (const typename object_traits<T>::id_type& id); find (const typename object_traits<T>::id_type& id);
template <typename T> template <typename T>
bool bool
find (const typename object_traits<T>::id_type& id, T& object); find (const typename object_traits<T>::id_type& id, T& object);
skipping to change at line 188 skipping to change at line 208
public: public:
virtual transaction_impl* virtual transaction_impl*
begin () = 0; begin () = 0;
// Connections. // Connections.
// //
public: public:
connection_ptr connection_ptr
connection (); connection ();
// SQL statement tracing.
//
public:
typedef odb::tracer tracer_type;
void
tracer (tracer_type&);
void
tracer (tracer_type*);
tracer_type*
tracer () const;
protected: protected:
database (); database ();
private:
database (const database&);
database& operator= (const database&);
protected: protected:
typedef odb::connection connection_type; typedef odb::connection connection_type;
virtual connection_type* virtual connection_type*
connection_ () = 0; connection_ () = 0;
protected: protected:
template <typename T> template <typename T>
typename object_traits<T>::id_type typename object_traits<T>::id_type
persist_ (const typename object_traits<T>::pointer_type&); persist_ (const typename object_traits<T>::pointer_type&);
skipping to change at line 213 skipping to change at line 251
void void
update_ (const typename object_traits<T>::pointer_type&); update_ (const typename object_traits<T>::pointer_type&);
template <typename T> template <typename T>
void void
erase_ (const typename object_traits<T>::pointer_type&); erase_ (const typename object_traits<T>::pointer_type&);
template <typename T, class_kind kind> template <typename T, class_kind kind>
struct query_; struct query_;
private: protected:
database (const database&); tracer_type* tracer_;
database& operator= (const database&);
}; };
} }
#include <odb/database.ixx> #include <odb/database.ixx>
#include <odb/database.txx> #include <odb/database.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_DATABASE_HXX #endif // ODB_DATABASE_HXX
 End of changes. 4 change blocks. 
3 lines changed or deleted 40 lines changed or added


 database.ixx   database.ixx 
skipping to change at line 12 skipping to change at line 12
// author : Boris Kolpackov <boris@codesynthesis.com> // author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <cstring> // std::string #include <cstring> // std::string
namespace odb namespace odb
{ {
inline database:: inline database::
database () database ()
: tracer_ (0)
{ {
} }
inline connection_ptr database:: inline connection_ptr database::
connection () connection ()
{ {
return connection_ptr (connection_ ()); return connection_ptr (connection_ ());
} }
inline void database::
tracer (tracer_type& t)
{
tracer_ = &t;
}
inline void database::
tracer (tracer_type* t)
{
tracer_ = t;
}
inline database::tracer_type* database::
tracer () const
{
return tracer_;
}
template <typename T> template <typename T>
inline typename object_traits<T>::id_type database:: inline typename object_traits<T>::id_type database::
persist (T* p) persist (T* p)
{ {
typedef typename object_traits<T>::pointer_type object_pointer; typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible // The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer // to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object. // does not assume ownership of the passed object.
// //
skipping to change at line 68 skipping to change at line 87
template <typename T> template <typename T>
inline typename object_traits<T>::id_type database:: inline typename object_traits<T>::id_type database::
persist (const typename object_traits<T>::pointer_type& pobj) persist (const typename object_traits<T>::pointer_type& pobj)
{ {
return persist_<T> (pobj); return persist_<T> (pobj);
} }
template <typename T> template <typename T>
inline void database:: 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, template <typename> class P>
inline void database::
reload (P<T>& p)
{
reload (odb::pointer_traits< P<T> >::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* p) update (T* p)
{ {
typedef typename object_traits<T>::pointer_type object_pointer; typedef typename object_traits<T>::pointer_type object_pointer;
// The passed pointer should be the same or implicit-convertible // The passed pointer should be the same or implicit-convertible
// to the object pointer. This way we make sure the object pointer // to the object pointer. This way we make sure the object pointer
// does not assume ownership of the passed object. // does not assume ownership of the passed object.
// //
const object_pointer& pobj (p); const object_pointer& pobj (p);
 End of changes. 3 change blocks. 
0 lines changed or deleted 49 lines changed or added


 database.txx   database.txx 
skipping to change at line 31 skipping to change at line 31
typedef typename odb::object_traits<T>::object_type object_type; typedef typename odb::object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
if (!transaction::has_current ()) if (!transaction::has_current ())
throw not_in_transaction (); throw not_in_transaction ();
object_traits::callback (*this, obj, callback_event::pre_persist); object_traits::callback (*this, obj, callback_event::pre_persist);
object_traits::persist (*this, obj); object_traits::persist (*this, obj);
object_traits::callback (*this, obj, callback_event::post_persist); object_traits::callback (*this, obj, callback_event::post_persist);
const typename object_traits::id_type& id (object_traits::id (obj)); reference_cache_traits<T>::insert (*this, obj);
reference_cache_traits<T>::insert (*this, id, obj);
return id; return object_traits::id (obj);
} }
template <typename T> template <typename T>
typename object_traits<T>::id_type database:: typename object_traits<T>::id_type database::
persist_ (const typename object_traits<T>::pointer_type& pobj) persist_ (const typename object_traits<T>::pointer_type& pobj)
{ {
// T can be const T while object_type will always be T. // T can be const T while object_type will always be T.
// //
typedef typename odb::object_traits<T>::object_type object_type; typedef typename odb::object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
skipping to change at line 57 skipping to change at line 57
if (!transaction::has_current ()) if (!transaction::has_current ())
throw not_in_transaction (); throw not_in_transaction ();
T& obj (pointer_traits::get_ref (pobj)); T& obj (pointer_traits::get_ref (pobj));
object_traits::callback (*this, obj, callback_event::pre_persist); object_traits::callback (*this, obj, callback_event::pre_persist);
object_traits::persist (*this, obj); object_traits::persist (*this, obj);
object_traits::callback (*this, obj, callback_event::post_persist); object_traits::callback (*this, obj, callback_event::post_persist);
const typename object_traits::id_type& id (object_traits::id (obj)); pointer_cache_traits<pointer_type>::insert (*this, pobj);
pointer_cache_traits<pointer_type>::insert (*this, id, pobj);
return id; return object_traits::id (obj);
} }
template <typename T> template <typename T>
typename object_traits<T>::pointer_type database:: typename object_traits<T>::pointer_type database::
load (const typename object_traits<T>::id_type& id) load (const typename object_traits<T>::id_type& id)
{ {
// T is always object_type. // T is always object_type.
// //
typedef typename object_traits<T>::pointer_type pointer_type; typedef typename object_traits<T>::pointer_type pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
skipping to change at line 88 skipping to change at line 88
template <typename T> template <typename T>
void database:: void database::
load (const typename object_traits<T>::id_type& id, T& obj) load (const typename object_traits<T>::id_type& id, T& obj)
{ {
if (!find<T> (id, obj)) if (!find<T> (id, obj))
throw object_not_persistent (); throw object_not_persistent ();
} }
template <typename T> template <typename T>
void database::
reload (T& obj)
{
// T should be object_type (cannot be const).
//
typedef odb::object_traits<T> object_traits;
if (!object_traits::reload (*this, obj))
throw object_not_persistent ();
}
template <typename T>
typename object_traits<T>::pointer_type database:: typename object_traits<T>::pointer_type database::
find (const typename object_traits<T>::id_type& id) find (const typename object_traits<T>::id_type& id)
{ {
// T is always object_type. // T is always object_type.
// //
typedef odb::object_traits<T> object_traits; typedef odb::object_traits<T> object_traits;
typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::pointer_type pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
// First check the session. // First check the session.
skipping to change at line 141 skipping to change at line 153
{ {
// T can be const T while object_type will always be T. // T can be const T while object_type will always be T.
// //
typedef typename odb::object_traits<T>::object_type object_type; typedef typename odb::object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
if (!transaction::has_current ()) if (!transaction::has_current ())
throw not_in_transaction (); throw not_in_transaction ();
object_traits::callback (*this, obj,callback_event::pre_update); object_traits::callback (*this, obj,callback_event::pre_update);
// Compiler error pointing here? Perhaps the object is readonly or
// doesn't have an object id? Such objects cannot be updated.
//
object_traits::update (*this, obj); object_traits::update (*this, obj);
object_traits::callback (*this, obj, callback_event::post_update); object_traits::callback (*this, obj, callback_event::post_update);
} }
template <typename T> template <typename T>
void database:: void database::
update_ (const typename object_traits<T>::pointer_type& pobj) update_ (const typename object_traits<T>::pointer_type& pobj)
{ {
// T can be const T while object_type will always be T. // T can be const T while object_type will always be T.
// //
typedef typename odb::object_traits<T>::object_type object_type; typedef typename odb::object_traits<T>::object_type object_type;
skipping to change at line 163 skipping to change at line 180
typedef typename odb::object_traits<T>::pointer_type pointer_type; typedef typename odb::object_traits<T>::pointer_type pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
if (!transaction::has_current ()) if (!transaction::has_current ())
throw not_in_transaction (); throw not_in_transaction ();
T& obj (pointer_traits::get_ref (pobj)); T& obj (pointer_traits::get_ref (pobj));
object_traits::callback (*this, obj, callback_event::pre_update); object_traits::callback (*this, obj, callback_event::pre_update);
// Compiler error pointing here? Perhaps the object is readonly or
// doesn't have an object id? Such objects cannot be updated.
//
object_traits::update (*this, obj); object_traits::update (*this, obj);
object_traits::callback (*this, obj, callback_event::post_update); object_traits::callback (*this, obj, callback_event::post_update);
} }
template <typename T> template <typename T>
void database:: void database::
erase (const typename object_traits<T>::id_type& id) erase (const typename object_traits<T>::id_type& id)
{ {
// T is always object_type. // T is always object_type.
// //
typedef odb::object_traits<T> object_traits; typedef odb::object_traits<T> object_traits;
skipping to change at line 199 skipping to change at line 221
typedef typename odb::object_traits<T>::object_type object_type; typedef typename odb::object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
typedef typename object_traits::pointer_type pointer_type; typedef typename object_traits::pointer_type pointer_type;
if (!transaction::has_current ()) if (!transaction::has_current ())
throw not_in_transaction (); throw not_in_transaction ();
typename object_traits::id_type id (object_traits::id (obj)); typename object_traits::id_type id (object_traits::id (obj));
object_traits::callback (*this, obj, callback_event::pre_erase); object_traits::callback (*this, obj, callback_event::pre_erase);
object_traits::erase (*this, id); object_traits::erase (*this, obj);
pointer_cache_traits<pointer_type>::erase (*this, id); pointer_cache_traits<pointer_type>::erase (*this, id);
object_traits::callback (*this, obj, callback_event::post_erase); object_traits::callback (*this, obj, callback_event::post_erase);
} }
template <typename T> template <typename T>
unsigned long long database:: unsigned long long database::
erase_query (const odb::query<T>& q) erase_query (const odb::query<T>& q)
{ {
// T is always object_type. // T is always object_type.
// //
 End of changes. 8 change blocks. 
7 lines changed or deleted 29 lines changed or added


 exceptions.hxx   exceptions.hxx 
skipping to change at line 95 skipping to change at line 95
virtual const char* virtual const char*
what () const throw (); what () const throw ();
}; };
struct LIBODB_EXPORT object_already_persistent: exception struct LIBODB_EXPORT object_already_persistent: exception
{ {
virtual const char* virtual const char*
what () const throw (); what () const throw ();
}; };
struct LIBODB_EXPORT object_changed: exception
{
virtual const char*
what () const throw ();
};
struct LIBODB_EXPORT result_not_cached: exception struct LIBODB_EXPORT result_not_cached: exception
{ {
virtual const char* virtual const char*
what () const throw (); what () const throw ();
}; };
struct LIBODB_EXPORT database_exception: exception struct LIBODB_EXPORT database_exception: exception
{ {
}; };
skipping to change at line 143 skipping to change at line 149
using odb::already_in_session; using odb::already_in_session;
using odb::not_in_session; using odb::not_in_session;
using odb::recoverable; using odb::recoverable;
using odb::deadlock; using odb::deadlock;
using odb::connection_lost; using odb::connection_lost;
using odb::timeout; using odb::timeout;
using odb::object_not_persistent; using odb::object_not_persistent;
using odb::object_already_persistent; using odb::object_already_persistent;
using odb::object_changed;
using odb::result_not_cached; using odb::result_not_cached;
using odb::database_exception; using odb::database_exception;
using odb::unknown_schema; using odb::unknown_schema;
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_EXCEPTIONS_HXX #endif // ODB_EXCEPTIONS_HXX
 End of changes. 2 change blocks. 
0 lines changed or deleted 7 lines changed or added


 forward.hxx   forward.hxx 
// file : odb/forward.hxx // file : odb/forward.hxx
// author : Boris Kolpackov <boris@codesynthesis.com> // author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#ifndef ODB_FORWARD_HXX #ifndef ODB_FORWARD_HXX
#define ODB_FORWARD_HXX #define ODB_FORWARD_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/export.hxx>
#include <odb/details/shared-ptr-fwd.hxx> #include <odb/details/shared-ptr-fwd.hxx>
namespace odb namespace odb
{ {
class database; class database;
class connection; class connection;
typedef details::shared_ptr<connection> connection_ptr; typedef details::shared_ptr<connection> connection_ptr;
class transaction; class transaction;
class statement;
class session; class session;
namespace core namespace core
{ {
using odb::database; using odb::database;
using odb::connection; using odb::connection;
using odb::connection_ptr; using odb::connection_ptr;
using odb::transaction; using odb::transaction;
using odb::statement;
using odb::session; using odb::session;
} }
// Tracing.
//
class tracer; // Not in core.
extern LIBODB_EXPORT tracer& stderr_tracer;
namespace core
{
using odb::stderr_tracer;
}
// Implementation details. // Implementation details.
// //
class access class access
{ {
public: public:
template <typename T> template <typename T>
class object_traits; class object_traits;
template <typename T, typename P> template <typename T, typename P>
 End of changes. 4 change blocks. 
0 lines changed or deleted 13 lines changed or added


 object-result.hxx   object-result.hxx 
skipping to change at line 23 skipping to change at line 23
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
class result_impl<T, class_object>: public details::shared_base class object_result_impl;
template <typename T>
class object_result_impl_no_id;
template <typename T, typename ID>
class object_result_iterator;
template <typename T, typename ID = typename object_traits<T>::id_type>
struct object_result_impl_selector
{
typedef object_result_impl<T> type;
};
template <typename T>
struct object_result_impl_selector<T, void>
{
typedef object_result_impl_no_id<T> type;
};
// Implementation for objects with object id.
//
template <typename T>
class object_result_impl: public details::shared_base
{ {
public: public:
virtual virtual
~result_impl (); ~object_result_impl ();
protected: protected:
typedef odb::database database_type;
// In result_impl, T is always non-const and the same as object_type.
//
typedef T object_type;
typedef odb::object_traits<object_type> object_traits;
typedef typename object_traits::id_type id_type;
typedef typename object_traits::pointer_type pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits;
friend class result<T>; friend class result<T>;
friend class result<const T>; friend class result<const T>;
friend class result_iterator<T, class_object>; friend class result_iterator<T, class_object>;
friend class result_iterator<const T, class_object>; friend class result_iterator<const T, class_object>;
friend class object_result_iterator<T, id_type>;
friend class object_result_iterator<const T, id_type>;
protected:
object_result_impl (database_type& db)
: begin_ (true), end_ (false), db_ (db), current_ ()
{
}
database_type&
database () const
{
return db_;
}
// To make this work with all kinds of pointers (raw, std::auto_ptr,
// shared), we need to make sure we don't make any copies of the
// pointer on the return path.
//
pointer_type&
current ();
void
release ()
{
current_ = pointer_type ();
guard_.release ();
}
void
begin ()
{
if (begin_)
{
next ();
begin_ = false;
}
}
bool
end () const
{
return end_;
}
protected:
// The fetch argument is a hint to the implementation. If it is
// false then it means load_id() was already called (and presumably
// fetched the data into the object image) and the object image
// is still valid (so the implementation doesn't need to fetch
// the data again).
//
virtual void
load (object_type&, bool fetch = true) = 0;
virtual id_type
load_id () = 0;
virtual void
next () = 0;
virtual void
cache () = 0;
virtual std::size_t
size () = 0;
protected:
void
current (pointer_type p)
{
current_ = p;
guard_.reset (current_);
}
bool begin_;
bool end_;
private:
database_type& db_;
pointer_type current_;
typename pointer_traits::guard guard_;
};
// Implementation for objects without object id.
//
template <typename T>
class object_result_impl_no_id: public details::shared_base
{
public:
virtual
~object_result_impl_no_id ();
protected:
typedef odb::database database_type; typedef odb::database database_type;
// In result_impl, T is always non-const and the same as object_type. // In result_impl, T is always non-const and the same as object_type.
// //
typedef T object_type; typedef T object_type;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
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 odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
result_impl (database_type& db) friend class result<T>;
friend class result<const T>;
friend class result_iterator<T, class_object>;
friend class result_iterator<const T, class_object>;
friend class object_result_iterator<T, void>;
friend class object_result_iterator<const T, void>;
protected:
object_result_impl_no_id (database_type& db)
: begin_ (true), end_ (false), db_ (db), current_ () : begin_ (true), end_ (false), db_ (db), current_ ()
{ {
} }
database_type& database_type&
database () const database () const
{ {
return db_; return db_;
} }
skipping to change at line 91 skipping to change at line 225
bool bool
end () const end () const
{ {
return end_; return end_;
} }
protected: protected:
virtual void virtual void
load (object_type&) = 0; load (object_type&) = 0;
virtual id_type
load_id () = 0;
virtual void virtual void
next () = 0; next () = 0;
virtual void virtual void
cache () = 0; cache () = 0;
virtual std::size_t virtual std::size_t
size () = 0; size () = 0;
protected: protected:
skipping to change at line 120 skipping to change at line 251
bool begin_; bool begin_;
bool end_; bool end_;
private: private:
database_type& db_; database_type& db_;
pointer_type current_; pointer_type current_;
typename pointer_traits::guard guard_; typename pointer_traits::guard guard_;
}; };
//
// result_iterator
//
template <typename T, typename ID>
class object_result_iterator
{
public:
// T can be const T while object_type is always non-const.
//
typedef typename object_traits<T>::object_type object_type;
typedef typename object_traits<T>::id_type id_type;
typedef object_result_impl<object_type> result_impl_type;
public:
object_result_iterator (result_impl_type* res)
: res_ (res)
{
}
public:
typename object_traits<T>::pointer_type
load ()
{
typename object_traits<T>::pointer_type r (res_->current ());
res_->release ();
return r;
}
void
load (object_type&);
id_type
id ()
{
return res_->load_id ();
}
protected:
result_impl_type* res_;
};
template <typename T>
class object_result_iterator<T, void>
{
public:
// T can be const T while object_type is always non-const.
//
typedef typename object_traits<T>::object_type object_type;
typedef object_result_impl_no_id<object_type> result_impl_type;
public:
object_result_iterator (result_impl_type* res)
: res_ (res)
{
}
public:
typename object_traits<T>::pointer_type
load ()
{
typename object_traits<T>::pointer_type r (res_->current ());
res_->release ();
return r;
}
void
load (object_type& obj)
{
// Objects without ids are not stored in session cache.
//
if (!res_->end ())
res_->load (obj);
}
protected:
result_impl_type* res_;
};
template <typename T> template <typename T>
class result_iterator<T, class_object> class result_iterator<T, class_object>: public object_result_iterator<
T,
typename object_traits<T>::id_type>
{ {
public: public:
typedef T value_type; typedef T value_type;
typedef value_type& reference; typedef value_type& reference;
typedef value_type* pointer; typedef value_type* pointer;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef std::input_iterator_tag iterator_category; typedef std::input_iterator_tag iterator_category;
// T can be const T while object_type is always non-const. // T can be const T while object_type is always non-const.
// //
typedef typename object_traits<T>::object_type object_type; typedef
typedef typename object_traits<T>::id_type id_type; object_result_iterator<T, typename object_traits<T>::id_type>
base_type;
typedef result_impl<object_type, class_object> result_impl_type;
public: public:
explicit explicit
result_iterator (result_impl_type* res = 0) result_iterator (typename base_type::result_impl_type* res = 0)
: res_ (res) : base_type (res)
{ {
} }
// Input iterator requirements. // Input iterator requirements.
// //
public: public:
reference reference
operator* () const operator* () const
{ {
return pointer_traits::get_ref (res_->current ()); return pointer_traits::get_ref (this->res_->current ());
} }
// Our value_type is already a pointer so return it instead of // Our value_type is already a pointer so return it instead of
// a pointer to it (operator-> will just have to go one deeper // a pointer to it (operator-> will just have to go one deeper
// in the latter case). // in the latter case).
// //
pointer pointer
operator-> () const operator-> () const
{ {
return pointer_traits::get_ptr (res_->current ()); return pointer_traits::get_ptr (this->res_->current ());
} }
result_iterator& result_iterator&
operator++ () operator++ ()
{ {
res_->next (); this->res_->next ();
return *this; return *this;
} }
result_iterator result_iterator
operator++ (int) operator++ (int)
{ {
// All non-end iterators for a result object move together. // All non-end iterators for a result object move together.
// //
res_->next (); this->res_->next ();
return *this; return *this;
} }
public: public:
typename object_traits<T>::pointer_type
load ()
{
typename object_traits<T>::pointer_type r (res_->current ());
res_->release ();
return r;
}
void
load (object_type&);
public:
bool bool
equal (result_iterator j) const equal (result_iterator j) const
{ {
return (res_ ? res_->end () : true) == (j.res_ ? j.res_->end () : tr return (this->res_ ? this->res_->end () : true) ==
ue); (j.res_ ? j.res_->end () : true);
} }
private: private:
// Use unrestricted pointer traits since that's what is returned by // Use unrestricted pointer traits since that's what is returned by
// result_impl. // result_impl.
// //
typedef typedef
odb::pointer_traits<typename object_traits<object_type>::pointer_type> odb::pointer_traits<
typename object_traits<
typename base_type::object_type>::pointer_type>
pointer_traits; pointer_traits;
result_impl_type* res_;
}; };
// //
// //
template <typename T> template <typename T>
class result_base<T, class_object> class result_base<T, class_object>
{ {
public: public:
typedef typename object_traits<T>::pointer_type value_type; typedef typename object_traits<T>::pointer_type value_type;
// T can be const T while object_type is always non-const. // T can be const T while object_type is always non-const.
// //
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
typedef result_impl<object_type, class_object> result_impl_type; typedef
typename object_result_impl_selector<object_type>::type
result_impl_type;
}; };
} }
#include <odb/object-result.txx> #include <odb/object-result.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_OBJECT_RESULT_HXX #endif // ODB_OBJECT_RESULT_HXX
 End of changes. 21 change blocks. 
36 lines changed or deleted 239 lines changed or added


 object-result.txx   object-result.txx 
skipping to change at line 12 skipping to change at line 12
// author : Boris Kolpackov <boris@codesynthesis.com> // author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <odb/session.hxx> #include <odb/session.hxx>
#include <odb/cache-traits.hxx> #include <odb/cache-traits.hxx>
namespace odb namespace odb
{ {
// //
// result_impl // object_result_impl
// //
template <typename T> template <typename T>
result_impl<T, class_object>:: object_result_impl<T>::
~result_impl () ~object_result_impl ()
{ {
} }
template <typename T> template <typename T>
typename result_impl<T, class_object>::pointer_type& typename object_result_impl<T>::pointer_type&
result_impl<T, class_object>:: object_result_impl<T>::
current () current ()
{ {
if (pointer_traits::null_ptr (current_) && !end_) if (pointer_traits::null_ptr (current_) && !end_)
{ {
if (!session::has_current ()) if (!session::has_current ())
{ {
pointer_type p (object_traits::create ()); pointer_type p (object_traits::create ());
object_type& obj (pointer_traits::get_ref (p)); object_type& obj (pointer_traits::get_ref (p));
current (p); current (p);
load (obj); load (obj);
skipping to change at line 55 skipping to change at line 55
current (p); current (p);
else else
{ {
pointer_type p (object_traits::create ()); pointer_type p (object_traits::create ());
typename pointer_cache_traits<pointer_type>::insert_guard ig ( typename pointer_cache_traits<pointer_type>::insert_guard ig (
pointer_cache_traits<pointer_type>::insert (database (), id, p) ); pointer_cache_traits<pointer_type>::insert (database (), id, p) );
object_type& obj (pointer_traits::get_ref (p)); object_type& obj (pointer_traits::get_ref (p));
current (p); current (p);
load (obj); load (obj, false);
ig.release (); ig.release ();
} }
} }
} }
return current_; return current_;
} }
// //
// result_iterator // object_result_impl_no_id
// //
template <typename T>
object_result_impl_no_id<T>::
~object_result_impl_no_id ()
{
}
template <typename T> template <typename T>
void result_iterator<T, class_object>:: typename object_result_impl_no_id<T>::pointer_type&
object_result_impl_no_id<T>::
current ()
{
if (pointer_traits::null_ptr (current_) && !end_)
{
// Objects without ids are not stored in session cache.
//
pointer_type p (object_traits::create ());
object_type& obj (pointer_traits::get_ref (p));
current (p);
load (obj);
}
return current_;
}
//
// object_result_iterator
//
template <typename T, typename ID>
void object_result_iterator<T, ID>::
load (object_type& obj) load (object_type& obj)
{ {
if (res_->end ()) if (res_->end ())
return; return;
if (!session::has_current ()) if (!session::has_current ())
res_->load (obj); res_->load (obj);
else else
{ {
typename reference_cache_traits<object_type>::insert_guard ig ( typename reference_cache_traits<object_type>::insert_guard ig (
reference_cache_traits<object_type>::insert ( reference_cache_traits<object_type>::insert (
res_->database (), res_->load_id (), obj)); res_->database (), res_->load_id (), obj));
res_->load (obj); res_->load (obj, false);
ig.release (); ig.release ();
} }
} }
} }
 End of changes. 8 change blocks. 
9 lines changed or deleted 36 lines changed or added


 result.hxx   result.hxx 
skipping to change at line 21 skipping to change at line 21
#include <cstddef> // std::ptrdiff_t, std::size_t #include <cstddef> // std::ptrdiff_t, std::size_t
#include <odb/forward.hxx> // result #include <odb/forward.hxx> // result
#include <odb/traits.hxx> #include <odb/traits.hxx>
namespace odb namespace odb
{ {
template <typename T, class_kind kind> template <typename T, class_kind kind>
class result_base; class result_base;
template <typename T, class_kind kind>
class result_impl;
template <typename T, class_kind kind = class_traits<T>::kind> template <typename T, class_kind kind = class_traits<T>::kind>
class result_iterator; class result_iterator;
// Input iterator requirements. // Input iterator requirements.
// //
template <typename T, class_kind kind> template <typename T, class_kind kind>
inline bool inline bool
operator== (result_iterator<T, kind> i, result_iterator<T, kind> j) operator== (result_iterator<T, kind> i, result_iterator<T, kind> j)
{ {
return i.equal (j); return i.equal (j);
skipping to change at line 62 skipping to change at line 59
typedef value_type* pointer; typedef value_type* pointer;
typedef const value_type* const_pointer; typedef const value_type* const_pointer;
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef result_iterator<T, kind> iterator; typedef result_iterator<T, kind> iterator;
typedef std::size_t size_type; typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
// T can be const T while result_impl's argument is always non-const.
//
typedef typename base::result_impl_type result_impl_type; typedef typename base::result_impl_type result_impl_type;
public: public:
result () result ()
{ {
} }
explicit explicit
result (details::shared_ptr<result_impl_type> impl) result (details::shared_ptr<result_impl_type> impl)
: impl_ (impl) : impl_ (impl)
 End of changes. 2 change blocks. 
5 lines changed or deleted 0 lines changed or added


 transaction.hxx   transaction.hxx 
skipping to change at line 52 skipping to change at line 52
// Return the database this transaction is on. // Return the database this transaction is on.
// //
database_type& database_type&
database (); database ();
// Return the connection this transaction is on. // Return the connection this transaction is on.
// //
connection_type& connection_type&
connection (); connection ();
public:
// Return true if there is a transaction in effect. // Return true if there is a transaction in effect.
// //
static bool static bool
has_current (); has_current ();
// Return current transaction or throw if there is no transaction // Return current transaction or throw if there is no transaction
// in effect. // in effect.
// //
static transaction& static transaction&
current (); current ();
skipping to change at line 73 skipping to change at line 74
// Set the current thread's transaction. // Set the current thread's transaction.
// //
static void static void
current (transaction&); current (transaction&);
// Revert to the no transaction in effect state for the current thread. // Revert to the no transaction in effect state for the current thread.
// //
static void static void
reset_current (); reset_current ();
// SQL statement tracing.
//
public:
typedef odb::tracer tracer_type;
void
tracer (tracer_type&);
void
tracer (tracer_type*);
tracer_type*
tracer () const;
public: public:
transaction_impl& transaction_impl&
implementation (); implementation ();
// Copying or assignment of transactions is not supported. // Copying or assignment of transactions is not supported.
// //
private: private:
transaction (const transaction&); transaction (const transaction&);
transaction& operator= (const transaction&); transaction& operator= (const transaction&);
 End of changes. 2 change blocks. 
0 lines changed or deleted 15 lines changed or added


 transaction.ixx   transaction.ixx 
// file : odb/transaction.ixx // file : odb/transaction.ixx
// author : Boris Kolpackov <boris@codesynthesis.com> // author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
#include <odb/connection.hxx>
namespace odb namespace odb
{ {
inline transaction::database_type& transaction:: inline transaction::database_type& transaction::
database () database ()
{ {
return impl_->database (); return impl_->database ();
} }
inline transaction::connection_type& transaction:: inline transaction::connection_type& transaction::
connection () connection ()
{ {
return impl_->connection (); return impl_->connection ();
} }
inline transaction_impl& transaction:: inline transaction_impl& transaction::
implementation () implementation ()
{ {
return *impl_; return *impl_;
} }
// The transaction-specific tracer is stored in the connection. See
// the connection class for the reason.
//
inline void transaction::
tracer (tracer_type& t)
{
impl_->connection ().transaction_tracer_ = &t;
}
inline void transaction::
tracer (tracer_type* t)
{
impl_->connection ().transaction_tracer_ = t;
}
inline transaction::tracer_type* transaction::
tracer () const
{
return impl_->connection ().transaction_tracer_;
}
} }
 End of changes. 2 change blocks. 
0 lines changed or deleted 23 lines changed or added


 version.hxx   version.hxx 
skipping to change at line 30 skipping to change at line 30
// 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
// //
// ODB interface version: minor, major, and alpha/beta versions. // ODB interface version: minor, major, and alpha/beta versions.
// //
#define ODB_VERSION 10600 #define ODB_VERSION 10700
#define ODB_VERSION_STR "1.6" #define ODB_VERSION_STR "1.7"
// libodb version: interface version plus the bugfix version. // libodb version: interface version plus the bugfix version.
// //
#define LIBODB_VERSION 1060000 #define LIBODB_VERSION 1070000
#define LIBODB_VERSION_STR "1.6.0" #define LIBODB_VERSION_STR "1.7.0"
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_VERSION_HXX #endif // ODB_VERSION_HXX
 End of changes. 2 change blocks. 
4 lines changed or deleted 4 lines changed or added


 view-result.hxx   view-result.hxx 
skipping to change at line 23 skipping to change at line 23
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
class result_impl<T, class_view>: public details::shared_base class view_result_impl: public details::shared_base
{ {
public: public:
virtual virtual
~result_impl (); ~view_result_impl ();
protected: protected:
friend class result<T>; friend class result<T>;
friend class result<const T>; friend class result<const T>;
friend class result_iterator<T, class_view>; friend class result_iterator<T, class_view>;
friend class result_iterator<const T, class_view>; friend class result_iterator<const T, class_view>;
typedef odb::database database_type; typedef odb::database database_type;
// In result_impl, T is always non-const and the same as view_type. // In result_impl, T is always non-const and the same as view_type.
// //
typedef T view_type; typedef T view_type;
typedef odb::view_traits<view_type> view_traits; typedef odb::view_traits<view_type> view_traits;
typedef typename view_traits::pointer_type pointer_type; typedef typename view_traits::pointer_type pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
result_impl (database_type& db) view_result_impl (database_type& db)
: begin_ (true), end_ (false), db_ (db), current_ () : begin_ (true), end_ (false), db_ (db), current_ ()
{ {
} }
database_type& database_type&
database () const database () const
{ {
return db_; return db_;
} }
skipping to change at line 130 skipping to change at line 130
typedef T value_type; typedef T value_type;
typedef value_type& reference; typedef value_type& reference;
typedef value_type* pointer; typedef value_type* pointer;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef std::input_iterator_tag iterator_category; typedef std::input_iterator_tag iterator_category;
// T can be const T while view_type is always non-const. // T can be const T while view_type is always non-const.
// //
typedef typename view_traits<T>::view_type view_type; typedef typename view_traits<T>::view_type view_type;
typedef result_impl<view_type, class_view> result_impl_type; typedef view_result_impl<view_type> result_impl_type;
public: public:
explicit explicit
result_iterator (result_impl_type* res = 0) result_iterator (result_impl_type* res = 0)
: res_ (res) : res_ (res)
{ {
} }
// Input iterator requirements. // Input iterator requirements.
// //
skipping to change at line 215 skipping to change at line 215
// //
template <typename T> template <typename T>
class result_base<T, class_view> class result_base<T, class_view>
{ {
public: public:
typedef typename view_traits<T>::pointer_type value_type; typedef typename view_traits<T>::pointer_type value_type;
// T can be const T while view_type is always non-const. // T can be const T while view_type is always non-const.
// //
typedef typename view_traits<T>::view_type view_type; typedef typename view_traits<T>::view_type view_type;
typedef result_impl<view_type, class_view> result_impl_type; typedef view_result_impl<view_type> result_impl_type;
}; };
} }
#include <odb/view-result.txx> #include <odb/view-result.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_VIEW_RESULT_HXX #endif // ODB_VIEW_RESULT_HXX
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added


 view-result.txx   view-result.txx 
// file : odb/view-result.txx // file : odb/view-result.txx
// author : Boris Kolpackov <boris@codesynthesis.com> // author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC // copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : GNU GPL v2; see accompanying LICENSE file // license : GNU GPL v2; see accompanying LICENSE file
namespace odb namespace odb
{ {
// //
// result_impl // view_result_impl
// //
template <typename T> template <typename T>
result_impl<T, class_view>:: view_result_impl<T>::
~result_impl () ~view_result_impl ()
{ {
} }
template <typename T> template <typename T>
typename result_impl<T, class_view>::pointer_type& typename view_result_impl<T>::pointer_type&
result_impl<T, class_view>:: view_result_impl<T>::
current () current ()
{ {
if (pointer_traits::null_ptr (current_) && !end_) if (pointer_traits::null_ptr (current_) && !end_)
{ {
pointer_type p (view_traits::create ()); pointer_type p (view_traits::create ());
view_type& view (pointer_traits::get_ref (p)); view_type& view (pointer_traits::get_ref (p));
current (p); current (p);
load (view); load (view);
} }
 End of changes. 3 change blocks. 
5 lines changed or deleted 5 lines changed or added


 wrapper-traits.hxx   wrapper-traits.hxx 
skipping to change at line 15 skipping to change at line 15
#ifndef ODB_WRAPPER_TRAITS_HXX #ifndef ODB_WRAPPER_TRAITS_HXX
#define ODB_WRAPPER_TRAITS_HXX #define ODB_WRAPPER_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <memory> // std::auto_ptr #include <memory> // std::auto_ptr
#include <odb/nullable.hxx> #include <odb/nullable.hxx>
#include <odb/details/meta/remove-const.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
class wrapper_traits; class wrapper_traits;
// Sample specialization for raw pointers. It is not enabled by default // Sample specialization for raw pointers. It is not enabled by default
// since it makes many assumptions that may not always hold true (such // since it makes many assumptions that may not always hold true (such
// as that instances are allocated with new and freed with delete). // as that instances are allocated with new and freed with delete).
// This makes it too dangerous to be enable unconditionally. If you // This makes it too dangerous to be enable unconditionally. If you
// need this functionality, you can copy the below code into your // need this functionality, you can copy the below code into your
skipping to change at line 37 skipping to change at line 39
// do the wrong thing for char*). // do the wrong thing for char*).
// //
#if 0 #if 0
template <typename T> template <typename T>
class wrapper_traits<T*> class wrapper_traits<T*>
{ {
public: public:
typedef T wrapped_type; typedef T wrapped_type;
typedef T* wrapper_type; typedef T* wrapper_type;
// T can be const.
//
typedef
typename details::meta::remove_const<T>::result
unrestricted_wrapped_type;
static const bool null_handler = true; static const bool null_handler = true;
static const bool null_default = false; static const bool null_default = false;
static bool static bool
get_null (const wrapper_type& p) get_null (const wrapper_type& p)
{ {
return p == 0; return p == 0;
} }
static void static void
set_null (wrapper_type& p) set_null (wrapper_type& p)
{ {
delete p; delete p;
p = 0; p = 0;
} }
static const type& static const wrapped_type&
get_ref (const wrapper_type& p) get_ref (const wrapper_type& p)
{ {
return *p; return *p;
} }
static type& static unrestricted_wrapped_type&
set_ref (wrapper_type& p) set_ref (wrapper_type& p)
{ {
if (p == 0) if (p == 0)
p = new type; p = new unrestricted_wrapped_type;
return *p; return const_cast<unrestricted_wrapped_type&> (*p);
} }
}; };
#endif #endif
// Specialization for std::auto_ptr. // Specialization for std::auto_ptr.
// //
template <typename T> template <typename T>
class wrapper_traits< std::auto_ptr<T> > class wrapper_traits< std::auto_ptr<T> >
{ {
public: public:
// T can be const.
//
typedef T wrapped_type; typedef T wrapped_type;
typedef std::auto_ptr<T> wrapper_type; typedef std::auto_ptr<T> wrapper_type;
// T can be const.
//
typedef
typename odb::details::meta::remove_const<T>::result
unrestricted_wrapped_type;
static const bool null_handler = true; static const bool null_handler = true;
static const bool null_default = false; static const bool null_default = false;
static bool static bool
get_null (const wrapper_type& p) get_null (const wrapper_type& p)
{ {
return p.get () == 0; return p.get () == 0;
} }
static void static void
skipping to change at line 100 skipping to change at line 116
{ {
p.reset (); p.reset ();
} }
static const wrapped_type& static const wrapped_type&
get_ref (const wrapper_type& p) get_ref (const wrapper_type& p)
{ {
return *p; return *p;
} }
static wrapped_type& static unrestricted_wrapped_type&
set_ref (wrapper_type& p) set_ref (wrapper_type& p)
{ {
if (p.get () == 0) if (p.get () == 0)
p.reset (new wrapped_type); p.reset (new unrestricted_wrapped_type ());
return *p; return const_cast<unrestricted_wrapped_type&> (*p);
} }
}; };
// Specialization for odb::nullable. // Specialization for odb::nullable.
// //
template <typename T> template <typename T>
class wrapper_traits< nullable<T> > class wrapper_traits< nullable<T> >
{ {
public: public:
// T can be const.
//
typedef T wrapped_type; typedef T wrapped_type;
typedef nullable<T> wrapper_type; typedef nullable<T> wrapper_type;
// T can be const.
//
typedef
typename odb::details::meta::remove_const<T>::result
unrestricted_wrapped_type;
static const bool null_handler = true; static const bool null_handler = true;
static const bool null_default = true; static const bool null_default = true;
static bool static bool
get_null (const wrapper_type& n) get_null (const wrapper_type& n)
{ {
return n.null (); return n.null ();
} }
static void static void
skipping to change at line 140 skipping to change at line 164
{ {
n.reset (); n.reset ();
} }
static const wrapped_type& static const wrapped_type&
get_ref (const wrapper_type& n) get_ref (const wrapper_type& n)
{ {
return *n; return *n;
} }
static wrapped_type& static unrestricted_wrapped_type&
set_ref (wrapper_type& n) set_ref (wrapper_type& n)
{ {
if (n.null ()) if (n.null ())
n = T (); n = unrestricted_wrapped_type ();
return *n; return const_cast<unrestricted_wrapped_type&> (*n);
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_WRAPPER_TRAITS_HXX #endif // ODB_WRAPPER_TRAITS_HXX
 End of changes. 16 change blocks. 
10 lines changed or deleted 34 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/