aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/oracle/traits.cxx84
-rw-r--r--odb/oracle/traits.hxx61
2 files changed, 51 insertions, 94 deletions
diff --git a/odb/oracle/traits.cxx b/odb/oracle/traits.cxx
index 8c0f236..eabfe28 100644
--- a/odb/oracle/traits.cxx
+++ b/odb/oracle/traits.cxx
@@ -12,90 +12,6 @@ namespace odb
namespace oracle
{
//
- // string_value_traits
- //
-
- void string_value_traits::
- set_image (char* b,
- size_t c,
- size_t& n,
- bool& is_null,
- const string& v)
- {
- is_null = false;
- n = v.size ();
-
- assert (n <= c);
-
- if (n != 0 && n <= c)
- memcpy (b, v.c_str (), n);
- }
-
- //
- // c_string_value_traits
- //
-
- void c_string_value_traits::
- set_image (char* b,
- size_t c,
- size_t& n,
- bool& is_null,
- const char* v)
- {
- is_null = false;
- n = strlen (v);
-
- assert (n <= c);
-
- if (n != 0 && n <= c)
- memcpy (b, v, n);
- }
-
- //
- // default_value_traits<vector<char>, id_raw>
- //
-
- void default_value_traits<vector<char>, id_raw>::
- set_image (char* b,
- size_t c,
- size_t& n,
- bool& is_null,
- const value_type& v)
- {
- is_null = false;
- n = v.size ();
-
- assert (n <= c);
-
- // std::vector::data() may not be available in older compilers.
- //
- if (n != 0)
- memcpy (b, &v.front (), n);
- }
-
- //
- // default_value_traits<vector<unsigned char>, id_raw>
- //
-
- void default_value_traits<vector<unsigned char>, id_raw>::
- set_image (char* b,
- size_t c,
- size_t& n,
- bool& is_null,
- const value_type& v)
- {
- is_null = false;
- n = v.size ();
-
- assert (n <= c);
-
- // std::vector::data() may not be available in older compilers.
- //
- if (n != 0)
- memcpy (b, &v.front (), n);
- }
-
- //
// string_lob_value_traits
//
diff --git a/odb/oracle/traits.hxx b/odb/oracle/traits.hxx
index d060588..903502c 100644
--- a/odb/oracle/traits.hxx
+++ b/odb/oracle/traits.hxx
@@ -12,7 +12,6 @@
#include <vector>
#include <cstddef> // std::size_t
#include <cstring> // std::memcpy, std::memset, std::strlen
-#include <cassert>
#include <odb/traits.hxx>
#include <odb/wrapper-traits.hxx>
@@ -517,7 +516,17 @@ namespace odb
std::size_t c,
std::size_t& n,
bool& is_null,
- const std::string&);
+ const std::string& v)
+ {
+ is_null = false;
+ n = v.size ();
+
+ if (n > c)
+ n = c;
+
+ if (n != 0)
+ std::memcpy (b, v.c_str (), n);
+ }
};
template <>
@@ -546,11 +555,21 @@ namespace odb
typedef char* image_type;
static void
- set_image (char*,
+ set_image (char* b,
std::size_t c,
std::size_t& n,
bool& is_null,
- const char*);
+ const char* v)
+ {
+ is_null = false;
+ n = std::strlen (v);
+
+ if (n > c)
+ n = c;
+
+ if (n != 0)
+ std::memcpy (b, v, n);
+ }
};
template <>
@@ -611,7 +630,19 @@ namespace odb
std::size_t c,
std::size_t& n,
bool& is_null,
- const value_type& v);
+ const value_type& v)
+ {
+ is_null = false;
+ n = v.size ();
+
+ if (n > c)
+ n = c;
+
+ // std::vector::data() may not be available in older compilers.
+ //
+ if (n != 0)
+ std::memcpy (b, &v.front (), n);
+ }
};
// std::vector<unsigned char> (buffer) specialization for RAW.
@@ -641,7 +672,19 @@ namespace odb
std::size_t c,
std::size_t& n,
bool& is_null,
- const value_type& v);
+ const value_type& v)
+ {
+ is_null = false;
+ n = v.size ();
+
+ if (n > c)
+ n = c;
+
+ // std::vector::data() may not be available in older compilers.
+ //
+ if (n != 0)
+ std::memcpy (b, &v.front (), n);
+ }
};
// char[n] (buffer) specialization for RAW.
@@ -670,8 +713,7 @@ namespace odb
const char* v)
{
is_null = false;
- n = N;
- assert (N <= c);
+ n = N < c ? N : c;
std::memcpy (b, v, n);
}
};
@@ -705,8 +747,7 @@ namespace odb
const unsigned char* v)
{
is_null = false;
- n = N;
- assert (N <= c);
+ n = N < c ? N : c;
std::memcpy (b, v, n);
}
};