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

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

#include <util.hxx>

Inheritance diagram for pqxx::internal::PQAlloc< T, DELETER >:

Public Types

typedef T content_type
 

Public Member Functions

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

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 ( )
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::PQAlloc ( const PQAlloc< T, DELETER > &  rhs)
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::~PQAlloc ( )
template<typename T, void(*)(T *) DELETER = freepqmem_templated<T>>
pqxx::internal::PQAlloc< T, DELETER >::PQAlloc ( T *  obj)
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

Obtain underlying pointer.

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

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

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

Is this pointer non-null?

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

Is this pointer null?

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

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

Dereference pointer.

Throws a logic_error if the pointer is null.

Referenced by pqxx::internal::PQAlloc< const internal::result_data, internal::freemem_result_data >::operator*().

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

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