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/query.hxx | 10 ++++------ odb/sqlite/traits.cxx | 4 ++-- odb/sqlite/traits.hxx | 41 +++++++++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/odb/sqlite/query.hxx b/odb/sqlite/query.hxx index edf9222..98189ab 100644 --- a/odb/sqlite/query.hxx +++ b/odb/sqlite/query.hxx @@ -1059,7 +1059,7 @@ namespace odb init (const T& v) { bool dummy; - value_traits::set_image (image_, dummy, v); + value_traits::set_image (image_, dummy, v); } private: @@ -1093,7 +1093,7 @@ namespace odb init (const T& v) { bool dummy; - value_traits::set_image (image_, dummy, v); + value_traits::set_image (image_, dummy, v); } private: @@ -1128,8 +1128,7 @@ namespace odb { bool dummy; std::size_t cap (buffer_.capacity ()); - value_traits::set_image ( - buffer_, size_, dummy, v); + value_traits::set_image (buffer_, size_, dummy, v); return cap != buffer_.capacity (); } @@ -1166,8 +1165,7 @@ namespace odb { bool dummy; std::size_t cap (buffer_.capacity ()); - value_traits::set_image ( - buffer_, size_, dummy, v); + value_traits::set_image (buffer_, size_, dummy, v); return cap != buffer_.capacity (); } diff --git a/odb/sqlite/traits.cxx b/odb/sqlite/traits.cxx index de6c792..e73462a 100644 --- a/odb/sqlite/traits.cxx +++ b/odb/sqlite/traits.cxx @@ -17,7 +17,7 @@ namespace odb // default_value_traits // - void default_value_traits:: + void default_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, @@ -35,7 +35,7 @@ namespace odb // default_value_traits // - void default_value_traits:: + void default_value_traits:: set_image (buffer& b, size_t& n, bool& is_null, 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