diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-03 08:16:50 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-03 08:16:50 +0200 |
commit | 0acb35c3ff7ce7e98fd6f3a92552558ec39f7c3d (patch) | |
tree | 6ec6be68d841e68b952a42a397213463d6f05803 /odb/pgsql/traits.cxx | |
parent | 6507a16de2e1e3d0a5432b37ada08baf4af3b790 (diff) |
Add support for mapping std::vector<unsigned char> to BLOB types
Diffstat (limited to 'odb/pgsql/traits.cxx')
-rw-r--r-- | odb/pgsql/traits.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/odb/pgsql/traits.cxx b/odb/pgsql/traits.cxx index a2c2f2f..9e31c9f 100644 --- a/odb/pgsql/traits.cxx +++ b/odb/pgsql/traits.cxx @@ -76,5 +76,27 @@ namespace odb if (n != 0) memcpy (b.data (), &v.front (), n); } + + // + // default_value_traits<vector<unsigned char>, id_bytea> + // + + void default_value_traits<vector<unsigned char>, 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.front (), n); + } } } |