diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-18 18:50:04 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-18 18:50:04 +0200 |
commit | 6f4f07fea0f98bdb1debffcc40a32d6af61ab5c0 (patch) | |
tree | 525de2a9e700871befc4ff92ed814cbccf5d27c1 /odb/mysql/query.hxx | |
parent | 1e1a40eb86919a19b0c6738741be50ec084be596 (diff) |
Implement automatic mapping for C++ enums
Diffstat (limited to 'odb/mysql/query.hxx')
-rw-r--r-- | odb/mysql/query.hxx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/odb/mysql/query.hxx b/odb/mysql/query.hxx index f4845cf..ca95f1c 100644 --- a/odb/mysql/query.hxx +++ b/odb/mysql/query.hxx @@ -18,6 +18,7 @@ #include <odb/mysql/version.hxx> #include <odb/mysql/forward.hxx> #include <odb/mysql/traits.hxx> +#include <odb/mysql/enum.hxx> #include <odb/mysql/binding.hxx> #include <odb/details/buffer.hxx> @@ -1676,6 +1677,8 @@ namespace odb // ENUM // + // The image type can be either integer or string. + // template <typename T> struct query_param_impl<T, id_enum>: query_param { @@ -1691,10 +1694,7 @@ namespace odb virtual void bind (MYSQL_BIND* b) { - b->buffer_type = MYSQL_TYPE_STRING; - b->buffer = buffer_.data (); - b->buffer_length = static_cast<unsigned long> (buffer_.capacity ()); - b->length = &size_; + enum_traits::bind (*b, image_, size_, 0); } private: @@ -1702,15 +1702,12 @@ namespace odb init (const T& v) { bool dummy; - std::size_t size, cap (buffer_.capacity ()); - value_traits<T, id_enum>::set_image (buffer_, size, dummy, v); - size_ = static_cast<unsigned long> (size); - return cap != buffer_.capacity (); + return enum_traits::set_image (image_, size_, dummy, v); } private: - details::buffer buffer_; - unsigned long size_; + typename value_traits<T, id_enum>::image_type image_; + unsigned long size_; // Keep size in case it is a string. }; // SET |