aboutsummaryrefslogtreecommitdiff
path: root/mysql
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-09-21 19:55:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-09-21 19:55:14 +0200
commit26d4b0a333e327d7ef42c67db4c06918bafb1d84 (patch)
tree74a424a54bdbe0d79d15e8dec7188d6b5f6df6b6 /mysql
parente291e5d0661c7980a969a243f8a6512d1b9cf5df (diff)
Redesign value_traits
Diffstat (limited to 'mysql')
-rw-r--r--mysql/types/traits.hxx61
1 files changed, 28 insertions, 33 deletions
diff --git a/mysql/types/traits.hxx b/mysql/types/traits.hxx
index d113e7d..726135d 100644
--- a/mysql/types/traits.hxx
+++ b/mysql/types/traits.hxx
@@ -17,11 +17,12 @@ namespace odb
namespace mysql
{
template <>
- class value_traits<date_time>
+ class value_traits<date_time, MYSQL_TIME>
{
public:
- typedef date_time type;
typedef date_time value_type;
+ typedef date_time query_type;
+ typedef MYSQL_TIME image_type;
static void
set_value (date_time& v, const MYSQL_TIME& i, bool is_null)
@@ -56,39 +57,26 @@ namespace odb
};
template <>
- class value_traits<buffer>
+ class value_traits<buffer, details::buffer>
{
public:
- typedef buffer type;
typedef buffer value_type;
+ typedef buffer query_type;
+ typedef details::buffer image_type;
static void
- set_value (buffer& v, const char* s, std::size_t n, bool is_null)
+ set_value (buffer& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
{
if (!is_null)
- v.assign (s, n);
+ v.assign (b.data (), n);
else
v.assign (0, 0);
}
static void
- set_image (char* s,
- std::size_t c,
- std::size_t& n,
- bool& is_null,
- const buffer& v)
- {
- is_null = false;
- n = v.size ();
-
- if (n > c)
- n = c;
-
- if (n != 0)
- std::memcpy (s, v.data (), n);
- }
-
- static void
set_image (details::buffer& b,
std::size_t& n,
bool& is_null,
@@ -106,11 +94,12 @@ namespace odb
};
template <>
- class value_traits<bitfield>
+ class value_traits<bitfield, unsigned char*>
{
public:
- typedef bitfield type;
typedef bitfield value_type;
+ typedef bitfield query_type;
+ typedef unsigned char* image_type;
static void
set_value (bitfield& v,
@@ -139,19 +128,24 @@ namespace odb
};
template <>
- class value_traits<set>
+ class value_traits<set, details::buffer>
{
public:
- typedef set type;
typedef set value_type;
+ typedef set query_type;
+ typedef details::buffer image_type;
static void
- set_value (set& v, const char* s, std::size_t n, bool is_null)
+ set_value (set& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
{
v.clear ();
if (!is_null)
{
+ const char* s (b.data ());
const char* e (s + n);
while (s < e)
@@ -196,19 +190,20 @@ namespace odb
};
template <>
- class value_traits<std::auto_ptr<std::string> >
+ class value_traits<std::auto_ptr<std::string>, details::buffer>
{
public:
- typedef std::auto_ptr<std::string> type;
- typedef std::string value_type;
+ typedef std::auto_ptr<std::string> value_type;
+ typedef std::string query_type;
+ typedef details::buffer image_type;
static void
set_value (std::auto_ptr<std::string>& v,
- const char* s,
+ const details::buffer& b,
std::size_t n,
bool is_null)
{
- v.reset (is_null ? 0 : new std::string (s, n));
+ v.reset (is_null ? 0 : new std::string (b.data (), n));
}
static void