OZO 「お象」
Boost.Asio and libpq based asynchronous PostgreSQL unofficial header-only C++17 client library.
ozo::connection_info< OidMap, Statistics > Class Template Reference

#include <ozo/connection_info.h>

Description

template<typename OidMap = empty_oid_map, typename Statistics = no_statistics>
class ozo::connection_info< OidMap, Statistics >

Connection source to a single host.

This connection source establishes a connection to a single host using (or via) the specified connection string.

Warning
Multi-host connection is not supported.
Template Parameters
OidMap— oid map type with custom types that should be used within a connection.
Statistics— statistics type which defines statistics is collected for this connection.
Models
ConnectionSource

Types

using connection_type = std::shared_ptr< ozo::connection< OidMap, Statistics > >
 Type of connection which is produced by the source.
 

Public Member Functions

 connection_info (std::string conn_str, const OidMap &=OidMap{}, Statistics statistics=Statistics{})
 Construct a new connection information object. More...
 
template<typename TimeConstraint , typename Handler >
void operator() (io_context &io, TimeConstraint t, Handler &&handler) const
 Provides connection is binded to the given io_context More...
 

Related Functions

(Note that these are not member functions.)

template<typename OidMap = empty_oid_map, typename Statistics = no_statistics>
auto make_connection_info (std::string conn_str, const OidMap &oid_map=OidMap{}, Statistics statistics=Statistics{})
 Constructs ozo::connection_info ConnectionSource. More...
 

Constructors

◆ connection_info()

template<typename OidMap = empty_oid_map, typename Statistics = no_statistics>
ozo::connection_info< OidMap, Statistics >::connection_info ( std::string  conn_str,
const OidMap &  = OidMap{},
Statistics  statistics = Statistics{} 
)

Construct a new connection information object.

Parameters
conn_str— connection string which is being used to create connection to a database. For details of how to make string see official libpq documentation
OidMap— #OidMap for custom types support.
statistics— statistics are being used for connections.

Member Function Documentation

◆ operator()()

template<typename OidMap = empty_oid_map, typename Statistics = no_statistics>
template<typename TimeConstraint , typename Handler >
void ozo::connection_info< OidMap, Statistics >::operator() ( io_context &  io,
TimeConstraint  t,
Handler &&  handler 
) const

Provides connection is binded to the given io_context

In case of success — the handler will be invoked as operation succeeded. In case of connection fail — the handler will be invoked as operation failed. This operation has a time constrain and would be interrupted if the time constrain expired by cancelling IO on a Connection's socket.

Parameters
ioio_context for the connection IO.
t— #TimeConstraint for the operation.
handlerHandler.