libpqxx  4.0.1
pqxx::internal::PQAlloc< T, DELETER > Class Template Reference

Reference-counted smart pointer to libpq-allocated object. More...

#include <util.hxx>

Public Types

typedef T content_type

Public Member Functions

 PQAlloc () throw ()
 PQAlloc (const PQAlloc &rhs) throw ()
 ~PQAlloc () throw ()
PQAllocoperator= (const PQAlloc &rhs) throw ()
 PQAlloc (T *obj) throw ()
 Assume ownership of a pointer.
void swap (PQAlloc &rhs) throw ()
 operator bool () const throw ()
 Is this pointer non-null?
bool operator! () const throw ()
 Is this pointer null?
T * operator-> () const throw (std::logic_error)
 Dereference pointer.
T & operator* () const throw (std::logic_error)
 Dereference pointer.
T * get () const throw ()
 Obtain underlying pointer.
void reset () throw ()

Detailed Description

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
class pqxx::internal::PQAlloc< T, DELETER >

Reference-counted smart pointer to libpq-allocated object.

Keep track of a libpq-allocated object, and free it once all references to it have died.

The memory is freed with PQfreemem() by default. This matters on Windows, where apparently under some circumstances, memory allocated by a DLL must be freed by the same DLL.

Warning
Copying, swapping, and destroying PQAlloc objects that refer to the same underlying libpq-allocated block is not thread-safe. If you wish to pass reference-counted objects around between threads, make sure that each of these operations is protected against concurrency with similar operations on the same object–or other copies of the same object.

Member Typedef Documentation

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
typedef T pqxx::internal::PQAlloc< T, DELETER >::content_type

Constructor & Destructor Documentation

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::PQAlloc ( ) throw ()
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::PQAlloc ( const PQAlloc< T, DELETER > &  rhs) throw ()
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::~PQAlloc ( ) throw ()
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::PQAlloc ( T *  obj) throw ()
explicit

Assume ownership of a pointer.

Warning
Don't to this more than once for a given object!

Member Function Documentation

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
T* pqxx::internal::PQAlloc< T, DELETER >::get ( ) const throw ()

Obtain underlying pointer.

Ownership of the pointer's memory remains with the PQAlloc object

Referenced by pqxx::connection_base::esc_raw(), pqxx::escape_binary(), and pqxx::connection_base::quote_name().

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::operator bool ( ) const throw ()

Is this pointer non-null?

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
bool pqxx::internal::PQAlloc< T, DELETER >::operator! ( ) const throw ()

Is this pointer null?

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
T& pqxx::internal::PQAlloc< T, DELETER >::operator* ( ) const throw (std::logic_error)

Dereference pointer.

Throws a logic_error if the pointer is null.

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
T* pqxx::internal::PQAlloc< T, DELETER >::operator-> ( ) const throw (std::logic_error)

Dereference pointer.

Throws a logic_error if the pointer is null.

Referenced by pqxx::internal::PQAlloc< unsigned char, pqxx::internal::freemallocmem_templated< unsigned char > >::operator*().

template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
PQAlloc& pqxx::internal::PQAlloc< T, DELETER >::operator= ( const PQAlloc< T, DELETER > &  rhs) throw ()
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
void pqxx::internal::PQAlloc< T, DELETER >::reset ( ) throw ()
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
void pqxx::internal::PQAlloc< T, DELETER >::swap ( PQAlloc< T, DELETER > &  rhs) throw ()

The documentation for this class was generated from the following file: