aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/traits.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-07-28 09:45:36 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-07-28 09:45:36 +0200
commit37f5dcb1d34205aa4a395c1e21e853e363fd7f12 (patch)
treef26a9be89a184a2bc3e60b11e04784006143d023 /odb/sqlite/traits.hxx
parentd32bbee7fdbad3eed60b8264d7950d10e4e36210 (diff)
Add value_traits specializations for std::vector<char>
This allows using it as a buffer for BLOB mapping.
Diffstat (limited to 'odb/sqlite/traits.hxx')
-rw-r--r--odb/sqlite/traits.hxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/odb/sqlite/traits.hxx b/odb/sqlite/traits.hxx
index 2fdac04..8863fb1 100644
--- a/odb/sqlite/traits.hxx
+++ b/odb/sqlite/traits.hxx
@@ -9,6 +9,7 @@
#include <odb/pre.hxx>
#include <string>
+#include <vector>
#include <cstddef> // std::size_t
#include <odb/traits.hxx>
@@ -132,6 +133,35 @@ namespace odb
const char*);
};
+ // std::vector<char> (buffer) specialization.
+ //
+ template <>
+ struct LIBODB_SQLITE_EXPORT default_value_traits<std::vector<char>, id_blob>
+ {
+ public:
+ typedef std::vector<char> value_type;
+ typedef std::vector<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)
+ v.assign (b.data (), b.data () + n);
+ else
+ v.clear ();
+ }
+
+ static void
+ set_image (details::buffer&,
+ std::size_t& n,
+ bool& is_null,
+ const value_type&);
+ };
+
//
// type_traits
//