answer.hxx   answer.hxx 
// file : odb/details/meta/answer.hxx // file : odb/details/meta/answer.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_DETAILS_META_ANSWER_HXX #ifndef ODB_DETAILS_META_ANSWER_HXX
#define ODB_DETAILS_META_ANSWER_HXX #define ODB_DETAILS_META_ANSWER_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 base.hxx   base.hxx 
// file : odb/details/shared-ptr/base.hxx // file : odb/details/shared-ptr/base.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_DETAILS_SHARED_PTR_BASE_HXX #ifndef ODB_DETAILS_SHARED_PTR_BASE_HXX
#define ODB_DETAILS_SHARED_PTR_BASE_HXX #define ODB_DETAILS_SHARED_PTR_BASE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <new> #include <new>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 base.ixx   base.ixx 
// file : odb/details/shared-ptr/base.ixx // file : odb/details/shared-ptr/base.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 details namespace details
{ {
// share // share
// //
inline share:: inline share::
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 base.txx   base.txx 
// file : odb/details/shared-ptr/base.txx // file : odb/details/shared-ptr/base.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/details/meta/answer.hxx> #include <odb/details/meta/answer.hxx>
#include <odb/details/meta/polymorphic-p.hxx> #include <odb/details/meta/polymorphic-p.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
{ {
namespace bits namespace bits
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 buffer.hxx   buffer.hxx 
// file : odb/details/buffer.hxx // file : odb/details/buffer.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_BUFFER_DETAILS_HXX #ifndef ODB_BUFFER_DETAILS_HXX
#define ODB_BUFFER_DETAILS_HXX #define ODB_BUFFER_DETAILS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <new> #include <new>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
skipping to change at line 52 skipping to change at line 52
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 (std::size_t capacity = 256)
: basic_buffer_base (capacity) : basic_buffer_base (capacity)
{ {
} }
T* T*
data () data ()
{ {
return static_cast<T*> (data_); return static_cast<T*> (data_);
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 1 lines changed or added


 cache-traits.hxx   cache-traits.hxx 
// file : odb/cache-traits.hxx // file : odb/cache-traits.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_CACHE_TRAITS_HXX #ifndef ODB_CACHE_TRAITS_HXX
#define ODB_CACHE_TRAITS_HXX #define ODB_CACHE_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#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>
#include <odb/no-op-cache-traits.hxx> #include <odb/no-op-cache-traits.hxx>
namespace odb namespace odb
{ {
// pointer_cache_traits // pointer_cache_traits
// //
// Caching traits for objects passed by pointer. P should be the canonica l // Caching traits for objects passed by pointer. P should be the canonica l
// pointer (non-const). // pointer (non-const).
// //
template <typename P, pointer_kind pk> template <typename P, typename S, pointer_kind pk>
struct pointer_cache_traits_impl struct pointer_cache_traits_impl
{ {
typedef P pointer_type; typedef P pointer_type;
typedef S session_type;
typedef odb::pointer_traits<pointer_type> pointer_traits; typedef odb::pointer_traits<pointer_type> pointer_traits;
typedef typename pointer_traits::element_type object_type; typedef typename pointer_traits::element_type object_type;
typedef typename object_traits<object_type>::id_type id_type; typedef typename object_traits<object_type>::id_type id_type;
typedef session::object_position<object_type> position_type; typedef typename session_type::template cache_position<object_type>
position_type;
struct insert_guard struct insert_guard
{ {
insert_guard () {} insert_guard () {}
insert_guard (const position_type& pos): pos_ (pos) {} insert_guard (const position_type& pos): pos_ (pos) {}
~insert_guard () {erase (pos_);} ~insert_guard () {session_type::_cache_erase (pos_);}
position_type const position_type&
position () const {return pos_;} position () const {return pos_;}
void void
release () {pos_.map_ = 0;} release () {pos_ = position_type ();}
// Note: doesn't call erase() on the old position (assumes not set). // Note: doesn't call erase() on the old position (assumes empty).
// //
void void
reset (const position_type& pos) {pos_ = pos;} reset (const position_type& pos) {pos_ = pos;}
private: private:
position_type pos_; position_type pos_;
}; };
// Cache management.
//
// We need the insert() overload with explicit id to handle self- // We need the insert() overload with explicit id to handle self-
// references. In such cases the object is not yet loaded and the // references. In such cases the object is not yet loaded and the
// id member does not contain the correct id. // 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 ()) return session_type::template _cache_insert<object_type> (db, id, p);
return session::current ().insert<object_type> (db, id, p);
else
return position_type ();
} }
static position_type static position_type
insert (odb::database& db, const pointer_type& p) insert (odb::database& db, const pointer_type& p)
{ {
const id_type& id ( const id_type& id (
object_traits<object_type>::id ( object_traits<object_type>::id (
pointer_traits::get_ref (p))); pointer_traits::get_ref (p)));
return insert (db, id, p); return session_type::template _cache_insert<object_type> (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 ()) return session_type::template _cache_find<object_type> (db, id);
return session::current ().find<object_type> (db, id);
else
return pointer_type ();
} }
static void static void
erase (odb::database& db, const id_type& id) erase (const position_type& p)
{ {
if (session::has_current ()) session_type::template _cache_erase<object_type> (p);
session::current ().erase<object_type> (db, id);
} }
// Notifications.
//
static void static void
erase (const position_type& p) persist (const position_type& p)
{
session_type::template _cache_persist<object_type> (p);
}
static void
load (const position_type& p)
{
session_type::template _cache_load<object_type> (p);
}
static void
update (odb::database& db, const object_type& obj)
{ {
if (p.map_ != 0) session_type::template _cache_update<object_type> (db, obj);
session::current ().erase<object_type> (p); }
static void
erase (odb::database& db, const id_type& id)
{
session_type::template _cache_erase<object_type> (db, id);
} }
}; };
// 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 S>
struct pointer_cache_traits_impl<P, pk_unique>: struct pointer_cache_traits_impl<P, S, pk_unique>:
no_op_pointer_cache_traits<P> {}; no_op_pointer_cache_traits<P> {};
template <typename P> template <typename P, typename S>
struct pointer_cache_traits: struct pointer_cache_traits:
pointer_cache_traits_impl<P, pointer_traits<P>::kind> {}; pointer_cache_traits_impl<P, S, pointer_traits<P>::kind> {};
// reference_cache_traits // reference_cache_traits
// //
// Caching traits for objects passed by reference. T should be the // Caching traits for objects passed by reference. T should be the
// canonical object type (non-const). Only if the object pointer // canonical object type (non-const). Only if the object pointer
// kind is raw do we add the object to the session. // kind is raw do we add the object to the session.
// //
template <typename T, pointer_kind pk> template <typename T, typename S, pointer_kind pk>
struct reference_cache_traits_impl: no_op_reference_cache_traits<T> {}; struct reference_cache_traits_impl: no_op_reference_cache_traits<T> {};
template <typename T> template <typename T, typename S>
struct reference_cache_traits_impl<T, pk_raw> struct reference_cache_traits_impl<T, S, pk_raw>
{ {
typedef T object_type; typedef T object_type;
typedef typename object_traits<object_type>::pointer_type pointer_type; typedef typename object_traits<object_type>::pointer_type pointer_type;
typedef typename object_traits<object_type>::id_type id_type; typedef typename object_traits<object_type>::id_type id_type;
typedef pointer_cache_traits<pointer_type> pointer_traits; typedef pointer_cache_traits<pointer_type, S> pointer_traits;
typedef typename pointer_traits::position_type position_type; typedef typename pointer_traits::position_type position_type;
typedef typename pointer_traits::insert_guard insert_guard; typedef typename pointer_traits::insert_guard insert_guard;
static position_type static position_type
insert (odb::database& db, const id_type& id, object_type& obj) insert (odb::database& db, const id_type& id, object_type& obj)
{ {
pointer_type p (&obj); pointer_type p (&obj);
return pointer_traits::insert (db, id, p); return pointer_traits::insert (db, id, p);
} }
static position_type static position_type
insert (odb::database& db, object_type& obj) insert (odb::database& db, object_type& obj)
{ {
pointer_type p (&obj); pointer_type p (&obj);
return pointer_traits::insert (db, p); return pointer_traits::insert (db, p);
} }
static void
persist (const position_type& p)
{
pointer_traits::persist (p);
}
static void
load (const position_type& p)
{
pointer_traits::load (p);
}
}; };
template <typename T> template <typename T, typename S>
struct reference_cache_traits: struct reference_cache_traits:
reference_cache_traits_impl< reference_cache_traits_impl<
T, pointer_traits<typename object_traits<T>::pointer_type>::kind> {}; T, S, pointer_traits<typename object_traits<T>::pointer_type>::kind> {};
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_CACHE_TRAITS_HXX #endif // ODB_CACHE_TRAITS_HXX
 End of changes. 26 change blocks. 
32 lines changed or deleted 60 lines changed or added


 callback.hxx   callback.hxx 
// file : odb/callback.hxx // file : odb/callback.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_CALLBACK_HXX #ifndef ODB_CALLBACK_HXX
#define ODB_CALLBACK_HXX #define ODB_CALLBACK_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> // odb::core
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
namespace odb namespace odb
{ {
struct LIBODB_EXPORT callback_event struct LIBODB_EXPORT callback_event
{ {
enum value enum value
{ {
pre_persist, pre_persist,
post_persist, post_persist,
skipping to change at line 35 skipping to change at line 36
post_erase post_erase
}; };
callback_event (value v): v_ (v) {} callback_event (value v): v_ (v) {}
operator value () const {return v_;} operator value () const {return v_;}
private: private:
value v_; value v_;
}; };
namespace core namespace common
{ {
using odb::callback_event; using odb::callback_event;
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_CALLBACK_HXX #endif // ODB_CALLBACK_HXX
 End of changes. 3 change blocks. 
2 lines changed or deleted 3 lines changed or added


 class-p.hxx   class-p.hxx 
// file : odb/details/meta/class-p.hxx // file : odb/details/meta/class-p.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_DETAILS_META_CLASS_HXX #ifndef ODB_DETAILS_META_CLASS_HXX
#define ODB_DETAILS_META_CLASS_HXX #define ODB_DETAILS_META_CLASS_HXX
#include <odb/pre.hxx> #include <odb/pre.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


 condition.hxx   condition.hxx 
// file : odb/details/condition.hxx // file : odb/details/condition.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_DETAILS_CONDITION_HXX #ifndef ODB_DETAILS_CONDITION_HXX
#define ODB_DETAILS_CONDITION_HXX #define ODB_DETAILS_CONDITION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> #include <odb/details/config.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 condition.ixx   condition.ixx 
// file : odb/details/posix/condition.ixx // file : odb/details/posix/condition.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/details/posix/exceptions.hxx> #include <odb/details/posix/exceptions.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
{ {
inline condition:: inline condition::
~condition () ~condition ()
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 config.h   config.h 
/* odb/details/config.h. Generated from config.h.in by configure. */ /* odb/details/config.h. Generated from config.h.in by configure. */
/* file : odb/details/config.h.in /* file : odb/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_DETAILS_CONFIG_H #ifndef ODB_DETAILS_CONFIG_H
#define ODB_DETAILS_CONFIG_H #define ODB_DETAILS_CONFIG_H
/* #undef ODB_THREADS_NONE */ /* #undef ODB_THREADS_NONE */
#define ODB_THREADS_POSIX 1 #define ODB_THREADS_POSIX 1
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 config.hxx   config.hxx 
// file : odb/details/config.hxx // file : odb/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_DETAILS_CONFIG_HXX #ifndef ODB_DETAILS_CONFIG_HXX
#define ODB_DETAILS_CONFIG_HXX #define ODB_DETAILS_CONFIG_HXX
// no pre // no pre
#ifdef _MSC_VER #ifdef _MSC_VER
# include <odb/details/config-vc.h> # include <odb/details/config-vc.h>
#elif defined(ODB_COMPILER) #elif defined(ODB_COMPILER)
# define ODB_THREADS_NONE # define ODB_THREADS_NONE
# define LIBODB_STATIC_LIB # define LIBODB_STATIC_LIB
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# define ODB_CXX11 # define ODB_CXX11
# if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 # if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
# define ODB_CXX_NULLPTR # define ODB_CXX_NULLPTR
# endif # endif
# define ODB_CXX11_DELETED_FUNCTION # define ODB_CXX11_DELETED_FUNCTION
# define ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR # define ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR
# define ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT # define ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
# define ODB_CXX11_VARIADIC_TEMPLATE
# define ODB_CXX11_INITIALIZER_LIST
# endif # endif
#else #else
# include <odb/details/config.h> # include <odb/details/config.h>
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L # if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
# define ODB_CXX11 # define ODB_CXX11
# ifdef __GNUC__ # ifdef __GNUC__
# if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 # if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6
# define ODB_CXX_NULLPTR # define ODB_CXX_NULLPTR
# endif # endif
# else # else
# define ODB_CXX_NULLPTR # define ODB_CXX_NULLPTR
# endif # endif
# define ODB_CXX11_DELETED_FUNCTION # define ODB_CXX11_DELETED_FUNCTION
# define ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR # define ODB_CXX11_EXPLICIT_CONVERSION_OPERATOR
# define ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT # define ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
# define ODB_CXX11_VARIADIC_TEMPLATE
# define ODB_CXX11_INITIALIZER_LIST
# endif # endif
#endif #endif
// no post // no post
#endif // ODB_DETAILS_CONFIG_HXX #endif // ODB_DETAILS_CONFIG_HXX
 End of changes. 3 change blocks. 
1 lines changed or deleted 5 lines changed or added


 connection.hxx   connection.hxx 
// file : odb/connection.hxx // file : odb/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_CONNECTION_HXX #ifndef ODB_CONNECTION_HXX
#define ODB_CONNECTION_HXX #define ODB_CONNECTION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <map>
#include <string> #include <string>
#include <cstddef> // std::size_t #include <memory> // std::auto_ptr, std::unique_ptr
#include <cstddef> // std::size_t
#include <typeinfo>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/traits.hxx>
#include <odb/query.hxx>
#include <odb/prepared-query.hxx>
#include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
#include <odb/details/c-string.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
class transaction_impl; class transaction_impl;
class connection; class connection;
typedef details::shared_ptr<connection> connection_ptr; typedef details::shared_ptr<connection> connection_ptr;
class LIBODB_EXPORT connection: public details::shared_base class LIBODB_EXPORT connection: public details::shared_base
skipping to change at line 53 skipping to change at line 61
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;
// 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 query<T>&);
template <typename T>
void
cache_query (const prepared_query<T>&);
template <typename T, typename P>
void
cache_query (const prepared_query<T>&, std::auto_ptr<P> params);
#ifdef ODB_CXX11
template <typename T, typename P>
void
cache_query (const prepared_query<T>&, std::unique_ptr<P> params);
#endif
template <typename T>
prepared_query<T>
lookup_query (const char* name) const;
template <typename T, typename P>
prepared_query<T>
lookup_query (const char* name, P*& params) const;
// SQL statement tracing. // SQL statement tracing.
// //
public: public:
typedef odb::tracer tracer_type; typedef odb::tracer tracer_type;
void void
tracer (tracer_type&); tracer (tracer_type&);
void void
tracer (tracer_type*); tracer (tracer_type*);
skipping to change at line 81 skipping to change at line 126
// the current() API. But that requires a TLS lookup, which can be // the current() API. But that requires a TLS lookup, which can be
// slow. // slow.
// //
tracer_type* tracer_type*
transaction_tracer () const; transaction_tracer () const;
public: public:
virtual virtual
~connection (); ~connection ();
// Recycle the connection to be used by another thread. This call
// invalidates uncached prepared queries.
//
void
recycle ();
protected: protected:
connection (database_type&); connection (database_type&);
template <typename T,
database_id DB,
class_kind kind = class_traits<T>::kind>
struct query_;
virtual void
cache_query_ (prepared_query_impl* pq,
const std::type_info& ti,
void* params,
const std::type_info* params_info,
void (*params_deleter) (void*));
prepared_query_impl*
lookup_query_ (const char* name,
const std::type_info& ti,
void** params, // out
const std::type_info* params_info) const;
template <typename P>
static void
params_deleter (void*);
private: private:
connection (const connection&); connection (const connection&);
connection& operator= (const connection&); connection& operator= (const connection&);
// Prepared query cache.
//
protected:
struct prepared_entry_type
{
details::shared_ptr<prepared_query_impl> prep_query;
const std::type_info* type_info;
void* params;
const std::type_info* params_info;
void (*params_deleter) (void*);
};
typedef
std::map<const char*, prepared_entry_type, details::c_string_comparator
>
prepared_map_type;
prepared_map_type prepared_map_;
void
clear_prepared_map ();
protected: protected:
database_type& database_; database_type& database_;
tracer_type* tracer_; tracer_type* tracer_;
// Active query result list.
//
protected:
friend class result_impl;
result_impl* results_;
void
invalidate_results ();
// Prepared but uncached query list (cached ones are stored in
// prepared_map_).
//
protected:
friend class prepared_query_impl;
prepared_query_impl* prepared_queries_;
protected: protected:
friend class transaction; friend class transaction;
tracer_type* transaction_tracer_; tracer_type* transaction_tracer_;
}; };
} }
#include <odb/connection.ixx> #include <odb/connection.ixx>
#include <odb/connection.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_MYSQL_CONNECTION_HXX #endif // ODB_MYSQL_CONNECTION_HXX
 End of changes. 12 change blocks. 
2 lines changed or deleted 114 lines changed or added


 connection.ixx   connection.ixx 
// file : odb/connection.ixx // file : odb/connection.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 <cstring> // std::string #include <cstring> // std::string
#include <cassert>
namespace odb namespace odb
{ {
inline connection:: inline connection::
connection (database_type& database) connection (database_type& database)
: database_ (database), tracer_ (0), transaction_tracer_ (0) : database_ (database),
tracer_ (0),
results_ (0),
prepared_queries_ (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::
skipping to change at line 33 skipping to change at line 38
{ {
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 ());
} }
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const char* q)
{
return prepare_query<T> (n, query<T> (q));
}
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const std::string& q)
{
return prepare_query<T> (n, query<T> (q));
}
template <typename T>
inline prepared_query<T> connection::
prepare_query (const char* n, const query<T>& q)
{
return query_<T, id_common>::call (*this, n, q);
}
template <typename T>
inline void connection::
cache_query (const prepared_query<T>& pq)
{
assert (pq);
cache_query_ (pq.impl_, typeid (T), 0, 0, 0);
}
template <typename T, typename P>
inline void connection::
cache_query (const prepared_query<T>& pq, std::auto_ptr<P> params)
{
assert (pq);
assert (params.get () != 0);
cache_query_ (
pq.impl_, typeid (T), params.get (), &typeid (P), &params_deleter<P>)
;
params.release ();
}
#ifdef ODB_CXX11
template <typename T, typename P>
inline void connection::
cache_query (const prepared_query<T>& pq, std::unique_ptr<P> params)
{
assert (pq);
assert (params);
cache_query_ (
pq.impl_, typeid (T), params.get (), &typeid (P), &params_deleter<P>)
;
params.release ();
}
#endif
template <typename T>
inline prepared_query<T> connection::
lookup_query (const char* name) const
{
return prepared_query<T> (lookup_query_ (name, typeid (T), 0, 0));
}
template <typename T, typename P>
inline prepared_query<T> connection::
lookup_query (const char* name, P*& params) const
{
return prepared_query<T> (
lookup_query_ (name,
typeid (T),
reinterpret_cast<void**> (&params),
&typeid (P)));
}
inline void connection:: inline void connection::
tracer (tracer_type& t) tracer (tracer_type& t)
{ {
tracer_ = &t; tracer_ = &t;
} }
inline void connection:: inline void connection::
tracer (tracer_type* t) tracer (tracer_type* t)
{ {
tracer_ = t; tracer_ = t;
 End of changes. 4 change blocks. 
2 lines changed or deleted 80 lines changed or added


 container-traits.hxx   container-traits.hxx 
// file : odb/container-traits.hxx // file : odb/container-traits.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_CONTAINER_TRAITS_HXX #ifndef ODB_CONTAINER_TRAITS_HXX
#define ODB_CONTAINER_TRAITS_HXX #define ODB_CONTAINER_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
skipping to change at line 49 skipping to change at line 49
// order is not preserved, then the index argument in the functions // order is not preserved, then the index argument in the functions
// below is not used. // below is not used.
// //
bool bool
ordered () const ordered () const
{ {
return ordered_; return ordered_;
} }
void void
insert_one (I index, const V& value) const insert (I index, const V& value) const
{ {
insert_one_ (index, value, data_); insert_ (index, value, data_);
} }
bool bool
load_all (I& next_index, V& next_value) const select (I& next_index, V& next_value) const
{ {
return load_all_ (next_index, next_value, data_); return select_ (next_index, next_value, data_);
} }
void void
delete_all () const delete_ () const
{ {
delete_all_ (data_); delete__ (data_);
} }
// Implementation details. // Implementation details.
// //
public: public:
typedef void (*insert_one_type) (I, const V&, void*); ordered_functions (void* data): data_ (data) {}
typedef bool (*load_all_type) (I&, V&, void*);
typedef void (*delete_all_type) (void*);
ordered_functions (void* data, public:
insert_one_type io, void* data_;
load_all_type la, bool ordered_;
delete_all_type da)
: data_ (data), insert_one_ (io), load_all_ (la), delete_all_ (da) void (*insert_) (I, const V&, void*);
bool (*select_) (I&, V&, void*);
void (*delete__) (void*);
};
template <typename I, typename V>
struct smart_ordered_functions
{
typedef I index_type;
typedef V value_type;
void
insert (I index, const V& value) const
{
insert_ (index, value, data_);
}
bool
select (I& next_index, V& next_value) const
{
return select_ (next_index, next_value, data_);
}
void
update (I index, const V& value) const
{ {
update_ (index, value, data_);
} }
// Delete all the elements starting with the specified index. To
// delete everything, pass 0.
//
void void
ordered (bool v) delete_ (I start_index) const
{ {
ordered_ = v; delete__ (start_index, data_);
} }
private: // Implementation details.
//
public:
smart_ordered_functions (void* data) : data_ (data) {}
public:
void* data_; void* data_;
bool ordered_;
insert_one_type insert_one_; void (*insert_) (I, const V&, void*);
load_all_type load_all_; bool (*select_) (I&, V&, void*);
delete_all_type delete_all_; void (*update_) (I, const V&, void*);
void (*delete__) (I, void*);
}; };
// Set/multiset containers. // Set/multiset containers.
// //
template <typename V> template <typename V>
struct set_functions struct set_functions
{ {
typedef V value_type; typedef V value_type;
void void
insert_one (const V& value) const insert (const V& value) const
{ {
insert_one_ (value, data_); insert_ (value, data_);
} }
bool bool
load_all (V& next_value) const select (V& next_value) const
{ {
return load_all_ (next_value, data_); return select_ (next_value, data_);
} }
void void
delete_all () const delete_ () const
{ {
delete_all_ (data_); delete__ (data_);
} }
// Implementation details. // Implementation details.
// //
public: public:
typedef void (*insert_one_type) (const V&, void*); set_functions (void* data): data_ (data) {}
typedef bool (*load_all_type) (V&, void*);
typedef void (*delete_all_type) (void*);
set_functions (void* data, public:
insert_one_type io,
load_all_type la,
delete_all_type da)
: data_ (data), insert_one_ (io), load_all_ (la), delete_all_ (da)
{
}
private:
void* data_; void* data_;
insert_one_type insert_one_;
load_all_type load_all_; void (*insert_) (const V&, void*);
delete_all_type delete_all_; bool (*select_) (V&, void*);
void (*delete__) (void*);
}; };
// Map/multimap containers. // Map/multimap containers.
// //
template <typename K, typename V> template <typename K, typename V>
struct map_functions struct map_functions
{ {
typedef K key_type; typedef K key_type;
typedef V value_type; typedef V value_type;
void void
insert_one (const K& key, const V& value) const insert (const K& key, const V& value) const
{ {
insert_one_ (key, value, data_); insert_ (key, value, data_);
} }
bool bool
load_all (K& next_key, V& next_value) const select (K& next_key, V& next_value) const
{ {
return load_all_ (next_key, next_value, data_); return select_ (next_key, next_value, data_);
} }
void void
delete_all () const delete_ () const
{ {
delete_all_ (data_); delete__ (data_);
} }
// Implementation details. // Implementation details.
// //
public: public:
typedef void (*insert_one_type) (const K&, const V&, void*); map_functions (void* data): data_ (data) {}
typedef bool (*load_all_type) (K&, V&, void*);
typedef void (*delete_all_type) (void*);
map_functions (void* data, public:
insert_one_type io,
load_all_type la,
delete_all_type da)
: data_ (data), insert_one_ (io), load_all_ (la), delete_all_ (da)
{
}
private:
void* data_; void* data_;
insert_one_type insert_one_;
load_all_type load_all_; void (*insert_) (const K&, const V&, void*);
delete_all_type delete_all_; bool (*select_) (K&, V&, void*);
void (*delete__) (void*);
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#include <odb/std-map-traits.hxx> #include <odb/std-map-traits.hxx>
#include <odb/std-set-traits.hxx> #include <odb/std-set-traits.hxx>
#include <odb/std-list-traits.hxx> #include <odb/std-list-traits.hxx>
#include <odb/std-vector-traits.hxx> #include <odb/std-vector-traits.hxx>
 End of changes. 33 change blocks. 
64 lines changed or deleted 78 lines changed or added


 core.hxx   core.hxx 
// file : odb/core.hxx // file : odb/core.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_CORE_HXX #ifndef ODB_CORE_HXX
#define ODB_CORE_HXX #define ODB_CORE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#ifdef ODB_COMPILER #ifdef ODB_COMPILER
# define PRAGMA_DB_IMPL(x) _Pragma (#x) # define PRAGMA_DB_IMPL(x) _Pragma (#x)
# define PRAGMA_DB(x) PRAGMA_DB_IMPL (db x) # define PRAGMA_DB(x) PRAGMA_DB_IMPL (db x)
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 counter-type.hxx   counter-type.hxx 
// file : odb/details/shared-ptr/counter-type.hxx // file : odb/details/shared-ptr/counter-type.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_DETAILS_SHARED_PTR_COUNTER_TYPE_HXX #ifndef ODB_DETAILS_SHARED_PTR_COUNTER_TYPE_HXX
#define ODB_DETAILS_SHARED_PTR_COUNTER_TYPE_HXX #define ODB_DETAILS_SHARED_PTR_COUNTER_TYPE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 database.hxx   database.hxx 
// file : odb/database.hxx // file : odb/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_DATABASE_HXX #ifndef ODB_DATABASE_HXX
#define ODB_DATABASE_HXX #define ODB_DATABASE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> // ODB_CXX11
#include <map>
#include <string> #include <string>
#include <memory> // std::auto_ptr, std::unique_ptr
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#ifdef ODB_CXX11
# include <functional> // std::function
#endif
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/query.hxx> #include <odb/query.hxx>
#include <odb/prepared-query.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/connection.hxx> #include <odb/connection.hxx>
#include <odb/exceptions.hxx> #include <odb/exceptions.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
#include <odb/details/c-string.hxx>
namespace odb namespace odb
{ {
class transaction_impl; class transaction_impl;
class LIBODB_EXPORT database class LIBODB_EXPORT database
{ {
public: public:
virtual virtual
~database (); ~database ();
skipping to change at line 66 skipping to change at line 76
persist (P<T>& obj_ptr); persist (P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
typename object_traits<T>::id_type typename object_traits<T>::id_type
persist (P<T, A1>& obj_ptr); persist (P<T, A1>& obj_ptr);
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& obj_ptr); persist (const typename object_traits<T>::pointer_type& obj_ptr);
// Throw object_not_persistent if not found. // Load an object. 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);
// Reload an object.
//
template <typename T> template <typename T>
void void
reload (T& object); reload (T& object);
template <typename T> template <typename T>
void void
reload (T* obj_ptr); reload (T* obj_ptr);
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
void void
skipping to change at line 104 skipping to change at line 116
reload (P<T>& obj_ptr); reload (P<T>& obj_ptr);
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
void void
reload (P<T, A1>& obj_ptr); reload (P<T, A1>& obj_ptr);
template <typename T> template <typename T>
void void
reload (const typename object_traits<T>::pointer_type& obj_ptr); reload (const typename object_traits<T>::pointer_type& obj_ptr);
// Return NULL/false if not found. // Loan an object if 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);
// Update the state of a modified objects. // Update the state of a modified objects.
skipping to change at line 215 skipping to change at line 227
query (const char*, bool cache = true); query (const char*, bool cache = true);
template <typename T> template <typename T>
result<T> result<T>
query (const std::string&, bool cache = true); query (const std::string&, bool cache = true);
template <typename T> template <typename T>
result<T> result<T>
query (const odb::query<T>&, bool cache = true); query (const odb::query<T>&, bool cache = true);
// 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 odb::query<T>&);
template <typename T>
void
cache_query (const prepared_query<T>&);
template <typename T, typename P>
void
cache_query (const prepared_query<T>&, std::auto_ptr<P> params);
#ifdef ODB_CXX11
template <typename T, typename P>
void
cache_query (const prepared_query<T>&, std::unique_ptr<P> params);
#endif
template <typename T>
prepared_query<T>
lookup_query (const char* name) const;
template <typename T, typename P>
prepared_query<T>
lookup_query (const char* name, P*& params) const;
// Prepared query factory.
//
public:
typedef odb::connection connection_type;
#ifdef ODB_CXX11
typedef
std::function<void (const char*, connection_type&)>
query_factory_type;
#else
typedef void (*query_factory_type) (const char*, connection_type&);
#endif
void
query_factory (const char* name, query_factory_type);
query_factory_type
lookup_query_factory (const char* name) const;
// Native database statement execution. // Native database statement execution.
// //
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);
unsigned long long unsigned long long
skipping to change at line 253 skipping to change at line 320
void void
tracer (tracer_type&); tracer (tracer_type&);
void void
tracer (tracer_type*); tracer (tracer_type*);
tracer_type* tracer_type*
tracer () const; tracer () const;
// Database id.
//
public:
database_id
id () const;
protected: protected:
database (); database (database_id);
private: private:
database (const database&); database (const database&);
database& operator= (const database&); database& operator= (const database&);
protected: protected:
typedef odb::connection connection_type;
virtual connection_type* virtual connection_type*
connection_ () = 0; connection_ () = 0;
protected: protected:
template <typename T> template <typename T, database_id DB>
typename object_traits<T>::id_type
persist_ (T&);
template <typename T, database_id DB>
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&);
template <typename T> template <typename T, database_id DB>
typename object_traits<T>::pointer_type
load_ (const typename object_traits<T>::id_type&);
template <typename T, database_id DB>
void
load_ (const typename object_traits<T>::id_type&, T&);
template <typename T, database_id DB>
void
reload_ (T&);
template <typename T, database_id DB>
typename object_traits<T>::pointer_type
find_ (const typename object_traits<T>::id_type&);
template <typename T, database_id DB>
bool
find_ (const typename object_traits<T>::id_type&, T&);
template <typename T, database_id DB>
void
update_ (T&);
template <typename T, database_id DB>
void void
update_ (const typename object_traits<T>::pointer_type&); update_ (const typename object_traits<T>::pointer_type&);
template <typename T> template <typename T, database_id DB>
void
erase_ (const typename object_traits<T>::id_type&);
template <typename T, database_id DB>
void
erase_ (T&);
template <typename T, database_id DB>
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,
database_id DB,
class_kind kind = class_traits<T>::kind>
struct query_; struct query_;
protected: protected:
typedef
std::map<const char*, query_factory_type, details::c_string_comparator>
query_factory_map;
database_id id_;
tracer_type* tracer_; tracer_type* tracer_;
query_factory_map query_factory_map_;
}; };
} }
#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. 19 change blocks. 
10 lines changed or deleted 125 lines changed or added


 database.ixx   database.ixx 
// file : odb/database.ixx // file : odb/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 <cstring> // std::strlen() #include <cstring> // std::strlen()
#include <utility> // std::move
#include <odb/transaction.hxx>
namespace odb namespace odb
{ {
inline database:: inline database::
database () database (database_id id)
: tracer_ (0) : id_ (id), tracer_ (0)
{
}
inline database_id database::
id () const
{ {
return id_;
} }
inline connection_ptr database:: inline connection_ptr database::
connection () connection ()
{ {
return connection_ptr (connection_ ()); return connection_ptr (connection_ ());
} }
inline void database:: inline void database::
query_factory (const char* name, query_factory_type f)
{
if (f)
#ifdef ODB_CXX11
query_factory_map_[name] = std::move (f);
#else
query_factory_map_[name] = f;
#endif
else
query_factory_map_.erase (name);
}
inline database::query_factory_type database::
lookup_query_factory (const char* name) const
{
query_factory_map::const_iterator i (query_factory_map_.find (name));
if (i == query_factory_map_.end ())
i = query_factory_map_.find (""); // Wildcard factory.
return i != query_factory_map_.end ()
? i->second
: database::query_factory_type ();
}
inline void database::
tracer (tracer_type& t) tracer (tracer_type& t)
{ {
tracer_ = &t; tracer_ = &t;
} }
inline void database:: inline void database::
tracer (tracer_type* t) tracer (tracer_type* t)
{ {
tracer_ = t; tracer_ = t;
} }
inline database::tracer_type* database:: inline database::tracer_type* database::
tracer () const tracer () const
{ {
return tracer_; 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& obj)
{
return persist_<T, id_common> (obj);
}
template <typename T>
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.
// //
const object_pointer& pobj (p); const object_pointer& pobj (p);
return persist_<T> (pobj); return persist_<T, id_common> (pobj);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
inline typename object_traits<T>::id_type database:: inline typename object_traits<T>::id_type database::
persist (const P<T>& p) persist (const P<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);
return persist_<T> (pobj); return persist_<T, id_common> (pobj);
} }
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
inline typename object_traits<T>::id_type database:: inline typename object_traits<T>::id_type database::
persist (const P<T, A1>& p) persist (const P<T, A1>& 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);
return persist_<T> (pobj); return persist_<T, id_common> (pobj);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
inline typename object_traits<T>::id_type database:: inline typename object_traits<T>::id_type database::
persist (P<T>& p) persist (P<T>& p)
{ {
const P<T>& cr (p); const P<T>& cr (p);
return persist<T, P> (cr); return persist<T, P> (cr);
} }
skipping to change at line 104 skipping to change at line 146
persist (P<T, A1>& p) persist (P<T, A1>& p)
{ {
const P<T, A1>& cr (p); const P<T, A1>& cr (p);
return persist<T, A1, P> (cr); return persist<T, A1, P> (cr);
} }
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, id_common> (pobj);
} }
template <typename T> template <typename T>
inline typename object_traits<T>::pointer_type database:: inline typename object_traits<T>::pointer_type database::
find (const typename object_traits<T>::id_type& id) load (const typename object_traits<T>::id_type& id)
{ {
// T is always object_type. return load_<T, id_common> (id);
// }
// Compiler error pointing here? Perhaps the object doesn't have the template <typename T>
// default constructor? inline void database::
// load (const typename object_traits<T>::id_type& id, T& obj)
return object_traits<T>::find (*this, id); {
return load_<T, id_common> (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_common> (id);
} }
template <typename T> template <typename T>
inline bool database:: inline bool database::
find (const typename object_traits<T>::id_type& id, T& obj) find (const typename object_traits<T>::id_type& id, T& obj)
{ {
// T is always object_type. return find_<T, id_common> (id, obj);
// }
return object_traits<T>::find (*this, id, obj);
template <typename T>
inline void database::
reload (T& obj)
{
reload_<T, id_common> (obj);
} }
template <typename T> template <typename T>
inline void database:: inline void database::
reload (T* p) reload (T* p)
{ {
reload<T> (*p); reload<T> (*p);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
skipping to change at line 175 skipping to change at line 230
inline void database:: inline void database::
reload (const typename object_traits<T>::pointer_type& pobj) reload (const typename object_traits<T>::pointer_type& pobj)
{ {
typedef typename object_traits<T>::pointer_type pointer_type; typedef typename object_traits<T>::pointer_type pointer_type;
reload (odb::pointer_traits<pointer_type>::get_ref (pobj)); reload (odb::pointer_traits<pointer_type>::get_ref (pobj));
} }
template <typename T> template <typename T>
inline void database:: inline void database::
update (T& obj)
{
update_<T, id_common> (obj);
}
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);
update_<T> (pobj); update_<T, id_common> (pobj);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
inline void database:: inline void database::
update (const P<T>& p) update (const P<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);
update_<T> (pobj); update_<T, id_common> (pobj);
} }
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
inline void database:: inline void database::
update (const P<T, A1>& p) update (const P<T, A1>& 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);
update_<T> (pobj); update_<T, id_common> (pobj);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
inline void database:: inline void database::
update (P<T>& p) update (P<T>& p)
{ {
const P<T>& cr (p); const P<T>& cr (p);
update<T, P> (cr); update<T, P> (cr);
} }
skipping to change at line 238 skipping to change at line 300
update (P<T, A1>& p) update (P<T, A1>& p)
{ {
const P<T, A1>& cr (p); const P<T, A1>& cr (p);
update<T, A1, P> (cr); update<T, A1, P> (cr);
} }
template <typename T> template <typename T>
inline void database:: inline void database::
update (const typename object_traits<T>::pointer_type& pobj) update (const typename object_traits<T>::pointer_type& pobj)
{ {
update_<T> (pobj); update_<T, id_common> (pobj);
} }
template <typename T> template <typename T>
inline void database:: inline void database::
update (T& obj) erase (const typename object_traits<T>::id_type& id)
{ {
// T can be const T while object_type will always be T. return erase_<T, id_common> (id);
//
typedef typename odb::object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits;
// 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);
} }
template <typename T> template <typename T>
inline void database:: inline void database::
update_ (const typename object_traits<T>::pointer_type& pobj) erase (T& obj)
{ {
// T can be const T while object_type will always be T. return erase_<T, id_common> (obj);
//
typedef typename odb::object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits;
typedef typename odb::object_traits<T>::pointer_type pointer_type;
typedef odb::pointer_traits<pointer_type> pointer_traits;
T& obj (pointer_traits::get_ref (pobj));
// 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);
} }
template <typename T> template <typename T>
inline void database:: inline void database::
erase (T* p) erase (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);
erase_<T> (pobj); erase_<T, id_common> (pobj);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
inline void database:: inline void database::
erase (const P<T>& p) erase (const P<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);
erase_<T> (pobj); erase_<T, id_common> (pobj);
} }
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
inline void database:: inline void database::
erase (const P<T, A1>& p) erase (const P<T, A1>& 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);
erase_<T> (pobj); erase_<T, id_common> (pobj);
} }
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
inline void database:: inline void database::
erase (P<T>& p) erase (P<T>& p)
{ {
const P<T>& cr (p); const P<T>& cr (p);
erase<T, P> (cr); erase<T, P> (cr);
} }
skipping to change at line 341 skipping to change at line 382
erase (P<T, A1>& p) erase (P<T, A1>& p)
{ {
const P<T, A1>& cr (p); const P<T, A1>& cr (p);
erase<T, A1, P> (cr); erase<T, A1, P> (cr);
} }
template <typename T> template <typename T>
inline void database:: inline void database::
erase (const typename object_traits<T>::pointer_type& pobj) erase (const typename object_traits<T>::pointer_type& pobj)
{ {
erase_<T> (pobj); erase_<T, id_common> (pobj);
}
template <typename T>
inline void database::
erase_ (const typename object_traits<T>::pointer_type& pobj)
{
typedef typename object_traits<T>::pointer_type pointer_type;
typedef pointer_traits<pointer_type> pointer_traits;
erase<T> (pointer_traits::get_ref (pobj));
}
template <typename T>
inline void database::
erase (const typename object_traits<T>::id_type& id)
{
// T is always object_type.
//
object_traits<T>::erase (*this, id);
}
template <typename T>
inline void database::
erase (T& obj)
{
// T can be const T while object_type will always be T.
//
typedef typename object_traits<T>::object_type object_type;
object_traits<object_type>::erase (*this, obj);
} }
template <typename T> template <typename T>
inline unsigned long long database:: inline unsigned long long database::
erase_query () erase_query ()
{ {
// T is always object_type. // T is always object_type.
// //
return erase_query<T> (odb::query<T> ()); return erase_query<T> (odb::query<T> ());
} }
skipping to change at line 407 skipping to change at line 418
// //
return erase_query<T> (odb::query<T> (q)); return erase_query<T> (odb::query<T> (q));
} }
template <typename T> template <typename T>
inline unsigned long long database:: inline 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.
// //
return object_traits<T>::erase_query (*this, q); return object_traits_impl<T, id_common>::erase_query (*this, q);
} }
template <typename T> template <typename T>
inline result<T> database:: inline result<T> database::
query (bool cache) query (bool cache)
{ {
return query<T> (odb::query<T> (), cache); return query<T> (odb::query<T> (), cache);
} }
template <typename T> template <typename T>
skipping to change at line 431 skipping to change at line 442
return query<T> (odb::query<T> (q), cache); return query<T> (odb::query<T> (q), cache);
} }
template <typename T> template <typename T>
inline result<T> database:: inline result<T> database::
query (const std::string& q, bool cache) query (const std::string& q, bool cache)
{ {
return query<T> (odb::query<T> (q), cache); return query<T> (odb::query<T> (q), cache);
} }
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const char* q)
{
return prepare_query<T> (n, odb::query<T> (q));
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const std::string& q)
{
return prepare_query<T> (n, odb::query<T> (q));
}
template <typename T>
inline prepared_query<T> database::
prepare_query (const char* n, const odb::query<T>& q)
{
connection_type& c (transaction::current ().connection ());
return c.prepare_query (n, q);
}
template <typename T>
inline void database::
cache_query (const prepared_query<T>& pq)
{
connection_type& c (transaction::current ().connection ());
c.cache_query (pq);
}
template <typename T, typename P>
inline void database::
cache_query (const prepared_query<T>& pq, std::auto_ptr<P> params)
{
connection_type& c (transaction::current ().connection ());
c.cache_query (pq, params);
}
#ifdef ODB_CXX11
template <typename T, typename P>
inline void database::
cache_query (const prepared_query<T>& pq, std::unique_ptr<P> params)
{
connection_type& c (transaction::current ().connection ());
c.cache_query (pq, std::move (params));
}
#endif
template <typename T>
inline prepared_query<T> database::
lookup_query (const char* name) const
{
connection_type& c (transaction::current ().connection ());
return c.lookup_query<T> (name);
}
template <typename T, typename P>
inline prepared_query<T> database::
lookup_query (const char* name, P*& params) const
{
connection_type& c (transaction::current ().connection ());
return c.lookup_query<T, P> (name, params);
}
// Implementations (i.e., the *_() functions).
//
template <typename T, database_id DB>
inline typename object_traits<T>::pointer_type database::
find_ (const typename object_traits<T>::id_type& id)
{
// T is always object_type.
//
// Compiler error pointing here? Perhaps the object doesn't have the
// default constructor?
//
return object_traits_impl<T, DB>::find (*this, id);
}
template <typename T, database_id DB>
inline bool database::
find_ (const typename object_traits<T>::id_type& id, T& obj)
{
// T is always object_type.
//
return object_traits_impl<T, DB>::find (*this, id, obj);
}
template <typename T, database_id DB>
inline void database::
update_ (T& obj)
{
// T can be const T while object_type will always be T.
//
typedef typename object_traits<T>::object_type object_type;
// Compiler error pointing here? Perhaps the object is readonly or
// doesn't have an object id? Such objects cannot be updated.
//
object_traits_impl<object_type, DB>::update (*this, obj);
}
template <typename T, database_id DB>
inline void database::
update_ (const typename object_traits<T>::pointer_type& pobj)
{
// T can be const T while object_type will always be T.
//
typedef typename object_traits<T>::object_type object_type;
typedef typename object_traits<T>::pointer_type pointer_type;
T& obj (pointer_traits<pointer_type>::get_ref (pobj));
// Compiler error pointing here? Perhaps the object is readonly or
// doesn't have an object id? Such objects cannot be updated.
//
object_traits_impl<object_type, DB>::update (*this, obj);
}
template <typename T, database_id DB>
inline void database::
erase_ (const typename object_traits<T>::id_type& id)
{
// T is always object_type.
//
object_traits_impl<T, DB>::erase (*this, id);
}
template <typename T, database_id DB>
inline void database::
erase_ (T& obj)
{
// T can be const T while object_type will always be T.
//
typedef typename object_traits<T>::object_type object_type;
object_traits_impl<object_type, DB>::erase (*this, obj);
}
template <typename T, database_id DB>
inline void database::
erase_ (const typename object_traits<T>::pointer_type& pobj)
{
typedef typename object_traits<T>::pointer_type pointer_type;
erase_<T, DB> (pointer_traits<pointer_type>::get_ref (pobj));
}
// execute()
//
inline unsigned long long database:: inline unsigned long long database::
execute (const char* statement) execute (const char* statement)
{ {
return execute (statement, std::strlen (statement)); return execute (statement, std::strlen (statement));
} }
inline unsigned long long database:: inline unsigned long long database::
execute (const std::string& statement) execute (const std::string& statement)
{ {
return execute (statement.c_str (), statement.size ()); return execute (statement.c_str (), statement.size ());
 End of changes. 29 change blocks. 
81 lines changed or deleted 242 lines changed or added


 database.txx   database.txx 
// file : odb/database.txx // file : odb/database.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/exceptions.hxx> #include <odb/exceptions.hxx>
#include <odb/transaction.hxx>
#include <odb/no-op-cache-traits.hxx> #include <odb/no-op-cache-traits.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
result<T> database::
query (const odb::query<T>& q, bool cache)
{
// T is always object_type. We also don't need to check for transaction
// here; object_traits::query () does this.
//
result<T> r (query_<T, id_common>::call (*this, q));
if (cache)
r.cache ();
return r;
}
// Implementations (i.e., the *_() functions).
//
template <typename T, database_id DB>
typename object_traits<T>::id_type database:: typename object_traits<T>::id_type database::
persist (T& obj) persist_ (T& obj)
{ {
// 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 object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits; typedef object_traits_impl<object_type, DB> object_traits;
object_traits::persist (*this, obj); object_traits::persist (*this, obj);
object_traits::reference_cache_traits::insert ( typename object_traits::reference_cache_traits::position_type p (
*this, reference_cache_type<T>::convert (obj)); object_traits::reference_cache_traits::insert (
*this, reference_cache_type<T>::convert (obj)));
object_traits::reference_cache_traits::persist (p);
return object_traits::id (obj); return object_traits::id (obj);
} }
template <typename T> template <typename T, database_id DB>
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 object_traits<T>::object_type object_type;
typedef odb::object_traits<object_type> object_traits; typedef typename object_traits<T>::pointer_type pointer_type;
typedef typename odb::object_traits<T>::pointer_type pointer_type; typedef object_traits_impl<object_type, DB> object_traits;
typedef odb::pointer_traits<pointer_type> pointer_traits;
T& obj (pointer_traits::get_ref (pobj)); T& obj (pointer_traits<pointer_type>::get_ref (pobj));
object_traits::persist (*this, obj); object_traits::persist (*this, obj);
// Get the canonical object pointer and insert it into object cache. // Get the canonical object pointer and insert it into object cache.
// //
object_traits::pointer_cache_traits::insert ( typename object_traits::pointer_cache_traits::position_type p (
*this, pointer_cache_type<pointer_type>::convert (pobj)); object_traits::pointer_cache_traits::insert (
*this, pointer_cache_type<pointer_type>::convert (pobj)));
object_traits::pointer_cache_traits::persist (p);
return object_traits::id (obj); return object_traits::id (obj);
} }
template <typename T> template <typename T, database_id DB>
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;
pointer_type r (find<T> (id)); pointer_type r (find_<T, DB> (id));
if (pointer_traits::null_ptr (r)) if (pointer_traits<pointer_type>::null_ptr (r))
throw object_not_persistent (); throw object_not_persistent ();
return r; return r;
} }
template <typename T> template <typename T, database_id DB>
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, DB> (id, obj))
throw object_not_persistent (); throw object_not_persistent ();
} }
template <typename T> template <typename T, database_id DB>
void database:: void database::
reload (T& obj) reload_ (T& obj)
{ {
// T should be object_type (cannot be const). // T should be object_type (cannot be const). We also don't need to
// check for transaction here; object_traits::reload () does this.
// //
typedef odb::object_traits<T> object_traits; if (!object_traits_impl<T, DB>::reload (*this, obj))
// We don't need to check for transaction here;
// object_traits::reload () does this.
if (!object_traits::reload (*this, obj))
throw object_not_persistent (); throw object_not_persistent ();
} }
template <typename T> template <typename T, database_id DB>
struct database::query_<T, class_object> struct database::query_<T, DB, class_object>
{ {
template <typename Q>
static result<T> static result<T>
call (database& db, const odb::query<T>& q) call (database& db, const Q& q)
{ {
return object_traits<T>::query (db, q); return object_traits_impl<T, DB>::query (db, q);
} }
}; };
template <typename T> template <typename T, database_id DB>
struct database::query_<T, class_view> struct database::query_<T, DB, class_view>
{ {
template <typename Q>
static result<T> static result<T>
call (database& db, const odb::query<T>& q) call (database& db, const Q& q)
{ {
return view_traits<T>::query (db, q); return view_traits_impl<T, DB>::query (db, q);
} }
}; };
template <typename T>
result<T> database::
query (const odb::query<T>& q, bool cache)
{
// T is always object_type.
//
// We don't need to check for transaction here;
// object_traits::query () does this.
result<T> r (query_<T, class_traits<T>::kind>::call (*this, q));
if (cache)
r.cache ();
return r;
}
} }
 End of changes. 32 change blocks. 
58 lines changed or deleted 58 lines changed or added


 exception.hxx   exception.hxx 
// file : odb/exception.hxx // file : odb/exception.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_EXCEPTION_HXX #ifndef ODB_EXCEPTION_HXX
#define ODB_EXCEPTION_HXX #define ODB_EXCEPTION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <exception> #include <exception>
#include <odb/forward.hxx> // odb::core
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
namespace odb namespace odb
{ {
struct LIBODB_EXPORT exception: std::exception struct LIBODB_EXPORT exception: std::exception
{ {
virtual const char* virtual const char*
what () const throw () = 0; what () const throw () = 0;
}; };
namespace core namespace common
{ {
using odb::exception; using odb::exception;
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_EXCEPTION_HXX #endif // ODB_EXCEPTION_HXX
 End of changes. 3 change blocks. 
2 lines changed or deleted 3 lines changed or added


 exceptions.hxx   exceptions.hxx 
// file : odb/exceptions.hxx // file : odb/exceptions.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_EXCEPTIONS_HXX #ifndef ODB_EXCEPTIONS_HXX
#define ODB_EXCEPTIONS_HXX #define ODB_EXCEPTIONS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <string> #include <string>
#include <odb/forward.hxx> // odb::core
#include <odb/exception.hxx> #include <odb/exception.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
namespace odb namespace odb
{ {
struct LIBODB_EXPORT null_pointer: exception struct LIBODB_EXPORT null_pointer: exception
{ {
virtual const char* virtual const char*
what () const throw (); what () const throw ();
skipping to change at line 130 skipping to change at line 131
virtual const char* virtual const char*
what () const throw (); what () const throw ();
}; };
struct LIBODB_EXPORT no_type_info: exception struct LIBODB_EXPORT no_type_info: exception
{ {
virtual const char* virtual const char*
what () const throw (); what () const throw ();
}; };
// Prepared query support exceptions.
//
struct LIBODB_EXPORT prepared_already_cached: exception
{
prepared_already_cached (const char* name);
~prepared_already_cached () throw ();
const char*
name () const
{
return name_;
}
virtual const char*
what () const throw ();
private:
const char* name_;
std::string what_;
};
struct LIBODB_EXPORT prepared_type_mismatch: exception
{
prepared_type_mismatch (const char* name);
~prepared_type_mismatch () throw ();
const char*
name () const
{
return name_;
}
virtual const char*
what () const throw ();
private:
const char* name_;
std::string what_;
};
// Schema catalog exceptions. // Schema catalog exceptions.
// //
struct LIBODB_EXPORT unknown_schema: exception struct LIBODB_EXPORT unknown_schema: exception
{ {
unknown_schema (const std::string& name); unknown_schema (const std::string& name);
~unknown_schema () throw (); ~unknown_schema () throw ();
const std::string& const std::string&
name () const name () const
{ {
skipping to change at line 151 skipping to change at line 192
} }
virtual const char* virtual const char*
what () const throw (); what () const throw ();
private: private:
std::string name_; std::string name_;
std::string what_; std::string what_;
}; };
namespace core namespace common
{ {
using odb::null_pointer; using odb::null_pointer;
using odb::already_in_transaction; using odb::already_in_transaction;
using odb::not_in_transaction; using odb::not_in_transaction;
using odb::transaction_already_finalized; using odb::transaction_already_finalized;
using odb::already_in_session; using odb::already_in_session;
using odb::not_in_session; using odb::not_in_session;
using odb::session_required; using odb::session_required;
 End of changes. 4 change blocks. 
2 lines changed or deleted 43 lines changed or added


 export.hxx   export.hxx 
// file : odb/details/export.hxx // file : odb/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_DETAILS_EXPORT_HXX #ifndef ODB_DETAILS_EXPORT_HXX
#define ODB_DETAILS_EXPORT_HXX #define ODB_DETAILS_EXPORT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> #include <odb/details/config.hxx>
#ifdef LIBODB_STATIC_LIB #ifdef LIBODB_STATIC_LIB
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 forward.hxx   forward.hxx 
// file : odb/forward.hxx // file : odb/forward.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_FORWARD_HXX #ifndef ODB_FORWARD_HXX
#define ODB_FORWARD_HXX #define ODB_FORWARD_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
#include <odb/details/shared-ptr-fwd.hxx> #include <odb/details/shared-ptr-fwd.hxx>
namespace odb namespace odb
{ {
// Common and core namespaces. The idea is that you can use the
// using directive to get database-independent (common) names or
// all core names (core).
//
namespace common {}
namespace core
{
using namespace common;
}
//
//
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 statement;
class session; class session;
namespace common
{
using odb::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::statement;
using odb::session;
} }
// Tracing. // Tracing.
// //
class tracer; // Not in core. class tracer; // Not in core.
extern LIBODB_EXPORT tracer& stderr_tracer; extern LIBODB_EXPORT tracer& stderr_tracer;
namespace core namespace common
{ {
using odb::stderr_tracer; using odb::stderr_tracer;
} }
// Implementation details. // Implementation details.
// //
// Keep real databases first since their enumerators are used as array
// indexes.
//
enum database_id
{
id_mysql,
id_sqlite,
id_pgsql,
id_oracle,
id_mssql,
id_common
};
// Number of real databases (i.e., excluding default) in the database_id
// enum.
//
const std::size_t database_count = id_common;
// Traits.
//
class access class access
{ {
public: public:
template <typename T> template <typename T>
class object_traits; class object_traits;
template <typename T, database_id DB>
class object_traits_impl;
template <typename T, typename P> template <typename T, typename P>
class object_factory; class object_factory;
template <typename T> template <typename T>
class view_traits; class view_traits;
template <typename T, database_id DB>
class view_traits_impl;
template <typename T, typename P> template <typename T, typename P>
class view_factory; class view_factory;
template <typename T, typename P> template <typename T, typename P>
class pointer_factory; class pointer_factory;
template <typename T> template <typename T, database_id DB>
class composite_value_traits; class composite_value_traits;
template <typename C> template <typename C>
class container_traits; class container_traits;
}; };
template <typename T> template <typename T>
struct object_traits; struct object_traits;
template <typename T, database_id DB>
struct object_traits_impl;
template <typename T> template <typename T>
struct view_traits; struct view_traits;
template <typename T, database_id DB>
struct view_traits_impl;
// Cache traits. // Cache traits.
// //
template <typename T> struct no_id_pointer_cache_traits; template <typename T> struct no_id_pointer_cache_traits;
template <typename T> struct no_op_pointer_cache_traits; template <typename T> struct no_op_pointer_cache_traits;
template <typename T> struct pointer_cache_traits; template <typename T, typename S> struct pointer_cache_traits;
template <typename T> struct no_id_reference_cache_traits; template <typename T> struct no_id_reference_cache_traits;
template <typename T> struct no_op_reference_cache_traits; template <typename T> struct no_op_reference_cache_traits;
template <typename T> struct reference_cache_traits; template <typename T, typename S> struct reference_cache_traits;
//
//
class query_base;
template <typename T>
struct query_column;
//
//
class result_impl;
class prepared_query_impl;
// Polymorphism support. // Polymorphism support.
// //
template <typename R> template <typename R>
struct polymorphic_map; struct polymorphic_map;
namespace details namespace details
{ {
template <> template <>
struct counter_type<connection> struct counter_type<connection>
 End of changes. 14 change blocks. 
6 lines changed or deleted 69 lines changed or added


 lazy-pointer-traits.hxx   lazy-pointer-traits.hxx 
// file : odb/lazy-pointer-traits.hxx // file : odb/lazy-pointer-traits.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_LAZY_POINTER_TRAITS_HXX #ifndef ODB_LAZY_POINTER_TRAITS_HXX
#define ODB_LAZY_POINTER_TRAITS_HXX #define ODB_LAZY_POINTER_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/lazy-ptr.hxx> #include <odb/lazy-ptr.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 lazy-ptr-impl.hxx   lazy-ptr-impl.hxx 
// file : odb/lazy-ptr-impl.hxx // file : odb/lazy-ptr-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_LAZY_PTR_IMPL_HXX #ifndef ODB_LAZY_PTR_IMPL_HXX
#define ODB_LAZY_PTR_IMPL_HXX #define ODB_LAZY_PTR_IMPL_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <utility> // std::move #include <utility> // std::move
#include <odb/forward.hxx> // odb::database #include <odb/forward.hxx> // odb::database
skipping to change at line 24 skipping to change at line 24
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
namespace odb namespace odb
{ {
struct LIBODB_EXPORT lazy_ptr_impl_ref struct LIBODB_EXPORT lazy_ptr_impl_ref
{ {
void* id_; void* id_;
database* db_; database* db_;
void* loader_;
void (*free_) (void*); void (*free_) (void*);
void* (*copy_) (const void*); void* (*copy_) (const void*);
}; };
class LIBODB_EXPORT lazy_ptr_base class LIBODB_EXPORT lazy_ptr_base
{ {
public: public:
typedef odb::database database_type; typedef odb::database database_type;
~lazy_ptr_base (); ~lazy_ptr_base ();
skipping to change at line 60 skipping to change at line 61
lazy_ptr_base& lazy_ptr_base&
operator= (lazy_ptr_base&&); operator= (lazy_ptr_base&&);
#endif #endif
public: public:
// Reset both the id and database. // Reset both the id and database.
// //
void void
reset (); reset ();
// Reset the id and set the database to the new value.
//
void
reset (database_type&);
// Reset the id. // Reset the id.
// //
void void
reset_id (); reset_id ();
void void
swap (lazy_ptr_base&); swap (lazy_ptr_base&);
database_type* database_type*
database () const; database () const;
skipping to change at line 91 skipping to change at line 87
operator lazy_ptr_impl_ref (); operator lazy_ptr_impl_ref ();
protected: protected:
typedef void (*free_func) (void*); typedef void (*free_func) (void*);
typedef void* (*copy_func) (const void*); typedef void* (*copy_func) (const void*);
// Makes a copy of id. // Makes a copy of id.
// //
void void
reset_ (database_type*, const void* id, free_func, copy_func); reset_ (database_type*,
void* loader,
const void* id,
free_func, copy_func);
template <typename T> template <typename T>
static void static void
free (void*); free (void*);
template <typename T> template <typename T>
static void* static void*
copy (const void*); copy (const void*);
template <typename T, typename DB>
static typename object_traits<T>::pointer_type
loader (database_type&, const typename object_traits<T>::id_type&);
protected: protected:
void* id_; void* id_;
database_type* db_; database_type* db_;
void* loader_;
private: private:
free_func free_; free_func free_;
copy_func copy_; copy_func copy_;
}; };
template <typename T> template <typename T>
class lazy_ptr_impl: public lazy_ptr_base class lazy_ptr_impl: public lazy_ptr_base
{ {
public: public:
lazy_ptr_impl (); lazy_ptr_impl ();
template <typename ID> template <typename DB, typename ID>
lazy_ptr_impl (database_type&, const ID&); lazy_ptr_impl (DB&, const ID&);
lazy_ptr_impl (const lazy_ptr_impl&); lazy_ptr_impl (const lazy_ptr_impl&);
template <typename Y> template <typename Y>
lazy_ptr_impl (const lazy_ptr_impl<Y>&); lazy_ptr_impl (const lazy_ptr_impl<Y>&);
lazy_ptr_impl (const lazy_ptr_impl_ref&); lazy_ptr_impl (const lazy_ptr_impl_ref&);
lazy_ptr_impl& lazy_ptr_impl&
operator= (const lazy_ptr_impl&); operator= (const lazy_ptr_impl&);
skipping to change at line 157 skipping to change at line 161
template <typename Y> template <typename Y>
lazy_ptr_impl& lazy_ptr_impl&
operator= (lazy_ptr_impl<Y>&&); operator= (lazy_ptr_impl<Y>&&);
#endif #endif
public: public:
using lazy_ptr_base::reset; using lazy_ptr_base::reset;
using lazy_ptr_base::reset_id; using lazy_ptr_base::reset_id;
template <typename ID> template <typename DB, typename ID>
void
reset (DB&, const ID&);
// Reset the id and set the database to the new value.
//
template <typename DB>
void void
reset (database_type&, const ID&); reset_db (DB&);
template <typename ID> template <typename ID>
void void
reset_id (const ID&); reset_id (const ID&);
template <typename O /* = T */> template <typename O /* = T */>
typename object_traits<O>::pointer_type typename object_traits<O>::pointer_type
load (bool reset_id); load (bool reset_id);
template <typename O /* = T */> template <typename O /* = T */>
 End of changes. 9 change blocks. 
11 lines changed or deleted 21 lines changed or added


 lazy-ptr-impl.ixx   lazy-ptr-impl.ixx 
// file : odb/lazy-ptr-impl.ixx // file : odb/lazy-ptr-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
{ {
// //
// lazy_ptr_base // lazy_ptr_base
// //
inline lazy_ptr_base:: inline lazy_ptr_base::
lazy_ptr_base () lazy_ptr_base ()
: id_ (0), db_ (0) : id_ (0), db_ (0), loader_ (0)
{ {
} }
inline lazy_ptr_base:: inline lazy_ptr_base::
lazy_ptr_base (const lazy_ptr_base& r) lazy_ptr_base (const lazy_ptr_base& r)
: id_ (0), db_ (r.db_), free_ (r.free_), copy_ (r.copy_) : id_ (0), db_ (r.db_), loader_ (r.loader_),
free_ (r.free_), copy_ (r.copy_)
{ {
if (r.id_) if (r.id_)
id_ = copy_ (r.id_); id_ = copy_ (r.id_);
} }
inline lazy_ptr_base:: inline lazy_ptr_base::
lazy_ptr_base (const lazy_ptr_impl_ref& r) lazy_ptr_base (const lazy_ptr_impl_ref& r)
: id_ (r.id_), db_ (r.db_), free_ (r.free_), copy_ (r.copy_) : id_ (r.id_), db_ (r.db_), loader_ (r.loader_),
free_ (r.free_), copy_ (r.copy_)
{ {
} }
#ifdef ODB_CXX11 #ifdef ODB_CXX11
inline lazy_ptr_base:: inline lazy_ptr_base::
lazy_ptr_base (lazy_ptr_base&& r) lazy_ptr_base (lazy_ptr_base&& r)
: id_ (r.id_), db_ (r.db_), free_ (r.free_), copy_ (r.copy_) : id_ (r.id_), db_ (r.db_), loader_ (r.loader_),
free_ (r.free_), copy_ (r.copy_)
{ {
r.id_ = 0; r.id_ = 0;
} }
inline lazy_ptr_base& lazy_ptr_base:: inline lazy_ptr_base& lazy_ptr_base::
operator= (lazy_ptr_base&& r) operator= (lazy_ptr_base&& r)
{ {
if (id_ != r.id_) if (id_ != r.id_)
{ {
reset_id (); reset_id ();
id_ = r.id_; id_ = r.id_;
db_ = r.db_; db_ = r.db_;
loader_ = r.loader_;
free_ = r.free_; free_ = r.free_;
copy_ = r.copy_; copy_ = r.copy_;
r.id_ = 0; r.id_ = 0;
} }
return *this; return *this;
} }
#endif #endif
inline void lazy_ptr_base:: inline void lazy_ptr_base::
reset_id () reset_ (database_type* db,
{ void* loader,
if (id_) const void* id,
free_ (id_); free_func free,
copy_func copy)
id_ = 0;
}
inline void lazy_ptr_base::
reset_ (database_type* db, const void* id, free_func free, copy_func copy
)
{ {
void* idc (id ? copy (id) : 0); void* idc (id ? copy (id) : 0);
if (id_) if (id_)
free_ (id_); free_ (id_);
free_ = free; free_ = free;
copy_ = copy; copy_ = copy;
id_ = idc; id_ = idc;
db_ = db; db_ = db;
loader_ = loader;
} }
inline void lazy_ptr_base:: inline void lazy_ptr_base::
reset () reset ()
{ {
reset_id (); reset_id ();
db_ = 0; db_ = 0;
loader_ = 0;
} }
inline void lazy_ptr_base:: inline void lazy_ptr_base::
reset (database_type& db) reset_id ()
{ {
reset_id (); if (id_)
db_ = &db; free_ (id_);
id_ = 0;
} }
inline lazy_ptr_base& lazy_ptr_base:: inline lazy_ptr_base& lazy_ptr_base::
operator= (const lazy_ptr_base& r) operator= (const lazy_ptr_base& r)
{ {
if (id_ != r.id_) if (id_ != r.id_)
reset_ (r.db_, r.id_, r.free_, r.copy_); reset_ (r.db_, r.loader_, r.id_, r.free_, r.copy_);
else else
{
db_ = r.db_; db_ = r.db_;
loader_ = r.loader_;
}
return *this; return *this;
} }
inline lazy_ptr_base& lazy_ptr_base:: inline lazy_ptr_base& lazy_ptr_base::
operator= (const lazy_ptr_impl_ref& r) operator= (const lazy_ptr_impl_ref& r)
{ {
if (id_ != r.id_) if (id_ != r.id_)
{ {
reset_id (); reset_id ();
id_ = r.id_; id_ = r.id_;
free_ = r.free_; free_ = r.free_;
copy_ = r.copy_; copy_ = r.copy_;
} }
db_ = r.db_; db_ = r.db_;
loader_ = r.loader_;
return *this; return *this;
} }
inline lazy_ptr_base:: inline lazy_ptr_base::
~lazy_ptr_base () ~lazy_ptr_base ()
{ {
if (id_) if (id_)
free_ (id_); free_ (id_);
} }
inline void lazy_ptr_base:: inline void lazy_ptr_base::
swap (lazy_ptr_base& r) swap (lazy_ptr_base& r)
{ {
void* id (id_); void* id (id_);
database_type* db (db_); database_type* db (db_);
void* l (loader_);
free_func f (free_); free_func f (free_);
copy_func c (copy_); copy_func c (copy_);
id_ = r.id_; id_ = r.id_;
db_ = r.db_; db_ = r.db_;
loader_ = r.loader_;
free_ = r.free_; free_ = r.free_;
copy_ = r.copy_; copy_ = r.copy_;
r.id_ = id; r.id_ = id;
r.db_ = db; r.db_ = db;
r.loader_ = l;
r.free_ = f; r.free_ = f;
r.copy_ = c; r.copy_ = c;
} }
inline lazy_ptr_base::database_type* lazy_ptr_base:: inline lazy_ptr_base::database_type* lazy_ptr_base::
database () const database () const
{ {
return db_; return db_;
} }
inline lazy_ptr_base:: inline lazy_ptr_base::
operator lazy_ptr_impl_ref () operator lazy_ptr_impl_ref ()
{ {
lazy_ptr_impl_ref r; lazy_ptr_impl_ref r;
r.id_ = id_; r.id_ = id_;
r.db_ = db_; r.db_ = db_;
r.loader_ = loader_;
r.free_ = free_; r.free_ = free_;
r.copy_ = copy_; r.copy_ = copy_;
id_ = 0; id_ = 0;
db_ = 0; db_ = 0;
loader_ = 0;
return r; return r;
} }
// //
// lazy_ptr_impl // lazy_ptr_impl
// //
template <typename T> template <typename T>
inline lazy_ptr_impl<T>:: inline lazy_ptr_impl<T>::
lazy_ptr_impl () lazy_ptr_impl ()
{ {
} }
template <typename T> template <typename T>
template <typename ID> template <typename DB, typename ID>
inline lazy_ptr_impl<T>:: inline lazy_ptr_impl<T>::
lazy_ptr_impl (database_type& db, const ID& id) lazy_ptr_impl (DB& db, const ID& id)
{ {
typedef typename object_traits<T>::id_type id_type; typedef typename object_traits<T>::id_type id_type;
typedef typename object_traits<T>::pointer_type pointer_type;
typedef pointer_type (*loader_type) (database_type&, const id_type&);
// Make sure that ID and T's object id types are the same // Make sure that ID and T's object id types are the same
// (or implicit-convertible). If you get a compile error // (or implicit-convertible). If you get a compile error
// pointing here, then you most likely used a wrong object // pointing here, then you most likely used a wrong object
// id argument in the constructor call. // id argument in the constructor call.
// //
const id_type& r (id); const id_type& r (id);
reset_ (&db, &r, &free<id_type>, &copy<id_type>); // Compiler error pointing here? Perhaps db is not an
// odb::<database>::database instance?
//
database_type& bdb (db);
// For some reason GCC needs this statically-typed pointer in
// order to instantiate the functions.
//
loader_type ldr (&loader<T, DB>);
reset_ (&bdb,
reinterpret_cast<void*> (ldr),
&r,
&free<id_type>,
&copy<id_type>);
} }
template <typename T> template <typename T>
inline lazy_ptr_impl<T>:: inline lazy_ptr_impl<T>::
lazy_ptr_impl (const lazy_ptr_impl& r) lazy_ptr_impl (const lazy_ptr_impl& r)
: lazy_ptr_base (r) : lazy_ptr_base (r)
{ {
} }
template <typename T> template <typename T>
skipping to change at line 280 skipping to change at line 308
inline lazy_ptr_impl<T>& lazy_ptr_impl<T>:: inline lazy_ptr_impl<T>& lazy_ptr_impl<T>::
operator= (lazy_ptr_impl<Y>&& r) operator= (lazy_ptr_impl<Y>&& r)
{ {
lazy_ptr_base& b (*this); lazy_ptr_base& b (*this);
b = std::move (r); b = std::move (r);
return *this; return *this;
} }
#endif #endif
template <typename T> template <typename T>
template <typename ID> template <typename DB, typename ID>
inline void lazy_ptr_impl<T>:: inline void lazy_ptr_impl<T>::
reset (database_type& db, const ID& id) reset (DB& db, const ID& id)
{ {
typedef typename object_traits<T>::id_type id_type; typedef typename object_traits<T>::id_type id_type;
typedef typename object_traits<T>::pointer_type pointer_type;
typedef pointer_type (*loader_type) (database_type&, const id_type&);
// Make sure that ID and T's object id types are the same // Make sure that ID and T's object id types are the same
// (or implicit-convertible). If you get a compile error // (or implicit-convertible). If you get a compile error
// pointing here, then you most likely used a wrong object // pointing here, then you most likely used a wrong object
// id argument in the constructor call. // id argument in the constructor call.
// //
const id_type& r (id); const id_type& r (id);
reset_ (&db, &r, &free<id_type>, &copy<id_type>); // Compiler error pointing here? Perhaps db is not an
// odb::<database>::database instance?
//
database_type& bdb (db);
// For some reason GCC needs this statically-typed pointer in
// order to instantiate the functions.
//
loader_type ldr (&loader<T, DB>);
reset_ (&bdb,
reinterpret_cast<void*> (ldr),
&r,
&free<id_type>,
&copy<id_type>);
}
template <typename T>
template <typename DB>
inline void lazy_ptr_impl<T>::
reset_db (DB& db)
{
typedef typename object_traits<T>::id_type id_type;
typedef typename object_traits<T>::pointer_type pointer_type;
typedef pointer_type (*loader_type) (database_type&, const id_type&);
reset_id ();
// Compiler error pointing here? Perhaps db is not an
// odb::<database>::database instance?
//
db_ = &db;
// For some reason GCC needs this statically-typed pointer in
// order to instantiate the functions.
//
loader_type ldr (&loader<T, DB>);
loader_ = reinterpret_cast<void*> (ldr);
} }
template <typename T> template <typename T>
template <typename ID> template <typename ID>
inline void lazy_ptr_impl<T>:: inline void lazy_ptr_impl<T>::
reset_id (const ID& id) reset_id (const ID& id)
{ {
typedef typename object_traits<T>::id_type id_type; typedef typename object_traits<T>::id_type id_type;
// Make sure that ID and T's object id types are the same // Make sure that ID and T's object id types are the same
// (or implicit-convertible). If you get a compile error // (or implicit-convertible). If you get a compile error
// pointing here, then you most likely used a wrong object // pointing here, then you most likely used a wrong object
// id argument in the constructor call. // id argument in the constructor call.
// //
const id_type& r (id); const id_type& r (id);
reset_ (db_, &r, &free<id_type>, &copy<id_type>); reset_ (db_, loader_, &r, &free<id_type>, &copy<id_type>);
} }
template <typename T> template <typename T>
template <typename O> template <typename O>
inline typename object_traits<O>::id_type lazy_ptr_impl<T>:: inline typename object_traits<O>::id_type lazy_ptr_impl<T>::
object_id () const object_id () const
{ {
typedef typename object_traits<T>::id_type id_type; typedef typename object_traits<T>::id_type id_type;
const id_type& id (*static_cast<const id_type*> (id_)); const id_type& id (*static_cast<const id_type*> (id_));
 End of changes. 29 change blocks. 
27 lines changed or deleted 93 lines changed or added


 lazy-ptr-impl.txx   lazy-ptr-impl.txx 
// file : odb/lazy-ptr-impl.txx // file : odb/lazy-ptr-impl.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/database.hxx> #include <odb/database.hxx>
namespace odb namespace odb
{ {
// //
// lazy_ptr_base // lazy_ptr_base
// //
skipping to change at line 27 skipping to change at line 27
delete static_cast<T*> (p); delete static_cast<T*> (p);
} }
template <typename T> template <typename T>
void* lazy_ptr_base:: void* lazy_ptr_base::
copy (const void* p) copy (const void* p)
{ {
return new T (*static_cast<const T*> (p)); return new T (*static_cast<const T*> (p));
} }
template <typename T, typename DB>
typename object_traits<T>::pointer_type lazy_ptr_base::
loader (database_type& db, const typename object_traits<T>::id_type& id)
{
return static_cast<DB&> (db).template load<T> (id);
}
// //
// lazy_ptr_impl // lazy_ptr_impl
// //
template <typename T> template <typename T>
template <typename O> template <typename O>
inline typename object_traits<O>::pointer_type lazy_ptr_impl<T>:: inline typename object_traits<O>::pointer_type lazy_ptr_impl<T>::
load (bool reset) load (bool reset)
{ {
typedef typename object_traits<T>::id_type id_type; typedef typename object_traits<T>::id_type id_type;
typedef typename object_traits<T>::pointer_type pointer_type; typedef typename object_traits<T>::pointer_type pointer_type;
typedef pointer_type (*loader_type) (database_type&, const id_type&);
loader_type loader (reinterpret_cast<loader_type> (loader_));
const id_type& id (*static_cast<const id_type*> (id_)); const id_type& id (*static_cast<const id_type*> (id_));
pointer_type p (db_->load<T> (id)); pointer_type p (loader (*db_, id));
if (reset) if (reset)
reset_id (); reset_id ();
// If you get a compile error pointing here, then you most likely // If you get a compile error pointing here, then you most likely
// used a wrong type as a template argument in the load() call. // used a wrong type as a template argument in the load() call.
// //
return p; return p;
} }
} }
 End of changes. 5 change blocks. 
2 lines changed or deleted 11 lines changed or added


 lazy-ptr.hxx   lazy-ptr.hxx 
// file : odb/lazy-ptr.hxx // file : odb/lazy-ptr.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_LAZY_PTR_HXX #ifndef ODB_LAZY_PTR_HXX
#define ODB_LAZY_PTR_HXX #define ODB_LAZY_PTR_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <memory> // std::auto_ptr, std::shared_ptr/weak_ptr #include <memory> // std::auto_ptr, std::shared_ptr/weak_ptr
#include <utility> // std::move #include <utility> // std::move
#include <odb/forward.hxx> // odb::database #include <odb/forward.hxx> // odb::core, odb::database
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/lazy-ptr-impl.hxx> #include <odb/lazy-ptr-impl.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
namespace odb namespace odb
{ {
// Raw pointer lazy version. // Raw pointer lazy version.
// //
template <class T> template <class T>
class lazy_ptr class lazy_ptr
skipping to change at line 75 skipping to change at line 75
// //
bool loaded () const; bool loaded () const;
T* load () const; T* load () const;
// Unload the pointer. For transient objects this function is // Unload the pointer. For transient objects this function is
// equivalent to reset(). // equivalent to reset().
// //
void unload () const; void unload () const;
template <class ID> lazy_ptr (database_type&, const ID&); template <class DB, class ID> lazy_ptr (DB&, const ID&);
template <class Y> lazy_ptr (database_type&, Y*); template <class DB, class Y> lazy_ptr (DB&, Y*);
template <class ID> void reset (database_type&, const ID&); template <class DB, class ID> void reset (DB&, const ID&);
template <class Y> void reset (database_type&, Y*); template <class DB, class Y> void reset (DB&, Y*);
#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT #ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
template <class O = T> template <class O = T>
#else #else
template <class O /* = T */> template <class O /* = T */>
#endif #endif
typename object_traits<O>::id_type object_id () const; typename object_traits<O>::id_type object_id () const;
database_type& database () const; database_type& database () const;
skipping to change at line 188 skipping to change at line 188
// //
bool loaded () const; bool loaded () const;
std::auto_ptr<T>& load () const; std::auto_ptr<T>& load () const;
// Unload the pointer. For transient objects this function is // Unload the pointer. For transient objects this function is
// equivalent to reset(). // equivalent to reset().
// //
void unload () const; void unload () const;
template <class ID> lazy_auto_ptr (database_type&, const ID&); template <class DB, class ID> lazy_auto_ptr (DB&, const ID&);
lazy_auto_ptr (database_type&, T*); template <class DB> lazy_auto_ptr (DB&, T*);
template <class Y> lazy_auto_ptr (database_type&, std::auto_ptr<Y>&); template <class DB, class Y> lazy_auto_ptr (DB&, std::auto_ptr<Y>&);
template <class ID> void reset (database_type&, const ID&); template <class DB, class ID> void reset (DB&, const ID&);
void reset (database_type&, T*); template <class DB> void reset (DB&, T*);
template <class Y> void reset (database_type&, std::auto_ptr<Y>&); template <class DB, class Y> void reset (DB&, std::auto_ptr<Y>&);
#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT #ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
template <class O = T> template <class O = T>
#else #else
template <class O /* = T */> template <class O /* = T */>
#endif #endif
typename object_traits<O>::id_type object_id () const; typename object_traits<O>::id_type object_id () const;
database_type& database () const; database_type& database () const;
skipping to change at line 308 skipping to change at line 308
// //
bool loaded () const; bool loaded () const;
std::unique_ptr<T, D>& load () const; std::unique_ptr<T, D>& load () const;
// Unload the pointer. For transient objects this function is // Unload the pointer. For transient objects this function is
// equivalent to reset(). // equivalent to reset().
// //
void unload () const; void unload () const;
template <class ID> lazy_unique_ptr (database_type&, const ID&); template <class DB, class ID> lazy_unique_ptr (DB&, const ID&);
lazy_unique_ptr (database_type&, pointer); template <class DB> lazy_unique_ptr (DB&, pointer);
lazy_unique_ptr (database_type&, pointer, const deleter_type&); template <class DB> lazy_unique_ptr (DB&, pointer, const deleter_type&)
lazy_unique_ptr (database_type&, pointer, deleter_type&&); ;
template <class T1, class D1> lazy_unique_ptr (database_type&, std::uni template <class DB> lazy_unique_ptr (DB&, pointer, deleter_type&&);
que_ptr<T1, D1>&&); template <class DB, class T1, class D1> lazy_unique_ptr (DB&, std::uniq
template <class T1> lazy_unique_ptr (database_type&, std::auto_ptr<T1>& ue_ptr<T1, D1>&&);
&); template <class DB, class T1> lazy_unique_ptr (DB&, std::auto_ptr<T1>&&
);
template <class ID> void reset (database_type&, const ID&);
void reset (database_type&, pointer); template <class DB, class ID> void reset (DB&, const ID&);
template <class T1, class D1> void reset (database_type&, std::unique_p template <class DB> void reset (DB&, pointer);
tr<T1, D1>&&); template <class DB, class T1, class D1> void reset (DB&, std::unique_pt
template <class T1> void reset (database_type&, std::auto_ptr<T1>&&); r<T1, D1>&&);
template <class DB, class T1> void reset (DB&, std::auto_ptr<T1>&&);
#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT #ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
template <class O = T> template <class O = T>
#else #else
template <class O /*= T*/> template <class O /*= T*/>
#endif #endif
typename object_traits<O>::id_type object_id () const; typename object_traits<O>::id_type object_id () const;
database_type& database () const; database_type& database () const;
skipping to change at line 467 skipping to change at line 467
// //
bool loaded () const; bool loaded () const;
std::shared_ptr<T> load () const; std::shared_ptr<T> load () const;
// Unload the pointer. For transient objects this function is // Unload the pointer. For transient objects this function is
// equivalent to reset(). // equivalent to reset().
// //
void unload () const; void unload () const;
template <class ID> lazy_shared_ptr (database_type&, const ID&); template <class DB, class ID> lazy_shared_ptr (DB&, const ID&);
template <class Y> lazy_shared_ptr (database_type&, Y*); template <class DB, class Y> lazy_shared_ptr (DB&, Y*);
template <class Y, class D> lazy_shared_ptr (database_type&, Y*, D); template <class DB, class Y, class D> lazy_shared_ptr (DB&, Y*, D);
template <class Y, class D, class A> lazy_shared_ptr (database_type&, Y template <class DB, class Y, class D, class A> lazy_shared_ptr (DB&, Y*
*, D, A); , D, A);
template <class Y> lazy_shared_ptr (database_type&, std::auto_ptr<Y>&&) template <class DB, class Y> lazy_shared_ptr (DB&, std::auto_ptr<Y>&&);
; template <class DB, class Y> lazy_shared_ptr (DB&, const std::shared_pt
template <class Y> lazy_shared_ptr (database_type&, const std::shared_p r<Y>&);
tr<Y>&); template <class DB, class Y> lazy_shared_ptr (DB&, std::shared_ptr<Y>&&
template <class Y> lazy_shared_ptr (database_type&, std::shared_ptr<Y>& );
&); template <class DB, class Y> lazy_shared_ptr (DB&, const std::weak_ptr<
template <class Y> lazy_shared_ptr (database_type&, const std::weak_ptr Y>&);
<Y>&);
template <class DB, class ID> void reset (DB&, const ID&);
template <class ID> void reset (database_type&, const ID&); template <class DB, class Y> void reset (DB&, Y*);
template <class Y> void reset (database_type&, Y*); template <class DB, class Y, class D> void reset (DB&, Y*, D);
template <class Y, class D> void reset (database_type&, Y*, D); template <class DB, class Y, class D, class A> void reset (DB&, Y*, D,
template <class Y, class D, class A> void reset (database_type&, Y*, D, A);
A); template <class DB, class Y> void reset (DB&, std::auto_ptr<Y>&&);
template <class Y> void reset (database_type&, std::auto_ptr<Y>&&); template <class DB, class Y> void reset (DB&, const std::shared_ptr<Y>&
template <class Y> void reset (database_type&, const std::shared_ptr<Y> );
&); template <class DB, class Y> void reset (DB&, std::shared_ptr<Y>&&);
template <class Y> void reset (database_type&, std::shared_ptr<Y>&&);
#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT #ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
template <class O = T> template <class O = T>
#else #else
template <class O /*= T*/> template <class O /*= T*/>
#endif #endif
typename object_traits<O>::id_type object_id () const; typename object_traits<O>::id_type object_id () const;
database_type& database () const; database_type& database () const;
skipping to change at line 596 skipping to change at line 596
// Performs both lock and load. // Performs both lock and load.
// //
std::shared_ptr<T> load () const; std::shared_ptr<T> load () const;
// Unload the pointer. For transient objects this function is // Unload the pointer. For transient objects this function is
// equivalent to reset(). // equivalent to reset().
// //
void unload () const; void unload () const;
template <class ID> lazy_weak_ptr (database_type&, const ID&); template <class DB, class ID> lazy_weak_ptr (DB&, const ID&);
template <class Y> lazy_weak_ptr (database_type&, const std::shared_ptr template <class DB, class Y> lazy_weak_ptr (DB&, const std::shared_ptr<
<Y>&); Y>&);
template <class Y> lazy_weak_ptr (database_type&, const std::weak_ptr<Y template <class DB, class Y> lazy_weak_ptr (DB&, const std::weak_ptr<Y>
>&); &);
template <class ID> void reset (database_type&, const ID&); template <class DB, class ID> void reset (DB&, const ID&);
template <class Y> void reset (database_type&, const std::shared_ptr<Y> template <class DB, class Y> void reset (DB&, const std::shared_ptr<Y>&
&); );
template <class Y> void reset (database_type&, const std::weak_ptr<Y>&) template <class DB, class Y> void reset (DB&, const std::weak_ptr<Y>&);
;
// The object_id() function can only be called when the object is // The object_id() function can only be called when the object is
// persistent, or: expired() XOR loaded() (can use != for XOR). // persistent, or: expired() XOR loaded() (can use != for XOR).
// //
#ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT #ifdef ODB_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGUMENT
template <class O = T> template <class O = T>
#else #else
template <class O /*= T*/> template <class O /*= T*/>
#endif #endif
typename object_traits<O>::id_type object_id () const; typename object_traits<O>::id_type object_id () const;
skipping to change at line 630 skipping to change at line 630
mutable std::weak_ptr<T> p_; mutable std::weak_ptr<T> p_;
mutable lazy_ptr_impl<T> i_; mutable lazy_ptr_impl<T> i_;
}; };
// operator< is not provided. // operator< is not provided.
// //
template <class T> void swap (lazy_weak_ptr<T>&, lazy_weak_ptr<T>&); template <class T> void swap (lazy_weak_ptr<T>&, lazy_weak_ptr<T>&);
#endif // ODB_CXX11 #endif // ODB_CXX11
namespace core namespace common
{ {
using odb::lazy_ptr; using odb::lazy_ptr;
using odb::lazy_auto_ptr; using odb::lazy_auto_ptr;
#ifdef ODB_CXX11 #ifdef ODB_CXX11
using odb::lazy_unique_ptr; using odb::lazy_unique_ptr;
using odb::lazy_shared_ptr; using odb::lazy_shared_ptr;
using odb::lazy_weak_ptr; using odb::lazy_weak_ptr;
#endif #endif
} }
 End of changes. 9 change blocks. 
62 lines changed or deleted 61 lines changed or added


 lazy-ptr.ixx   lazy-ptr.ixx 
// file : odb/lazy-ptr.ixx // file : odb/lazy-ptr.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
{ {
// //
// lazy_ptr // lazy_ptr
// //
template <class T> template <class T>
inline lazy_ptr<T>:: inline lazy_ptr<T>::
skipping to change at line 140 skipping to change at line 140
if (p_) if (p_)
{ {
if (i_.database () != 0) if (i_.database () != 0)
i_.reset_id (object_traits<object_type>::id (*p_)); i_.reset_id (object_traits<object_type>::id (*p_));
p_ = 0; p_ = 0;
} }
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline lazy_ptr<T>:: inline lazy_ptr<T>::
lazy_ptr (database_type& db, const ID& id): p_ (0), i_ (db, id) {} lazy_ptr (DB& db, const ID& id): p_ (0), i_ (db, id) {}
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_ptr<T>:: inline lazy_ptr<T>::
lazy_ptr (database_type& db, Y* r) lazy_ptr (DB& db, Y* r)
: p_ (r) : p_ (r)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline void lazy_ptr<T>:: inline void lazy_ptr<T>::
reset (database_type& db, const ID& id) reset (DB& db, const ID& id)
{ {
p_ = 0; p_ = 0;
i_.reset (db, id); i_.reset (db, id);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_ptr<T>:: inline void lazy_ptr<T>::
reset (database_type& db, Y* r) reset (DB& db, Y* r)
{ {
p_ = r; p_ = r;
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class O> template <class O>
inline typename object_traits<O>::id_type lazy_ptr<T>:: inline typename object_traits<O>::id_type lazy_ptr<T>::
object_id () const object_id () const
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
skipping to change at line 399 skipping to change at line 399
if (p_.get () != 0) if (p_.get () != 0)
{ {
if (i_.database () != 0) if (i_.database () != 0)
i_.reset_id (object_traits<object_type>::id (*p_)); i_.reset_id (object_traits<object_type>::id (*p_));
p_.reset (); p_.reset ();
} }
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline lazy_auto_ptr<T>:: inline lazy_auto_ptr<T>::
lazy_auto_ptr (database_type& db, const ID& id): i_ (db, id) {} lazy_auto_ptr (DB& db, const ID& id): i_ (db, id) {}
template <class T> template <class T>
template <class DB>
inline lazy_auto_ptr<T>:: inline lazy_auto_ptr<T>::
lazy_auto_ptr (database_type& db, T* p) lazy_auto_ptr (DB& db, T* p)
: p_ (p) : p_ (p)
{ {
if (p) if (p)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_auto_ptr<T>:: inline lazy_auto_ptr<T>::
lazy_auto_ptr (database_type& db, std::auto_ptr<Y>& p) lazy_auto_ptr (DB& db, std::auto_ptr<Y>& p)
: p_ (p) : p_ (p)
{ {
if (p_.get () != 0) if (p_.get () != 0)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline void lazy_auto_ptr<T>:: inline void lazy_auto_ptr<T>::
reset (database_type& db, const ID& id) reset (DB& db, const ID& id)
{ {
p_.reset (); p_.reset ();
i_.reset (db, id); i_.reset (db, id);
} }
template <class T> template <class T>
template <class DB>
inline void lazy_auto_ptr<T>:: inline void lazy_auto_ptr<T>::
reset (database_type& db, T* p) reset (DB& db, T* p)
{ {
p_.reset (p); p_.reset (p);
if (p) if (p)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_auto_ptr<T>:: inline void lazy_auto_ptr<T>::
reset (database_type& db, std::auto_ptr<Y>& p) reset (DB& db, std::auto_ptr<Y>& p)
{ {
p_ = p; p_ = p;
if (p_.get () != 0) if (p_.get () != 0)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class O> template <class O>
inline typename object_traits<O>::id_type lazy_auto_ptr<T>:: inline typename object_traits<O>::id_type lazy_auto_ptr<T>::
object_id () const object_id () const
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
skipping to change at line 668 skipping to change at line 670
if (p_) if (p_)
{ {
if (i_.database () != 0) if (i_.database () != 0)
i_.reset_id (object_traits<object_type>::id (*p_)); i_.reset_id (object_traits<object_type>::id (*p_));
p_.reset (); p_.reset ();
} }
} }
template <class T, class D> template <class T, class D>
template <class ID> template <class DB, class ID>
inline lazy_unique_ptr<T, D>:: inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (database_type& db, const ID& id): i_ (db, id) {} lazy_unique_ptr (DB& db, const ID& id): i_ (db, id) {}
template <class T, class D> template <class T, class D>
template <class DB>
inline lazy_unique_ptr<T, D>:: inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (database_type& db, T* p) lazy_unique_ptr (DB& db, T* p)
: p_ (p) : p_ (p)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T, class D> template <class T, class D>
template <class DB>
inline lazy_unique_ptr<T, D>:: inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (database_type& db, T* p, const deleter_type& d) lazy_unique_ptr (DB& db, T* p, const deleter_type& d)
: p_ (p, d) : p_ (p, d)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T, class D> template <class T, class D>
template <class DB>
inline lazy_unique_ptr<T, D>:: inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (database_type& db, T* p, deleter_type&& d) lazy_unique_ptr (DB& db, T* p, deleter_type&& d)
: p_ (p, std::move (d)) : p_ (p, std::move (d))
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T, class D> template <class T, class D>
template <class T1, class D1> template <class DB, class T1, class D1>
inline lazy_unique_ptr<T, D>:: inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (database_type& db, std::unique_ptr<T1, D1>&& p) lazy_unique_ptr (DB& db, std::unique_ptr<T1, D1>&& p)
: p_ (std::move (p)) : p_ (std::move (p))
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T, class D> template <class T, class D>
template <class T1> template <class DB, class T1>
inline lazy_unique_ptr<T, D>:: inline lazy_unique_ptr<T, D>::
lazy_unique_ptr (database_type& db, std::auto_ptr<T1>&& p) lazy_unique_ptr (DB& db, std::auto_ptr<T1>&& p)
: p_ (std::move (p)) : p_ (std::move (p))
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T, class D> template <class T, class D>
template <class ID> template <class DB, class ID>
inline void lazy_unique_ptr<T, D>:: inline void lazy_unique_ptr<T, D>::
reset (database_type& db, const ID& id) reset (DB& db, const ID& id)
{ {
p_.reset (); p_.reset ();
i_.reset (db, id); i_.reset (db, id);
} }
template <class T, class D> template <class T, class D>
template <class DB>
inline void lazy_unique_ptr<T, D>:: inline void lazy_unique_ptr<T, D>::
reset (database_type& db, T* p) reset (DB& db, T* p)
{ {
p_.reset (p); p_.reset (p);
if (p) if (p)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T, class D> template <class T, class D>
template <class T1, class D1> template <class DB, class T1, class D1>
inline void lazy_unique_ptr<T, D>:: inline void lazy_unique_ptr<T, D>::
reset (database_type& db, std::unique_ptr<T1, D1>&& p) reset (DB& db, std::unique_ptr<T1, D1>&& p)
{ {
p_ = std::move (p); p_ = std::move (p);
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T, class D> template <class T, class D>
template <class T1> template <class DB, class T1>
inline void lazy_unique_ptr<T, D>:: inline void lazy_unique_ptr<T, D>::
reset (database_type& db, std::auto_ptr<T1>&& p) reset (DB& db, std::auto_ptr<T1>&& p)
{ {
p_ = std::unique_ptr<T, D> (std::move (p)); p_ = std::unique_ptr<T, D> (std::move (p));
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T, class D> template <class T, class D>
template <class O> template <class O>
inline typename object_traits<O>::id_type lazy_unique_ptr<T, D>:: inline typename object_traits<O>::id_type lazy_unique_ptr<T, D>::
object_id () const object_id () const
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
skipping to change at line 1147 skipping to change at line 1153
if (p_) if (p_)
{ {
if (i_.database () != 0) if (i_.database () != 0)
i_.reset_id (object_traits<object_type>::id (*p_)); i_.reset_id (object_traits<object_type>::id (*p_));
p_.reset (); p_.reset ();
} }
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, const ID& id): i_ (db, id) {} lazy_shared_ptr (DB& db, const ID& id): i_ (db, id) {}
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, Y* p) lazy_shared_ptr (DB& db, Y* p)
: p_ (p) : p_ (p)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y, class D> template <class DB, class Y, class D>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, Y* p, D d) lazy_shared_ptr (DB& db, Y* p, D d)
: p_ (p, d) : p_ (p, d)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y, class D, class A> template <class DB, class Y, class D, class A>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, Y* p, D d, A a) lazy_shared_ptr (DB& db, Y* p, D d, A a)
: p_ (p, d, a) : p_ (p, d, a)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, std::auto_ptr<Y>&& r) lazy_shared_ptr (DB& db, std::auto_ptr<Y>&& r)
: p_ (std::move (r)) : p_ (std::move (r))
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, const std::shared_ptr<Y>& r) lazy_shared_ptr (DB& db, const std::shared_ptr<Y>& r)
: p_ (r) : p_ (r)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, std::shared_ptr<Y>&& r) lazy_shared_ptr (DB& db, std::shared_ptr<Y>&& r)
: p_ (std::move (r)) : p_ (std::move (r))
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_shared_ptr<T>:: inline lazy_shared_ptr<T>::
lazy_shared_ptr (database_type& db, const std::weak_ptr<Y>& r) lazy_shared_ptr (DB& db, const std::weak_ptr<Y>& r)
: p_ (r) : p_ (r)
{ {
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, const ID& id) reset (DB& db, const ID& id)
{ {
p_.reset (); p_.reset ();
i_.reset (db, id); i_.reset (db, id);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, Y* p) reset (DB& db, Y* p)
{ {
p_.reset (p); p_.reset (p);
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y, class D> template <class DB, class Y, class D>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, Y* p, D d) reset (DB& db, Y* p, D d)
{ {
p_.reset (p, d); p_.reset (p, d);
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y, class D, class A> template <class DB, class Y, class D, class A>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, Y* p, D d, A a) reset (DB& db, Y* p, D d, A a)
{ {
p_.reset (p, d, a); p_.reset (p, d, a);
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, std::auto_ptr<Y>&& r) reset (DB& db, std::auto_ptr<Y>&& r)
{ {
p_ = std::move (r); p_ = std::move (r);
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, const std::shared_ptr<Y>& r) reset (DB& db, const std::shared_ptr<Y>& r)
{ {
p_ = r; p_ = r;
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_shared_ptr<T>:: inline void lazy_shared_ptr<T>::
reset (database_type& db, std::shared_ptr<Y>&& r) reset (DB& db, std::shared_ptr<Y>&& r)
{ {
p_ = std::move (r); p_ = std::move (r);
if (p_) if (p_)
i_.reset (db); i_.reset_db (db);
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class O> template <class O>
inline typename object_traits<O>::id_type lazy_shared_ptr<T>:: inline typename object_traits<O>::id_type lazy_shared_ptr<T>::
object_id () const object_id () const
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
skipping to change at line 1487 skipping to change at line 1493
inline lazy_weak_ptr<T>:: inline lazy_weak_ptr<T>::
lazy_weak_ptr (const std::shared_ptr<Y>& r): p_ (r) {} lazy_weak_ptr (const std::shared_ptr<Y>& r): p_ (r) {}
template <class T> template <class T>
template <class Y> template <class Y>
inline lazy_weak_ptr<T>& lazy_weak_ptr<T>:: inline lazy_weak_ptr<T>& lazy_weak_ptr<T>::
operator= (const std::weak_ptr<Y>& r) operator= (const std::weak_ptr<Y>& r)
{ {
p_ = r; p_ = r;
i_.reset (); i_.reset ();
return this; return *this;
} }
template <class T> template <class T>
template <class Y> template <class Y>
inline lazy_weak_ptr<T>& lazy_weak_ptr<T>:: inline lazy_weak_ptr<T>& lazy_weak_ptr<T>::
operator= (const std::shared_ptr<Y>& r) operator= (const std::shared_ptr<Y>& r)
{ {
p_ = r; p_ = r;
i_.reset (); i_.reset ();
return this; return *this;
} }
template <class T> template <class T>
inline bool lazy_weak_ptr<T>:: inline bool lazy_weak_ptr<T>::
loaded () const loaded () const
{ {
bool i (i_); bool i (i_);
return expired () != i; // expired () XOR i_ return expired () != i; // expired () XOR i_
} }
skipping to change at line 1532 skipping to change at line 1538
template <class T> template <class T>
inline void lazy_weak_ptr<T>:: inline void lazy_weak_ptr<T>::
unload () const unload () const
{ {
// With weak pointer we always keep i_ up to date. // With weak pointer we always keep i_ up to date.
// //
p_.reset (); p_.reset ();
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline lazy_weak_ptr<T>:: inline lazy_weak_ptr<T>::
lazy_weak_ptr (database_type& db, const ID& id): i_ (db, id) {} lazy_weak_ptr (DB& db, const ID& id): i_ (db, id) {}
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_weak_ptr<T>:: inline lazy_weak_ptr<T>::
lazy_weak_ptr (database_type& db, const std::shared_ptr<Y>& r) lazy_weak_ptr (DB& db, const std::shared_ptr<Y>& r)
: p_ (r) : p_ (r)
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
if (r) if (r)
i_.reset (db, object_traits<object_type>::id (*r)); i_.reset (db, object_traits<object_type>::id (*r));
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline lazy_weak_ptr<T>:: inline lazy_weak_ptr<T>::
lazy_weak_ptr (database_type& db, const std::weak_ptr<Y>& r) lazy_weak_ptr (DB& db, const std::weak_ptr<Y>& r)
: p_ (r) : p_ (r)
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
std::shared_ptr<T> sp (p_.lock ()); std::shared_ptr<T> sp (p_.lock ());
if (sp) if (sp)
i_.reset (db, object_traits<object_type>::id (*sp)); i_.reset (db, object_traits<object_type>::id (*sp));
} }
template <class T> template <class T>
template <class ID> template <class DB, class ID>
inline void lazy_weak_ptr<T>:: inline void lazy_weak_ptr<T>::
reset (database_type& db, const ID& id) reset (DB& db, const ID& id)
{ {
p_.reset (); p_.reset ();
i_.reset (db, id); i_.reset (db, id);
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_weak_ptr<T>:: inline void lazy_weak_ptr<T>::
reset (database_type& db, const std::shared_ptr<Y>& r) reset (DB& db, const std::shared_ptr<Y>& r)
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
p_ = r; p_ = r;
if (r) if (r)
i_.reset (db, object_traits<object_type>::id (*r)); i_.reset (db, object_traits<object_type>::id (*r));
else else
i_.reset (); i_.reset ();
} }
template <class T> template <class T>
template <class Y> template <class DB, class Y>
inline void lazy_weak_ptr<T>:: inline void lazy_weak_ptr<T>::
reset (database_type& db, const std::weak_ptr<Y>& r) reset (DB& db, const std::weak_ptr<Y>& r)
{ {
typedef typename object_traits<T>::object_type object_type; typedef typename object_traits<T>::object_type object_type;
p_ = r; p_ = r;
std::shared_ptr<T> sp (p_.lock ()); std::shared_ptr<T> sp (p_.lock ());
if (sp) if (sp)
i_.reset (db, object_traits<object_type>::id (*sp)); i_.reset (db, object_traits<object_type>::id (*sp));
else else
i_.reset (); i_.reset ();
 End of changes. 112 change blocks. 
106 lines changed or deleted 112 lines changed or added


 lazy-ptr.txx   lazy-ptr.txx 
// file : odb/lazy-ptr.txx // file : odb/lazy-ptr.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
{ {
// //
// lazy_ptr // lazy_ptr
// //
template <class T> template <class T>
template <class Y> template <class Y>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 lock.hxx   lock.hxx 
// file : odb/details/lock.hxx // file : odb/details/lock.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_DETAILS_LOCK_HXX #ifndef ODB_DETAILS_LOCK_HXX
#define ODB_DETAILS_LOCK_HXX #define ODB_DETAILS_LOCK_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
#include <odb/details/mutex.hxx> #include <odb/details/mutex.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 memory.hxx   memory.hxx 
// file : odb/tr1/memory.hxx // file : odb/tr1/memory.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_TR1_MEMORY_HXX #ifndef ODB_TR1_MEMORY_HXX
#define ODB_TR1_MEMORY_HXX #define ODB_TR1_MEMORY_HXX
// //
// Try to include TR1 <memory> in a compiler-specific manner. Fall back // Try to include TR1 <memory> in a compiler-specific manner. Fall back
// on the Boost TR1 implementation if the compiler does not support TR1. // on the Boost TR1 implementation if the compiler does not support TR1.
// //
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 mutex.hxx   mutex.hxx 
// file : odb/details/mutex.hxx // file : odb/details/mutex.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_DETAILS_MUTEX_HXX #ifndef ODB_DETAILS_MUTEX_HXX
#define ODB_DETAILS_MUTEX_HXX #define ODB_DETAILS_MUTEX_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> #include <odb/details/config.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 mutex.ixx   mutex.ixx 
// file : odb/details/posix/mutex.ixx // file : odb/details/posix/mutex.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/details/posix/exceptions.hxx> #include <odb/details/posix/exceptions.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
{ {
inline mutex:: inline mutex::
~mutex () ~mutex ()
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 no-id-object-result.hxx   no-id-object-result.hxx 
// file : odb/no-id-object-result.hxx // file : odb/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_NO_ID_OBJECT_RESULT_HXX #ifndef ODB_NO_ID_OBJECT_RESULT_HXX
#define ODB_NO_ID_OBJECT_RESULT_HXX #define ODB_NO_ID_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <utility> // std::move #include <utility> // std::move
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/object-result.hxx> #include <odb/object-result.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
// Implementation for objects without object id (always non-polymorphic). // Implementation for objects without object id (always non-polymorphic).
// //
template <typename T> template <typename T>
class no_id_object_result_impl: public details::shared_base class no_id_object_result_impl: public result_impl
{ {
public:
virtual
~no_id_object_result_impl ();
protected: protected:
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::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;
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, void, false>; friend class object_result_iterator<T, void, false>;
friend class object_result_iterator<const T, void, false>; friend class object_result_iterator<const T, void, false>;
protected: protected:
no_id_object_result_impl (database_type& db) no_id_object_result_impl (odb::connection& conn)
: begin_ (true), end_ (false), db_ (db), current_ () : result_impl (conn), begin_ (true), end_ (false), current_ ()
{
}
database_type&
database () const
{ {
return db_;
} }
// To make this work with all kinds of pointers (raw, std::auto_ptr, // 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 // shared), we need to make sure we don't make any copies of the
// pointer on the return path. // pointer on the return path.
// //
pointer_type& pointer_type&
current () current ()
{ {
if (pointer_traits::null_ptr (current_) && !end_) if (pointer_traits::null_ptr (current_) && !end_)
skipping to change at line 143 skipping to change at line 130
#endif #endif
bool begin_; bool begin_;
bool end_; bool end_;
private: private:
void void
load (); load ();
private: private:
database_type& db_;
pointer_type current_; pointer_type current_;
typename pointer_traits::guard guard_; typename pointer_traits::guard guard_;
}; };
template <typename T> template <typename T>
class object_result_iterator<T, void, false> class object_result_iterator<T, void, false>
{ {
public: public:
// T can be const T while object_type is always non-const. // T can be const T while object_type is always non-const.
// //
 End of changes. 8 change blocks. 
18 lines changed or deleted 4 lines changed or added


 no-id-object-result.txx   no-id-object-result.txx 
// file : odb/no-id-object-result.txx // file : odb/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
namespace odb namespace odb
{ {
// //
// object_result_impl // object_result_impl
// //
template <typename T> template <typename T>
no_id_object_result_impl<T>::
~no_id_object_result_impl ()
{
}
template <typename T>
void no_id_object_result_impl<T>:: void no_id_object_result_impl<T>::
load () load ()
{ {
// Objects without ids are not stored in session cache. // Objects without ids are not stored in session cache.
// //
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);
} }
 End of changes. 2 change blocks. 
7 lines changed or deleted 1 lines changed or added


 no-op-cache-traits.hxx   no-op-cache-traits.hxx 
// file : odb/no-op-cache-traits.hxx // file : odb/no-op-cache-traits.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_NO_OP_CACHE_TRAITS_HXX #ifndef ODB_NO_OP_CACHE_TRAITS_HXX
#define ODB_NO_OP_CACHE_TRAITS_HXX #define ODB_NO_OP_CACHE_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
skipping to change at line 117 skipping to change at line 117
position_type position_type
position () const {return position_type ();} position () const {return position_type ();}
void void
release () {} release () {}
void void
reset (const position_type&) {} reset (const position_type&) {}
}; };
// Cache management.
//
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 static position_type
insert (odb::database&, const pointer_type&) {return position_type ();} insert (odb::database&, const pointer_type&) {return position_type ();}
// Special signature for unique pointers. // Special signature for unique pointers.
// //
static position_type static position_type
insert (odb::database&, void*) {return position_type ();} insert (odb::database&, void*) {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 (const position_type&) {}
// Notifications.
//
static void static void
erase (const position_type&) {} persist (const position_type&) {}
static void
load (const position_type&) {}
static void
update (odb::database&, const object_type&) {}
static void
erase (odb::database&, const id_type&) {}
}; };
template <typename P> template <typename P>
struct no_id_pointer_cache_traits struct no_id_pointer_cache_traits
{ {
typedef P pointer_type; typedef P pointer_type;
struct position_type {}; struct position_type {};
static position_type static position_type
insert (odb::database&, const pointer_type&) {return position_type ();} insert (odb::database&, const pointer_type&) {return position_type ();}
// Special signature for unique pointers. // Special signature for unique pointers.
// //
static position_type static position_type
insert (odb::database&, void*) {return position_type ();} insert (odb::database&, void*) {return position_type ();}
static void
persist (const position_type&) {}
static void
load (const position_type&) {}
}; };
// reference_cache_traits // reference_cache_traits
// //
// Caching traits for objects passed by reference. T should be the // Caching traits for objects passed by reference. T should be the
// canonical object type (non-const). // canonical object type (non-const).
// //
template <typename T> template <typename T>
struct no_op_reference_cache_traits struct no_op_reference_cache_traits
{ {
skipping to change at line 191 skipping to change at line 210
}; };
static position_type static position_type
insert (odb::database&, const id_type&, object_type&) insert (odb::database&, const id_type&, object_type&)
{ {
return position_type (); return position_type ();
} }
static position_type static position_type
insert (odb::database&, object_type&) {return position_type ();} insert (odb::database&, object_type&) {return position_type ();}
static void
persist (const position_type&) {}
static void
load (const position_type&) {}
}; };
template <typename T> template <typename T>
struct no_id_reference_cache_traits struct no_id_reference_cache_traits
{ {
typedef T object_type; typedef T object_type;
struct position_type {}; struct position_type {};
static position_type static position_type
insert (odb::database&, object_type&) {return position_type ();} insert (odb::database&, object_type&) {return position_type ();}
static void
persist (const position_type&) {}
static void
load (const position_type&) {}
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_NO_OP_CACHE_TRAITS_HXX #endif // ODB_NO_OP_CACHE_TRAITS_HXX
 End of changes. 8 change blocks. 
3 lines changed or deleted 34 lines changed or added


 nullable.hxx   nullable.hxx 
// file : odb/nullable.hxx // file : odb/nullable.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_NULLABLE_HXX #ifndef ODB_NULLABLE_HXX
#define ODB_NULLABLE_HXX #define ODB_NULLABLE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> // odb::core
namespace odb namespace odb
{ {
template <typename T> template <typename T>
class nullable class nullable
{ {
public: public:
typedef T value_type; typedef T value_type;
nullable (); nullable ();
nullable (const T&); nullable (const T&);
skipping to change at line 55 skipping to change at line 57
void reset (); void reset ();
private: private:
void true_value () {}; void true_value () {};
T value_; T value_;
bool null_; bool null_;
}; };
namespace core namespace common
{ {
using odb::nullable; using odb::nullable;
} }
template <typename T> template <typename T>
inline nullable<T>:: inline nullable<T>::
nullable () nullable ()
: null_ (true) : null_ (true)
{ {
} }
 End of changes. 3 change blocks. 
2 lines changed or deleted 4 lines changed or added


 object-result.hxx   object-result.hxx 
// file : odb/object-result.hxx // file : odb/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_OBJECT_RESULT_HXX #ifndef ODB_OBJECT_RESULT_HXX
#define ODB_OBJECT_RESULT_HXX #define ODB_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::ptrdiff_t #include <cstddef> // std::ptrdiff_t
#include <iterator> // iterator categories #include <iterator> // iterator categories
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 pointer-traits.hxx   pointer-traits.hxx 
// file : odb/pointer-traits.hxx // file : odb/pointer-traits.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_POINTER_TRAITS_HXX #ifndef ODB_POINTER_TRAITS_HXX
#define ODB_POINTER_TRAITS_HXX #define ODB_POINTER_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <new> // operators new/delete #include <new> // operators new/delete
#include <memory> // std::auto_ptr, std::unique_ptr, std::shared_ptr/weak_ ptr #include <memory> // std::auto_ptr, std::unique_ptr, std::shared_ptr/weak_ ptr
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 polymorphic-info.hxx   polymorphic-info.hxx 
// file : odb/polymorphic-info.hxx // file : odb/polymorphic-info.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_POLYMORPHIC_INFO_HXX #ifndef ODB_POLYMORPHIC_INFO_HXX
#define ODB_POLYMORPHIC_INFO_HXX #define ODB_POLYMORPHIC_INFO_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <typeinfo> #include <typeinfo>
#include <odb/forward.hxx> // database #include <odb/forward.hxx> // database
skipping to change at line 89 skipping to change at line 89
public: public:
discriminator_type discriminator; discriminator_type discriminator;
create_function create; create_function create;
dispatch_function dispatch; dispatch_function dispatch;
delayed_loader_function delayed_loader; delayed_loader_function delayed_loader;
}; };
// Register concrete type T in the root's map. // Register concrete type T in the root's map.
// //
template <typename T> template <typename T, database_id DB>
struct polymorphic_entry struct polymorphic_entry
{ {
typedef T object_type; typedef T object_type;
typedef odb::object_traits<object_type> object_traits; typedef object_traits_impl<object_type, DB> object_traits;
typedef typename object_traits::root_type root_type; typedef typename object_traits::root_type root_type;
typedef odb::object_traits<root_type> root_traits;
polymorphic_entry (); polymorphic_entry ();
~polymorphic_entry (); ~polymorphic_entry ();
}; };
// Helper functions that either return the concrete info or NULL // Helper functions that either return the concrete info or NULL
// depending on what kind of info we pass (used in query support). // depending on what kind of info we pass (used in query support).
// //
template <typename R> template <typename R>
inline const polymorphic_concrete_info<R>* inline const polymorphic_concrete_info<R>*
 End of changes. 4 change blocks. 
5 lines changed or deleted 3 lines changed or added


 polymorphic-map.hxx   polymorphic-map.hxx 
// file : odb/polymorphic-map.hxx // file : odb/polymorphic-map.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_POLYMORPHIC_MAP_HXX #ifndef ODB_POLYMORPHIC_MAP_HXX
#define ODB_POLYMORPHIC_MAP_HXX #define ODB_POLYMORPHIC_MAP_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <map> #include <map>
#include <utility> // std::move #include <utility> // std::move
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
skipping to change at line 69 skipping to change at line 69
const info_type*, const info_type*,
discriminator_comparator> discriminator_comparator>
discriminator_map; discriminator_map;
public: public:
std::size_t ref_count_; std::size_t ref_count_;
type_map type_map_; type_map type_map_;
discriminator_map discriminator_map_; discriminator_map discriminator_map_;
}; };
template <typename R> template <typename R, database_id DB>
struct polymorphic_entry_impl struct polymorphic_entry_impl
{ {
typedef R root_type; typedef R root_type;
typedef object_traits<root_type> root_traits; typedef object_traits_impl<root_type, DB> root_traits;
typedef polymorphic_concrete_info<root_type> info_type; typedef polymorphic_concrete_info<root_type> info_type;
static void static void
insert (const info_type&); insert (const info_type&);
static void static void
erase (const info_type&); erase (const info_type&);
}; };
template <typename T> template <typename T>
skipping to change at line 106 skipping to change at line 106
// Implicit downcast. // Implicit downcast.
// //
#ifdef ODB_CXX11 #ifdef ODB_CXX11
root_pointer_type r (std::move (p)); root_pointer_type r (std::move (p));
#else #else
root_pointer_type r (p); root_pointer_type r (p);
#endif #endif
return r; return r;
} }
template <typename T, typename R> template <typename T, database_id DB, typename R>
struct dispatch_load struct dispatch_load
{ {
static void static void
call (database& db, T& obj, std::size_t d) call (database& db, T& obj, std::size_t d)
{ {
object_traits<T>::load_ (db, obj, d); object_traits_impl<T, DB>::load_ (db, obj, d);
} }
}; };
template <typename R> template <typename R, database_id DB>
struct dispatch_load<R, R> struct dispatch_load<R, DB, R>
{ {
static void static void
call (database&, R&, std::size_t) call (database&, R&, std::size_t)
{ {
assert (false); assert (false);
} }
}; };
template <typename T, bool auto_id> template <typename T, database_id DB, bool auto_id>
struct dispatch_persist struct dispatch_persist
{ {
static void static void
call (database& db, const T& obj) call (database& db, const T& obj)
{ {
// Top-level call, no dynamic type checking. // Top-level call, no dynamic type checking.
// //
object_traits<T>::persist (db, obj, true, false); object_traits_impl<T, DB>::persist (db, obj, true, false);
} }
}; };
template <typename T> template <typename T, database_id DB>
struct dispatch_persist<T, true> struct dispatch_persist<T, DB, true>
{ {
static void static void
call (database& db, const T& obj) call (database& db, const T& obj)
{ {
// Top-level call, no dynamic type checking. // Top-level call, no dynamic type checking.
// //
object_traits<T>::persist (db, const_cast<T&> (obj), true, false); object_traits_impl<T, DB>::persist (
db, const_cast<T&> (obj), true, false);
} }
}; };
template <typename T> template <typename T, database_id DB>
bool dispatch_impl ( bool dispatch_impl (
typename polymorphic_concrete_info< typename polymorphic_concrete_info<
typename object_traits<T>::root_type>::call_type c, typename object_traits<T>::root_type>::call_type c,
database& db, database& db,
const typename object_traits<T>::root_type* pobj, const typename object_traits<T>::root_type* pobj,
const void* arg) const void* arg)
{ {
typedef object_traits<T> derived_traits; typedef object_traits_impl<T, DB> derived_traits;
typedef typename derived_traits::root_type root_type; typedef typename derived_traits::root_type root_type;
typedef object_traits<root_type> root_traits; typedef object_traits_impl<root_type, DB> root_traits;
typedef typename root_traits::id_type id_type; typedef typename root_traits::id_type id_type;
typedef polymorphic_concrete_info<root_type> info_type; typedef polymorphic_concrete_info<root_type> info_type;
bool r (false); bool r (false);
switch (c) switch (c)
{ {
case info_type::call_callback: case info_type::call_callback:
{ {
derived_traits::callback ( derived_traits::callback (
db, db,
*const_cast<T*> (static_cast<const T*> (pobj)), *const_cast<T*> (static_cast<const T*> (pobj)),
*static_cast<const callback_event*> (arg)); *static_cast<const callback_event*> (arg));
break; break;
} }
case info_type::call_persist: case info_type::call_persist:
{ {
dispatch_persist<T, root_traits::auto_id>::call ( dispatch_persist<T, DB, root_traits::auto_id>::call (
db, db,
*static_cast<const T*> (pobj)); *static_cast<const T*> (pobj));
break; break;
} }
case info_type::call_update: case info_type::call_update:
{ {
derived_traits::update ( derived_traits::update (
db, db,
*static_cast<const T*> (pobj), *static_cast<const T*> (pobj),
true, // Top-level call. true, // Top-level call.
skipping to change at line 211 skipping to change at line 212
case info_type::call_reload: case info_type::call_reload:
{ {
r = derived_traits::reload ( r = derived_traits::reload (
db, db,
*const_cast<T*> (static_cast<const T*> (pobj)), *const_cast<T*> (static_cast<const T*> (pobj)),
false); // No dynamic type checking. false); // No dynamic type checking.
break; break;
} }
case info_type::call_load: case info_type::call_load:
{ {
dispatch_load<T, root_type>::call ( dispatch_load<T, DB, root_type>::call (
db, db,
*const_cast<T*> (static_cast<const T*> (pobj)), *const_cast<T*> (static_cast<const T*> (pobj)),
*static_cast<const std::size_t*> (arg)); *static_cast<const std::size_t*> (arg));
break; break;
} }
case info_type::call_erase: case info_type::call_erase:
{ {
if (pobj != 0) if (pobj != 0)
derived_traits::erase ( derived_traits::erase (
db, db,
 End of changes. 15 change blocks. 
17 lines changed or deleted 18 lines changed or added


 polymorphic-map.ixx   polymorphic-map.ixx 
// file : odb/polymorphic-map.ixx // file : odb/polymorphic-map.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
{ {
template <typename T> template <typename T, database_id DB>
inline polymorphic_entry<T>:: inline polymorphic_entry<T, DB>::
polymorphic_entry () polymorphic_entry ()
{ {
polymorphic_entry_impl<root_type>::insert (object_traits::info); polymorphic_entry_impl<root_type, DB>::insert (object_traits::info);
} }
template <typename T> template <typename T, database_id DB>
inline polymorphic_entry<T>:: inline polymorphic_entry<T, DB>::
~polymorphic_entry () ~polymorphic_entry ()
{ {
polymorphic_entry_impl<root_type>::erase (object_traits::info); polymorphic_entry_impl<root_type, DB>::erase (object_traits::info);
} }
} }
 End of changes. 5 change blocks. 
7 lines changed or deleted 7 lines changed or added


 polymorphic-map.txx   polymorphic-map.txx 
// file : odb/polymorphic-map.txx // file : odb/polymorphic-map.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 <odb/exceptions.hxx> // no_type_info #include <odb/exceptions.hxx> // no_type_info
namespace odb namespace odb
{ {
// //
// polymorphic_map // polymorphic_map
// //
skipping to change at line 42 skipping to change at line 42
if (i != discriminator_map_.end ()) if (i != discriminator_map_.end ())
return *i->second; return *i->second;
else else
throw no_type_info (); throw no_type_info ();
} }
// //
// polymorphic_entry_impl // polymorphic_entry_impl
// //
template <typename R> template <typename R, database_id DB>
void polymorphic_entry_impl<R>:: void polymorphic_entry_impl<R, DB>::
insert (const info_type& i) insert (const info_type& i)
{ {
// VC10 cannot grok constructor call syntax here. // VC10 cannot grok constructor call syntax here.
// //
polymorphic_map<root_type>*& pm = root_traits::map; polymorphic_map<root_type>*& pm = root_traits::map;
if (pm == 0) if (pm == 0)
pm = new polymorphic_map<root_type>; pm = new polymorphic_map<root_type>;
else else
pm->ref_count_++; pm->ref_count_++;
pm->type_map_[&i.type] = &i; pm->type_map_[&i.type] = &i;
pm->discriminator_map_[&i.discriminator] = &i; pm->discriminator_map_[&i.discriminator] = &i;
} }
template <typename R> template <typename R, database_id DB>
void polymorphic_entry_impl<R>:: void polymorphic_entry_impl<R, DB>::
erase (const info_type& i) erase (const info_type& i)
{ {
// VC10 cannot grok constructor call syntax here. // VC10 cannot grok constructor call syntax here.
// //
polymorphic_map<root_type>*& pm = root_traits::map; polymorphic_map<root_type>*& pm = root_traits::map;
pm->discriminator_map_.erase (&i.discriminator); pm->discriminator_map_.erase (&i.discriminator);
pm->type_map_.erase (&i.type); pm->type_map_.erase (&i.type);
if (--pm->ref_count_ == 0) if (--pm->ref_count_ == 0)
 End of changes. 3 change blocks. 
5 lines changed or deleted 5 lines changed or added


 polymorphic-object-result.hxx   polymorphic-object-result.hxx 
// file : odb/polymorphic-object-result.hxx // file : odb/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_POLYMORPHIC_OBJECT_RESULT_HXX #ifndef ODB_POLYMORPHIC_OBJECT_RESULT_HXX
#define ODB_POLYMORPHIC_OBJECT_RESULT_HXX #define ODB_POLYMORPHIC_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <utility> // std::move #include <utility> // std::move
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/object-result.hxx> #include <odb/object-result.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
// Implementation for polymorphic objects with object id. // Implementation for polymorphic objects with object id.
// //
template <typename T> template <typename T>
class polymorphic_object_result_impl: public details::shared_base class polymorphic_object_result_impl: public result_impl
{ {
public:
virtual
~polymorphic_object_result_impl ();
protected: protected:
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::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;
typedef typename object_traits::root_type root_type; typedef typename object_traits::root_type root_type;
skipping to change at line 57 skipping to change at line 50
typedef typename root_traits::discriminator_type discriminator_type; typedef typename root_traits::discriminator_type discriminator_type;
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, true>; friend class object_result_iterator<T, id_type, true>;
friend class object_result_iterator<const T, id_type, true>; friend class object_result_iterator<const T, id_type, true>;
protected: protected:
polymorphic_object_result_impl (database_type& db) polymorphic_object_result_impl (odb::connection& conn)
: begin_ (true), end_ (false), db_ (db), current_ () : result_impl (conn), begin_ (true), end_ (false), current_ ()
{
}
database_type&
database () const
{ {
return db_;
} }
// To make this work with all kinds of pointers (raw, std::auto_ptr, // 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 // shared), we need to make sure we don't make any copies of the
// pointer on the return path. // pointer on the return path.
// //
pointer_type& pointer_type&
current () current ()
{ {
if (pointer_traits::null_ptr (current_) && !end_) if (pointer_traits::null_ptr (current_) && !end_)
skipping to change at line 114 skipping to change at line 101
protected: protected:
// The fetch argument is a hint to the implementation. If it is // The fetch argument is a hint to the implementation. If it is
// false then it means load_id() was already called (and presumably // false then it means load_id() was already called (and presumably
// fetched the data into the object image) and the object image // fetched the data into the object image) and the object image
// is still valid (so the implementation doesn't need to fetch // is still valid (so the implementation doesn't need to fetch
// the data again). // the data again).
// //
// The load() signature differs from the non-polymorphic cases in // The load() signature differs from the non-polymorphic cases in
// that we pass a pointer to object instead of a reference. The // that we pass a pointer to object instead of a reference. The
// object is only passed if the user requests loading into an // object is only passed if the user requests loading into an
// existing instance. Otherwise, we pass NULL an load() is // existing instance. Otherwise, we pass NULL and load() is
// responsible for creating the object of a correct dynamic // responsible for creating the object of a correct dynamic
// type and managing the object cache insertion. // type and managing the object cache insertion.
// //
virtual void virtual void
load (object_type*, bool fetch = true) = 0; load (object_type*, bool fetch = true) = 0;
virtual id_type virtual id_type
load_id () = 0; load_id () = 0;
virtual discriminator_type virtual discriminator_type
skipping to change at line 175 skipping to change at line 162
#endif #endif
bool begin_; bool begin_;
bool end_; bool end_;
private: private:
void void
load (); load ();
private: private:
database_type& db_;
pointer_type current_; pointer_type current_;
typename pointer_traits::guard guard_; typename pointer_traits::guard guard_;
}; };
template <typename T, typename ID> template <typename T, typename ID>
class object_result_iterator<T, ID, true> class object_result_iterator<T, ID, true>
{ {
public: public:
// T can be const T while object_type is always non-const. // T can be const T while object_type is always non-const.
// //
 End of changes. 9 change blocks. 
19 lines changed or deleted 5 lines changed or added


 polymorphic-object-result.txx   polymorphic-object-result.txx 
// file : odb/polymorphic-object-result.txx // file : odb/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 <odb/exceptions.hxx> #include <odb/exceptions.hxx>
namespace odb namespace odb
{ {
// //
// polymorphic_object_result_impl // polymorphic_object_result_impl
// //
template <typename T> template <typename T>
polymorphic_object_result_impl<T>::
~polymorphic_object_result_impl ()
{
}
template <typename T>
void polymorphic_object_result_impl<T>:: void polymorphic_object_result_impl<T>::
load () load ()
{ {
typedef typename root_traits::pointer_type root_pointer_type; typedef typename root_traits::pointer_type root_pointer_type;
typedef typename root_traits::pointer_traits root_pointer_traits; typedef typename root_traits::pointer_traits root_pointer_traits;
// First check the session. // First check the session.
// //
const id_type& id (load_id ()); const id_type& id (load_id ());
root_pointer_type rp ( root_pointer_type rp (
object_traits::pointer_cache_traits::find (database (), id)); object_traits::pointer_cache_traits::find (this->db_, id));
if (!root_pointer_traits::null_ptr (rp)) if (!root_pointer_traits::null_ptr (rp))
{ {
// Check if the types match. // Check if the types match.
// //
pointer_type p ( pointer_type p (
root_pointer_traits::template dynamic_pointer_cast< root_pointer_traits::template dynamic_pointer_cast<
object_type> (rp)); object_type> (rp));
if (!pointer_traits::null_ptr (p)) if (!pointer_traits::null_ptr (p))
skipping to change at line 69 skipping to change at line 63
template <typename T, typename ID> template <typename T, typename ID>
void object_result_iterator<T, ID, true>:: void object_result_iterator<T, ID, true>::
load (object_type& obj) load (object_type& obj)
{ {
if (res_->end ()) if (res_->end ())
return; return;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
typename object_traits::reference_cache_traits::insert_guard ig ( typename object_traits::reference_cache_traits::position_type p (
object_traits::reference_cache_traits::insert ( object_traits::reference_cache_traits::insert (
res_->database (), res_->load_id (), obj)); res_->db_, res_->load_id (), obj));
typename object_traits::reference_cache_traits::insert_guard ig (p);
res_->load (&obj, false); res_->load (&obj, false);
object_traits::reference_cache_traits::load (p);
ig.release (); ig.release ();
} }
} }
 End of changes. 6 change blocks. 
10 lines changed or deleted 6 lines changed or added


 polymorphic-p.hxx   polymorphic-p.hxx 
// file : odb/details/meta/polymorphic-p.hxx // file : odb/details/meta/polymorphic-p.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_DETAILS_META_POLYMORPHIC_HXX #ifndef ODB_DETAILS_META_POLYMORPHIC_HXX
#define ODB_DETAILS_META_POLYMORPHIC_HXX #define ODB_DETAILS_META_POLYMORPHIC_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/meta/class-p.hxx> #include <odb/details/meta/class-p.hxx>
#include <odb/details/meta/remove-const-volatile.hxx> #include <odb/details/meta/remove-const-volatile.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 post.hxx   post.hxx 
// file : odb/post.hxx // file : odb/post.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
#ifdef _MSC_VER #ifdef _MSC_VER
# include <odb/compilers/vc/post.hxx> # include <odb/compilers/vc/post.hxx>
#endif #endif
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 pre.hxx   pre.hxx 
// file : odb/pre.hxx // file : odb/pre.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
#ifdef _MSC_VER #ifdef _MSC_VER
# include <odb/compilers/vc/pre.hxx> # include <odb/compilers/vc/pre.hxx>
#endif #endif
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 query.hxx   query.hxx 
// file : odb/query.hxx // file : odb/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_QUERY_HXX #ifndef ODB_QUERY_HXX
#define ODB_QUERY_HXX #define ODB_QUERY_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx>
#include <odb/traits.hxx> #include <odb/traits.hxx>
namespace odb namespace odb
{ {
// Table alias for type T and alias tag Tag. The dummy third template // Table alias for type T and tag Tag.
// argument is used to make the C++ compiler weed out duplicates.
// //
// The alias_traits interface consists of two things: the table_name // The alias_traits interface consists of two things: the table_name
// static variable containing the name and, in case of a derived type // static variable containing the name and, in case of a derived type
// in a polymorphic hierarchy, the base_traits typedef. Note that the // in a polymorphic hierarchy, the base_traits typedef. Note that the
// same interface is exposed by object_traits, which is used when // same interface is exposed by object_traits, which is used when
// we need straight tables instead of aliases. // we need straight tables instead of aliases.
// //
// //
template <typename T, typename Tag, bool dummy = true> template <typename T, database_id DB, typename Tag>
struct alias_traits; struct alias_traits;
template <typename T> template <typename T, database_id DB>
struct query_columns_base; struct query_columns_base;
template <typename T, typename Alias> template <typename T, database_id DB, typename A>
struct query_columns; struct query_columns;
template <typename T, typename Alias> template <typename T, database_id DB, typename A>
struct pointer_query_columns; struct pointer_query_columns;
// Object pointer syntax wrapper. // Object pointer syntax wrapper.
// //
template <typename T> template <typename T>
struct query_pointer struct query_pointer
{ {
query_pointer () query_pointer ()
{ {
// For some reason GCC needs this dummy c-tor if we make a static // For some reason GCC needs this dummy c-tor if we make a static
// data member of this type const. // data member of this type const.
} }
T* T*
operator-> () const operator-> () const
{ {
return 0; // All members in T are static. return 0; // All members in T are static.
} }
}; };
// Query parameter decay traits.
//
template <typename T>
struct decay_traits
{
typedef const T& type;
static type
instance ();
};
template <typename T, std::size_t N>
struct decay_traits<T[N]>
{
typedef const T* type;
// Use the pointer comparability as a proxy for data comparability.
// Note that it is stricter than using element comparability (i.e.,
// one can compare int to char but not int* to char*).
//
static type
instance ();
};
// VC9 cannot handle certain cases of non-type arguments with default // VC9 cannot handle certain cases of non-type arguments with default
// values in template functions (e.g., database::query()). As a result, // values in template functions (e.g., database::query()). As a result,
// we have to use the impl trick below instead of simply having kind // we have to use the impl trick below instead of simply having kind
// as a second template argument with a default value. // as a second template argument with a default value.
// //
template <typename T, class_kind kind> template <typename T, database_id DB, class_kind kind>
struct query_selector_impl; struct query_selector_impl;
template <typename T> template <typename T, database_id DB>
struct query_selector_impl<T, class_object> struct query_selector_impl<T, DB, class_object>
{ {
typedef typename object_traits<T>::query_base_type base_type; typedef typename object_traits_impl<T, DB>::query_base_type base_type;
typedef query_columns<T, access::object_traits<T> > columns_type;
typedef
query_columns<T, DB, access::object_traits_impl<T, DB> >
columns_type;
}; };
template <typename T> template <typename T, database_id DB>
struct query_selector_impl<T, class_view> struct query_selector_impl<T, DB, class_view>
{ {
typedef typename view_traits<T>::query_base_type base_type; typedef typename view_traits_impl<T, DB>::query_base_type base_type;
typedef typename view_traits<T>::query_columns columns_type; typedef typename view_traits_impl<T, DB>::query_columns columns_type;
}; };
template <typename T> template <typename T, database_id DB>
struct query_selector: query_selector_impl<T, class_traits<T>::kind> struct query_selector: query_selector_impl<T, DB, class_traits<T>::kind>
{ {
}; };
template <typename T, typename Q = typename query_selector<T>::base_type> template <typename T,
typename B = typename query_selector<T, id_common>::base_type>
class query; class query;
namespace core namespace core
{ {
using odb::query; using odb::query;
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
 End of changes. 15 change blocks. 
19 lines changed or deleted 47 lines changed or added


 remove-const-volatile.hxx   remove-const-volatile.hxx 
// file : odb/details/meta/remove-const-volatile.hxx // file : odb/details/meta/remove-const-volatile.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_DETAILS_META_REMOVE_CONST_VOLATILE_HXX #ifndef ODB_DETAILS_META_REMOVE_CONST_VOLATILE_HXX
#define ODB_DETAILS_META_REMOVE_CONST_VOLATILE_HXX #define ODB_DETAILS_META_REMOVE_CONST_VOLATILE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/meta/remove-const.hxx> #include <odb/details/meta/remove-const.hxx>
#include <odb/details/meta/remove-volatile.hxx> #include <odb/details/meta/remove-volatile.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 remove-const.hxx   remove-const.hxx 
// file : odb/details/meta/remove-const.hxx // file : odb/details/meta/remove-const.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_DETAILS_META_REMOVE_CONST_HXX #ifndef ODB_DETAILS_META_REMOVE_CONST_HXX
#define ODB_DETAILS_META_REMOVE_CONST_HXX #define ODB_DETAILS_META_REMOVE_CONST_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 remove-pointer.hxx   remove-pointer.hxx 
// file : odb/details/meta/remove-pointer.hxx // file : odb/details/meta/remove-pointer.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_DETAILS_META_REMOVE_POINTER_HXX #ifndef ODB_DETAILS_META_REMOVE_POINTER_HXX
#define ODB_DETAILS_META_REMOVE_POINTER_HXX #define ODB_DETAILS_META_REMOVE_POINTER_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 remove-volatile.hxx   remove-volatile.hxx 
// file : odb/details/meta/remove-volatile.hxx // file : odb/details/meta/remove-volatile.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_DETAILS_META_REMOVE_VOLATILE_HXX #ifndef ODB_DETAILS_META_REMOVE_VOLATILE_HXX
#define ODB_DETAILS_META_REMOVE_VOLATILE_HXX #define ODB_DETAILS_META_REMOVE_VOLATILE_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 result.hxx   result.hxx 
// file : odb/result.hxx // file : odb/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_RESULT_HXX #ifndef ODB_RESULT_HXX
#define ODB_RESULT_HXX #define ODB_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::ptrdiff_t, std::size_t #include <cstddef> // std::ptrdiff_t, std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx> // odb::core
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/details/export.hxx>
#include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
class LIBODB_EXPORT result_impl: public details::shared_base
{
public:
virtual
~result_impl ();
virtual void
invalidate () = 0;
protected:
result_impl (connection&);
protected:
database& db_;
connection& conn_;
// Doubly-linked list of results.
//
// prev_ == 0 means we are the first element.
// next_ == 0 means we are the last element.
// next_ == this means we are not on the list.
//
protected:
friend class connection;
void
list_remove ();
result_impl* prev_;
result_impl* next_;
};
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_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
skipping to change at line 183 skipping to change at line 218
{ {
return impl_ ? impl_->size () : 0; return impl_ ? impl_->size () : 0;
} }
private: private:
friend class result<const T>; friend class result<const T>;
details::shared_ptr<result_impl_type> impl_; details::shared_ptr<result_impl_type> impl_;
}; };
namespace core namespace common
{ {
using odb::result; using odb::result;
using odb::result_iterator; using odb::result_iterator;
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_RESULT_HXX #endif // ODB_RESULT_HXX
 End of changes. 5 change blocks. 
3 lines changed or deleted 38 lines changed or added


 schema-catalog-impl.hxx   schema-catalog-impl.hxx 
// file : odb/schema-catalog-impl.hxx // file : odb/schema-catalog-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_SCHEMA_CATALOG_IMPL_HXX #ifndef ODB_SCHEMA_CATALOG_IMPL_HXX
#define ODB_SCHEMA_CATALOG_IMPL_HXX #define ODB_SCHEMA_CATALOG_IMPL_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> #include <cstddef>
#include <odb/forward.hxx> #include <odb/forward.hxx>
skipping to change at line 38 skipping to change at line 38
~schema_catalog_init (); ~schema_catalog_init ();
}; };
static const schema_catalog_init schema_catalog_init_; static const schema_catalog_init schema_catalog_init_;
// Catalog entry registration. // Catalog entry registration.
// //
struct LIBODB_EXPORT schema_catalog_entry struct LIBODB_EXPORT schema_catalog_entry
{ {
schema_catalog_entry ( schema_catalog_entry (
database_id id,
const char* name, const char* name,
bool (*entry) (database&, unsigned short pass, bool drop)); bool (*create_function) (database&, unsigned short pass, bool drop));
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SCHEMA_CATALOG_IMPL_HXX #endif // ODB_SCHEMA_CATALOG_IMPL_HXX
 End of changes. 3 change blocks. 
2 lines changed or deleted 3 lines changed or added


 schema-catalog.hxx   schema-catalog.hxx 
// file : odb/schema-catalog.hxx // file : odb/schema-catalog.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_SCHEMA_CATALOG_HXX #ifndef ODB_SCHEMA_CATALOG_HXX
#define ODB_SCHEMA_CATALOG_HXX #define ODB_SCHEMA_CATALOG_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <string> #include <string>
#include <odb/forward.hxx> #include <odb/forward.hxx> // odb::core
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
namespace odb namespace odb
{ {
class LIBODB_EXPORT schema_catalog class LIBODB_EXPORT schema_catalog
{ {
public: public:
static void static void
create_schema (database&, const std::string& name = ""); create_schema (database&, const std::string& name = "");
static bool
exists (database_id, const std::string& name);
static bool
exists (const database& db, const std::string& name)
{
return exists (db.id (), name);
}
}; };
namespace core namespace common
{ {
using odb::schema_catalog; using odb::schema_catalog;
} }
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SCHEMA_CATALOG_HXX #endif // ODB_SCHEMA_CATALOG_HXX
 End of changes. 4 change blocks. 
3 lines changed or deleted 12 lines changed or added


 session.hxx   session.hxx 
// file : odb/session.hxx // file : odb/session.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_SESSION_HXX #ifndef ODB_SESSION_HXX
#define ODB_SESSION_HXX #define ODB_SESSION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <map> #include <map>
#include <typeinfo> #include <typeinfo>
skipping to change at line 45 skipping to change at line 45
// //
~session (); ~session ();
// Current session. // Current session.
// //
public: public:
// Return true if there is a session in effect in the current // Return true if there is a session in effect in the current
// thread. // thread.
// //
static bool static bool
has_current (); has_current () {return current_pointer () != 0;}
// Get current thread's session. Throw if no session is in effect. // Get current thread's session. Throw if no session is in effect.
// //
static session& static session&
current (); current ();
// Set current thread's session. // Set current thread's session.
// //
static void static void
current (session&); current (session& s) {current_pointer (&s);}
// Revert to the no session in effect state for the current thread. // Revert to the no session in effect state for the current thread.
// //
static void static void
reset_current (); reset_current () {current_pointer (0);}
// Pointer versions.
//
static session*
current_pointer ();
static void
current_pointer (session*);
// Copying or assignment of sessions is not supported. // Copying or assignment of sessions is not supported.
// //
private: private:
session (const session&); session (const session&);
session& operator= (const session&); session& operator= (const session&);
protected: public:
struct LIBODB_EXPORT object_map_base: details::shared_base struct LIBODB_EXPORT object_map_base: details::shared_base
{ {
virtual virtual
~object_map_base (); ~object_map_base ();
}; };
template <typename T> template <typename T>
struct object_map: struct object_map: object_map_base,
object_map_base, std::map<typename object_traits<T>::id_type,
std::map<typename object_traits<T>::id_type, typename object_traits<T>::pointer_type>
typename object_traits<T>::pointer_type>
{ {
}; };
// Object cache. // Object cache.
// //
public: public:
// Position in the cache of the inserted element.
//
template <typename T> template <typename T>
struct object_position struct cache_position;
{
typedef T object_type;
typedef object_map<object_type> map;
typedef typename map::iterator iterator;
object_position (): map_ (0) {}
object_position (map& m, const iterator& p): map_ (&m), pos_ (p) {}
map* map_;
iterator pos_;
};
template <typename T> template <typename T>
object_position<T> cache_position<T>
insert (database_type&, cache_insert (database_type&,
const typename object_traits<T>::id_type&, const typename object_traits<T>::id_type&,
const typename object_traits<T>::pointer_type&); const typename object_traits<T>::pointer_type&);
template <typename T> template <typename T>
typename object_traits<T>::pointer_type typename object_traits<T>::pointer_type
find (database_type&, const typename object_traits<T>::id_type&) const; cache_find (database_type&,
const typename object_traits<T>::id_type&) const;
template <typename T> template <typename T>
void void
erase (database_type&, const typename object_traits<T>::id_type&); cache_erase (const cache_position<T>&);
template <typename T> template <typename T>
void void
erase (const object_position<T>&); cache_erase (database_type&, const typename object_traits<T>::id_type&) ;
protected: // Low-level object cache access (iteration, etc).
//
public:
typedef std::map<const std::type_info*, typedef std::map<const std::type_info*,
details::shared_ptr<object_map_base>, details::shared_ptr<object_map_base>,
details::type_info_comparator> type_map; details::type_info_comparator> type_map;
typedef std::map<database_type*, type_map> database_map; typedef std::map<database_type*, type_map> database_map;
database_map&
map () {return db_map_;}
const database_map&
map () const {return db_map_;}
// Static cache API as expected by the rest of ODB.
//
public:
// Position in the cache of the inserted element. The requirements
// for this class template are: default and copy-constructible as
// well as copy-assignable. The default constructor creates an
// empty/NULL position.
//
template <typename T>
struct cache_position
{
typedef object_map<T> map;
typedef typename map::iterator iterator;
cache_position (): map_ (0) {}
cache_position (map& m, const iterator& p): map_ (&m), pos_ (p) {}
cache_position&
operator= (const cache_position& p)
{
// It might not be ok to use an uninitialized iterator on the rhs.
//
if (p.map_ != 0)
pos_ = p.pos_;
map_ = p.map_;
return *this;
}
map* map_;
iterator pos_;
};
// The following cache management functions are all static to
// allow for a custom notion of a current session. The erase()
// function is called to remove the object if the operation
// that caused it to be inserted (e.g., load) failed.
//
template <typename T>
static cache_position<T>
_cache_insert (database_type&,
const typename object_traits<T>::id_type&,
const typename object_traits<T>::pointer_type&);
template <typename T>
static typename object_traits<T>::pointer_type
_cache_find (database_type&, const typename object_traits<T>::id_type&)
;
template <typename T>
static void
_cache_erase (const cache_position<T>&);
// Notifications. These are called after per-object callbacks for
// post_{persist, load, update, erase} events.
//
template <typename T>
static void
_cache_persist (const cache_position<T>&) {}
template <typename T>
static void
_cache_load (const cache_position<T>&) {}
template <typename T>
static void
_cache_update (database_type&, const T&) {}
template <typename T>
static void
_cache_erase (database_type&, const typename object_traits<T>::id_type&
);
protected:
database_map db_map_; database_map db_map_;
}; };
} }
#include <odb/session.ixx> #include <odb/session.ixx>
#include <odb/session.txx> #include <odb/session.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_SESSION_HXX #endif // ODB_SESSION_HXX
 End of changes. 14 change blocks. 
29 lines changed or deleted 109 lines changed or added


 session.ixx   session.ixx 
// file : odb/session.ixx // file : odb/session.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/exceptions.hxx> #include <odb/exceptions.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
inline void session:: inline void session::
erase (const object_position<T>& p) cache_erase (const cache_position<T>& p)
{ {
// @@ Empty maps are not cleaned up by this version of erase. // @@ Empty maps are not cleaned up by this version of erase.
// //
p.map_->erase (p.pos_); if (p.map_ != 0)
p.map_->erase (p.pos_);
}
template <typename T>
inline typename session::cache_position<T> session::
_cache_insert (database_type& db,
const typename object_traits<T>::id_type& id,
const typename object_traits<T>::pointer_type& obj)
{
if (session* s = current_pointer ())
return s->cache_insert<T> (db, id, obj);
else
return cache_position<T> ();
}
template <typename T>
inline typename object_traits<T>::pointer_type session::
_cache_find (database_type& db, const typename object_traits<T>::id_type&
id)
{
typedef typename object_traits<T>::pointer_type pointer_type;
if (const session* s = current_pointer ())
return s->cache_find<T> (db, id);
else
return pointer_type ();
}
template <typename T>
inline void session::
_cache_erase (const cache_position<T>& p)
{
// @@ Empty maps are not cleaned up by this version of erase.
//
if (p.map_ != 0)
p.map_->erase (p.pos_);
}
template <typename T>
inline void session::
_cache_erase (database_type& db,
const typename object_traits<T>::id_type& id)
{
if (session* s = current_pointer ())
s->cache_erase<T> (db, id);
} }
} }
 End of changes. 3 change blocks. 
3 lines changed or deleted 48 lines changed or added


 session.txx   session.txx 
// file : odb/session.txx // file : odb/session.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/pointer-traits.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
typename session::object_position<T> session:: typename session::cache_position<T> session::
insert (database_type& db, cache_insert (database_type& db,
const typename object_traits<T>::id_type& id, const typename object_traits<T>::id_type& id,
const typename object_traits<T>::pointer_type& obj) const typename object_traits<T>::pointer_type& obj)
{ {
typedef odb::object_traits<T> object_traits;
type_map& tm (db_map_[&db]); type_map& tm (db_map_[&db]);
details::shared_ptr<object_map_base>& pom (tm[&typeid (T)]); details::shared_ptr<object_map_base>& pom (tm[&typeid (T)]);
if (!pom) if (!pom)
pom.reset (new (details::shared) object_map<T>); pom.reset (new (details::shared) object_map<T>);
object_map<T>& om (static_cast<object_map<T>&> (*pom)); object_map<T>& om (static_cast<object_map<T>&> (*pom));
typename object_map<T>::value_type vt (id, obj); typename object_map<T>::value_type vt (id, obj);
std::pair<typename object_map<T>::iterator, bool> r (om.insert (vt)); std::pair<typename object_map<T>::iterator, bool> r (om.insert (vt));
// In what situation may we possibly attempt to reinsert the object? // In what situation may we possibly attempt to reinsert the object?
// For example, when the user loads the same object in two different // For example, when the user loads the same object in two different
// instances (i.e., load into a pre-allocated object). In this case // instances (i.e., load into a pre-allocated object). In this case
// we should probably update our entries accordingly. // we should probably update our entries accordingly.
// //
if (!r.second) if (!r.second)
r.first->second = obj; r.first->second = obj;
return object_position<T> (om, r.first); return cache_position<T> (om, r.first);
} }
template <typename T> template <typename T>
typename object_traits<T>::pointer_type session:: typename object_traits<T>::pointer_type session::
find (database_type& db, const typename object_traits<T>::id_type& id) co cache_find (database_type& db,
nst const typename object_traits<T>::id_type& id) const
{ {
typedef typename object_traits<T>::pointer_type pointer_type; typedef typename object_traits<T>::pointer_type pointer_type;
database_map::const_iterator di (db_map_.find (&db)); database_map::const_iterator di (db_map_.find (&db));
if (di == db_map_.end ()) if (di == db_map_.end ())
return pointer_type (); return pointer_type ();
const type_map& tm (di->second); const type_map& tm (di->second);
type_map::const_iterator ti (tm.find (&typeid (T))); type_map::const_iterator ti (tm.find (&typeid (T)));
skipping to change at line 67 skipping to change at line 64
typename object_map<T>::const_iterator oi (om.find (id)); typename object_map<T>::const_iterator oi (om.find (id));
if (oi == om.end ()) if (oi == om.end ())
return pointer_type (); return pointer_type ();
return oi->second; return oi->second;
} }
template <typename T> template <typename T>
void session:: void session::
erase (database_type& db, const typename object_traits<T>::id_type& id) cache_erase (database_type& db, const typename object_traits<T>::id_type& id)
{ {
database_map::iterator di (db_map_.find (&db)); database_map::iterator di (db_map_.find (&db));
if (di == db_map_.end ()) if (di == db_map_.end ())
return; return;
type_map& tm (di->second); type_map& tm (di->second);
type_map::iterator ti (tm.find (&typeid (T))); type_map::iterator ti (tm.find (&typeid (T)));
if (ti == tm.end ()) if (ti == tm.end ())
 End of changes. 7 change blocks. 
13 lines changed or deleted 9 lines changed or added


 shared-ptr-fwd.hxx   shared-ptr-fwd.hxx 
// file : odb/details/shared-ptr-fwd.hxx // file : odb/details/shared-ptr-fwd.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_DETAILS_SHARED_PTR_FWD_HXX #ifndef ODB_DETAILS_SHARED_PTR_FWD_HXX
#define ODB_DETAILS_SHARED_PTR_FWD_HXX #define ODB_DETAILS_SHARED_PTR_FWD_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/shared-ptr/counter-type.hxx> #include <odb/details/shared-ptr/counter-type.hxx>
namespace odb namespace odb
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 shared-ptr.hxx   shared-ptr.hxx 
// file : odb/details/shared-ptr.hxx // file : odb/details/shared-ptr.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_DETAILS_SHARED_PTR_HXX #ifndef ODB_DETAILS_SHARED_PTR_HXX
#define ODB_DETAILS_SHARED_PTR_HXX #define ODB_DETAILS_SHARED_PTR_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/shared-ptr-fwd.hxx> #include <odb/details/shared-ptr-fwd.hxx>
#include <odb/details/shared-ptr/base.hxx> #include <odb/details/shared-ptr/base.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 simple-object-result.hxx   simple-object-result.hxx 
// file : odb/simple-object-result.hxx // file : odb/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_SIMPLE_OBJECT_RESULT_HXX #ifndef ODB_SIMPLE_OBJECT_RESULT_HXX
#define ODB_SIMPLE_OBJECT_RESULT_HXX #define ODB_SIMPLE_OBJECT_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <utility> // std::move #include <utility> // std::move
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/object-result.hxx> #include <odb/object-result.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
// Implementation for non-polymorphic objects with object id. // Implementation for non-polymorphic objects with object id.
// //
template <typename T> template <typename T>
class object_result_impl: public details::shared_base class object_result_impl: public result_impl
{ {
public:
virtual
~object_result_impl ();
protected: protected:
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::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;
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, false>; friend class object_result_iterator<T, id_type, false>;
friend class object_result_iterator<const T, id_type, false>; friend class object_result_iterator<const T, id_type, false>;
protected: protected:
object_result_impl (database_type& db) object_result_impl (odb::connection& conn)
: begin_ (true), end_ (false), db_ (db), current_ () : result_impl (conn), begin_ (true), end_ (false), current_ ()
{
}
database_type&
database () const
{ {
return db_;
} }
// To make this work with all kinds of pointers (raw, std::auto_ptr, // 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 // shared), we need to make sure we don't make any copies of the
// pointer on the return path. // pointer on the return path.
// //
pointer_type& pointer_type&
current () current ()
{ {
if (pointer_traits::null_ptr (current_) && !end_) if (pointer_traits::null_ptr (current_) && !end_)
skipping to change at line 161 skipping to change at line 148
#endif #endif
bool begin_; bool begin_;
bool end_; bool end_;
private: private:
void void
load (); load ();
private: private:
database_type& db_;
pointer_type current_; pointer_type current_;
typename pointer_traits::guard guard_; typename pointer_traits::guard guard_;
}; };
template <typename T, typename ID> template <typename T, typename ID>
class object_result_iterator<T, ID, false> class object_result_iterator<T, ID, false>
{ {
public: public:
// T can be const T while object_type is always non-const. // T can be const T while object_type is always non-const.
// //
 End of changes. 8 change blocks. 
18 lines changed or deleted 4 lines changed or added


 simple-object-result.txx   simple-object-result.txx 
// file : odb/simple-object-result.txx // file : odb/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
namespace odb namespace odb
{ {
// //
// object_result_impl // object_result_impl
// //
template <typename T> template <typename T>
object_result_impl<T>::
~object_result_impl ()
{
}
template <typename T>
void object_result_impl<T>:: void object_result_impl<T>::
load () load ()
{ {
// First check the session. // First check the session.
// //
const id_type& id (load_id ()); const id_type& id (load_id ());
pointer_type p ( pointer_type p (object_traits::pointer_cache_traits::find (db_, id));
object_traits::pointer_cache_traits::find (database (), id));
if (!pointer_traits::null_ptr (p)) if (!pointer_traits::null_ptr (p))
current (p, false); // Pointer from cache should not be guarded. current (p, false); // Pointer from cache should not be guarded.
else else
{ {
p = object_traits::create (); p = object_traits::create ();
typename object_traits::pointer_cache_traits::insert_guard ig ( typename object_traits::pointer_cache_traits::insert_guard ig (
object_traits::pointer_cache_traits::insert (database (), id, p)); object_traits::pointer_cache_traits::insert (db_, id, p));
object_type& obj (pointer_traits::get_ref (p)); object_type& obj (pointer_traits::get_ref (p));
current (p); current (p);
load (obj, false); load (obj, false);
object_traits::pointer_cache_traits::load (ig.position ());
ig.release (); ig.release ();
} }
} }
// //
// object_result_iterator // object_result_iterator
// //
template <typename T, typename ID> template <typename T, typename ID>
void object_result_iterator<T, ID, false>:: void object_result_iterator<T, ID, false>::
load (object_type& obj) load (object_type& obj)
{ {
if (res_->end ()) if (res_->end ())
return; return;
typedef odb::object_traits<object_type> object_traits; typedef odb::object_traits<object_type> object_traits;
typename object_traits::reference_cache_traits::insert_guard ig ( typename object_traits::reference_cache_traits::position_type p (
object_traits::reference_cache_traits::insert ( object_traits::reference_cache_traits::insert (
res_->database (), res_->load_id (), obj)); res_->db_, res_->load_id (), obj));
typename object_traits::reference_cache_traits::insert_guard ig (p);
res_->load (obj, false); res_->load (obj, false);
object_traits::reference_cache_traits::load (p);
ig.release (); ig.release ();
} }
} }
 End of changes. 8 change blocks. 
12 lines changed or deleted 8 lines changed or added


 statement.hxx   statement.hxx 
// file : odb/statement.hxx // file : odb/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_STATEMENT_HXX #ifndef ODB_STATEMENT_HXX
#define ODB_STATEMENT_HXX #define ODB_STATEMENT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx> // connection
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
class LIBODB_EXPORT statement: public details::shared_base class LIBODB_EXPORT statement: public details::shared_base
{ {
public:
virtual
~statement () = 0;
statement () {}
private: private:
statement (const statement&); statement (const statement&);
statement& operator= (const statement&); statement& operator= (const statement&);
public: public:
typedef odb::connection connection_type;
virtual const char* virtual const char*
text () const = 0; text () const = 0;
virtual connection_type&
connection () = 0;
virtual
~statement () = 0;
protected:
statement () {}
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_MYSQL_STATEMENT_HXX #endif // ODB_MYSQL_STATEMENT_HXX
 End of changes. 5 change blocks. 
8 lines changed or deleted 13 lines changed or added


 std-array-traits.hxx   std-array-traits.hxx 
// file : odb/std-array-traits.hxx // file : odb/std-array-traits.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_STD_ARRAY_TRAITS_HXX #ifndef ODB_STD_ARRAY_TRAITS_HXX
#define ODB_STD_ARRAY_TRAITS_HXX #define ODB_STD_ARRAY_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <array> #include <array>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <cassert> #include <cassert>
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
namespace odb namespace odb
{ {
template <typename V, std::size_t N> template <typename V, std::size_t N>
class access::container_traits<std::array<V, N>> class access::container_traits<std::array<V, N>>
{ {
public: public:
static container_kind const kind = ck_ordered; static const container_kind kind = ck_ordered;
static const bool smart = false;
typedef std::array<V, N> container_type; typedef std::array<V, N> container_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::size_type index_type; typedef typename container_type::size_type index_type;
typedef ordered_functions<index_type, value_type> functions; typedef ordered_functions<index_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (index_type i (0); i < N; ++i) for (index_type i (0); i < N; ++i)
f.insert_one (i, c[i]); f.insert (i, c[i]);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
index_type i (0); index_type i (0);
for (; more && i < N; ++i) for (; more && i < N; ++i)
{ {
index_type dummy; index_type dummy;
more = f.load_all (dummy, c[i]); more = f.select (dummy, c[i]);
} }
assert (!more && i == N); assert (!more && i == N);
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (index_type i (0); i < N; ++i) for (index_type i (0); i < N; ++i)
f.insert_one (i, c[i]); f.insert (i, c[i]);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_ARRAY_TRAITS_HXX #endif // ODB_STD_ARRAY_TRAITS_HXX
 End of changes. 7 change blocks. 
7 lines changed or deleted 8 lines changed or added


 std-forward-list-traits.hxx   std-forward-list-traits.hxx 
// file : odb/std-forward-list-traits.hxx // file : odb/std-forward-list-traits.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_STD_FORWARD_LIST_TRAITS_HXX #ifndef ODB_STD_FORWARD_LIST_TRAITS_HXX
#define ODB_STD_FORWARD_LIST_TRAITS_HXX #define ODB_STD_FORWARD_LIST_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <forward_list> #include <forward_list>
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
namespace odb namespace odb
{ {
template <typename V, typename A> template <typename V, typename A>
class access::container_traits<std::forward_list<V, A>> class access::container_traits<std::forward_list<V, A>>
{ {
public: public:
static container_kind const kind = ck_ordered; static const container_kind kind = ck_ordered;
static const bool smart = false;
typedef std::forward_list<V, A> container_type; typedef std::forward_list<V, A> container_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::size_type index_type; typedef typename container_type::size_type index_type;
typedef ordered_functions<index_type, value_type> functions; typedef ordered_functions<index_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
index_type i (0); index_type i (0);
for (typename container_type::const_iterator j (c.begin ()), for (typename container_type::const_iterator j (c.begin ()),
e (c.end ()); j != e; ++j) e (c.end ()); j != e; ++j)
f.insert_one (i++, *j); f.insert (i++, *j);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
for (typename container_type::iterator i (c.before_begin ()); more; ) for (typename container_type::iterator i (c.before_begin ()); more; )
{ {
index_type dummy; index_type dummy;
i = c.insert_after (i, value_type ()); i = c.insert_after (i, value_type ());
more = f.load_all (dummy, *i); more = f.select (dummy, *i);
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
index_type i (0); index_type i (0);
for (typename container_type::const_iterator j (c.begin ()), for (typename container_type::const_iterator j (c.begin ()),
e (c.end ()); j != e; ++j) e (c.end ()); j != e; ++j)
f.insert_one (i++, *j); f.insert (i++, *j);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_FORWARD_LIST_TRAITS_HXX #endif // ODB_STD_FORWARD_LIST_TRAITS_HXX
 End of changes. 7 change blocks. 
7 lines changed or deleted 8 lines changed or added


 std-list-traits.hxx   std-list-traits.hxx 
// file : odb/std-list-traits.hxx // file : odb/std-list-traits.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_STD_LIST_TRAITS_HXX #ifndef ODB_STD_LIST_TRAITS_HXX
#define ODB_STD_LIST_TRAITS_HXX #define ODB_STD_LIST_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <list> #include <list>
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
namespace odb namespace odb
{ {
template <typename V, typename A> template <typename V, typename A>
class access::container_traits<std::list<V, A> > class access::container_traits<std::list<V, A> >
{ {
public: public:
static container_kind const kind = ck_ordered; static const container_kind kind = ck_ordered;
static const bool smart = false;
typedef std::list<V, A> container_type; typedef std::list<V, A> container_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::size_type index_type; typedef typename container_type::size_type index_type;
typedef ordered_functions<index_type, value_type> functions; typedef ordered_functions<index_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
index_type i (0); index_type i (0);
for (typename container_type::const_iterator j (c.begin ()), for (typename container_type::const_iterator j (c.begin ()),
e (c.end ()); j != e; ++j) e (c.end ()); j != e; ++j)
f.insert_one (i++, *j); f.insert (i++, *j);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
index_type dummy; index_type dummy;
c.push_back (value_type ()); c.push_back (value_type ());
more = f.load_all (dummy, c.back ()); more = f.select (dummy, c.back ());
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
index_type i (0); index_type i (0);
for (typename container_type::const_iterator j (c.begin ()), for (typename container_type::const_iterator j (c.begin ()),
e (c.end ()); j != e; ++j) e (c.end ()); j != e; ++j)
f.insert_one (i++, *j); f.insert (i++, *j);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_LIST_TRAITS_HXX #endif // ODB_STD_LIST_TRAITS_HXX
 End of changes. 7 change blocks. 
7 lines changed or deleted 8 lines changed or added


 std-map-traits.hxx   std-map-traits.hxx 
// file : odb/std-map-traits.hxx // file : odb/std-map-traits.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_STD_MAP_TRAITS_HXX #ifndef ODB_STD_MAP_TRAITS_HXX
#define ODB_STD_MAP_TRAITS_HXX #define ODB_STD_MAP_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <map> #include <map>
#include <utility> // std::move #include <utility> // std::move
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
namespace odb namespace odb
{ {
template <typename K, typename V, typename C, typename A> template <typename K, typename V, typename C, typename A>
class access::container_traits<std::map<K, V, C, A> > class access::container_traits<std::map<K, V, C, A> >
{ {
public: public:
static container_kind const kind = ck_map; static const container_kind kind = ck_map;
static const bool smart = false;
typedef std::map<K, V, C, A> container_type; typedef std::map<K, V, C, A> container_type;
typedef K key_type; typedef K key_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::value_type pair_type; typedef typename container_type::value_type pair_type;
typedef map_functions<key_type, value_type> functions; typedef map_functions<key_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
key_type k; key_type k;
value_type v; value_type v;
more = f.load_all (k, v); more = f.select (k, v);
#ifdef ODB_CXX11 #ifdef ODB_CXX11
c.insert (pair_type (std::move (k), std::move (v))); c.insert (pair_type (std::move (k), std::move (v)));
#else #else
c.insert (pair_type (k, v)); c.insert (pair_type (k, v));
#endif #endif
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
// C++03 does not guarantee insertion order of equal values but C++11 // C++03 does not guarantee insertion order of equal values but C++11
// changes that. The current implementation in the generated code does // changes that. The current implementation in the generated code does
// not guarantee this either. // not guarantee this either.
// //
template <typename K, typename V, typename C, typename A> template <typename K, typename V, typename C, typename A>
class access::container_traits<std::multimap<K, V, C, A> > class access::container_traits<std::multimap<K, V, C, A> >
{ {
public: public:
static container_kind const kind = ck_multimap; static const container_kind kind = ck_multimap;
static const bool smart = false;
typedef std::multimap<K, V, C, A> container_type; typedef std::multimap<K, V, C, A> container_type;
typedef K key_type; typedef K key_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::value_type pair_type; typedef typename container_type::value_type pair_type;
typedef map_functions<key_type, value_type> functions; typedef map_functions<key_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
key_type k; key_type k;
value_type v; value_type v;
more = f.load_all (k, v); more = f.select (k, v);
#ifdef ODB_CXX11 #ifdef ODB_CXX11
c.insert (pair_type (std::move (k), std::move (v))); c.insert (pair_type (std::move (k), std::move (v)));
#else #else
c.insert (pair_type (k, v)); c.insert (pair_type (k, v));
#endif #endif
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_MAP_TRAITS_HXX #endif // ODB_STD_MAP_TRAITS_HXX
 End of changes. 13 change blocks. 
13 lines changed or deleted 15 lines changed or added


 std-set-traits.hxx   std-set-traits.hxx 
// file : odb/std-set-traits.hxx // file : odb/std-set-traits.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_STD_SET_TRAITS_HXX #ifndef ODB_STD_SET_TRAITS_HXX
#define ODB_STD_SET_TRAITS_HXX #define ODB_STD_SET_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <set> #include <set>
#include <utility> // std::move #include <utility> // std::move
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
namespace odb namespace odb
{ {
template <typename V, typename C, typename A> template <typename V, typename C, typename A>
class access::container_traits<std::set<V, C, A> > class access::container_traits<std::set<V, C, A> >
{ {
public: public:
static container_kind const kind = ck_set; static const container_kind kind = ck_set;
static const bool smart = false;
typedef std::set<V, C, A> container_type; typedef std::set<V, C, A> container_type;
typedef V value_type; typedef V value_type;
typedef set_functions<value_type> functions; typedef set_functions<value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
value_type v; value_type v;
more = f.load_all (v); more = f.select (v);
#ifdef ODB_CXX11 #ifdef ODB_CXX11
c.insert (std::move (v)); c.insert (std::move (v));
#else #else
c.insert (v); c.insert (v);
#endif #endif
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
// C++03 does not guarantee insertion order of equal values but C++11 // C++03 does not guarantee insertion order of equal values but C++11
// changes that. The current implementation in the generated code does // changes that. The current implementation in the generated code does
// not guarantee this either. // not guarantee this either.
// //
template <typename V, typename C, typename A> template <typename V, typename C, typename A>
class access::container_traits<std::multiset<V, C, A> > class access::container_traits<std::multiset<V, C, A> >
{ {
public: public:
static container_kind const kind = ck_multiset; static const container_kind kind = ck_multiset;
static const bool smart = false;
typedef std::multiset<V, C, A> container_type; typedef std::multiset<V, C, A> container_type;
typedef V value_type; typedef V value_type;
typedef set_functions<value_type> functions; typedef set_functions<value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
value_type v; value_type v;
more = f.load_all (v); more = f.select (v);
#ifdef ODB_CXX11 #ifdef ODB_CXX11
c.insert (std::move (v)); c.insert (std::move (v));
#else #else
c.insert (v); c.insert (v);
#endif #endif
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_SET_TRAITS_HXX #endif // ODB_STD_SET_TRAITS_HXX
 End of changes. 13 change blocks. 
13 lines changed or deleted 15 lines changed or added


 std-unordered-map-traits.hxx   std-unordered-map-traits.hxx 
// file : odb/std-unordered-map-traits.hxx // file : odb/std-unordered-map-traits.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_STD_UNORDERED_MAP_TRAITS_HXX #ifndef ODB_STD_UNORDERED_MAP_TRAITS_HXX
#define ODB_STD_UNORDERED_MAP_TRAITS_HXX #define ODB_STD_UNORDERED_MAP_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <utility> // std::move #include <utility> // std::move
#include <unordered_map> #include <unordered_map>
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
namespace odb namespace odb
{ {
template <typename K, typename V, typename H, typename P, typename A> template <typename K, typename V, typename H, typename P, typename A>
class access::container_traits<std::unordered_map<K, V, H, P, A>> class access::container_traits<std::unordered_map<K, V, H, P, A>>
{ {
public: public:
static container_kind const kind = ck_map; static const container_kind kind = ck_map;
static const bool smart = false;
typedef std::unordered_map<K, V, H, P, A> container_type; typedef std::unordered_map<K, V, H, P, A> container_type;
typedef K key_type; typedef K key_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::value_type pair_type; typedef typename container_type::value_type pair_type;
typedef map_functions<key_type, value_type> functions; typedef map_functions<key_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
key_type k; key_type k;
value_type v; value_type v;
more = f.load_all (k, v); more = f.select (k, v);
c.insert (pair_type (std::move (k), std::move (v))); c.insert (pair_type (std::move (k), std::move (v)));
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
// @@ Does multimap preserve insertion order of equal elements? The // @@ Does multimap preserve insertion order of equal elements? The
// current implementation in the generated code does not guarantee // current implementation in the generated code does not guarantee
// this. // this.
// //
template <typename K, typename V, typename H, typename P, typename A> template <typename K, typename V, typename H, typename P, typename A>
class access::container_traits<std::unordered_multimap<K, V, H, P, A>> class access::container_traits<std::unordered_multimap<K, V, H, P, A>>
{ {
public: public:
static container_kind const kind = ck_multimap; static const container_kind kind = ck_multimap;
static const bool smart = false;
typedef std::unordered_multimap<K, V, H, P, A> container_type; typedef std::unordered_multimap<K, V, H, P, A> container_type;
typedef K key_type; typedef K key_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::value_type pair_type; typedef typename container_type::value_type pair_type;
typedef map_functions<key_type, value_type> functions; typedef map_functions<key_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
key_type k; key_type k;
value_type v; value_type v;
more = f.load_all (k, v); more = f.select (k, v);
c.insert (pair_type (std::move (k), std::move (v))); c.insert (pair_type (std::move (k), std::move (v)));
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (i->first, i->second); f.insert (i->first, i->second);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_UNORDERED_MAP_TRAITS_HXX #endif // ODB_STD_UNORDERED_MAP_TRAITS_HXX
 End of changes. 13 change blocks. 
13 lines changed or deleted 15 lines changed or added


 std-unordered-set-traits.hxx   std-unordered-set-traits.hxx 
// file : odb/std-unordered-set-traits.hxx // file : odb/std-unordered-set-traits.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_STD_UNORDERED_SET_TRAITS_HXX #ifndef ODB_STD_UNORDERED_SET_TRAITS_HXX
#define ODB_STD_UNORDERED_SET_TRAITS_HXX #define ODB_STD_UNORDERED_SET_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <utility> // std::move #include <utility> // std::move
#include <unordered_set> #include <unordered_set>
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
namespace odb namespace odb
{ {
template <typename V, typename H, typename P, typename A> template <typename V, typename H, typename P, typename A>
class access::container_traits<std::unordered_set<V, H, P, A>> class access::container_traits<std::unordered_set<V, H, P, A>>
{ {
public: public:
static container_kind const kind = ck_set; static const container_kind kind = ck_set;
static const bool smart = false;
typedef std::unordered_set<V, H, P, A> container_type; typedef std::unordered_set<V, H, P, A> container_type;
typedef V value_type; typedef V value_type;
typedef set_functions<value_type> functions; typedef set_functions<value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
value_type v; value_type v;
more = f.load_all (v); more = f.select (v);
c.insert (std::move (v)); c.insert (std::move (v));
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
// @@ Does multiset preserve insertion order of equal elements? The // @@ Does multiset preserve insertion order of equal elements? The
// current implementation in the generated code does not guarantee // current implementation in the generated code does not guarantee
// this. // this.
// //
template <typename V, typename H, typename P, typename A> template <typename V, typename H, typename P, typename A>
class access::container_traits<std::unordered_multiset<V, H, P, A>> class access::container_traits<std::unordered_multiset<V, H, P, A>>
{ {
public: public:
static container_kind const kind = ck_multiset; static const container_kind kind = ck_multiset;
static const bool smart = false;
typedef std::unordered_multiset<V, H, P, A> container_type; typedef std::unordered_multiset<V, H, P, A> container_type;
typedef V value_type; typedef V value_type;
typedef set_functions<value_type> functions; typedef set_functions<value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
value_type v; value_type v;
more = f.load_all (v); more = f.select (v);
c.insert (std::move (v)); c.insert (std::move (v));
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (typename container_type::const_iterator i (c.begin ()), for (typename container_type::const_iterator i (c.begin ()),
e (c.end ()); i != e; ++i) e (c.end ()); i != e; ++i)
f.insert_one (*i); f.insert (*i);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_UNORDERED_SET_TRAITS_HXX #endif // ODB_STD_UNORDERED_SET_TRAITS_HXX
 End of changes. 13 change blocks. 
13 lines changed or deleted 15 lines changed or added


 std-vector-traits.hxx   std-vector-traits.hxx 
// file : odb/std-vector-traits.hxx // file : odb/std-vector-traits.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_STD_VECTOR_TRAITS_HXX #ifndef ODB_STD_VECTOR_TRAITS_HXX
#define ODB_STD_VECTOR_TRAITS_HXX #define ODB_STD_VECTOR_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <vector> #include <vector>
#include <odb/container-traits.hxx> #include <odb/container-traits.hxx>
namespace odb namespace odb
{ {
template <typename V, typename A> template <typename V, typename A>
class access::container_traits<std::vector<V, A> > class access::container_traits<std::vector<V, A> >
{ {
public: public:
static container_kind const kind = ck_ordered; static const container_kind kind = ck_ordered;
static const bool smart = false;
typedef std::vector<V, A> container_type; typedef std::vector<V, A> container_type;
typedef V value_type; typedef V value_type;
typedef typename container_type::size_type index_type; typedef typename container_type::size_type index_type;
typedef ordered_functions<index_type, value_type> functions; typedef ordered_functions<index_type, value_type> functions;
public: public:
static void static void
persist (const container_type& c, const functions& f) persist (const container_type& c, const functions& f)
{ {
for (index_type i (0), n (c.size ()); i < n; ++i) for (index_type i (0), n (c.size ()); i < n; ++i)
f.insert_one (i, c[i]); f.insert (i, c[i]);
} }
static void static void
load (container_type& c, bool more, const functions& f) load (container_type& c, bool more, const functions& f)
{ {
c.clear (); c.clear ();
while (more) while (more)
{ {
index_type dummy; index_type dummy;
c.push_back (value_type ()); c.push_back (value_type ());
more = f.load_all (dummy, c.back ()); more = f.select (dummy, c.back ());
} }
} }
static void static void
update (const container_type& c, const functions& f) update (const container_type& c, const functions& f)
{ {
f.delete_all (); f.delete_ ();
for (index_type i (0), n (c.size ()); i < n; ++i) for (index_type i (0), n (c.size ()); i < n; ++i)
f.insert_one (i, c[i]); f.insert (i, c[i]);
} }
static void static void
erase (const functions& f) erase (const functions& f)
{ {
f.delete_all (); f.delete_ ();
} }
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_STD_VECTOR_TRAITS_HXX #endif // ODB_STD_VECTOR_TRAITS_HXX
 End of changes. 7 change blocks. 
7 lines changed or deleted 8 lines changed or added


 thread.hxx   thread.hxx 
// file : odb/details/thread.hxx // file : odb/details/thread.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_DETAILS_THREAD_HXX #ifndef ODB_DETAILS_THREAD_HXX
#define ODB_DETAILS_THREAD_HXX #define ODB_DETAILS_THREAD_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> #include <odb/details/config.hxx>
#ifdef ODB_THREADS_NONE #ifdef ODB_THREADS_NONE
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 thread.ixx   thread.ixx 
// file : odb/details/posix/thread.ixx // file : odb/details/posix/thread.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/details/posix/exceptions.hxx> #include <odb/details/posix/exceptions.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
{ {
inline thread:: inline thread::
~thread () ~thread ()
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 tls.hxx   tls.hxx 
// file : odb/details/tls.hxx // file : odb/details/tls.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_DETAILS_TLS_HXX #ifndef ODB_DETAILS_TLS_HXX
#define ODB_DETAILS_TLS_HXX #define ODB_DETAILS_TLS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/details/config.hxx> #include <odb/details/config.hxx>
#ifdef ODB_THREADS_NONE #ifdef ODB_THREADS_NONE
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 tls.ixx   tls.ixx 
// file : odb/details/posix/tls.ixx // file : odb/details/posix/tls.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 details namespace details
{ {
template <typename T> template <typename T>
inline tls<T>:: inline tls<T>::
tls () tls ()
{ {
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 tls.txx   tls.txx 
// file : odb/details/posix/tls.txx // file : odb/details/posix/tls.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/details/unique-ptr.hxx> #include <odb/details/unique-ptr.hxx>
#include <odb/details/posix/exceptions.hxx> #include <odb/details/posix/exceptions.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
{ {
// tls<T> // tls<T>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 tracer.hxx   tracer.hxx 
// file : odb/tracer.hxx // file : odb/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_TRACER_HXX #ifndef ODB_TRACER_HXX
#define ODB_TRACER_HXX #define ODB_TRACER_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 traits.hxx   traits.hxx 
// file : odb/traits.hxx // file : odb/traits.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_TRAITS_HXX #ifndef ODB_TRAITS_HXX
#define ODB_TRAITS_HXX #define ODB_TRAITS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
skipping to change at line 81 skipping to change at line 81
}; };
}; };
// //
// class_traits // class_traits
// //
enum class_kind enum class_kind
{ {
class_object, class_object,
class_view, class_view,
class_composite,
class_other class_other
}; };
template <typename T> template <typename T>
struct class_traits struct class_traits
{ {
static const class_kind kind = class_other; static const class_kind kind = class_other;
}; };
template <typename T> template <typename T>
struct class_traits<const T> struct class_traits<const T>
{ {
static const class_kind kind = class_traits<T>::kind; static const class_kind kind = class_traits<T>::kind;
}; };
// //
// object_traits // object_traits
// //
template <typename T> template <typename T>
//
// If a C++ compiler issues an error pointing to this struct and
// saying that it is incomplete, then you are most likely trying to
// perform a database operation on a C++ type that is not a persistent
// object. Or you forgot to include the corresponding -odb.hxx file.
//
struct object_traits: struct object_traits:
access::object_traits<T>, access::object_traits<T>,
access::object_factory<T, typename access::object_traits<T>::pointer_ty pe> access::object_factory<T, typename access::object_traits<T>::pointer_ty pe>
{ {
//
// If a C++ compiler issues an error pointing to this struct and
// saying that it is incomplete, then you are most likely trying to
// perform a database operation on a C++ type that is not a persistent
// object. Or you forgot to include the corresponding -odb.hxx file.
//
typedef typedef
odb::pointer_traits<typename access::object_traits<T>::pointer_type> odb::pointer_traits<typename access::object_traits<T>::pointer_type>
pointer_traits; pointer_traits;
typedef typename access::object_traits<T>::object_type object_type; typedef typename access::object_traits<T>::object_type object_type;
typedef typename access::object_traits<T>::pointer_type pointer_type; typedef typename access::object_traits<T>::pointer_type pointer_type;
typedef typename pointer_traits::const_pointer_type const_pointer_type; typedef typename pointer_traits::const_pointer_type const_pointer_type;
}; };
// Specialization for const objects. It only defines the id, object, // Specialization for const objects. It only defines the id, object,
skipping to change at line 163 skipping to change at line 161
struct id_type {}; struct id_type {};
}; };
template <typename T> template <typename T>
struct object_traits<T* const> struct object_traits<T* const>
{ {
struct id_type {}; struct id_type {};
}; };
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
struct object_traits< P<T> > struct object_traits<P<T> >
{ {
struct id_type {}; struct id_type {};
}; };
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
struct object_traits< P<T, A1> > struct object_traits<P<T, A1> >
{ {
struct id_type {}; struct id_type {};
}; };
template <typename T, template <typename> class P> template <typename T, template <typename> class P>
struct object_traits< const P<T> > struct object_traits<const P<T> >
{ {
struct id_type {}; struct id_type {};
}; };
template <typename T, typename A1, template <typename, typename> class P> template <typename T, typename A1, template <typename, typename> class P>
struct object_traits< const P<T, A1> > struct object_traits<const P<T, A1> >
{ {
struct id_type {}; struct id_type {};
}; };
template <typename T, database_id DB>
//
// If a C++ compiler issues an error pointing to this struct and
// saying that it is incomplete, then you are most likely trying to
// perform a database operation on a C++ type that is not a persistent
// object. Or you forgot to include the corresponding -odb.hxx file.
//
struct object_traits_impl:
access::object_traits_impl<T, DB>,
access::object_factory<T, typename access::object_traits<T>::pointer_ty
pe>
{
typedef
odb::pointer_traits<typename access::object_traits<T>::pointer_type>
pointer_traits;
typedef typename access::object_traits<T>::object_type object_type;
typedef typename access::object_traits<T>::pointer_type pointer_type;
typedef typename pointer_traits::const_pointer_type const_pointer_type;
};
// //
// view_traits // view_traits
// //
template <typename T> template <typename T>
//
// If a C++ compiler issues an error pointing to this struct and
// saying that it is incomplete, then you are most likely trying to
// perform a database operation on a C++ type that is not a view
// Or you forgot to include the corresponding -odb.hxx file.
//
struct view_traits: struct view_traits:
access::view_traits<T>, access::view_traits<T>,
access::view_factory<T, typename access::view_traits<T>::pointer_type> access::view_factory<T, typename access::view_traits<T>::pointer_type>
{ {
//
// If a C++ compiler issues an error pointing to this struct and
// saying that it is incomplete, then you are most likely trying to
// perform a database operation on a C++ type that is not a view
// Or you forgot to include the corresponding -odb.hxx file.
//
typedef typedef
odb::pointer_traits<typename access::view_traits<T>::pointer_type> odb::pointer_traits<typename access::view_traits<T>::pointer_type>
pointer_traits; pointer_traits;
typedef typename access::view_traits<T>::view_type view_type; typedef typename access::view_traits<T>::view_type view_type;
typedef typename access::view_traits<T>::pointer_type pointer_type; typedef typename access::view_traits<T>::pointer_type pointer_type;
}; };
// Specialization for const views. It only defines the view, pointer, // Specialization for const views. It only defines the view, pointer,
// and const_pointer types with pointer and const_pointer being the // and const_pointer types with pointer and const_pointer being the
skipping to change at line 230 skipping to change at line 247
typedef typedef
odb::pointer_traits<typename access::view_traits<T>::pointer_type> odb::pointer_traits<typename access::view_traits<T>::pointer_type>
pointer_traits; pointer_traits;
public: public:
typedef typename access::view_traits<T>::view_type view_type; typedef typename access::view_traits<T>::view_type view_type;
typedef typename pointer_traits::const_pointer_type const_pointer_type; typedef typename pointer_traits::const_pointer_type const_pointer_type;
typedef const_pointer_type pointer_type; typedef const_pointer_type pointer_type;
}; };
template <typename T, database_id DB>
//
// If a C++ compiler issues an error pointing to this struct and
// saying that it is incomplete, then you are most likely trying to
// perform a database operation on a C++ type that is not a view
// Or you forgot to include the corresponding -odb.hxx file.
//
struct view_traits_impl:
access::view_traits_impl<T, DB>,
access::view_factory<T, typename access::view_traits<T>::pointer_type>
{
typedef
odb::pointer_traits<typename access::view_traits<T>::pointer_type>
pointer_traits;
typedef typename access::view_traits<T>::view_type view_type;
typedef typename access::view_traits<T>::pointer_type pointer_type;
};
// //
// composite_value_traits // composite_value_traits
// //
template <typename T> template <typename T, database_id DB>
struct composite_value_traits: access::composite_value_traits<T> struct composite_value_traits: access::composite_value_traits<T, DB>
{ {
}; };
} }
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_TRAITS_HXX #endif // ODB_TRAITS_HXX
 End of changes. 13 change blocks. 
22 lines changed or deleted 59 lines changed or added


 transaction.hxx   transaction.hxx 
// file : odb/transaction.hxx // file : odb/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_TRANSACTION_HXX #ifndef ODB_TRANSACTION_HXX
#define ODB_TRANSACTION_HXX #define ODB_TRANSACTION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <vector>
#include <cstddef> // std::size_t
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
#include <odb/details/unique-ptr.hxx> #include <odb/details/unique-ptr.hxx>
namespace odb namespace odb
{ {
class transaction_impl; class transaction_impl;
class LIBODB_EXPORT transaction class LIBODB_EXPORT transaction
skipping to change at line 96 skipping to change at line 99
void void
tracer (tracer_type&); tracer (tracer_type&);
void void
tracer (tracer_type*); tracer (tracer_type*);
tracer_type* tracer_type*
tracer () const; tracer () const;
// Post-commit/rollback callbacks.
//
public:
static const unsigned short event_commit = 0x01;
static const unsigned short event_rollback = 0x02;
static const unsigned short event_all = event_commit | event_rollback;
typedef void (*callback_type) (
unsigned short event, void* key, unsigned long long data);
// Register a post-commit/rollback callback. The data argument
// can be used to store any user data that does not exceed 8
// bytes and doesn't require alignment greater than unsigned
// long long, such as an old value that needs to be restored
// in case of a rollback.
//
// The state argument can be used to indicate to the caller
// that the callback has been unregistered because the
// transaction has terminated. In this case the transaction
// resets the passed pointer to 0.
//
// Note that the order in which the callbacks are called is
// unspecified.
//
void
callback_register (callback_type,
void* key,
unsigned short event = event_all,
unsigned long long data = 0,
transaction** state = 0);
// Unregister a post-commit/rollback callback. Note that this is a
// potentially slow operation. You also don't need to unregister
// a callback that has been called or auto-reset using the state
// argument passed to register(). This function does nothing if
// the key is not found.
//
void
callback_unregister (void* key);
// Update the event, data, and state values for a callback. Note
// that just like unregister(), this is a potentially slow operation.
//
void
callback_update (void* key,
unsigned short event,
unsigned long long data = 0,
transaction** state = 0);
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&);
protected: protected:
friend struct rollback_guard;
std::size_t
callback_find (void* key);
void
callback_call (unsigned short event);
protected:
bool finalized_; bool finalized_;
details::unique_ptr<transaction_impl> impl_; details::unique_ptr<transaction_impl> impl_;
// Callbacks.
//
struct callback_data
{
unsigned short event;
callback_type func;
void* key;
unsigned long long data;
transaction** state;
};
// Slots for the first 20 callback are pre-allocated on the stack.
// For the rest they are allocated dynamically as needed.
//
// Note, if you change stack_callback_count, make sure you also
// update the common/transaction/callback test accordingly.
//
static const std::size_t stack_callback_count = 20;
static const std::size_t max_callback_count = ~(std::size_t (0));
callback_data stack_callbacks_[stack_callback_count];
std::vector<callback_data> dyn_callbacks_;
// When a callback is unregistered, the free slot from the stack is
// added to the linked list of free slots which is organized by
// re-using the key data member to store the slot's index (we cannot
// store a pointer because std::vector may move slots on expansion).
// The value equal to max_callback_count indicates no free slots are
// available.
//
std::size_t free_callback_;
// Total number of used slots, both registered and in the free list.
//
std::size_t callback_count_;
}; };
class LIBODB_EXPORT transaction_impl class LIBODB_EXPORT transaction_impl
{ {
public: public:
typedef odb::database database_type; typedef odb::database database_type;
typedef odb::connection connection_type; typedef odb::connection connection_type;
virtual virtual
~transaction_impl (); ~transaction_impl ();
 End of changes. 5 change blocks. 
1 lines changed or deleted 98 lines changed or added


 transaction.ixx   transaction.ixx 
// file : odb/transaction.ixx // file : odb/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/connection.hxx> #include <odb/connection.hxx>
namespace odb namespace odb
{ {
inline transaction:: inline transaction::
transaction (transaction_impl* impl, bool make_current) transaction (transaction_impl* impl, bool make_current)
: finalized_ (true), impl_ (0) : finalized_ (true),
impl_ (0),
free_callback_ (max_callback_count),
callback_count_ (0)
{ {
reset (impl, make_current); reset (impl, make_current);
} }
inline transaction::database_type& transaction:: inline transaction::database_type& transaction::
database () database ()
{ {
return impl_->database (); return impl_->database ();
} }
 End of changes. 2 change blocks. 
2 lines changed or deleted 5 lines changed or added


 transfer-ptr.hxx   transfer-ptr.hxx 
// file : odb/details/transfer-ptr.hxx // file : odb/details/transfer-ptr.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_DETAILS_TRANSFER_PTR_HXX #ifndef ODB_DETAILS_TRANSFER_PTR_HXX
#define ODB_DETAILS_TRANSFER_PTR_HXX #define ODB_DETAILS_TRANSFER_PTR_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <memory> // std::auto_ptr, std::unique_ptr #include <memory> // std::auto_ptr, std::unique_ptr
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 type-info.hxx   type-info.hxx 
// file : odb/details/type-info.hxx // file : odb/details/type-info.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_DETAILS_TYPE_INFO_HXX #ifndef ODB_DETAILS_TYPE_INFO_HXX
#define ODB_DETAILS_TYPE_INFO_HXX #define ODB_DETAILS_TYPE_INFO_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <typeinfo> #include <typeinfo>
#include <odb/details/export.hxx> #include <odb/details/export.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 unique-ptr.hxx   unique-ptr.hxx 
// file : odb/details/unique-ptr.hxx // file : odb/details/unique-ptr.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_DETAILS_UNIQUE_PTR_HXX #ifndef ODB_DETAILS_UNIQUE_PTR_HXX
#define ODB_DETAILS_UNIQUE_PTR_HXX #define ODB_DETAILS_UNIQUE_PTR_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
namespace odb namespace odb
{ {
namespace details namespace details
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 unused.hxx   unused.hxx 
// file : odb/details/unused.hxx // file : odb/details/unused.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_UNUSED_DETAILS_HXX #ifndef ODB_UNUSED_DETAILS_HXX
#define ODB_UNUSED_DETAILS_HXX #define ODB_UNUSED_DETAILS_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
// VC++ doesn't like the (void)x expression if x is a reference to // VC++ doesn't like the (void)x expression if x is a reference to
// an incomplete type. On the other hand, GCC warns that (void*)&x // an incomplete type. On the other hand, GCC warns that (void*)&x
// doesn't have any effect. // doesn't have any effect.
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 version.hxx   version.hxx 
// file : odb/version.hxx // file : odb/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_VERSION_HXX #ifndef ODB_VERSION_HXX
#define ODB_VERSION_HXX #define ODB_VERSION_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
// Version format is AABBCCDD where // Version format is AABBCCDD where
// //
// AA - major version number // AA - major version number
skipping to change at line 29 skipping to change at line 29
// 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 20100 #define ODB_VERSION 20200
#define ODB_VERSION_STR "2.1" #define ODB_VERSION_STR "2.2"
// libodb version: interface version plus the bugfix version. // libodb version: interface version plus the bugfix version.
// //
#define LIBODB_VERSION 2010100 #define LIBODB_VERSION 2020000
#define LIBODB_VERSION_STR "2.1.1" #define LIBODB_VERSION_STR "2.2.0"
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_VERSION_HXX #endif // ODB_VERSION_HXX
 End of changes. 3 change blocks. 
5 lines changed or deleted 5 lines changed or added


 view-result.hxx   view-result.hxx 
// file : odb/view-result.hxx // file : odb/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_VIEW_RESULT_HXX #ifndef ODB_VIEW_RESULT_HXX
#define ODB_VIEW_RESULT_HXX #define ODB_VIEW_RESULT_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <cstddef> // std::ptrdiff_t, std::size_t #include <cstddef> // std::ptrdiff_t, std::size_t
#include <iterator> // iterator categories #include <iterator> // iterator categories
#include <utility> // std::move #include <utility> // std::move
#include <odb/forward.hxx> #include <odb/forward.hxx>
#include <odb/traits.hxx> #include <odb/traits.hxx>
#include <odb/result.hxx> #include <odb/result.hxx>
#include <odb/pointer-traits.hxx> #include <odb/pointer-traits.hxx>
#include <odb/details/config.hxx> // ODB_CXX11 #include <odb/details/config.hxx> // ODB_CXX11
#include <odb/details/shared-ptr.hxx>
namespace odb namespace odb
{ {
template <typename T> template <typename T>
class view_result_impl: public details::shared_base class view_result_impl: public result_impl
{ {
public:
virtual
~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;
// 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;
view_result_impl (database_type& db) view_result_impl (odb::connection& conn)
: begin_ (true), end_ (false), db_ (db), current_ () : result_impl (conn), begin_ (true), end_ (false), current_ ()
{
}
database_type&
database () const
{ {
return db_;
} }
// To make this work with all kinds of pointers (raw, std::auto_ptr, // 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 // shared), we need to make sure we don't make any copies of the
// pointer on the return path. // pointer on the return path.
// //
pointer_type& pointer_type&
current (); current ();
void void
skipping to change at line 128 skipping to change at line 115
{ {
current_ = p; current_ = p;
guard_.reset (current_); guard_.reset (current_);
} }
#endif #endif
bool begin_; bool begin_;
bool end_; bool end_;
private: private:
database_type& db_;
pointer_type current_; pointer_type current_;
typename pointer_traits::guard guard_; typename pointer_traits::guard guard_;
}; };
template <typename T> template <typename T>
class result_iterator<T, class_view> class result_iterator<T, class_view>
{ {
public: public:
typedef T value_type; typedef T value_type;
typedef value_type& reference; typedef value_type& reference;
 End of changes. 8 change blocks. 
18 lines changed or deleted 4 lines changed or added


 view-result.txx   view-result.txx 
// file : odb/view-result.txx // file : odb/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
namespace odb namespace odb
{ {
// //
// view_result_impl // view_result_impl
// //
template <typename T> template <typename T>
view_result_impl<T>::
~view_result_impl ()
{
}
template <typename T>
typename view_result_impl<T>::pointer_type& typename view_result_impl<T>::pointer_type&
view_result_impl<T>:: 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. 2 change blocks. 
7 lines changed or deleted 1 lines changed or added


 wrapper-p.hxx   wrapper-p.hxx 
// file : odb/details/wrapper-p.hxx // file : odb/details/wrapper-p.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_DETAILS_WRAPPER_P_HXX #ifndef ODB_DETAILS_WRAPPER_P_HXX
#define ODB_DETAILS_WRAPPER_P_HXX #define ODB_DETAILS_WRAPPER_P_HXX
#include <odb/pre.hxx> #include <odb/pre.hxx>
#include <odb/wrapper-traits.hxx> #include <odb/wrapper-traits.hxx>
#include <odb/details/meta/answer.hxx> #include <odb/details/meta/answer.hxx>
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 wrapper-traits.hxx   wrapper-traits.hxx 
// file : odb/wrapper-traits.hxx // file : odb/wrapper-traits.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_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, std::unique_ptr, std::shared_ptr/weak_p tr #include <memory> // std::auto_ptr, std::unique_ptr, std::shared_ptr/weak_p tr
#include <odb/nullable.hxx> #include <odb/nullable.hxx>
 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/