libpqxx  7.9.0
pqxx::internal Namespace Reference

Internal items for libpqxx' own use. Do not use these yourself. More...

Namespaces

 gate
 
 pq
 

Classes

class  basic_robusttransaction
 Helper base class for the robusttransaction class template. More...
 
class  result_iter
 
struct  enum_traits
 Helper class for defining enum conversions. More...
 
class  basic_transaction
 Helper base class for the transaction class template. More...
 

Typedefs

template<typename CALLABLE >
using args_t = decltype(args_f(std::declval< CALLABLE >()))
 A callable's parameter types, as a tuple. More...
 
template<typename... TYPES>
using strip_types_t = decltype(strip_types(std::declval< TYPES... >()))
 Take a tuple type and apply strip_t to its component types. More...
 

Functions

void PQXX_COLD skip_init_ssl (int skips) noexcept
 Control OpenSSL/crypto library initialisation. More...
 
void clear_result (pq::PGresult const *) noexcept
 C++ wrapper for libpq's PQclear. More...
 
std::string demangle_type_name (char const[])
 Attempt to demangle std::type_info::name() to something human-readable. More...
 
template<typename LEFT , typename RIGHT >
constexpr bool cmp_less (LEFT lhs, RIGHT rhs) noexcept
 Same as std::cmp_less, or a workaround where that's not available. More...
 
template<typename LEFT , typename RIGHT >
constexpr bool cmp_greater (LEFT lhs, RIGHT rhs) noexcept
 C++20 std::cmp_greater, or workaround if not available. More...
 
template<typename LEFT , typename RIGHT >
constexpr bool cmp_less_equal (LEFT lhs, RIGHT rhs) noexcept
 C++20 std::cmp_less_equal, or workaround if not available. More...
 
template<typename LEFT , typename RIGHT >
constexpr bool cmp_greater_equal (LEFT lhs, RIGHT rhs) noexcept
 C++20 std::cmp_greater_equal, or workaround if not available. More...
 
std::string cat2 (std::string_view x, std::string_view y)
 Efficiently concatenate two strings. More...
 
template<typename CHAR >
constexpr bool is_digit (CHAR c) noexcept
 A safer and more generic replacement for std::isdigit. More...
 
std::string describe_object (std::string_view class_name, std::string_view name)
 Describe an object for humans, based on class name and optional name. More...
 
void check_unique_register (void const *old_guest, std::string_view old_class, std::string_view old_name, void const *new_guest, std::string_view new_class, std::string_view new_name)
 Check validity of registering a new "guest" in a "host.". More...
 
void check_unique_unregister (void const *old_guest, std::string_view old_class, std::string_view old_name, void const *new_guest, std::string_view new_class, std::string_view new_name)
 Like check_unique_register, but for un-registering a guest. More...
 
constexpr std::size_t size_esc_bin (std::size_t binary_bytes) noexcept
 Compute buffer size needed to escape binary data for use as a BYTEA. More...
 
constexpr std::size_t size_unesc_bin (std::size_t escaped_bytes) noexcept
 Compute binary size from the size of its escaped version. More...
 
void esc_bin (bytes_view binary_data, char buffer[]) noexcept
 Hex-escape binary data into a buffer. More...
 
std::string esc_bin (bytes_view binary_data)
 Hex-escape binary data into a std::string. More...
 
void unesc_bin (std::string_view escaped_data, std::byte buffer[])
 Reconstitute binary data from its escaped version. More...
 
bytes unesc_bin (std::string_view escaped_data)
 Reconstitute binary data from its escaped version. More...
 
template<typename T >
auto ssize (T const &c)
 Transitional: std::ssize(), or custom implementation if not available. More...
 
template<typename RETURN , typename... ARGS>
std::tuple< ARGS... > args_f (RETURN(&func)(ARGS...))
 Helper for determining a function's parameter types. More...
 
template<typename RETURN , typename... ARGS>
std::tuple< ARGS... > args_f (std::function< RETURN(ARGS...)> const &)
 Helper for determining a std::function's parameter types. More...
 
template<typename CLASS , typename RETURN , typename... ARGS>
std::tuple< ARGS... > member_args_f (RETURN(CLASS::*)(ARGS...))
 Helper for determining a member function's parameter types. More...
 
template<typename CALLABLE >
auto args_f (CALLABLE const &f) -> decltype(member_args_f(&CALLABLE::operator()))
 Helper for determining a callable type's parameter types. More...
 
template<typename... TYPES>
std::tuple< strip_t< TYPES >... > strip_types (std::tuple< TYPES... > const &)
 Helper: Apply strip_t to each of a tuple type's component types. More...
 
constexpr char unescape_char (char escaped) noexcept
 Return original byte for escaped character. More...
 
template<std::size_t BYTES>
char const *PQXX_COLD error_string (int err_num, std::array< char, BYTES > &buffer)
 Get error string for a given errno value. More...
 
int PQXX_VERSION_CHECK () noexcept
 Library version check stub. More...
 
constexpr char const * as_c_string (char const str[]) noexcept
 Get a raw C string pointer. More...
 
template<std::size_t N>
constexpr char const * as_c_string (char(&str)[N]) noexcept
 Get a raw C string pointer. More...
 
constexpr char const * as_c_string (pqxx::zview str) noexcept
 Get a raw C string pointer. More...
 
char const * as_c_string (std::string const &str) noexcept
 Get a raw C string pointer. More...
 
pqxx::internal::encoding_group enc_group (std::string_view encoding_name)
 Convert libpq encoding name to its libpqxx encoding group. More...
 
PQXX_PURE char const * name_encoding (int encoding_id)
 
encoding_group enc_group (int libpq_enc_id)
 
PQXX_PURE glyph_scanner_func * get_glyph_scanner (encoding_group enc)
 
void PQXX_COLD throw_null_conversion (std::string const &type)
 
std::string PQXX_COLD state_buffer_overrun (int have_bytes, int need_bytes)
 
template<typename T >
std::string to_string_float (T value)
 Floating-point implementations for pqxx::to_string(). More...
 
template std::string to_string_float (float)
 
template std::string to_string_float (double)
 
template std::string to_string_float (long double)
 

Variables

constexpr char empty_composite_str [] {"()"}
 
template<pqxx::isolation_level isolation, pqxx::write_policy rw>
const zview begin_cmd
 The SQL command for starting a given type of transaction. More...
 

Detailed Description

Internal items for libpqxx' own use. Do not use these yourself.

Private namespace for libpqxx's internal use; do not access.

This namespace hides definitions internal to libpqxx. These are not supposed to be used by client programs, and they may change at any time without notice.

Conversely, if you find something in this namespace tremendously useful, by all means do lodge a request for its publication.

Warning
Here be dragons!

Version check.

Copyright (c) 2000-2024, Jeroen T. Vermeulen.

See COPYING for copyright license. If you did not receive a file called COPYING with this source code, please notify the distributor of this mistake, or contact the author.

Typedef Documentation

◆ args_t

template<typename CALLABLE >
using pqxx::internal::args_t = typedef decltype(args_f(std::declval<CALLABLE>()))

A callable's parameter types, as a tuple.

◆ strip_types_t

template<typename... TYPES>
using pqxx::internal::strip_types_t = typedef decltype(strip_types(std::declval<TYPES...>()))

Take a tuple type and apply strip_t to its component types.

Function Documentation

◆ args_f() [1/3]

template<typename CALLABLE >
auto pqxx::internal::args_f ( CALLABLE const &  f) -> decltype(member_args_f(&CALLABLE::operator()))

Helper for determining a callable type's parameter types.

This specialisation should work for lambdas.

This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.

◆ args_f() [2/3]

template<typename RETURN , typename... ARGS>
std::tuple<ARGS...> pqxx::internal::args_f ( RETURN(&)(ARGS...)  func)

Helper for determining a function's parameter types.

This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.

◆ args_f() [3/3]

template<typename RETURN , typename... ARGS>
std::tuple<ARGS...> pqxx::internal::args_f ( std::function< RETURN(ARGS...)> const &  )

Helper for determining a std::function's parameter types.

This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.

◆ as_c_string() [1/4]

constexpr char const* pqxx::internal::as_c_string ( char const  str[])
constexprnoexcept

Get a raw C string pointer.

◆ as_c_string() [2/4]

template<std::size_t N>
constexpr char const* pqxx::internal::as_c_string ( char(&)  str[N])
constexprnoexcept

Get a raw C string pointer.

◆ as_c_string() [3/4]

constexpr char const* pqxx::internal::as_c_string ( pqxx::zview  str)
constexprnoexcept

Get a raw C string pointer.

◆ as_c_string() [4/4]

char const* pqxx::internal::as_c_string ( std::string const &  str)
noexcept

Get a raw C string pointer.

◆ cat2()

std::string pqxx::internal::cat2 ( std::string_view  x,
std::string_view  y 
)

Efficiently concatenate two strings.

This is a special case of concatenate(), needed because dependency management does not let us use that function here.

Referenced by pqxx::check_cast().

◆ check_unique_register()

void pqxx::internal::check_unique_register ( void const *  old_guest,
std::string_view  old_class,
std::string_view  old_name,
void const *  new_guest,
std::string_view  new_class,
std::string_view  new_name 
)

Check validity of registering a new "guest" in a "host.".

The host might be e.g. a connection, and the guest a transaction. The host can only have one guest at a time, so it is an error to register a new guest while the host already has a guest.

If the new registration is an error, this function throws a descriptive exception.

Pass the old guest (if any) and the new guest (if any), for both, a type name (at least if the guest is not null), and optionally an object name (but which may be omitted if the caller did not assign one).

References describe_object().

◆ check_unique_unregister()

void pqxx::internal::check_unique_unregister ( void const *  old_guest,
std::string_view  old_class,
std::string_view  old_name,
void const *  new_guest,
std::string_view  new_class,
std::string_view  new_name 
)

Like check_unique_register, but for un-registering a guest.

Pass the guest which was registered, as well as the guest which is being unregistered, so that the function can check that they are the same one.

References describe_object().

◆ clear_result()

void pqxx::internal::clear_result ( pq::PGresult const *  data)
noexcept

C++ wrapper for libpq's PQclear.

◆ cmp_greater()

template<typename LEFT , typename RIGHT >
constexpr bool pqxx::internal::cmp_greater ( LEFT  lhs,
RIGHT  rhs 
)
constexprnoexcept

C++20 std::cmp_greater, or workaround if not available.

References cmp_less().

Referenced by pqxx::check_cast().

◆ cmp_greater_equal()

template<typename LEFT , typename RIGHT >
constexpr bool pqxx::internal::cmp_greater_equal ( LEFT  lhs,
RIGHT  rhs 
)
constexprnoexcept

C++20 std::cmp_greater_equal, or workaround if not available.

References cmp_less().

◆ cmp_less()

template<typename LEFT , typename RIGHT >
constexpr bool pqxx::internal::cmp_less ( LEFT  lhs,
RIGHT  rhs 
)
constexprnoexcept

Same as std::cmp_less, or a workaround where that's not available.

Referenced by cmp_greater(), cmp_greater_equal(), cmp_less_equal(), pqxx::string_traits< binarystring >::into_buf(), and pqxx::largeobjectaccess::write().

◆ cmp_less_equal()

template<typename LEFT , typename RIGHT >
constexpr bool pqxx::internal::cmp_less_equal ( LEFT  lhs,
RIGHT  rhs 
)
constexprnoexcept

C++20 std::cmp_less_equal, or workaround if not available.

References cmp_less().

Referenced by pqxx::largeobject_streambuf< CHAR, TRAITS >::overflow().

◆ demangle_type_name()

std::string pqxx::internal::demangle_type_name ( char const  raw[])

Attempt to demangle std::type_info::name() to something human-readable.

References demangle_type_name().

Referenced by demangle_type_name().

◆ describe_object()

std::string pqxx::internal::describe_object ( std::string_view  class_name,
std::string_view  name 
)

Describe an object for humans, based on class name and optional name.

Interprets an empty name as "no name given."

Referenced by check_unique_register(), check_unique_unregister(), pqxx::connection::close(), and pqxx::transaction_focus::description().

◆ enc_group() [1/2]

encoding_group pqxx::internal::enc_group ( int  libpq_enc_id)

References enc_group(), and name_encoding().

◆ enc_group() [2/2]

pqxx::internal::encoding_group pqxx::internal::enc_group ( std::string_view  encoding_name)

Convert libpq encoding name to its libpqxx encoding group.

References enc_group().

Referenced by enc_group(), and pqxx::connection::esc_like().

◆ error_string()

template<std::size_t BYTES>
char const* PQXX_COLD pqxx::internal::error_string ( int  err_num,
std::array< char, BYTES > &  buffer 
)

Get error string for a given errno value.

References pqxx::ignore_unused().

◆ esc_bin() [1/2]

std::string pqxx::internal::esc_bin ( bytes_view  binary_data)

Hex-escape binary data into a std::string.

References esc_bin(), and size_esc_bin().

◆ esc_bin() [2/2]

void pqxx::internal::esc_bin ( bytes_view  binary_data,
char  buffer[] 
)
noexcept

Hex-escape binary data into a buffer.

The buffer must be able to accommodate size_esc_bin(std::size(binary_data)) bytes, and the function will write exactly that number of bytes into the buffer. This includes a trailing zero.

Referenced by esc_bin(), pqxx::connection::esc_raw(), and pqxx::string_traits< binarystring >::into_buf().

◆ get_glyph_scanner()

PQXX_PURE glyph_scanner_func* pqxx::internal::get_glyph_scanner ( encoding_group  enc)

◆ is_digit()

template<typename CHAR >
constexpr bool pqxx::internal::is_digit ( CHAR  c)
constexprnoexcept

A safer and more generic replacement for std::isdigit.

Turns out std::isdigit isn't as easy to use as it sounds. It takes an int, but requires it to be nonnegative. Which means it's an outright liability on systems where char is signed.

◆ member_args_f()

template<typename CLASS , typename RETURN , typename... ARGS>
std::tuple< ARGS... > pqxx::internal::member_args_f ( RETURN(CLASS::*)(ARGS...)  )

Helper for determining a member function's parameter types.

Helper for determining a const member function's parameter types.

This function has no definition. It's not meant to be actually called. It's just there for pattern-matching in the compiler, so we can use its hypothetical return value.

◆ name_encoding()

PQXX_PURE char const* pqxx::internal::name_encoding ( int  encoding_id)

◆ PQXX_VERSION_CHECK()

int pqxx::internal::PQXX_VERSION_CHECK ( )
noexcept

Library version check stub.

Helps detect version mismatches between libpqxx headers and the libpqxx library binary.

Sometimes users run into trouble linking their code against libpqxx because they build their own libpqxx, but the system also has a different version installed. The declarations in the headers against which they compile their code will differ from the ones used to build the libpqxx version they're using, leading to confusing link errors. The solution is to generate a link error when the libpqxx binary is not the same version as the libpqxx headers used to compile the code.

This function's definition is in the libpqxx binary, so it's based on the version as found in the binary. The headers contain a call to the function, whose name contains the libpqxx version as found in the headers. (The library build process will use its own local headers even if another version of the headers is installed on the system.)

If the libpqxx binary was compiled for a different version than the user's code, linking will fail with an error: check_pqxx_version_*_* will not exist for the given version number.

Referenced by pqxx::check_version().

◆ size_esc_bin()

constexpr std::size_t pqxx::internal::size_esc_bin ( std::size_t  binary_bytes)
constexprnoexcept

Compute buffer size needed to escape binary data for use as a BYTEA.

This uses the hex-escaping format. The return value includes room for the "\x" prefix.

Referenced by esc_bin(), and pqxx::string_traits< binarystring >::size_buffer().

◆ size_unesc_bin()

constexpr std::size_t pqxx::internal::size_unesc_bin ( std::size_t  escaped_bytes)
constexprnoexcept

Compute binary size from the size of its escaped version.

Do not include a terminating zero in escaped_bytes.

Referenced by pqxx::string_traits< binarystring >::from_string(), unesc_bin(), pqxx::connection::unesc_bin(), and pqxx::connection::unesc_raw().

◆ skip_init_ssl()

void PQXX_COLD pqxx::internal::skip_init_ssl ( int  skips)
noexcept

Control OpenSSL/crypto library initialisation.

This is an internal helper. Unless you're working on libpqxx itself, use pqxx::skip_init_ssl instead.

Parameters
flagsa bitmask of 1 << flag for each of the skip_init flags.

Ignores the skip_init::nothing flag.

Referenced by pqxx::skip_init_ssl().

◆ ssize()

template<typename T >
auto pqxx::internal::ssize ( T const &  c)

Transitional: std::ssize(), or custom implementation if not available.

Referenced by pqxx::params::make_c_params(), and pqxx::params::ssize().

◆ state_buffer_overrun()

std::string PQXX_COLD pqxx::internal::state_buffer_overrun ( int  have_bytes,
int  need_bytes 
)

References state_buffer_overrun().

Referenced by state_buffer_overrun().

◆ strip_types()

template<typename... TYPES>
std::tuple<strip_t<TYPES>...> pqxx::internal::strip_types ( std::tuple< TYPES... > const &  )

Helper: Apply strip_t to each of a tuple type's component types.

This function has no definition. It is not meant to be called, only to be used to deduce the right types.

◆ throw_null_conversion()

void PQXX_COLD pqxx::internal::throw_null_conversion ( std::string const &  type)

◆ to_string_float() [1/4]

template std::string pqxx::internal::to_string_float ( double  )

References to_string_float().

◆ to_string_float() [2/4]

template std::string pqxx::internal::to_string_float ( float  )

References to_string_float().

◆ to_string_float() [3/4]

template std::string pqxx::internal::to_string_float ( long double  )

References to_string_float().

◆ to_string_float() [4/4]

template<typename T >
std::string pqxx::internal::to_string_float ( value)

Floating-point implementations for pqxx::to_string().

References to_string_float().

Referenced by to_string_float().

◆ unesc_bin() [1/2]

pqxx::bytes pqxx::internal::unesc_bin ( std::string_view  escaped_data)

Reconstitute binary data from its escaped version.

References size_unesc_bin(), and unesc_bin().

◆ unesc_bin() [2/2]

void pqxx::internal::unesc_bin ( std::string_view  escaped_data,
std::byte  buffer[] 
)

◆ unescape_char()

constexpr char pqxx::internal::unescape_char ( char  escaped)
constexprnoexcept

Return original byte for escaped character.

Variable Documentation

◆ begin_cmd

template<pqxx::isolation_level isolation, pqxx::write_policy rw>
const zview pqxx::internal::begin_cmd
extern

The SQL command for starting a given type of transaction.

◆ empty_composite_str

constexpr char pqxx::internal::empty_composite_str[] {"()"}
constexpr