libpqxx
4.0.1
|
The ultimate template that defines a connection type. More...
#include <basic_connection.hxx>
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 () |
![]() | |
void | disconnect () throw () |
Explicitly close connection. | |
bool PQXX_PURE | is_open () const throw () |
Is this connection open at the moment? | |
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. | |
void | trace (std::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. | |
std::string | quote_raw (const unsigned char str[], size_t len) |
Escape and quote a string of binary data. | |
std::string | quote_name (const std::string &identifier) |
Escape and quote an SQL identifier for use in a query. | |
template<typename T > | |
std::string | quote (const T &t) |
Represent object as SQL string, including quoting & escaping. | |
std::string | quote (const binarystring &) |
void | cancel_query () |
Attempt to cancel the ongoing query, if any. | |
void | set_verbosity (error_verbosity verbosity) throw () |
Set session verbosity. | |
error_verbosity | get_verbosity () const throw () |
Retrieve current error verbosity. | |
std::vector< errorhandler * > | get_errorhandlers () const |
Return pointers to the active errorhandlers. | |
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. | |
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 PQXX_PURE | backendpid () const throw () |
Process ID for backend process. | |
int PQXX_PURE | 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. | |
void | prepare (const std::string &name, const std::string &definition) |
Define a prepared statement. | |
void | 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 PQXX_PURE | protocol_version () const throw () |
What version of the PostgreSQL protocol is this connection using? | |
int PQXX_PURE | server_version () const throw () |
What version of the PostgreSQL server are we connected to? |
Additional Inherited Members | |
![]() | |
enum | error_verbosity { terse = 0, normal = 1, verbose = 2 } |
Error verbosity levels. More... | |
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_notify_payload, cap_end } |
Session capabilities. More... | |
![]() | |
connection_base (connectionpolicy &) | |
void | init () |
void | close () throw () |
void | wait_read () const |
void | wait_read (long seconds, long microseconds) const |
void | wait_write () const |
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.
pqxx::basic_connection< CONNECTPOLICY >::basic_connection | ( | ) |
References pqxx::connection_base::init().
|
explicit |
References pqxx::connection_base::init().
|
explicit |
References pqxx::connection_base::init().
pqxx::basic_connection< CONNECTPOLICY >::~basic_connection | ( | ) | throw () |
References pqxx::connection_base::close().
const std::string& pqxx::basic_connection< CONNECTPOLICY >::options | ( | ) | const throw () |