From 3ed6a781cf4aad7986f805dc8a8e5c487d10a805 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Nov 2011 08:57:37 +0200 Subject: Merge LOB callback function and context into struct This allows us to have one less member in the bind struct. --- odb/oracle/oracle-types.hxx | 26 ++++++++++++-------------- odb/oracle/statement.cxx | 28 +++++++++++++++------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/odb/oracle/oracle-types.hxx b/odb/oracle/oracle-types.hxx index 4b58c08..bd62fe1 100644 --- a/odb/oracle/oracle-types.hxx +++ b/odb/oracle/oracle-types.hxx @@ -60,16 +60,19 @@ namespace odb ub4 size, // [in] The result data size in bytes. chunk_position); // [in] The position of this chunk. - union lob_callback + struct lob_callback { - param_callback_type param; - result_callback_type result; - }; + union + { + param_callback_type param; + result_callback_type result; + } callback; - union lob_context - { - const void* param; - void* result; + union + { + const void* param; + void* result; + } context; }; struct bind @@ -112,15 +115,10 @@ namespace odb // bindings, this is interpreted as the OCIDefine // handle associated with the LOB result parameter. ub4 capacity; // The maximum number of bytes that can be stored in - // buffer. + // the buffer. sb2* indicator; // Pointer to an OCI indicator variable. lob_callback* callback; - - // This pointer is provided to the user through the context argument - // in both parameter and result callback functions. - // - lob_context* context; }; // An instance of this structure specifies the function to invoke and diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index 0bc4014..921a826 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -89,13 +89,14 @@ namespace odb if (*b.indicator != -1) { chunk_position pos; - if (!(*b.callback->param) (b.context->param, - &l->position, - const_cast (buffer), - size, - &pos, - l->buffer->data (), - l->buffer->capacity ())) + if (!(*b.callback->callback.param) ( + b.callback->context.param, + &l->position, + const_cast (buffer), + size, + &pos, + l->buffer->data (), + l->buffer->capacity ())) return OCI_ERROR; switch (pos) @@ -982,7 +983,7 @@ namespace odb b->type == bind::clob || b->type == bind::nclob) && (b->indicator == 0 || *b->indicator != -1) && - b->callback->result != 0) + b->callback->callback.result != 0) { lob* l (static_cast (b->buffer)); @@ -1038,11 +1039,12 @@ namespace odb // OCI generates and ORA-24343 error when an error code is // returned from a user callback. We simulate this. // - if (!(*b->callback->result) (b->context->result, - &position, - lob_buffer.data (), - static_cast (read), - cp)) + if (!(*b->callback->callback.result) ( + b->callback->context.result, + &position, + lob_buffer.data (), + static_cast (read), + cp)) throw database_exception (24343, "user defined callback error"); } while (r == OCI_NEED_DATA); -- cgit v1.1