libpqxx 3.1.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
pqxx::basic_connection< CONNECTPOLICY > Class Template Reference

The ultimate template that defines a connection type. More...

`#include <basic_connection.hxx>`

Inheritance diagram for pqxx::basic_connection< CONNECTPOLICY >:

## Public Member Functions

| basic_connection ()
| basic_connection (const std::string &opt)
| basic_connection (const char opt[])
| ~basic_connection () throw ()
const std::string & | options () const throw ()
Public Member Functions inherited from pqxx::connection_base
void | disconnect () throw ()
| Explicitly close connection.
bool | is_open () const throw ()
| Is this connection open at the moment?
void | trace (FILE *) throw ()
| Enable tracing to a given output stream, or NULL to disable.
void | set_client_encoding (const std::string &Encoding)
| Set client-side character encoding.
void | set_variable (const std::string &Var, const std::string &Value)
| Set session variable.
std::string | get_variable (const std::string &)
| Read session variable.
std::string | adorn_name (const std::string &)
| Suffix unique number to name to make it unique within session context.
std::string | esc (const char str[])
| Escape string for use as SQL string literal on this connection.
std::string | esc (const char str[], size_t maxlen)
| Escape string for use as SQL string literal on this connection.
std::string | esc (const std::string &str)
| Escape string for use as SQL string literal on this connection.
std::string | esc_raw (const unsigned char str[], size_t len)
| Escape binary string for use as SQL string literal on this connection.
template<typename T >
std::string | quote (const T &t)
| Represent object as SQL string, including quoting & escaping.
void | cancel_query ()
| Attempt to cancel the ongoing query, if any.
void | activate ()
| Explicitly activate deferred or deactivated connection.
void | deactivate ()
| Explicitly deactivate connection.
void | inhibit_reactivation (bool inhibit)
| Disallow (or permit) connection recovery.
void | simulate_failure ()
| Make the connection fail.
std::auto_ptr< noticer > | set_noticer (std::auto_ptr< noticer > N) throw ()
| Set handler for postgresql errors or warning messages.
noticer * | get_noticer () const throw ()
void | process_notice (const char[]) throw ()
| Invoke notice processor function. The message should end in newline.
void | process_notice (const std::string &) throw ()
| Invoke notice processor function. Newline at end is recommended.
const char * | dbname ()
| Name of database we're connected to, if any.
const char * | username ()
| Database user ID we're connected under, if any.
const char * | hostname ()
| Address of server, or NULL if none specified (i.e. default or local)
const char * | port ()
| Server port number we're connected to.
int | backendpid () const throw ()
| Process ID for backend process.
int | sock () const throw ()
| Socket currently used for connection, or -1 for none. Use with care!
int | get_notifs ()
| Check for pending notifications and take appropriate action.
int | await_notification ()
| Wait for a notification to come in.
int | await_notification (long seconds, long microseconds)
| Wait for a notification to come in, or for given timeout to pass.
prepare::declaration | prepare (const std::string &name, const std::string &definition)
| Define a prepared statement.
prepare::declaration | prepare (const std::string &definition)
| Define a nameless prepared statement.
void | unprepare (const std::string &name)
| Drop prepared statement.
void | prepare_now (const std::string &name)
| Request that prepared statement be registered with the server.
template<typename TRANSACTOR >
void | perform (const TRANSACTOR &T, int Attempts)
| Perform the transaction defined by a transactor-based object.
template<typename TRANSACTOR >
void | perform (const TRANSACTOR &T)
| Perform the transaction defined by a transactor-based object.
bool | supports (capability c) const throw ()
| Does this connection seem to support the given capability?
int | protocol_version () const throw ()
| What version of the PostgreSQL protocol is this connection using?
int | server_version () const throw ()
| What version of the PostgreSQL server are we connected to?

## Additional Inherited Members

Public Types inherited from pqxx::connection_base
enum | capability { cap_prepared_statements, cap_create_table_with_oids, cap_nested_transactions, cap_cursor_scroll, cap_cursor_with_hold, cap_cursor_update, cap_cursor_fetch_0, cap_table_column, cap_read_only_transactions, cap_statement_varargs, cap_prepare_unnamed_statement, cap_parameterized_statements, cap_end }
| Session capabilities. More...
Protected Member Functions inherited from pqxx::connection_base
| connection_base (connectionpolicy &)
void | init ()
void | close () throw ()
void | wait_read () const
void | wait_read (long seconds, long microseconds) const
void | wait_write () const

## Detailed Description

### template<typename CONNECTPOLICY>
class pqxx::basic_connection< CONNECTPOLICY >

The ultimate template that defines a connection type.

Combines connection_base (the highly complex class implementing essentially all connection-related functionality) with a connection policy (a simpler helper class determining the rules that govern the process of setting up the underlying connection to the backend).

The pattern used to combine these classes is the same as for basic_transaction. Through use of the template mechanism, the policy object is embedded in the basic_connection object so that it does not need to be allocated separately. At the same time this construct avoids the need for any virtual functions in this class, which reduces risks of bugs in construction and destruction; as well as any need to templatize the larger body of code in the connection_base class which might otherwise lead to unacceptable code duplication.

## Constructor & Destructor Documentation

template<typename CONNECTPOLICY >

pqxx::basic_connection< CONNECTPOLICY >::basic_connection | ( |  | ) |

References pqxx::connection_base::init().

template<typename CONNECTPOLICY >

pqxx::basic_connection< CONNECTPOLICY >::basic_connection | ( | const std::string & | opt | ) |

explicit

References pqxx::connection_base::init().

template<typename CONNECTPOLICY >

pqxx::basic_connection< CONNECTPOLICY >::basic_connection | ( | const char | opt[] | ) |

explicit

References pqxx::connection_base::init().

template<typename CONNECTPOLICY >

pqxx::basic_connection< CONNECTPOLICY >::~basic_connection | ( |  | ) | throw ()

References pqxx::connection_base::close(), and pqxx::connection_base::set_noticer().

## Member Function Documentation

template<typename CONNECTPOLICY >

const std::string& pqxx::basic_connection< CONNECTPOLICY >::options | ( |  | ) | const throw ()

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

- basic_connection.hxx