From e04d780ade5f663de1b2314a73cf758db95af439 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 18 Apr 2011 18:30:06 +0200 Subject: Get rid of image type argument in value_traits --- odb/sqlite/traits.hxx | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'odb/sqlite/traits.hxx') 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 + struct image_traits; + + template <> + struct image_traits {typedef long long image_type;}; + + template <> + struct image_traits {typedef double image_type;}; + + template <> + struct image_traits {typedef details::buffer image_type;}; + + template <> + struct image_traits {typedef details::buffer image_type;}; + + // // value_traits // - template + template struct default_value_traits; - template - class value_traits: public default_value_traits + template + class value_traits: public default_value_traits { }; - template + template struct default_value_traits { typedef T value_type; typedef T query_type; - typedef I image_type; + typedef typename image_traits::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 { 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 { typedef const char* value_type; typedef const char* query_type; -- cgit v1.1