diff options
-rw-r--r-- | odb/oracle/details/number.cxx | 10 | ||||
-rw-r--r-- | odb/oracle/details/number.hxx | 7 | ||||
-rw-r--r-- | odb/oracle/traits.hxx | 46 |
3 files changed, 51 insertions, 12 deletions
diff --git a/odb/oracle/details/number.cxx b/odb/oracle/details/number.cxx index 044a99b..d328b1f 100644 --- a/odb/oracle/details/number.cxx +++ b/odb/oracle/details/number.cxx @@ -102,7 +102,7 @@ namespace odb } void - int64_to_number (char* b, long long v) + int64_to_number (char* b, size_t& n, long long v) { // We assume that b is long enough to contain a long long VARNUM // representation, that being 12 bytes. @@ -121,8 +121,8 @@ namespace odb } bool sig (false); - size_t n (0); unsigned char t[11], *m (t); + n = 0; if (v < 0) { @@ -169,6 +169,7 @@ namespace odb // Set the length. // ub[0] = static_cast<unsigned char> (m - t + 1); + n = static_cast<size_t> (ub[0] + 1); // Set the significant digits in big-endian byte order and the // terminator, if any. @@ -227,7 +228,7 @@ namespace odb } void - uint64_to_number (char* b, unsigned long long v) + uint64_to_number (char* b, size_t& n, unsigned long long v) { // We assume that b is long enough to contain an unsigned long long // VARNUM representation, that being 12 bytes. @@ -246,8 +247,8 @@ namespace odb } bool sig (false); - size_t n (0); unsigned char t[11], *m (t); + n = 0; while (v != 0) { @@ -268,6 +269,7 @@ namespace odb // Set the length. // ub[0] = static_cast<unsigned char> (m - t + 1); + n = static_cast<size_t> (ub[0] + 1); // Set the significant digits in big-endian byte order. // diff --git a/odb/oracle/details/number.hxx b/odb/oracle/details/number.hxx index fe355da..90fb038 100644 --- a/odb/oracle/details/number.hxx +++ b/odb/oracle/details/number.hxx @@ -7,6 +7,9 @@ #define ODB_ORACLE_NUMBER_HXX #include <odb/pre.hxx> + +#include <cstddef> // std::size_t + #include <odb/oracle/details/export.hxx> namespace odb @@ -27,13 +30,13 @@ namespace odb number_to_int64 (const char* buffer); LIBODB_ORACLE_EXPORT void - int64_to_number (char* buffer, long long value); + int64_to_number (char* buffer, std::size_t& n, long long val); LIBODB_ORACLE_EXPORT unsigned long long number_to_uint64 (const char* buffer); LIBODB_ORACLE_EXPORT void - uint64_to_number (char* buffer, unsigned long long value); + uint64_to_number (char* buffer, std::size_t& n, unsigned long long val); } } } diff --git a/odb/oracle/traits.hxx b/odb/oracle/traits.hxx index eafa2a4..b5dfc80 100644 --- a/odb/oracle/traits.hxx +++ b/odb/oracle/traits.hxx @@ -260,7 +260,21 @@ namespace odb vtraits::set_image (i, is_null, wtraits::get_ref (v)); } - // big_int, big_float, timestamp, string, nstring, raw. + // big_int, big_float. + // + static void + set_value (W& v, const char* i, bool is_null) + { + vtraits::set_value (wtraits::set_ref (v), i, is_null); + } + + static void + set_image (char* i, std::size_t& n, bool& is_null, const W& v) + { + vtraits::set_image (i, n, is_null, wtraits::get_ref (v)); + } + + // timestamp, string, nstring, raw. // static void set_value (W& v, const char* i, std::size_t n, bool is_null) @@ -326,7 +340,27 @@ namespace odb vtraits::set_image (i, is_null, wtraits::get_ref (v)); } - // big_int, big_float, timestamp, string, nstring, raw. + // big_int, big_float. + // + static void + set_value (W& v, const char& i, bool is_null) + { + if (is_null) + wtraits::set_null (v); + else + vtraits::set_value (wtraits::set_ref (v), i, is_null); + } + + static void + set_image (char* i, std::size_t& n, bool& is_null, const W& v) + { + is_null = wtraits::get_null (v); + + if (!is_null) + vtraits::set_image (i, n, is_null, wtraits::get_ref (v)); + } + + // timestamp, string, nstring, raw. // static void set_value (W& v, const char* i, std::size_t n, bool is_null) @@ -416,10 +450,10 @@ namespace odb } static void - set_image (char* b, bool& is_null, T v) + set_image (char* b, std::size_t& n, bool& is_null, T v) { is_null = false; - details::int64_to_number (b, static_cast<long long> (v)); + details::int64_to_number (b, n, static_cast<long long> (v)); } }; @@ -436,10 +470,10 @@ namespace odb } static void - set_image (char* b, bool& is_null, T v) + set_image (char* b, std::size_t& n, bool& is_null, T v) { is_null = false; - details::uint64_to_number (b, static_cast<unsigned long long> (v)); + details::uint64_to_number (b, n, static_cast<unsigned long long> (v)); } }; |