aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-10-14 14:36:38 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-10-14 14:36:38 +0200
commit3ee62fe4711ed3f3621fb3b94607a24783b5442e (patch)
tree69df057e4ed3de868a6bf71c02ea32d78dfcf28f
parent25f9d60705e54c77704404a19001dc6711227bef (diff)
Improve default LOB parameter callback implementations
-rw-r--r--odb/oracle/traits.cxx84
1 files changed, 21 insertions, 63 deletions
diff --git a/odb/oracle/traits.cxx b/odb/oracle/traits.cxx
index d358acf..f437d3c 100644
--- a/odb/oracle/traits.cxx
+++ b/odb/oracle/traits.cxx
@@ -108,32 +108,18 @@ namespace odb
bool string_lob_value_traits::
param_callback (const void* ctx,
- ub4* pos_ctx,
- void** b,
+ ub4*,
+ const void** b,
ub4* s,
chunk_position* p,
- void* temp_b,
- ub4 cap)
+ void*,
+ ub4)
{
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
- // specifying that this is so.
- //
- *s = static_cast<ub4> (v.size ()) - *pos_ctx;
-
- if (*s <= cap)
- *p = *pos_ctx == 0 ? one_chunk : last_chunk;
- else
- {
- *p = *pos_ctx == 0 ? first_chunk : next_chunk;
- *s = cap;
- *pos_ctx += *s;
- }
-
- *b = temp_b;
- memcpy (temp_b, v.c_str () + *pos_ctx, *s);
+ *p= one_chunk;
+ *s= static_cast<ub4> (v.size ());
+ *b = v.c_str ();
return true;
}
@@ -144,32 +130,18 @@ namespace odb
bool c_string_lob_value_traits::
param_callback (const void* ctx,
- ub4* pos_ctx,
- void** b,
+ ub4*,
+ const void** b,
ub4* s,
chunk_position* p,
- void* temp_b,
- ub4 cap)
+ void*,
+ ub4)
{
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
- // specifying that this is so.
- //
- *s = static_cast<ub4> (strlen (v)) - *pos_ctx;
-
- if (*s <= cap)
- *p = *pos_ctx == 0 ? one_chunk : last_chunk;
- else
- {
- *p = *pos_ctx == 0 ? first_chunk : next_chunk;
- *s = cap;
- *pos_ctx += *s;
- }
-
- *b = temp_b;
- memcpy (temp_b, v + *pos_ctx, *s);
+ *p = one_chunk;
+ *s = static_cast<ub4> (strlen (v));
+ *b = v;
return true;
}
@@ -206,32 +178,18 @@ namespace odb
bool default_value_traits<std::vector<char>, id_blob>::
param_callback (const void* ctx,
- ub4* pos_ctx,
- void** b,
+ ub4*,
+ const void** b,
ub4* s,
chunk_position* p,
- void* temp_b,
- ub4 cap)
+ void*,
+ ub4)
{
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
- // oracle-types.hxx specifying that this is so.
- //
- *s = static_cast<ub4> (v.size ()) - *pos_ctx;
-
- if (*s <= cap)
- *p = *pos_ctx == 0 ? one_chunk : last_chunk;
- else
- {
- *p = *pos_ctx == 0 ? first_chunk : next_chunk;
- *s = cap;
- *pos_ctx += *s;
- }
-
- *b = temp_b;
- memcpy (temp_b, &v[*pos_ctx], *s);
+ *p = one_chunk;
+ *s = static_cast<ub4> (v.size ());
+ *b = &v.front ();
return true;
}