container-statements.hxx   container-statements.hxx 
skipping to change at line 28 skipping to change at line 28
#include <odb/mysql/statement.hxx> #include <odb/mysql/statement.hxx>
#include <odb/mysql/details/export.hxx> #include <odb/mysql/details/export.hxx>
namespace odb namespace odb
{ {
namespace mysql namespace mysql
{ {
class connection; class connection;
// Template argument is the generated container traits type. // Template argument is the generated abstract container traits type.
// That is, it doesn't need to provide column counts and statements.
// //
template <typename T> template <typename T>
class container_statements class container_statements
{ {
public: public:
typedef T traits; typedef T traits;
typedef typename traits::id_image_type id_image_type;
typedef typename traits::data_image_type data_image_type; typedef typename traits::data_image_type data_image_type;
typedef typename traits::cond_image_type cond_image_type; typedef typename traits::cond_image_type cond_image_type;
typedef typename traits::functions_type functions_type; typedef typename traits::functions_type functions_type;
typedef mysql::insert_statement insert_statement_type; typedef mysql::insert_statement insert_statement_type;
typedef mysql::select_statement select_statement_type; typedef mysql::select_statement select_statement_type;
typedef mysql::delete_statement delete_statement_type; typedef mysql::delete_statement delete_statement_type;
typedef mysql::connection connection_type; typedef mysql::connection connection_type;
skipping to change at line 64 skipping to change at line 64
} }
// Functions. // Functions.
// //
functions_type& functions_type&
functions () functions ()
{ {
return functions_; return functions_;
} }
// Id image (external). // Id image binding (external).
// //
id_image_type& const binding&
id_image () id_binding ()
{ {
return *id_image_; return *id_binding_;
} }
void void
id_image (id_image_type& i) id_binding (const binding& b)
{ {
id_image_ = &i; id_binding_ = &b;
} }
// Condition image. // Condition image.
// //
cond_image_type& cond_image_type&
cond_image () cond_image ()
{ {
return cond_image_; return cond_image_;
} }
skipping to change at line 99 skipping to change at line 99
return cond_image_version_; return cond_image_version_;
} }
void void
cond_image_version (std::size_t v) cond_image_version (std::size_t v)
{ {
cond_image_version_ = v; cond_image_version_ = v;
} }
std::size_t std::size_t
cond_id_image_version () const cond_id_binding_version () const
{ {
return cond_id_image_version_; return cond_id_binding_version_;
} }
void void
cond_id_image_version (std::size_t v) cond_id_binding_version (std::size_t v)
{ {
cond_id_image_version_ = v; cond_id_binding_version_ = v;
} }
binding& binding&
cond_image_binding () cond_image_binding ()
{ {
return cond_image_binding_; return cond_image_binding_;
} }
// Data image. // Data image.
// //
skipping to change at line 137 skipping to change at line 137
return data_image_version_; return data_image_version_;
} }
void void
data_image_version (std::size_t v) data_image_version (std::size_t v)
{ {
data_image_version_ = v; data_image_version_ = v;
} }
std::size_t std::size_t
data_id_image_version () const data_id_binding_version () const
{ {
return data_id_image_version_; return data_id_binding_version_;
} }
void void
data_id_image_version (std::size_t v) data_id_binding_version (std::size_t v)
{ {
data_id_image_version_ = v; data_id_binding_version_ = v;
} }
binding& binding&
data_image_binding () data_image_binding ()
{ {
return data_image_binding_; return data_image_binding_;
} }
my_bool* my_bool*
data_image_truncated () data_image_truncated ()
skipping to change at line 170 skipping to change at line 170
// //
// Statements. // Statements.
// //
insert_statement_type& insert_statement_type&
insert_one_statement () insert_one_statement ()
{ {
if (insert_one_ == 0) if (insert_one_ == 0)
insert_one_.reset ( insert_one_.reset (
new (details::shared) insert_statement_type ( new (details::shared) insert_statement_type (
conn_, traits::insert_one_statement, data_image_binding_)); conn_, insert_one_text_, data_image_binding_));
return *insert_one_; return *insert_one_;
} }
select_statement_type& select_statement_type&
select_all_statement () select_all_statement ()
{ {
if (select_all_ == 0) if (select_all_ == 0)
select_all_.reset ( select_all_.reset (
new (details::shared) select_statement_type ( new (details::shared) select_statement_type (
conn_, conn_,
traits::select_all_statement, select_all_text_,
cond_image_binding_, cond_image_binding_,
data_image_binding_)); data_image_binding_));
return *select_all_; return *select_all_;
} }
delete_statement_type& delete_statement_type&
delete_all_statement () delete_all_statement ()
{ {
if (delete_all_ == 0) if (delete_all_ == 0)
delete_all_.reset ( delete_all_.reset (
new (details::shared) delete_statement_type ( new (details::shared) delete_statement_type (
conn_, traits::delete_all_statement, cond_image_binding_)); conn_, delete_all_text_, cond_image_binding_));
return *delete_all_; return *delete_all_;
} }
private: private:
container_statements (const container_statements&); container_statements (const container_statements&);
container_statements& operator= (const container_statements&); container_statements& operator= (const container_statements&);
private: protected:
connection_type& conn_; connection_type& conn_;
functions_type functions_; functions_type functions_;
id_image_type* id_image_; const binding* id_binding_;
cond_image_type cond_image_; cond_image_type cond_image_;
std::size_t cond_image_version_; std::size_t cond_image_version_;
std::size_t cond_id_image_version_; std::size_t cond_id_binding_version_;
binding cond_image_binding_; binding cond_image_binding_;
MYSQL_BIND cond_image_bind_[traits::cond_column_count]; MYSQL_BIND* cond_image_bind_;
data_image_type data_image_; data_image_type data_image_;
std::size_t data_image_version_; std::size_t data_image_version_;
std::size_t data_id_image_version_; std::size_t data_id_binding_version_;
binding data_image_binding_; binding data_image_binding_;
MYSQL_BIND data_image_bind_[traits::data_column_count]; MYSQL_BIND* data_image_bind_;
my_bool data_image_truncated_[traits::data_column_count]; my_bool* data_image_truncated_;
const char* insert_one_text_;
const char* select_all_text_;
const char* delete_all_text_;
details::shared_ptr<insert_statement_type> insert_one_; details::shared_ptr<insert_statement_type> insert_one_;
details::shared_ptr<select_statement_type> select_all_; details::shared_ptr<select_statement_type> select_all_;
details::shared_ptr<delete_statement_type> delete_all_; details::shared_ptr<delete_statement_type> delete_all_;
}; };
// Template argument is the generated concrete container traits type.
//
template <typename T>
class container_statements_impl: public T::statements_type
{
public:
typedef T traits;
typedef typename T::statements_type base;
typedef mysql::connection connection_type;
container_statements_impl (connection_type&);
private:
container_statements_impl (const container_statements_impl&);
container_statements_impl& operator= (const container_statements_impl
&);
private:
MYSQL_BIND cond_image_bind_array_[traits::cond_column_count];
MYSQL_BIND data_image_bind_array_[traits::data_column_count];
my_bool data_image_truncated_array_[traits::data_column_count];
};
} }
} }
#include <odb/mysql/container-statements.txx> #include <odb/mysql/container-statements.txx>
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_MYSQL_CONTAINER_STATEMENTS_HXX #endif // ODB_MYSQL_CONTAINER_STATEMENTS_HXX
 End of changes. 25 change blocks. 
26 lines changed or deleted 53 lines changed or added


 container-statements.txx   container-statements.txx 
skipping to change at line 24 skipping to change at line 24
// //
template <typename T> template <typename T>
container_statements<T>:: container_statements<T>::
container_statements (connection_type& conn) container_statements (connection_type& conn)
: conn_ (conn), : conn_ (conn),
functions_ (this, functions_ (this,
&traits::insert_one, &traits::insert_one,
&traits::load_all, &traits::load_all,
&traits::delete_all), &traits::delete_all),
id_image_ (0), id_binding_ (0),
cond_image_binding_ (cond_image_bind_, traits::cond_column_count) cond_image_binding_ (0, 0), // Initialized by impl.
, data_image_binding_ (0, 0) // Initialized by impl.
data_image_binding_ (data_image_bind_, traits::data_column_count)
{ {
cond_image_.version = 0; cond_image_.version = 0;
cond_image_version_ = 0; cond_image_version_ = 0;
cond_id_image_version_ = 0; cond_id_binding_version_ = 0;
data_image_.version = 0; data_image_.version = 0;
data_image_version_ = 0; data_image_version_ = 0;
data_id_image_version_ = 0; data_id_binding_version_ = 0;
}
template <typename T>
container_statements_impl<T>::
container_statements_impl (connection_type& conn)
: base (conn)
{
this->cond_image_bind_ = cond_image_bind_array_;
this->data_image_bind_ = data_image_bind_array_;
this->data_image_truncated_ = data_image_truncated_array_;
std::memset (cond_image_bind_, 0, sizeof (cond_image_bind_)); this->cond_image_binding_.bind = this->cond_image_bind_;
std::memset (data_image_bind_, 0, sizeof (data_image_bind_)); this->cond_image_binding_.count = traits::cond_column_count;
std::memset (data_image_truncated_, 0, sizeof (data_image_truncated_)
); this->data_image_binding_.bind = this->data_image_bind_;
this->data_image_binding_.count = traits::data_column_count;
std::memset (cond_image_bind_array_, 0, sizeof (cond_image_bind_array
_));
std::memset (data_image_bind_array_, 0, sizeof (data_image_bind_array
_));
std::memset (data_image_truncated_array_,
0,
sizeof (data_image_truncated_array_));
for (std::size_t i (0); i < traits::data_column_count; ++i) for (std::size_t i (0); i < traits::data_column_count; ++i)
data_image_bind_[i].error = data_image_truncated_ + i; data_image_bind_array_[i].error = data_image_truncated_array_ + i;
this->insert_one_text_ = traits::insert_one_statement;
this->select_all_text_ = traits::select_all_statement;
this->delete_all_text_ = traits::delete_all_statement;
} }
} }
} }
 End of changes. 5 change blocks. 
11 lines changed or deleted 33 lines changed or added


 forward.hxx   forward.hxx 
skipping to change at line 23 skipping to change at line 23
namespace mysql namespace mysql
{ {
class database; class database;
class connection; class connection;
class connection_factory; class connection_factory;
class transaction; class transaction;
class query; class query;
// Implementation details. // Implementation details.
// //
class binding;
class select_statement; class select_statement;
template <typename T> template <typename T>
class object_statements; class object_statements;
template <typename T> template <typename T>
class container_statements; class container_statements;
} }
} }
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 query.hxx   query.hxx 
skipping to change at line 21 skipping to change at line 21
#include <string> #include <string>
#include <vector> #include <vector>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <odb/query.hxx> #include <odb/query.hxx>
#include <odb/mysql/mysql.hxx> #include <odb/mysql/mysql.hxx>
#include <odb/mysql/version.hxx> #include <odb/mysql/version.hxx>
#include <odb/mysql/forward.hxx> #include <odb/mysql/forward.hxx>
#include <odb/mysql/traits.hxx> #include <odb/mysql/traits.hxx>
#include <odb/mysql/enum.hxx>
#include <odb/mysql/binding.hxx> #include <odb/mysql/binding.hxx>
#include <odb/details/buffer.hxx> #include <odb/details/buffer.hxx>
#include <odb/details/shared-ptr.hxx> #include <odb/details/shared-ptr.hxx>
#include <odb/mysql/details/export.hxx> #include <odb/mysql/details/export.hxx>
namespace odb namespace odb
{ {
namespace mysql namespace mysql
skipping to change at line 1033 skipping to change at line 1034
b->buffer_type = MYSQL_TYPE_TINY; b->buffer_type = MYSQL_TYPE_TINY;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, signed char, id_tiny>::set_image (image_, dummy, v) ; value_traits<T, id_tiny>::set_image (image_, dummy, v);
} }
private: private:
signed char image_; signed char image_;
}; };
template <typename T> template <typename T>
struct query_param_impl<T, id_utiny>: query_param struct query_param_impl<T, id_utiny>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
skipping to change at line 1066 skipping to change at line 1067
b->buffer_type = MYSQL_TYPE_TINY; b->buffer_type = MYSQL_TYPE_TINY;
b->is_unsigned = true; b->is_unsigned = true;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, unsigned char, id_utiny>::set_image (image_, dummy, v); value_traits<T, id_utiny>::set_image (image_, dummy, v);
} }
private: private:
unsigned char image_; unsigned char image_;
}; };
// SHORT // SHORT
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_short>: query_param struct query_param_impl<T, id_short>: query_param
skipping to change at line 1101 skipping to change at line 1102
b->buffer_type = MYSQL_TYPE_SHORT; b->buffer_type = MYSQL_TYPE_SHORT;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, short, id_short>::set_image (image_, dummy, v); value_traits<T, id_short>::set_image (image_, dummy, v);
} }
private: private:
short image_; short image_;
}; };
template <typename T> template <typename T>
struct query_param_impl<T, id_ushort>: query_param struct query_param_impl<T, id_ushort>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
skipping to change at line 1134 skipping to change at line 1135
b->buffer_type = MYSQL_TYPE_SHORT; b->buffer_type = MYSQL_TYPE_SHORT;
b->is_unsigned = true; b->is_unsigned = true;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, unsigned short, id_ushort>::set_image ( value_traits<T, id_ushort>::set_image (image_, dummy, v);
image_, dummy, v);
} }
private: private:
unsigned short image_; unsigned short image_;
}; };
// LONG // LONG
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_long>: query_param struct query_param_impl<T, id_long>: query_param
skipping to change at line 1170 skipping to change at line 1170
b->buffer_type = MYSQL_TYPE_LONG; b->buffer_type = MYSQL_TYPE_LONG;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, int, id_long>::set_image (image_, dummy, v); value_traits<T, id_long>::set_image (image_, dummy, v);
} }
private: private:
int image_; int image_;
}; };
template <typename T> template <typename T>
struct query_param_impl<T, id_ulong>: query_param struct query_param_impl<T, id_ulong>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
skipping to change at line 1203 skipping to change at line 1203
b->buffer_type = MYSQL_TYPE_LONG; b->buffer_type = MYSQL_TYPE_LONG;
b->is_unsigned = true; b->is_unsigned = true;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, unsigned int, id_ulong>::set_image (image_, dummy, v); value_traits<T, id_ulong>::set_image (image_, dummy, v);
} }
private: private:
unsigned int image_; unsigned int image_;
}; };
// LONGLONG // LONGLONG
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_longlong>: query_param struct query_param_impl<T, id_longlong>: query_param
skipping to change at line 1238 skipping to change at line 1238
b->buffer_type = MYSQL_TYPE_LONGLONG; b->buffer_type = MYSQL_TYPE_LONGLONG;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, long long, id_longlong>::set_image (image_, dummy, v); value_traits<T, id_longlong>::set_image (image_, dummy, v);
} }
private: private:
long long image_; long long image_;
}; };
template <typename T> template <typename T>
struct query_param_impl<T, id_ulonglong>: query_param struct query_param_impl<T, id_ulonglong>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
skipping to change at line 1271 skipping to change at line 1271
b->buffer_type = MYSQL_TYPE_LONGLONG; b->buffer_type = MYSQL_TYPE_LONGLONG;
b->is_unsigned = true; b->is_unsigned = true;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, unsigned long long, id_ulonglong>::set_image ( value_traits<T, id_ulonglong>::set_image (image_, dummy, v);
image_, dummy, v);
} }
private: private:
unsigned long long image_; unsigned long long image_;
}; };
// FLOAT // FLOAT
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_float>: query_param struct query_param_impl<T, id_float>: query_param
skipping to change at line 1307 skipping to change at line 1306
b->buffer_type = MYSQL_TYPE_FLOAT; b->buffer_type = MYSQL_TYPE_FLOAT;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, float, id_float>::set_image (image_, dummy, v); value_traits<T, id_float>::set_image (image_, dummy, v);
} }
private: private:
float image_; float image_;
}; };
// DOUBLE // DOUBLE
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_double>: query_param struct query_param_impl<T, id_double>: query_param
skipping to change at line 1342 skipping to change at line 1341
b->buffer_type = MYSQL_TYPE_DOUBLE; b->buffer_type = MYSQL_TYPE_DOUBLE;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, double, id_double>::set_image (image_, dummy, v); value_traits<T, id_double>::set_image (image_, dummy, v);
} }
private: private:
double image_; double image_;
}; };
// DECIMAL // DECIMAL
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_decimal>: query_param struct query_param_impl<T, id_decimal>: query_param
skipping to change at line 1378 skipping to change at line 1377
b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ; b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ;
b->length = &size_; b->length = &size_;
} }
private: private:
bool bool
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
std::size_t size, cap (buffer_.capacity ()); std::size_t size, cap (buffer_.capacity ());
value_traits<T, details::buffer, id_decimal>::set_image ( value_traits<T, id_decimal>::set_image (buffer_, size, dummy, v);
buffer_, size, dummy, v);
size_ = static_cast<unsigned long> (size); size_ = static_cast<unsigned long> (size);
return cap != buffer_.capacity (); return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; details::buffer buffer_;
unsigned long size_; unsigned long size_;
}; };
// DATE // DATE
skipping to change at line 1416 skipping to change at line 1414
{ {
b->buffer_type = MYSQL_TYPE_DATE; b->buffer_type = MYSQL_TYPE_DATE;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, MYSQL_TIME, id_date>::set_image (image_, dummy, v); value_traits<T, id_date>::set_image (image_, dummy, v);
} }
private: private:
MYSQL_TIME image_; MYSQL_TIME image_;
}; };
// TIME // TIME
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_time>: query_param struct query_param_impl<T, id_time>: query_param
skipping to change at line 1450 skipping to change at line 1448
{ {
b->buffer_type = MYSQL_TYPE_TIME; b->buffer_type = MYSQL_TYPE_TIME;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, MYSQL_TIME, id_time>::set_image (image_, dummy, v); value_traits<T, id_time>::set_image (image_, dummy, v);
} }
private: private:
MYSQL_TIME image_; MYSQL_TIME image_;
}; };
// DATETIME // DATETIME
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_datetime>: query_param struct query_param_impl<T, id_datetime>: query_param
skipping to change at line 1484 skipping to change at line 1482
{ {
b->buffer_type = MYSQL_TYPE_DATETIME; b->buffer_type = MYSQL_TYPE_DATETIME;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, MYSQL_TIME, id_datetime>::set_image (image_, dummy, v); value_traits<T, id_datetime>::set_image (image_, dummy, v);
} }
private: private:
MYSQL_TIME image_; MYSQL_TIME image_;
}; };
// TIMESTAMP // TIMESTAMP
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_timestamp>: query_param struct query_param_impl<T, id_timestamp>: query_param
skipping to change at line 1518 skipping to change at line 1516
{ {
b->buffer_type = MYSQL_TYPE_TIMESTAMP; b->buffer_type = MYSQL_TYPE_TIMESTAMP;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, MYSQL_TIME, id_timestamp>::set_image ( value_traits<T, id_timestamp>::set_image (image_, dummy, v);
image_, dummy, v);
} }
private: private:
MYSQL_TIME image_; MYSQL_TIME image_;
}; };
// YEAR // YEAR
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_year>: query_param struct query_param_impl<T, id_year>: query_param
skipping to change at line 1554 skipping to change at line 1551
b->buffer_type = MYSQL_TYPE_SHORT; b->buffer_type = MYSQL_TYPE_SHORT;
b->is_unsigned = false; b->is_unsigned = false;
b->buffer = &image_; b->buffer = &image_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
value_traits<T, short, id_year>::set_image (image_, dummy, v); value_traits<T, id_year>::set_image (image_, dummy, v);
} }
private: private:
short image_; short image_;
}; };
// STRING // STRING
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_string>: query_param struct query_param_impl<T, id_string>: query_param
skipping to change at line 1590 skipping to change at line 1587
b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ; b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ;
b->length = &size_; b->length = &size_;
} }
private: private:
bool bool
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
std::size_t size, cap (buffer_.capacity ()); std::size_t size, cap (buffer_.capacity ());
value_traits<T, details::buffer, id_string>::set_image ( value_traits<T, id_string>::set_image (buffer_, size, dummy, v);
buffer_, size, dummy, v);
size_ = static_cast<unsigned long> (size); size_ = static_cast<unsigned long> (size);
return cap != buffer_.capacity (); return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; details::buffer buffer_;
unsigned long size_; unsigned long size_;
}; };
// BLOB // BLOB
skipping to change at line 1630 skipping to change at line 1626
b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ; b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ;
b->length = &size_; b->length = &size_;
} }
private: private:
bool bool
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
std::size_t size, cap (buffer_.capacity ()); std::size_t size, cap (buffer_.capacity ());
value_traits<T, details::buffer, id_blob>::set_image ( value_traits<T, id_blob>::set_image (buffer_, size, dummy, v);
buffer_, size, dummy, v);
size_ = static_cast<unsigned long> (size); size_ = static_cast<unsigned long> (size);
return cap != buffer_.capacity (); return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; details::buffer buffer_;
unsigned long size_; unsigned long size_;
}; };
// BIT // BIT
skipping to change at line 1671 skipping to change at line 1666
b->buffer_length = static_cast<unsigned long> (sizeof (buffer_)); b->buffer_length = static_cast<unsigned long> (sizeof (buffer_));
b->length = &size_; b->length = &size_;
} }
private: private:
void void
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
std::size_t size; std::size_t size;
value_traits<T, details::buffer, id_bit>::set_image ( value_traits<T, id_bit>::set_image (
buffer_, sizeof (buffer_), size, dummy, v); buffer_, sizeof (buffer_), size, dummy, v);
size_ = static_cast<unsigned long> (size); size_ = static_cast<unsigned long> (size);
} }
private: private:
// Max 64 bit. // Max 64 bit.
// //
unsigned char buffer_[8]; unsigned char buffer_[8];
unsigned long size_; unsigned long size_;
}; };
// ENUM // ENUM
// //
// The image type can be either integer or string.
//
template <typename T> template <typename T>
struct query_param_impl<T, id_enum>: query_param struct query_param_impl<T, id_enum>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
virtual bool virtual bool
init () init ()
{ {
return init (*static_cast<const T*> (value_)); return init (*static_cast<const T*> (value_));
} }
virtual void virtual void
bind (MYSQL_BIND* b) bind (MYSQL_BIND* b)
{ {
b->buffer_type = MYSQL_TYPE_STRING; enum_traits::bind (*b, image_, size_, 0);
b->buffer = buffer_.data ();
b->buffer_length = static_cast<unsigned long> (buffer_.capacity ())
;
b->length = &size_;
} }
private: private:
bool bool
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
std::size_t size, cap (buffer_.capacity ()); return enum_traits::set_image (image_, size_, dummy, v);
value_traits<T, details::buffer, id_enum>::set_image (
buffer_, size, dummy, v);
size_ = static_cast<unsigned long> (size);
return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; typename value_traits<T, id_enum>::image_type image_;
unsigned long size_; unsigned long size_; // Keep size in case it is a string.
}; };
// SET // SET
// //
template <typename T> template <typename T>
struct query_param_impl<T, id_set>: query_param struct query_param_impl<T, id_set>: query_param
{ {
query_param_impl (ref_bind<T> r) : query_param (&r.ref) {} query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);} query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
skipping to change at line 1752 skipping to change at line 1742
b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ; b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()) ;
b->length = &size_; b->length = &size_;
} }
private: private:
bool bool
init (const T& v) init (const T& v)
{ {
bool dummy; bool dummy;
std::size_t size, cap (buffer_.capacity ()); std::size_t size, cap (buffer_.capacity ());
value_traits<T, details::buffer, id_set>::set_image ( value_traits<T, id_set>::set_image (buffer_, size, dummy, v);
buffer_, size, dummy, v);
size_ = static_cast<unsigned long> (size); size_ = static_cast<unsigned long> (size);
return cap != buffer_.capacity (); return cap != buffer_.capacity ();
} }
private: private:
details::buffer buffer_; details::buffer buffer_;
unsigned long size_; unsigned long size_;
}; };
} }
} }
 End of changes. 25 change blocks. 
39 lines changed or deleted 27 lines changed or added


 result.txx   result.txx 
skipping to change at line 42 skipping to change at line 42
load (object_type& obj) load (object_type& obj)
{ {
if (count_ > statement_->fetched ()) if (count_ > statement_->fetched ())
fetch (); fetch ();
// This is a top-level call so the statements cannot be locked. // This is a top-level call so the statements cannot be locked.
// //
assert (!statements_.locked ()); assert (!statements_.locked ());
typename object_statements<object_type>::auto_lock l (statements_); typename object_statements<object_type>::auto_lock l (statements_);
typename object_traits::image_type& im (statements_.image ()); typename object_traits::image_type& i (statements_.image ());
object_traits::init (obj, im, this->database ()); object_traits::init (obj, i, this->database ());
// Initialize the id image and load the rest of the object // Initialize the id image and binding and load the rest of the objec t
// (containers, etc). // (containers, etc).
// //
object_traits::init (statements_.id_image (), object_traits::id (im)) typename object_traits::id_image_type& idi (statements_.id_image ());
; object_traits::init (idi, object_traits::id (i));
binding& idb (statements_.id_image_binding ());
if (idi.version != statements_.id_image_version () || idb.version ==
0)
{
object_traits::bind (idb.bind, idi);
statements_.id_image_version (idi.version);
idb.version++;
}
object_traits::load_ (statements_, obj); object_traits::load_ (statements_, obj);
statements_.load_delayed (); statements_.load_delayed ();
l.unlock (); l.unlock ();
} }
template <typename T> template <typename T>
typename result_impl<T>::id_type result_impl<T>:: typename result_impl<T>::id_type result_impl<T>::
load_id () load_id ()
{ {
skipping to change at line 118 skipping to change at line 128
switch (r) switch (r)
{ {
case select_statement::truncated: case select_statement::truncated:
{ {
// Don't re-fetch data we are skipping. // Don't re-fetch data we are skipping.
// //
if (count_ != statement_->fetched ()) if (count_ != statement_->fetched ())
continue; continue;
typename object_traits::image_type& im (statements_.image ()); typename object_traits::image_type& im (statements_.image ());
object_traits::grow (im, statements_.out_image_truncated ());
if (object_traits::grow (im, statements_.out_image_truncated ()
))
im.version++;
if (im.version != statements_.out_image_version ()) if (im.version != statements_.out_image_version ())
{ {
binding& b (statements_.out_image_binding ()); binding& b (statements_.out_image_binding ());
object_traits::bind (b.bind, im, true); object_traits::bind (b.bind, im, true);
statements_.out_image_version (im.version); statements_.out_image_version (im.version);
b.version++; b.version++;
statement_->refetch (); statement_->refetch ();
} }
// Fall throught. // Fall throught.
 End of changes. 4 change blocks. 
6 lines changed or deleted 19 lines changed or added


 traits.hxx   traits.hxx 
skipping to change at line 57 skipping to change at line 57
id_string, id_string,
id_blob, id_blob,
id_bit, id_bit,
id_enum, id_enum,
id_set id_set
}; };
// //
// image_traits
//
template <database_type_id>
struct image_traits;
template <>
struct image_traits<id_tiny> {typedef signed char image_type;};
template <>
struct image_traits<id_utiny> {typedef unsigned char image_type;};
template <>
struct image_traits<id_short> {typedef short image_type;};
template <>
struct image_traits<id_ushort> {typedef unsigned short image_type;};
template <>
struct image_traits<id_long> {typedef int image_type;};
template <>
struct image_traits<id_ulong> {typedef unsigned int image_type;};
template <>
struct image_traits<id_longlong> {typedef long long image_type;};
template <>
struct image_traits<id_ulonglong> {typedef unsigned long long image_typ
e;};
template <>
struct image_traits<id_float> {typedef float image_type;};
template <>
struct image_traits<id_double> {typedef double image_type;};
template <>
struct image_traits<id_decimal> {typedef details::buffer image_type;};
template <>
struct image_traits<id_date> {typedef MYSQL_TIME image_type;};
template <>
struct image_traits<id_time> {typedef MYSQL_TIME image_type;};
template <>
struct image_traits<id_datetime> {typedef MYSQL_TIME image_type;};
template <>
struct image_traits<id_timestamp> {typedef MYSQL_TIME image_type;};
template <>
struct image_traits<id_year> {typedef short image_type;};
template <>
struct image_traits<id_string> {typedef details::buffer image_type;};
template <>
struct image_traits<id_blob> {typedef details::buffer image_type;};
template <>
struct image_traits<id_bit> {typedef unsigned char* image_type;};
// Note: default mapping is to integer. Alternative mapping is to
// string.
//
template <>
struct image_traits<id_enum> {typedef unsigned short image_type;};
template <>
struct image_traits<id_set> {typedef details::buffer image_type;};
//
// value_traits // value_traits
// //
template <typename T, typename I, database_type_id> template <typename T, database_type_id>
struct default_value_traits; struct default_value_traits;
template <typename T, typename I, database_type_id ID> template <typename T, database_type_id ID>
class value_traits: public default_value_traits<T, I, ID> class value_traits: public default_value_traits<T, ID>
{ {
}; };
template <typename T, typename I, database_type_id> template <typename T, database_type_id ID>
struct default_value_traits struct default_value_traits
{ {
typedef T value_type; typedef T value_type;
typedef T query_type; typedef T query_type;
typedef I image_type; typedef typename image_traits<ID>::image_type image_type;
static void static void
set_value (T& v, I i, bool is_null) set_value (T& v, const image_type& i, bool is_null)
{ {
if (!is_null) if (!is_null)
v = T (i); v = T (i);
else else
v = T (); v = T ();
} }
static void static void
set_image (I& i, bool& is_null, T v) set_image (image_type& i, bool& is_null, T v)
{
is_null = false;
i = image_type (v);
}
};
// Specialization for numeric enum representations (C++ enum, integer
// types, etc). In particular, this specialization works only for C++
// enum type as long as its numeric value space starts with 0, is
// ascending and contiguous (i.e., the default enumerator assignment).
//
template <typename T>
struct default_value_traits<T, id_enum>
{
typedef T value_type;
typedef T query_type;
typedef unsigned short image_type;
static void
set_value (T& v, unsigned short i, bool is_null)
{
// In MySQL first enumerator has index 1.
//
if (!is_null)
v = static_cast<T> (i - 1);
else
v = T ();
}
static void
set_image (unsigned short& i, bool& is_null, const T& v)
{ {
is_null = false; is_null = false;
i = I (v); i = static_cast<unsigned short> (v) + 1;
} }
}; };
// std::string specialization. // std::string specialization.
// //
class LIBODB_MYSQL_EXPORT string_value_traits class LIBODB_MYSQL_EXPORT string_value_traits
{ {
public: public:
typedef std::string value_type; typedef std::string value_type;
typedef std::string query_type; typedef std::string query_type;
skipping to change at line 121 skipping to change at line 225
} }
static void static void
set_image (details::buffer&, set_image (details::buffer&,
std::size_t& n, std::size_t& n,
bool& is_null, bool& is_null,
const std::string&); const std::string&);
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<std::string, id_string>
std::string, details::buffer, id_string>: string_value_traits :
string_value_traits
{ {
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<std::string, id_decimal
std::string, details::buffer, id_decimal>: string_value_traits >:
string_value_traits
{ {
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<std::string, id_enum>:
std::string, details::buffer, id_enum>: string_value_traits string_value_traits
{ {
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<std::string, id_set>:
std::string, details::buffer, id_set>: string_value_traits string_value_traits
{ {
}; };
// const char* specialization // const char* specialization
// //
// Specialization for const char* which only supports initialization // Specialization for const char* which only supports initialization
// of an image from the value but not the other way around. This way // of an image from the value but not the other way around. This way
// we can pass such values to the queries. // we can pass such values to the queries.
// //
class LIBODB_MYSQL_EXPORT c_string_value_traits class LIBODB_MYSQL_EXPORT c_string_value_traits
skipping to change at line 165 skipping to change at line 269
typedef details::buffer image_type; typedef details::buffer image_type;
static void static void
set_image (details::buffer&, set_image (details::buffer&,
std::size_t& n, std::size_t& n,
bool& is_null, bool& is_null,
const char*); const char*);
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<const char*, id_string>
const char*, details::buffer, id_string>: c_string_value_traits :
c_string_value_traits
{ {
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<const char*, id_decimal
const char*, details::buffer, id_decimal>: c_string_value_traits >:
c_string_value_traits
{ {
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<const char*, id_enum>:
const char*, details::buffer, id_enum>: c_string_value_traits c_string_value_traits
{ {
}; };
template <> template <>
struct LIBODB_MYSQL_EXPORT default_value_traits< struct LIBODB_MYSQL_EXPORT default_value_traits<const char*, id_set>:
const char*, details::buffer, id_set>: c_string_value_traits c_string_value_traits
{ {
}; };
// //
// type_traits // type_traits
// //
template <typename T> template <typename T>
struct default_type_traits; struct default_type_traits;
 End of changes. 16 change blocks. 
24 lines changed or deleted 133 lines changed or added


 version.hxx   version.hxx 
skipping to change at line 40 skipping to change at line 40
// Version AABBCCDD // Version AABBCCDD
// 2.0.0 02000000 // 2.0.0 02000000
// 2.1.0 02010000 // 2.1.0 02010000
// 2.1.1 02010100 // 2.1.1 02010100
// 2.2.0.a1 02019901 // 2.2.0.a1 02019901
// 3.0.0.b2 02999952 // 3.0.0.b2 02999952
// //
// Check that we have compatible ODB version. // Check that we have compatible ODB version.
// //
#if ODB_VERSION != 10300 #if ODB_VERSION != 10400
# error incompatible odb interface version detected # error incompatible odb interface version detected
#endif #endif
// Check that we have a compatible MySQL version (5.0.3 or later). // Check that we have a compatible MySQL version (5.0.3 or later).
// //
#if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID < 50003 #if !defined(MYSQL_VERSION_ID) || MYSQL_VERSION_ID < 50003
# error incompatible MySQL version detected # error incompatible MySQL version detected
#endif #endif
// libodb-mysql version: odb interface version plus the bugfix // libodb-mysql version: odb interface version plus the bugfix
// version. // version.
// //
#define LIBODB_MYSQL_VERSION 1030000 #define LIBODB_MYSQL_VERSION 1040000
#define LIBODB_MYSQL_VERSION_STR "1.3.0" #define LIBODB_MYSQL_VERSION_STR "1.4.0"
#include <odb/post.hxx> #include <odb/post.hxx>
#endif // ODB_MYSQL_VERSION_HXX #endif // ODB_MYSQL_VERSION_HXX
 End of changes. 2 change blocks. 
3 lines changed or deleted 3 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/