aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/query.hxx
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-07-14 09:53:29 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-07-14 09:53:29 +0200
commitdebdd3fa1bcf3c003636476484064ef919bc4d62 (patch)
tree2651d0aa01e6991b1e6fe66b7a9dd5c421313c5a /odb/pgsql/query.hxx
parentdb26f79d8c2a367d6ed3b6ef91de29213f3430c7 (diff)
Add support for binary format NUMERIC type
Diffstat (limited to 'odb/pgsql/query.hxx')
-rw-r--r--odb/pgsql/query.hxx80
1 files changed, 43 insertions, 37 deletions
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 <typename T>
- // struct query_param_impl<T, id_numeric>: query_param
- // {
- // query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
- // query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
-
- // virtual bool
- // init ()
- // {
- // return init (*static_cast<const T*> (value_));
- // }
-
- // virtual void
- // bind (pgsql::bind* b)
- // {
- // b->type = bind::numeric;
- // b->buffer = buffer_.data ();
- // b->buffer_length = static_cast<unsigned long> (buffer_.capacity ());
- // b->length = &size_;
- // }
-
- // private:
- // bool
- // init (const T& v)
- // {
- // bool dummy;
- // std::size_t size, cap (buffer_.capacity ());
- // value_traits<T, id_decimal>::set_image (buffer_, size, dummy, v);
- // size_ = static_cast<unsigned long> (size);
- // return cap != buffer_.capacity ();
- // }
-
- // private:
- // details::buffer buffer_;
- // unsigned long size_;
- // };
+ template <typename T>
+ struct query_param_impl<T, id_numeric>: query_param
+ {
+ query_param_impl (ref_bind<T> r) : query_param (&r.ref) {}
+ query_param_impl (val_bind<T> v) : query_param (0) {init (v.val);}
+
+ virtual bool
+ init ()
+ {
+ return init (*static_cast<const T*> (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<T, id_numeric>::set_image (buffer_, size, dummy, v);
+ size_ = size;
+ return cap != buffer_.capacity ();
+ }
+
+ private:
+ details::buffer buffer_;
+ std::size_t size_;
+ };
// DATE
//