diff options
-rw-r--r-- | odb/oracle/details/number.hxx | 8 | ||||
-rw-r--r-- | odb/oracle/traits.hxx | 55 |
2 files changed, 63 insertions, 0 deletions
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 <odb/details/wrapper-p.hxx> #include <odb/oracle/details/export.hxx> +#include <odb/oracle/details/number.hxx> namespace odb { @@ -394,6 +395,60 @@ namespace odb } }; + // id_big_int partial specialization. + // + template <typename T, bool unsign> + struct big_int_value_traits; + + template <typename T> + struct big_int_value_traits<T, false> + { + static void + set_value (T v, char* b, bool is_null) + { + if (!is_null) + v = static_cast<T> (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<long long> (v)); + } + }; + + template <typename T> + struct big_int_value_traits<T, true> + { + static void + set_value (T v, char* b, bool is_null) + { + if (!is_null) + v = details::number_to_uint64 (static_cast<unsigned long long> (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<unsigned long long> (v)); + } + }; + + template <typename T> + struct default_value_traits<T, id_big_int>: + big_int_value_traits<T, int_traits<T>::unsign> + { + typedef T value_type; + typedef T query_type; + typedef typename image_traits<T, id_big_int>::image_type image_type; + }; + // std::string specialization. // class LIBODB_ORACLE_EXPORT string_value_traits |