libpqxx
The C++ client library for PostgreSQL
util.hxx File Reference
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iterator>
#include <limits>
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <typeinfo>
#include <utility>
#include <vector>
#include "pqxx/except.hxx"
#include "pqxx/types.hxx"
#include "pqxx/version.hxx"
#include <pqxx/internal/libpq-forward.hxx>
#include "pqxx/internal/ignore-deprecated-pre.hxx"
#include "pqxx/internal/ignore-deprecated-post.hxx"

Go to the source code of this file.

Classes

struct  pqxx::thread_safety_model
 Descriptor of library's thread-safety model. More...
 
struct  pqxx::byte_char_traits
 Custom std::char_trast if the compiler does not provide one. More...
 
struct  pqxx::has_generic_char_traits< TYPE, typename >
 
struct  pqxx::has_generic_char_traits< TYPE, std::void_t< decltype(std::char_traits< TYPE >::eof)> >
 

Namespaces

 pqxx
 The home of all libpqxx classes, functions, templates, etc.
 
 pqxx::internal
 Internal items for libpqxx' own use. Do not use these yourself.
 
 pqxx::internal::pq
 Forward declarations of libpq types as needed in libpqxx headers.
 

Macros

#define PQXX_UNREACHABLE   while (false)
 
#define PQXX_POTENTIAL_BINARY_ARG   typename
 
#define PQXX_CHAR_SIZED_ARG   typename
 

Typedefs

using pqxx::bytes = std::conditional< has_generic_bytes_char_traits, std::basic_string< std::byte >, std::basic_string< std::byte, byte_char_traits >>::type
 Type alias for a container containing bytes. More...
 
using pqxx::bytes_view = std::conditional< has_generic_bytes_char_traits, std::basic_string_view< std::byte >, std::basic_string_view< std::byte, byte_char_traits >>::type
 Type alias for a view of bytes. More...
 
template<typename CALLABLE >
using pqxx::internal::args_t = decltype(args_f(std::declval< CALLABLE >()))
 A callable's parameter types, as a tuple. More...
 
template<typename... TYPES>
using pqxx::internal::strip_types_t = decltype(strip_types(std::declval< TYPES... >()))
 Take a tuple type and apply strip_t to its component types. More...
 

Functions

template<typename LEFT , typename RIGHT >
constexpr bool pqxx::internal::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 pqxx::internal::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 pqxx::internal::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 pqxx::internal::cmp_greater_equal (LEFT lhs, RIGHT rhs) noexcept
 C++20 std::cmp_greater_equal, or workaround if not available. More...
 
std::string pqxx::internal::cat2 (std::string_view x, std::string_view y)
 Efficiently concatenate two strings. More...
 
template<typename... T>
constexpr void pqxx::ignore_unused (T &&...) noexcept
 Suppress compiler warning about an unused item. More...
 
template<typename TO , typename FROM >
TO pqxx::check_cast (FROM value, std::string_view description)
 Cast a numeric value to another type, or throw if it underflows/overflows. More...
 
PQXX_PRIVATE void pqxx::check_version () noexcept
 
PQXX_LIBEXPORT thread_safety_model pqxx::describe_thread_safety ()
 Describe thread safety available in this build. More...
 
template<typename TYPE >
bytes_view pqxx::binary_cast (TYPE const &data)
 End a code block started by "ignore-deprecated-pre.hxx". More...
 
template<typename CHAR , typename SIZE >
bytes_view pqxx::binary_cast (CHAR const *data, SIZE size)
 Construct a type that libpqxx will recognise as binary. More...
 
template<typename CHAR >
constexpr bool pqxx::internal::is_digit (CHAR c) noexcept
 A safer and more generic replacement for std::isdigit. More...
 
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. More...
 
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.". More...
 
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. More...
 
constexpr std::size_t pqxx::internal::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 pqxx::internal::size_unesc_bin (std::size_t escaped_bytes) noexcept
 Compute binary size from the size of its escaped version. More...
 
void PQXX_LIBEXPORT pqxx::internal::esc_bin (bytes_view binary_data, char buffer[]) noexcept
 Hex-escape binary data into a buffer. More...
 
std::string PQXX_LIBEXPORT pqxx::internal::esc_bin (bytes_view binary_data)
 Hex-escape binary data into a std::string. More...
 
void PQXX_LIBEXPORT pqxx::internal::unesc_bin (std::string_view escaped_data, std::byte buffer[])
 Reconstitute binary data from its escaped version. More...
 
bytes PQXX_LIBEXPORT pqxx::internal::unesc_bin (std::string_view escaped_data)
 Reconstitute binary data from its escaped version. More...
 
template<typename T >
auto pqxx::internal::ssize (T const &c)
 Transitional: std::ssize(), or custom implementation if not available. More...
 
template<typename RETURN , typename... ARGS>
std::tuple< ARGS... > pqxx::internal::args_f (RETURN(&func)(ARGS...))
 Helper for determining a function's parameter types. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
constexpr char pqxx::internal::unescape_char (char escaped) noexcept
 Return original byte for escaped character. More...
 
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. More...
 
void pqxx::internal::pq::pqfreemem (void const *) noexcept
 Wrapper for PQfreemem(), with C++ linkage. More...
 

Variables

constexpr bool pqxx::has_generic_bytes_char_traits
 
constexpr oid pqxx::oid_none {0}
 The "null" oid. More...
 

Class Documentation

struct pqxx::thread_safety_model

Descriptor of library's thread-safety model.

This describes what the library knows about various risks to thread-safety.

Class Members
string description A human-readable description of any thread-safety issues.
bool safe_kerberos Is Kerberos thread-safe?
Warning
Is currently always false.

If your application uses Kerberos, all accesses to libpqxx or Kerberos must be serialized. Confine their use to a single thread, or protect it with a global lock.

bool safe_libpq Is the underlying libpq build thread-safe?

Macro Definition Documentation

#define PQXX_CHAR_SIZED_ARG   typename
#define PQXX_POTENTIAL_BINARY_ARG   typename
#define PQXX_UNREACHABLE   while (false)