From 9abf73c8180e3664a71bac73629f67851c6c12da Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 Jul 2011 09:45:36 +0200 Subject: Add value_traits specializations for std::vector This allows using it as a buffer for BLOB mapping. --- odb/pgsql/traits.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'odb/pgsql/traits.cxx') diff --git a/odb/pgsql/traits.cxx b/odb/pgsql/traits.cxx index bdffa45..1c167b8 100644 --- a/odb/pgsql/traits.cxx +++ b/odb/pgsql/traits.cxx @@ -54,5 +54,27 @@ namespace odb if (n != 0) memcpy (b.data (), v, n); } + + // + // default_value_traits, id_bytea> + // + + void default_value_traits, id_bytea>:: + set_image (details::buffer& b, + size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = v.size (); + + if (n > b.capacity ()) + b.capacity (n); + + // std::vector::data() may not be available in older compilers. + // + if (n != 0) + memcpy (b.data (), &v[0], n); + } } } -- cgit v1.1