From 25f9d60705e54c77704404a19001dc6711227bef Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Fri, 14 Oct 2011 14:34:51 +0200 Subject: Handle mapping of std::vector to Oracle SQL type RAW by default --- odb/oracle/traits.cxx | 22 ++++++++++++++++++++++ odb/oracle/traits.hxx | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/odb/oracle/traits.cxx b/odb/oracle/traits.cxx index a37f440..d358acf 100644 --- a/odb/oracle/traits.cxx +++ b/odb/oracle/traits.cxx @@ -56,6 +56,28 @@ namespace odb } // + // default_value_traits, id_raw> + // + + void default_value_traits, id_raw>:: + set_image (char* b, + size_t c, + size_t& n, + bool& is_null, + const value_type& v) + { + is_null = false; + n = v.size (); + + assert (n <= c); + + // std::vector::data() may not be available in older compilers. + // + if (n != 0) + memcpy (b, &v.front (), n); + } + + // // string_lob_value_traits // diff --git a/odb/oracle/traits.hxx b/odb/oracle/traits.hxx index d156fb3..efe35b1 100644 --- a/odb/oracle/traits.hxx +++ b/odb/oracle/traits.hxx @@ -582,6 +582,33 @@ namespace odb { }; + // std::vector specialization for RAW. + // + template <> + struct default_value_traits, id_raw> + { + public: + typedef std::vector value_type; + typedef std::vector query_type; + typedef lob_callback image_type; + + static void + set_value (value_type& v, const char* b, std::size_t n, bool is_null) + { + if (!is_null) + v.assign (b, b + n); + else + v.clear (); + } + + static void + set_image (char* b, + std::size_t c, + std::size_t& n, + bool& is_null, + const value_type& v); + }; + // std::string specialization for LOBs. // class string_lob_value_traits -- cgit v1.1