aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/traits.cxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-05-27 17:21:38 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-05-27 17:21:38 +0200
commit88fb6802608818b70617340b1ed826c1b8a9f1ea (patch)
tree0bfc9f07838c1c3eecdc9e5804e2bc8c71229aa6 /odb/pgsql/traits.cxx
parent1b61b6780496fb7d188e521f9a22a0db7e591544 (diff)
Add traits
Diffstat (limited to 'odb/pgsql/traits.cxx')
-rw-r--r--odb/pgsql/traits.cxx58
1 files changed, 58 insertions, 0 deletions
diff --git a/odb/pgsql/traits.cxx b/odb/pgsql/traits.cxx
new file mode 100644
index 0000000..bdffa45
--- /dev/null
+++ b/odb/pgsql/traits.cxx
@@ -0,0 +1,58 @@
+// file : odb/pgsql/traits.cxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <cstring> // std::memcpy, std::strlen
+
+#include <odb/pgsql/traits.hxx>
+
+using namespace std;
+
+namespace odb
+{
+ namespace pgsql
+ {
+ using details::buffer;
+
+ //
+ // string_value_traits
+ //
+
+ void string_value_traits::
+ set_image (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);
+ }
+
+ //
+ // c_string_value_traits
+ //
+
+ void c_string_value_traits::
+ set_image (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);
+ }
+ }
+}