diff options
author | Constantin Michael <constantin@codesynthesis.com> | 2011-10-14 14:34:51 +0200 |
---|---|---|
committer | Constantin Michael <constantin@codesynthesis.com> | 2011-10-14 14:34:51 +0200 |
commit | 25f9d60705e54c77704404a19001dc6711227bef (patch) | |
tree | ec0186d86e6e0fb16df1a5954e4a3e305e9d27a1 | |
parent | bbac9d4b7e9015811ad3dd3d49024981e7fce73d (diff) |
Handle mapping of std::vector<char> to Oracle SQL type RAW by default
-rw-r--r-- | odb/oracle/traits.cxx | 22 | ||||
-rw-r--r-- | odb/oracle/traits.hxx | 27 |
2 files changed, 49 insertions, 0 deletions
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<vector<char>, id_raw> + // + + void default_value_traits<vector<char>, 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<std::vector<char>, id_raw> + { + public: + typedef std::vector<char> value_type; + typedef std::vector<char> 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 |