aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-05-24 16:33:50 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-05-24 16:33:50 +0200
commitfa6c1cdfe3fed38144ca945289fe6c059ec502c8 (patch)
tree16afd4540cb2b22e76582d6c5e72dd4934235f1c /odb
parent3c9c10f340a3013e5d67e5cac9b89990cf567538 (diff)
Update result_ptr to be standard and safe
Diffstat (limited to 'odb')
-rw-r--r--odb/pgsql/result-ptr.hxx19
1 files changed, 16 insertions, 3 deletions
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_;
};