OZO 「お象」
Boost.Asio and libpq based asynchronous PostgreSQL unofficial header-only C++17 client library.
Functions

Description

Core utility functions of the library.

Functions

template<typename Operation >
constexpr auto ozo::get_operation_initiator (const Operation &op)
 Get asynchronous operation initiator. More...
 
template<typename Operation , typename Factory >
constexpr auto ozo::construct_initiator (Factory &&f, const Operation &op)
 Create asynchronous operation initiator using factory. More...
 
template<typename T >
constexpr decltype(auto) ozo::is_null (const T &v) noexcept(noexcept(is_null_impl< T >::apply(v)))
 Indicates if value is in null state. More...
 
template<typename T , typename Alloc >
void ozo::allocate_nullable (T &out, const Alloc &a)
 Allocates nullable object of given type. More...
 
template<typename Map , typename Key >
constexpr decltype(auto) ozo::get_option (Map &&map, ozo::option< Key > op)
 Get the option object from Hana.Map. More...
 
template<typename Map , typename Key , typename T >
constexpr decltype(auto) ozo::get_option (Map &&map, ozo::option< Key > op, T &&default_)
 Get the option object from Hana.Map. More...
 
template<typename ... Options>
constexpr auto ozo::make_options (Options &&...opts)
 Constructor for options map. More...
 
template<typename T >
constexpr decltype(auto) ozo::unwrap_recursive (T &&v) noexcept
 Unwraps argument underlying value recursively. More...
 
template<typename T >
constexpr bool ozo::is_null_recursive (T &&v) noexcept
 Indicates if one of unwrapped values is in null state. More...
 
template<typename T >
constexpr decltype(auto) ozo::unwrap (T &&v) noexcept(noexcept(unwrap_impl< std::decay_t< T >>::apply(std::forward< T >(v))))
 Unwraps argument underlying value or forwards the argument. More...
 
constexpr time_traits::time_point ozo::deadline (time_traits::time_point t) noexcept
 Dealdine calculation. More...
 
constexpr time_traits::time_point ozo::deadline (time_traits::duration after, time_traits::time_point now) noexcept
 Dealdine calculation. More...
 
time_traits::time_point ozo::deadline (time_traits::duration after) noexcept
 Dealdine calculation. More...
 
constexpr auto ozo::deadline (none_t) noexcept
 Dealdine calculation. More...
 
constexpr time_traits::duration ozo::time_left (time_traits::time_point t, time_traits::time_point now) noexcept
 Time left to deadline. More...
 
time_traits::duration ozo::time_left (time_traits::time_point t) noexcept
 Time left to deadline. More...
 
bool ozo::expired (time_traits::time_point t, time_traits::time_point now) noexcept
 Deadline is expired. More...
 
bool ozo::expired (time_traits::time_point t) noexcept
 Deadline is expired. More...
 

Function Documentation

◆ allocate_nullable()

template<typename T , typename Alloc >
void ozo::allocate_nullable ( T &  out,
const Alloc &  a 
)

Allocates nullable object of given type.

This function allocates memory and constructs nullable object of given type by means of given allocator if applicable. It uses ozo::allocate_nullable_impl functional object as an implementation.

Note
The function implementation may use no allocator and ignore the argument (e.g.: if it is not applicable to the given object type).
Parameters
out— object to allocate to
a— allocator to use

◆ construct_initiator()

template<typename Operation , typename Factory >
constexpr auto ozo::construct_initiator ( Factory &&  f,
const Operation &  op 
)
constexpr

Create asynchronous operation initiator using factory.

The function constructs asynchronous operation initiator using factory object. The default behaviour is static assertion. The behaviour should be customized for a particular factory.

Parameters
f— factory for asynchronous operation initiator object.
op— asynchronous operation object.
Returns
initiator functional object.

Customization Point

Default implementation is static assertion

template <typename Factory, typename Operation>
struct construct_initiator_impl {
constexpr static auto apply(const Factory&, const Operation&) {
static_assert(std::is_void_v<Factory>, "Factory is not supported for the Operation");
}
};

◆ deadline() [1/4]

constexpr auto ozo::deadline ( none_t  )
constexprnoexcept

Dealdine calculation.

Calculates deadline from ozo::none_t.

Parameters
none_t
Returns
ozo::none

References ozo::none.

Referenced by ozo::deadline().

◆ deadline() [2/4]

time_traits::time_point ozo::deadline ( time_traits::duration  after)
noexcept

Dealdine calculation.

Calculates deadline time point in a given duration from now. The result value is limited by time_traits::time_point::max(). Literally: time_traits::now() + after.

Parameters
after— duration to a deadline time point
Returns
calculated deadline time point

References ozo::deadline(), and ozo::time_traits::now().

◆ deadline() [3/4]

constexpr time_traits::time_point ozo::deadline ( time_traits::duration  after,
time_traits::time_point  now 
)
constexprnoexcept

Dealdine calculation.

Calculates deadline time point in a given duration from a given time point. The result value range is [now, time_traits::time_point::max()]. Literally: now + after.

Parameters
after— duration to a deadline time point
now— start time point for the duration
Returns
calculated deadline time point

◆ deadline() [4/4]

constexpr time_traits::time_point ozo::deadline ( time_traits::time_point  t)
constexprnoexcept

Dealdine calculation.

Calculate deadline from time point. Literally returns it's argument.

Parameters
t— time point of a deadline
Returns
it's argument

Referenced by ozo::failover::retry_strategy< Options >::get_first_try().

◆ expired() [1/2]

bool ozo::expired ( time_traits::time_point  t)
noexcept

Deadline is expired.

Indicates if a given dedline is expired. Deadline is expired then time left duration to the deadline is 0.

Parameters
t— deadline time point
Returns
true — deadline has been expired
false — there is time left to deadline

References ozo::time_traits::now().

◆ expired() [2/2]

bool ozo::expired ( time_traits::time_point  t,
time_traits::time_point  now 
)
noexcept

Deadline is expired.

Indicates if a given dedline is expired for a given time point. Deadline is expired then time left duration to the deadline is 0.

Parameters
t— deadline time point
Returns
true — deadline has been expired
false — there is time left to deadline

References ozo::time_left().

◆ get_operation_initiator()

template<typename Operation >
constexpr auto ozo::get_operation_initiator ( const Operation &  op)
constexpr

Get asynchronous operation initiator.

Initiator is a functional object which may be used with boost::asio::async_initiate to start an asynchronous operation. Typically this is detail zone of an operation, but in OZO this is a part of operations customization for extentions like failover.

Parameters
op— asynchronous operation object
Returns
initiator functional object

Customization Point

The function is implemented via ozo::get_operation_initiator_impl. The default implementation is:

template <typename Operation>
struct get_operation_initiator_impl {
constexpr static auto apply(const Operation& op) {
return op.get_initiator();
}
};

So this behaviour may be changed via specialization of the template.

Referenced by ozo::begin(), ozo::execute(), ozo::get_connection(), and ozo::request().

◆ get_option() [1/2]

template<typename Map , typename Key >
constexpr decltype(auto) ozo::get_option ( Map &&  map,
ozo::option< Key >  op 
)
constexpr

Get the option object from Hana.Map.

This function is similar to map[op] call, but it makes a static assert that map should contain an option. This produces human readable compile error in case of no option found.

Parameters
map— map to get option from
op— the option
Returns
option value reference

Referenced by ozo::failover::basic_try< Options, Context >::get_conditions(), ozo::failover::basic_try< Options, Context >::get_next_try(), ozo::get_transaction_deferrability(), ozo::get_transaction_isolation_level(), ozo::get_transaction_mode(), and ozo::failover::basic_try< Options, Context >::tries_remain().

◆ get_option() [2/2]

template<typename Map , typename Key , typename T >
constexpr decltype(auto) ozo::get_option ( Map &&  map,
ozo::option< Key >  op,
T &&  default_ 
)
constexpr

Get the option object from Hana.Map.

This function is similar to map[op] call, but returns default value if no such option has been found.

Parameters
map— map to get option from
op— the option
default_— the default value for the option which is not found
Returns
option value reference or forwarded default value

Referenced by ozo::options_factory_base< options_factory< decltype(hana::make_map()) >, decltype(hana::make_map()) >::get().

◆ is_null()

template<typename T >
constexpr decltype(auto) ozo::is_null ( const T &  v)
constexprnoexcept

Indicates if value is in null state.

This utility function indicates if given value is in null state. If argument is not #Nullable it always returns false

Parameters
value— object to examine
Returns
true — object is in null-state,
false — overwise.

Referenced by ozo::send(), and ozo::size_of().

◆ is_null_recursive()

template<typename T >
constexpr bool ozo::is_null_recursive ( T &&  v)
constexprnoexcept

Indicates if one of unwrapped values is in null state.

This utility function recursively examines the value for a null state. The function is useful to examine Connection object for a null state because it is normal for such object to be wrapped.

The function is equal to this pesudo-code:

constexpr bool is_null_recursive(auto&& arg) noexcept {
while (decltype(arg) != unwrap_type<decltype(arg)>) {
if (is_null(arg)) {
return true;
}
arg = unwrap(arg);
}
return false;
}
Parameters
v— object to examine
Returns
true — one of the objects is in null-state,
false — overwise.
See also
ozo::is_null(), ozo::unwrap()

Referenced by ozo::defer_close_connection(), and ozo::error_message().

◆ make_options()

template<typename ... Options>
constexpr auto ozo::make_options ( Options &&...  opts)
constexpr

Constructor for options map.

This function is a semantic wrapper for boost::hana::make_map.

Example

namespace demo {
}
using namespace std::literals;
auto options = ozo::make_options(demo::foo="Foo"s, demo::buzz=777);
Parameters
opts— pairs of options and its' values
Returns
— constructed boost::hana::map

◆ time_left() [1/2]

time_traits::duration ozo::time_left ( time_traits::time_point  t)
noexcept

Time left to deadline.

Calculates time left to a given deadline time point.

Parameters
t— deadline time point
Returns
time left to the time point which is more or equal to a zero.

References ozo::time_traits::now().

Referenced by ozo::expired().

◆ time_left() [2/2]

constexpr time_traits::duration ozo::time_left ( time_traits::time_point  t,
time_traits::time_point  now 
)
constexprnoexcept

Time left to deadline.

Calculates time left form given now time point to a given deadline time point t.

Parameters
t— deadline time point
now— time point to calculate duration from
Returns
time left to the time point which is more or equal to a zero.

◆ unwrap()

template<typename T >
constexpr decltype(auto) ozo::unwrap ( T &&  v)
constexprnoexcept

Unwraps argument underlying value or forwards the argument.

This utility function returns underlying value of it's argument as defined by the operation implementation ozo::unwrap_impl.

In-library implementations returns:

  • reference on an underlying value - std::reference_wrapper and other types like pointers, optional values which are defined via External adaptors,
  • argument itself by default.
Parameters
value— object to unwrap
Returns
implementation depended result of unwrap_impl<std::decay_t<T>>::apply(std::forward<T>(v)) call

Referenced by ozo::pooled_connection< Rep, Executor >::close(), ozo::failover::basic_try< Options, Context >::get_context(), ozo::pooled_connection< Rep, Executor >::get_error_context(), ozo::failover::get_next_try(), ozo::failover::get_try_context(), ozo::failover::initiate_next_try(), ozo::transaction< Connection, Options >::lowest_layer(), ozo::pooled_connection< Rep, Executor >::native_handle(), ozo::pooled_connection< Rep, Executor >::oid_map(), ozo::failover::role_based_connection_provider< Source >::rebind_role(), ozo::send(), and ozo::size_of().

◆ unwrap_recursive()

template<typename T >
constexpr decltype(auto) ozo::unwrap_recursive ( T &&  v)
constexprnoexcept

Unwraps argument underlying value recursively.

This utility function unwraps argument recursively applying ozo::unwrap() function until the type of unwrapped value and type of it's argument become the same.

Note
Before applying the function it is better to check the object recursively for a null state via ozo::is_null_recursive().

The function is equal to this pesudo-code:

constexpr decltype(auto) unwrap_recursive(auto&& arg) noexcept {
while (decltype(arg) != unwrap_type<decltype(arg)>) {
arg = unwrap(arg);
}
return arg;
}
Parameters
value— object to unwrap
Returns
implementation depended result of recursively applied ozo::unwrap()
See also
ozo::is_null_recursive()
ozo::unwrap
constexpr decltype(auto) unwrap(T &&v) noexcept(noexcept(unwrap_impl< std::decay_t< T >>::apply(std::forward< T >(v))))
Unwraps argument underlying value or forwards the argument.
Definition: unwrap.h:57
ozo::make_options
constexpr auto make_options(Options &&...opts)
Constructor for options map.
Definition: options.h:105
ozo::is_null_recursive
constexpr bool is_null_recursive(T &&v) noexcept
Indicates if one of unwrapped values is in null state.
Definition: recursive.h:78
ozo::unwrap_recursive
constexpr decltype(auto) unwrap_recursive(T &&v) noexcept
Unwraps argument underlying value recursively.
Definition: recursive.h:36
ozo::unwrap_type
typename get_unwrapped_type< T >::type unwrap_type
Shortcut for ozo::get_unwrapped_type.
Definition: unwrap.h:107
ozo::option
Option class.
Definition: options.h:33
ozo::is_null
constexpr decltype(auto) is_null(const T &v) noexcept(noexcept(is_null_impl< T >::apply(v)))
Indicates if value is in null state.
Definition: nullable.h:85