aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/traits.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-04-18 18:30:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-04-18 18:30:06 +0200
commite04d780ade5f663de1b2314a73cf758db95af439 (patch)
treefb806024a2d06210d2a61f813b8078eeaac09efb /odb/sqlite/traits.hxx
parent12da812979d06cc739d247f891abba4137cf9285 (diff)
Get rid of image type argument in value_traits
Diffstat (limited to 'odb/sqlite/traits.hxx')
-rw-r--r--odb/sqlite/traits.hxx41
1 files changed, 29 insertions, 12 deletions
diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx
index e5ef318..2fdac04 100644
--- a/odb/sqlite/traits.hxx
+++ b/odb/sqlite/traits.hxx
@@ -30,26 +30,45 @@ namespace odb
};
//
+ // image_traits
+ //
+
+ template <database_type_id>
+ struct image_traits;
+
+ template <>
+ struct image_traits<id_integer> {typedef long long image_type;};
+
+ template <>
+ struct image_traits<id_real> {typedef double image_type;};
+
+ template <>
+ struct image_traits<id_text> {typedef details::buffer image_type;};
+
+ template <>
+ struct image_traits<id_blob> {typedef details::buffer image_type;};
+
+ //
// value_traits
//
- template <typename T, typename I, database_type_id>
+ template <typename T, database_type_id>
struct default_value_traits;
- template <typename T, typename I, database_type_id ID>
- class value_traits: public default_value_traits<T, I, ID>
+ template <typename T, database_type_id 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
{
typedef T value_type;
typedef T query_type;
- typedef I image_type;
+ typedef typename image_traits<ID>::image_type image_type;
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)
v = T (i);
@@ -58,18 +77,17 @@ namespace odb
}
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 = I (v);
+ i = image_type (v);
}
};
// std::string specialization.
//
template <>
- struct LIBODB_SQLITE_EXPORT default_value_traits<
- std::string, details::buffer, id_text>
+ struct LIBODB_SQLITE_EXPORT default_value_traits<std::string, id_text>
{
typedef std::string value_type;
typedef std::string query_type;
@@ -101,8 +119,7 @@ namespace odb
// we can pass such values to the queries.
//
template <>
- struct LIBODB_SQLITE_EXPORT default_value_traits<
- const char*, details::buffer, id_text>
+ struct LIBODB_SQLITE_EXPORT default_value_traits<const char*, id_text>
{
typedef const char* value_type;
typedef const char* query_type;