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

Description

Database-related type system functions.

Functions

template<typename T >
constexpr auto ozo::type_name () noexcept
 Function returns type name in Postgre SQL. More...
 
template<typename T >
constexpr auto ozo::type_name (const T &) noexcept
 Function returns type name in Postgre SQL. More...
 
template<typename ... Ts>
constexpr oid_map_t< Ts... > ozo::register_types () noexcept
 Provides #OidMap implementation for user-defined types. More...
 
template<typename T , typename ... Ts>
void ozo::set_type_oid (oid_map_t< Ts... > &map, oid_t oid) noexcept
 
template<typename T , typename OidMap >
oid_t ozo::type_oid (const OidMap &map) noexcept
 Function returns oid for a type from #OidMap. More...
 
template<typename T , typename OidMap >
oid_t ozo::type_oid (const OidMap &map, const T &v) noexcept template< typename T
 Function returns oid for type from #OidMap. More...
 
template<typename T , typename OidMap >
bool ozo::accepts_oid (const OidMap &map, const T &, oid_t oid) noexcept
 
template<typename ... Ts>
constexpr bool ozo::empty (const oid_map_t< Ts... > &map) noexcept
 

Function Documentation

◆ accepts_oid()

template<typename T , typename OidMap >
bool ozo::accepts_oid ( const OidMap &  map,
const T &  ,
oid_t  oid 
)
noexcept

Function returns true if type can be obtained from DB response with specified OID.

Parameters
map— #OidMap to get type OID from
constT& — type to examine
oid— OID to check for compatibility

◆ empty()

template<typename ... Ts>
constexpr bool ozo::empty ( const oid_map_t< Ts... > &  map)
constexprnoexcept

Checks if #OidMap contains no items.

Example

static_assert(empty(ozo::empty_oid_map{}));
Parameters
map— #OidMap to check
Returns
true — if map contains no items
false — if contains items.

◆ register_types()

template<typename ... Ts>
constexpr oid_map_t<Ts...> ozo::register_types ( )
constexprnoexcept

Provides #OidMap implementation for user-defined types.

This function have to be used to provide information about custom types are being used within requests for a ConnectionSource.

Example

// User defined type
struct custom_type;
//...
// Providing type information and corresponding database type
OZO_PG_DEFINE_CUSTOM_TYPE(custom_type, "code.custom_type")
//...
// Creating ConnectionSource for futher requests to a database
const ozo::connection_info conn_source("...", register_types<custom_type>());
Returns
oid_map_t object.

◆ set_type_oid()

template<typename T , typename ... Ts>
void ozo::set_type_oid ( oid_map_t< Ts... > &  map,
oid_t  oid 
)
noexcept

Function sets oid for a type in #OidMap.

Template Parameters
T— type to set oid for.
Parameters
map— #OidMap to modify.
oid— OID to set.

◆ type_name() [1/2]

template<typename T >
constexpr auto ozo::type_name ( )
constexprnoexcept

Function returns type name in Postgre SQL.

Template Parameters
T— type
Returns
const char* — name of the type

◆ type_name() [2/2]

template<typename T >
constexpr auto ozo::type_name ( const T &  )
constexprnoexcept

Function returns type name in Postgre SQL.

Parameters
T— type
Returns
const char* — name of the type

◆ type_oid() [1/2]

template<typename T , typename OidMap >
oid_t ozo::type_oid ( const OidMap &  map)
noexcept

Function returns oid for a type from #OidMap.

Template Parameters
T— type to get OID for.
Parameters
map— #OidMap to get OID from.
Returns
oid_t — OID of the type

Referenced by ozo::send_frame().

◆ type_oid() [2/2]

template<typename T , typename OidMap >
oid_t ozo::type_oid ( const OidMap &  map,
const T &  v 
)
noexcept

Function returns oid for type from #OidMap.

Parameters
map— #OidMap to get OID from.
v— object for which type's OID will return.
Returns
oid_t — OID of the type Function returns true if type can be obtained from DB response with specified OID.
Template Parameters
T— type to examine
Parameters
map— #OidMap to get type OID from
oid— OID to check for compatibility
OZO_PG_DEFINE_CUSTOM_TYPE
#define OZO_PG_DEFINE_CUSTOM_TYPE(Type, Name, Size)
Helper macro to define custom type mapping.
Definition: type_traits.h:455
ozo::empty
constexpr bool empty(const oid_map_t< Ts... > &map) noexcept
Definition: type_traits.h:674
ozo::register_types
constexpr oid_map_t< Ts... > register_types() noexcept
Provides #OidMap implementation for user-defined types.
Definition: type_traits.h:562
ozo::empty_oid_map
std::decay_t< decltype(register_types<>())> empty_oid_map
Type alias for empty #OidMap.
Definition: type_traits.h:570