aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/traits.hxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-09-27 17:26:29 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-09-27 17:26:29 +0200
commitdf2082d9921d8c8f6d61fd3482cef683f914e4d3 (patch)
tree43075878c5ae89f8d0925607e51f674e8aeb0cbb /odb/oracle/traits.hxx
parent7b9c412736f51965473649cac8caf5e933ae6b9e (diff)
Implement partial specialization of default_value_traits for id_big_int
Diffstat (limited to 'odb/oracle/traits.hxx')
-rw-r--r--odb/oracle/traits.hxx55
1 files changed, 55 insertions, 0 deletions
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