From 7b9c412736f51965473649cac8caf5e933ae6b9e Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 27 Sep 2011 17:15:48 +0200 Subject: Pass parameter callback user context as a const void* This avoids usage of const_cast when manipulating the const qualified values in set_image functions within the traits implementations. --- odb/oracle/oracle-types.hxx | 2 +- odb/oracle/traits.cxx | 12 ++++++------ odb/oracle/traits.hxx | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/odb/oracle/oracle-types.hxx b/odb/oracle/oracle-types.hxx index a3b45c6..c027e5d 100644 --- a/odb/oracle/oracle-types.hxx +++ b/odb/oracle/oracle-types.hxx @@ -28,7 +28,7 @@ namespace odb // statement execution is aborted. // typedef bool (*param_callback_type) ( - void* context, // [in] The user context. + const void* context, // [in] The user context. ub4* position_context, // [in] A position context. A callback is free to // use this to track position information. void** buffer, // [out] On return, a pointer to a buffer diff --git a/odb/oracle/traits.cxx b/odb/oracle/traits.cxx index c934cc1..a37f440 100644 --- a/odb/oracle/traits.cxx +++ b/odb/oracle/traits.cxx @@ -85,7 +85,7 @@ namespace odb } bool string_lob_value_traits:: - param_callback (void* ctx, + param_callback (const void* ctx, ub4* pos_ctx, void** b, ub4* s, @@ -93,7 +93,7 @@ namespace odb void* temp_b, ub4 cap) { - const string& v (*reinterpret_cast (ctx)); + const string& v (*static_cast (ctx)); // @@ We rely on *pos_ctx == 0 for the first call. Make sure that this is // set by the generated code, and update comment in oracle-types.hxx @@ -121,7 +121,7 @@ namespace odb // bool c_string_lob_value_traits:: - param_callback (void* ctx, + param_callback (const void* ctx, ub4* pos_ctx, void** b, ub4* s, @@ -129,7 +129,7 @@ namespace odb void* temp_b, ub4 cap) { - const char* v (reinterpret_cast (ctx)); + const char* v (static_cast (ctx)); // @@ We rely on *pos_ctx == 0 for the first call. Make sure that this is // set by the generated code, and update comment in oracle-types.hxx @@ -183,7 +183,7 @@ namespace odb } bool default_value_traits, id_blob>:: - param_callback (void* ctx, + param_callback (const void* ctx, ub4* pos_ctx, void** b, ub4* s, @@ -191,7 +191,7 @@ namespace odb void* temp_b, ub4 cap) { - const value_type& v (*reinterpret_cast (ctx)); + const value_type& v (*static_cast (ctx)); // @@ We rely on *position_context == 0 for the first call. Make sure // that this is set by the generated code and update the comment in diff --git a/odb/oracle/traits.hxx b/odb/oracle/traits.hxx index 687d28a..cedf064 100644 --- a/odb/oracle/traits.hxx +++ b/odb/oracle/traits.hxx @@ -516,20 +516,20 @@ namespace odb static void set_image (param_callback_type& cb, - void*& context, + const void*& context, bool& is_null, const std::string& v) { is_null = false; cb = ¶m_callback; - context = const_cast (&v); + context = &v; } static bool result_callback (void* context, void* buffer, ub4 size, chunk_position); static bool - param_callback (void* context, + param_callback (const void* context, ub4* position_context, void** buffer, ub4* size, @@ -565,17 +565,17 @@ namespace odb static void set_image (param_callback_type& cb, - void*& context, + const void*& context, bool& is_null, const char* v) { is_null = false; cb = ¶m_callback; - context = const_cast (v); + context = v; } static bool - param_callback (void* context, + param_callback (const void* context, ub4* position_context, void** buffer, ub4* size, @@ -646,20 +646,20 @@ namespace odb static void set_image (param_callback_type& cb, - void*& context, + const void*& context, bool& is_null, const value_type& v) { is_null = false; cb = ¶m_callback; - context = const_cast (&v); + context = &v; } static bool result_callback (void* context, void* buffer, ub4 size, chunk_position); static bool - param_callback (void* context, + param_callback (const void* context, ub4* position_context, void** buffer, ub4* size, -- cgit v1.1