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 | 68f64ea9543f44b71f580f165bff52286e005c79 (patch) | |
tree | 79c920db6297376970e6ada6f8713d8f78c501ee /odb/mysql/traits.cxx | |
parent | ef497ac84e9832de256c234670380850ab682585 (diff) |
Add support for mapping std::vector<unsigned char> to BLOB types
Diffstat (limited to 'odb/mysql/traits.cxx')
-rw-r--r-- | odb/mysql/traits.cxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/odb/mysql/traits.cxx b/odb/mysql/traits.cxx index 7b901c5..0727861 100644 --- a/odb/mysql/traits.cxx +++ b/odb/mysql/traits.cxx @@ -76,5 +76,27 @@ namespace odb if (n != 0) memcpy (b.data (), &v.front (), n); } + + // + // default_value_traits<vector<unsigned char>, id_blob> + // + + void default_value_traits<vector<unsigned char>, id_blob>:: + 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); + } } } |