From fa6c1cdfe3fed38144ca945289fe6c059ec502c8 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Tue, 24 May 2011 16:33:50 +0200 Subject: Update result_ptr to be standard and safe --- odb/pgsql/result-ptr.hxx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'odb') diff --git a/odb/pgsql/result-ptr.hxx b/odb/pgsql/result-ptr.hxx index 1772cc9..4cfe58d 100644 --- a/odb/pgsql/result-ptr.hxx +++ b/odb/pgsql/result-ptr.hxx @@ -21,23 +21,36 @@ namespace odb class LIBODB_PGSQL_EXPORT result_ptr { public: - result_ptr (PGresult* r) + result_ptr (PGresult* r = 0) : r_ (r) { } ~result_ptr () { - if (r_) + if (r_ != 0) PQclear (r_); } PGresult* - get () + get () const { return r_; } + void + reset (PGresult* r = 0) + { + if (r_ != 0) + PQclear (r_); + + r_ = r; + } + + private: + result_ptr (const result_ptr&); + result_ptr& operator= (const result_ptr&); + private: PGresult* r_; }; -- cgit v1.1