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.hxx | |
parent | ef497ac84e9832de256c234670380850ab682585 (diff) |
Add support for mapping std::vector<unsigned char> to BLOB types
Diffstat (limited to 'odb/mysql/traits.hxx')
-rw-r--r-- | odb/mysql/traits.hxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/odb/mysql/traits.hxx b/odb/mysql/traits.hxx index c508624..7994d59 100644 --- a/odb/mysql/traits.hxx +++ b/odb/mysql/traits.hxx @@ -519,6 +519,40 @@ namespace odb const value_type&); }; + // std::vector<unsigned char> (buffer) specialization. + // + template <> + struct LIBODB_MYSQL_EXPORT default_value_traits< + std::vector<unsigned char>, id_blob> + { + public: + typedef std::vector<unsigned char> value_type; + typedef std::vector<unsigned char> query_type; + typedef details::buffer image_type; + + static void + set_value (value_type& v, + const details::buffer& b, + std::size_t n, + bool is_null) + { + if (!is_null) + { + const unsigned char* d ( + reinterpret_cast<const unsigned char*> (b.data ())); + v.assign (d, d + n); + } + else + v.clear (); + } + + static void + set_image (details::buffer&, + std::size_t& n, + bool& is_null, + const value_type&); + }; + // // type_traits // |