aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-09-27 17:15:48 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-09-27 17:20:06 +0200
commit7b9c412736f51965473649cac8caf5e933ae6b9e (patch)
treec4b2d89becc49fa7e5a56cea8b6352a4153d9885
parentafd8e6dd307288b68c4ce6163f918198d92bf363 (diff)
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.
-rw-r--r--odb/oracle/oracle-types.hxx2
-rw-r--r--odb/oracle/traits.cxx12
-rw-r--r--odb/oracle/traits.hxx18
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<string*> (ctx));
+ const string& v (*static_cast<const string*> (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<char*> (ctx));
+ const char* v (static_cast<const char*> (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<std::vector<char>, 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<value_type*> (ctx));
+ const value_type& v (*static_cast<const value_type*> (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 = &param_callback;
- context = const_cast<std::string*> (&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 = &param_callback;
- context = const_cast<char*> (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 = &param_callback;
- context = const_cast<value_type*> (&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,