aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-03 10:05:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-03 10:05:55 +0200
commit951f324ae01c4d8f9cbe1edb19b5f1c370f825a2 (patch)
tree7b305bd87aefbae495b668c68374d1976306aaf0 /odb
parentf2a1bfb98f447e6c922c12f4403a387243dd65c5 (diff)
Add position context to LOB result callback
It turns out position context can be useful in result handling as well.
Diffstat (limited to 'odb')
-rw-r--r--odb/oracle/oracle-types.hxx14
-rw-r--r--odb/oracle/statement.cxx2
-rw-r--r--odb/oracle/traits.cxx6
-rw-r--r--odb/oracle/traits.hxx18
4 files changed, 29 insertions, 11 deletions
diff --git a/odb/oracle/oracle-types.hxx b/odb/oracle/oracle-types.hxx
index 0687335..3327c57 100644
--- a/odb/oracle/oracle-types.hxx
+++ b/odb/oracle/oracle-types.hxx
@@ -48,10 +48,14 @@ namespace odb
// the database. If false is returned, database_exception is thrown.
//
typedef bool (*result_callback_type) (
- void* context, // [in] The user context.
- void* buffer, // [in] A buffer containing the result data.
- ub4 size, // [in] The result data size in bytes.
- chunk_position); // [in] The position of this chunk.
+ void* context, // [in] The user context.
+ ub4* position_context, // [in] A position context. A callback is free to
+ // use this to track position information. This is
+ // initialized to zero before the callback is
+ // invoked for the first time.
+ void* buffer, // [in] A buffer containing the result data.
+ ub4 size, // [in] The result data size in bytes.
+ chunk_position); // [in] The position of this chunk.
union lob_callback
{
@@ -98,7 +102,7 @@ namespace odb
buffer_type type; // The type stored by buffer.
void* buffer; // Data buffer pointer. When result callbacks are in
- // use, this is interpreted as an lob_auto_descriptor*.
+ // use, this is interpreted as a lob_auto_descriptor*.
ub2* size; // The number of bytes in buffer. When parameter
// callbacks are in use, this is interpreted as a ub4*
// indicating the current position. For LOB result
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx
index 476377d..c1747a3 100644
--- a/odb/oracle/statement.cxx
+++ b/odb/oracle/statement.cxx
@@ -465,6 +465,7 @@ namespace odb
auto_descriptor<OCILobLocator>& locator (
*reinterpret_cast<auto_descriptor<OCILobLocator>*> (b->buffer));
+ ub4 position (0); // Position context.
ub1 piece (OCI_FIRST_PIECE);
// Setting the value pointed to by the byte_amt argument to 0 on the
@@ -517,6 +518,7 @@ namespace odb
// returned from a user callback. We simulate this.
//
if (!(*b->callback->result) (b->context->result,
+ &position,
lob_buffer.data (),
static_cast<ub4> (read),
cp))
diff --git a/odb/oracle/traits.cxx b/odb/oracle/traits.cxx
index 40543ba..af0266f 100644
--- a/odb/oracle/traits.cxx
+++ b/odb/oracle/traits.cxx
@@ -104,7 +104,7 @@ namespace odb
//
bool string_lob_value_traits::
- result_callback (void* c, void* b, ub4 s, chunk_position p)
+ result_callback (void* c, ub4*, void* b, ub4 s, chunk_position p)
{
string& v (*static_cast<string*> (c));
@@ -173,7 +173,7 @@ namespace odb
//
bool default_value_traits<std::vector<char>, id_blob>::
- result_callback (void* c, void* b, ub4 s, chunk_position p)
+ result_callback (void* c, ub4*, void* b, ub4 s, chunk_position p)
{
value_type& v (*static_cast<value_type*> (c));
@@ -222,7 +222,7 @@ namespace odb
//
bool default_value_traits<std::vector<unsigned char>, id_blob>::
- result_callback (void* c, void* b, ub4 s, chunk_position p)
+ result_callback (void* c, ub4*, void* b, ub4 s, chunk_position p)
{
value_type& v (*static_cast<value_type*> (c));
diff --git a/odb/oracle/traits.hxx b/odb/oracle/traits.hxx
index edaeebf..8edaa54 100644
--- a/odb/oracle/traits.hxx
+++ b/odb/oracle/traits.hxx
@@ -668,7 +668,11 @@ namespace odb
}
static bool
- result_callback (void* context, void* buffer, ub4 size, chunk_position);
+ result_callback (void* context,
+ ub4* position_context,
+ void* buffer,
+ ub4 size,
+ chunk_position);
static bool
param_callback (const void* context,
@@ -799,7 +803,11 @@ namespace odb
}
static bool
- result_callback (void* context, void* buffer, ub4 size, chunk_position);
+ result_callback (void* context,
+ ub4* position_context,
+ void* buffer,
+ ub4 size,
+ chunk_position);
static bool
param_callback (const void* context,
@@ -848,7 +856,11 @@ namespace odb
}
static bool
- result_callback (void* context, void* buffer, ub4 size, chunk_position);
+ result_callback (void* context,
+ ub4* position_context,
+ void* buffer,
+ ub4 size,
+ chunk_position);
static bool
param_callback (const void* context,