From 951f324ae01c4d8f9cbe1edb19b5f1c370f825a2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 3 Nov 2011 10:05:55 +0200 Subject: Add position context to LOB result callback It turns out position context can be useful in result handling as well. --- odb/oracle/oracle-types.hxx | 14 +++++++++----- odb/oracle/statement.cxx | 2 ++ odb/oracle/traits.cxx | 6 +++--- odb/oracle/traits.hxx | 18 +++++++++++++++--- 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& locator ( *reinterpret_cast*> (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 (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 (c)); @@ -173,7 +173,7 @@ namespace odb // bool default_value_traits, 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 (c)); @@ -222,7 +222,7 @@ namespace odb // bool default_value_traits, 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 (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, -- cgit v1.1