From 0f04eb5bc2069a63c86489258da06f007d8ac3c7 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 5 Jul 2011 13:04:34 +0200 Subject: Implement PostgreSQL specific query --- odb/pgsql/query.hxx | 83 +++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 44 deletions(-) (limited to 'odb/pgsql/query.hxx') diff --git a/odb/pgsql/query.hxx b/odb/pgsql/query.hxx index 632fde5..1d34545 100644 --- a/odb/pgsql/query.hxx +++ b/odb/pgsql/query.hxx @@ -126,14 +126,8 @@ namespace odb std::string clause () const; - binding& - parameters_binding () const; - native_binding& - native_parameters_binding () const - { - return native_binding_; - } + parameters_binding () const; const unsigned int* parameter_types () const @@ -213,6 +207,9 @@ namespace odb std::string clause_; parameters_type parameters_; + typedef std::pair parameter_offset; + std::vector parameter_offsets_; + mutable std::vector bind_; mutable binding binding_; @@ -1501,47 +1498,45 @@ namespace odb std::size_t size_; }; - // @@ BIT + // BIT // - // 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);} + 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 () - // { - // init (*static_cast (value_)); - // return false; - // } + virtual bool + init () + { + return init (*static_cast (value_)); + } - // virtual void - // bind (pgsql::bind* b) - // { - // b->type = bind::bit; - // b->buffer = buffer_; - // b->capacity = sizeof (buffer_); - // b->size = &size_; - // } + virtual void + bind (pgsql::bind* b) + { + b->type = bind::bit; + b->buffer = buffer_.data (); + b->capacity = buffer_.capacity (); + b->size = &size_; + } - // private: - // void - // init (const T& v) - // { - // bool dummy; - // std::size_t size; - // value_traits::set_image ( - // buffer_, sizeof (buffer_), size, dummy, v); - // size_ = static_cast (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_ = size; - // private: - // // Max 64 bit. - // // - // unsigned char buffer_[8]; - // unsigned long size_; - // }; + return cap != buffer_.capacity (); + } + + private: + details::ubuffer buffer_; + std::size_t size_; + }; // VARBIT // @@ -1584,7 +1579,7 @@ namespace odb } private: - details::buffer buffer_; + details::ubuffer buffer_; std::size_t size_; }; -- cgit v1.1