From df2082d9921d8c8f6d61fd3482cef683f914e4d3 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 27 Sep 2011 17:26:29 +0200 Subject: Implement partial specialization of default_value_traits for id_big_int --- odb/oracle/details/number.hxx | 8 +++++++ odb/oracle/traits.hxx | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/odb/oracle/details/number.hxx b/odb/oracle/details/number.hxx index 345cbe0..fe355da 100644 --- a/odb/oracle/details/number.hxx +++ b/odb/oracle/details/number.hxx @@ -11,10 +11,18 @@ namespace odb { + // @@ Revise this. + // + namespace details + { + } + namespace oracle { namespace details { + using namespace odb::details; + LIBODB_ORACLE_EXPORT long long number_to_int64 (const char* buffer); diff --git a/odb/oracle/traits.hxx b/odb/oracle/traits.hxx index cedf064..1898833 100644 --- a/odb/oracle/traits.hxx +++ b/odb/oracle/traits.hxx @@ -22,6 +22,7 @@ #include #include +#include namespace odb { @@ -394,6 +395,60 @@ namespace odb } }; + // id_big_int partial specialization. + // + template + struct big_int_value_traits; + + template + struct big_int_value_traits + { + static void + set_value (T v, char* b, bool is_null) + { + if (!is_null) + v = static_cast (details::number_to_int64 (b)); + else + v = 0; + } + + static void + set_image (char* b, bool& is_null, T v) + { + is_null = false; + details::int64_to_number (b, static_cast (v)); + } + }; + + template + struct big_int_value_traits + { + static void + set_value (T v, char* b, bool is_null) + { + if (!is_null) + v = details::number_to_uint64 (static_cast (b)); + else + v = 0; + } + + static void + set_image (char* b, bool& is_null, T v) + { + is_null = false; + details::uint64_to_number (b, static_cast (v)); + } + }; + + template + struct default_value_traits: + big_int_value_traits::unsign> + { + typedef T value_type; + typedef T query_type; + typedef typename image_traits::image_type image_type; + }; + // std::string specialization. // class LIBODB_ORACLE_EXPORT string_value_traits -- cgit v1.1