aboutsummaryrefslogtreecommitdiff
path: root/odb/oracle/details
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-11 08:25:30 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-14 13:12:02 +0200
commitd8227f949940cd83ebf7d349b1e97d116474758b (patch)
tree807a400d92462072004a2c431e94aa999dc5bb0b /odb/oracle/details
parent6a2421094edb84224b0c7d02690522f3f7b8a86c (diff)
Allow for size to be returned from big_int set_image functions
The OCI interface requires size information for any buffer passed to its bind interface. By adding a return path for this data, we avert any need to obtain this from the actual VARNUM binary data using messy byte manipulation.
Diffstat (limited to 'odb/oracle/details')
-rw-r--r--odb/oracle/details/number.cxx10
-rw-r--r--odb/oracle/details/number.hxx7
2 files changed, 11 insertions, 6 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);
}
}
}