From debdd3fa1bcf3c003636476484064ef919bc4d62 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 14 Jul 2011 09:53:29 +0200 Subject: Add support for binary format NUMERIC type --- odb/pgsql/query.hxx | 80 ++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 37 deletions(-) (limited to 'odb/pgsql/query.hxx') diff --git a/odb/pgsql/query.hxx b/odb/pgsql/query.hxx index 879517c..8ccc1f8 100644 --- a/odb/pgsql/query.hxx +++ b/odb/pgsql/query.hxx @@ -1267,44 +1267,50 @@ namespace odb double image_; }; - // @@ NUMERIC + // NUMERIC // - // template - // struct query_param_impl: query_param - // { - // query_param_impl (ref_bind r) : query_param (&r.ref) {} - // query_param_impl (val_bind v) : query_param (0) {init (v.val);} - - // virtual bool - // init () - // { - // return init (*static_cast (value_)); - // } - - // virtual void - // bind (pgsql::bind* b) - // { - // b->type = bind::numeric; - // b->buffer = buffer_.data (); - // b->buffer_length = static_cast (buffer_.capacity ()); - // b->length = &size_; - // } - - // private: - // bool - // init (const T& v) - // { - // bool dummy; - // std::size_t size, cap (buffer_.capacity ()); - // value_traits::set_image (buffer_, size, dummy, v); - // size_ = static_cast (size); - // return cap != buffer_.capacity (); - // } - - // private: - // details::buffer buffer_; - // unsigned long size_; - // }; + template + struct query_param_impl: query_param + { + query_param_impl (ref_bind r) : query_param (&r.ref) {} + query_param_impl (val_bind v) : query_param (0) {init (v.val);} + + virtual bool + init () + { + return init (*static_cast (value_)); + } + + virtual void + bind (pgsql::bind* b) + { + b->type = bind::numeric; + b->buffer = buffer_.data (); + b->capacity = buffer_.capacity (); + b->size = &size_; + } + + virtual unsigned int + oid () const + { + return numeric_oid; + } + + private: + bool + init (const T& v) + { + bool dummy; + std::size_t size, cap (buffer_.capacity ()); + value_traits::set_image (buffer_, size, dummy, v); + size_ = size; + return cap != buffer_.capacity (); + } + + private: + details::buffer buffer_; + std::size_t size_; + }; // DATE // -- cgit v1.1