aboutsummaryrefslogtreecommitdiff
path: root/odb/mysql/traits.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-08-30 15:51:23 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-08-30 15:51:23 +0200
commit1692b3e82521e7d73a908f532eced90491e1eded (patch)
treec45272faba67485f3702395f43282a81a981cf5f /odb/mysql/traits.cxx
parent4452be925b749572f0e3edcb21e9af818647eb55 (diff)
Support for automake and VC++ builds
Diffstat (limited to 'odb/mysql/traits.cxx')
-rw-r--r--odb/mysql/traits.cxx90
1 files changed, 90 insertions, 0 deletions
diff --git a/odb/mysql/traits.cxx b/odb/mysql/traits.cxx
new file mode 100644
index 0000000..f90cc0b
--- /dev/null
+++ b/odb/mysql/traits.cxx
@@ -0,0 +1,90 @@
+// file : odb/mysql/traits.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <cstring> // std::memcpy, std::strlen
+
+#include <odb/mysql/traits.hxx>
+
+using namespace std;
+
+namespace odb
+{
+ namespace mysql
+ {
+ //
+ // value_traits<string>
+ //
+
+ void value_traits<string>::
+ set_image (char* s,
+ size_t c,
+ size_t& n,
+ bool& is_null,
+ const string& v)
+ {
+ is_null = false;
+ n = v.size ();
+
+ if (n > c)
+ n = c;
+
+ if (n != 0)
+ memcpy (s, v.c_str (), n);
+ }
+
+ void value_traits<string>::
+ set_image (details::buffer& b,
+ size_t& n,
+ bool& is_null,
+ const string& v)
+ {
+ is_null = false;
+ n = v.size ();
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ if (n != 0)
+ memcpy (b.data (), v.c_str (), n);
+ }
+
+ //
+ // value_traits<const char*>
+ //
+
+ void value_traits<const char*>::
+ set_image (char* s,
+ size_t c,
+ size_t& n,
+ bool& is_null,
+ const char* v)
+ {
+ is_null = false;
+ n = strlen (v);
+
+ if (n > c)
+ n = c;
+
+ if (n != 0)
+ memcpy (s, v, n);
+ }
+
+ void value_traits<const char*>::
+ set_image (details::buffer& b,
+ size_t& n,
+ bool& is_null,
+ const char* v)
+ {
+ is_null = false;
+ n = strlen (v);
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ if (n != 0)
+ memcpy (b.data (), v, n);
+ }
+ }
+}