libpqxx
The C++ client library for PostgreSQL
Loading...
Searching...
No Matches
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

namespace  pqxx
 The home of all libpqxx classes, functions, templates, etc.
namespace  pqxx::internal
 Internal items for libpqxx' own use. Do not use these yourself.
namespace  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_IGNORING_DEPRECATED
#define PQXX_CHAR_SIZED_ARG   typename

Typedefs

using pqxx::bytes
 Type alias for a container containing bytes.
using pqxx::bytes_view
 Type alias for a view of bytes.
template<typename CALLABLE>
using pqxx::internal::args_t = decltype(args_f(std::declval<CALLABLE>()))
 A callable's parameter types, as a tuple.
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.

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

Variables

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

Class Documentation

◆ pqxx::thread_safety_model

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 = false 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 = false Is the underlying libpq build thread-safe?

Macro Definition Documentation

◆ PQXX_CHAR_SIZED_ARG

#define PQXX_CHAR_SIZED_ARG   typename

◆ PQXX_IGNORING_DEPRECATED

#define PQXX_IGNORING_DEPRECATED

◆ PQXX_POTENTIAL_BINARY_ARG

#define PQXX_POTENTIAL_BINARY_ARG   typename

◆ PQXX_UNREACHABLE

#define PQXX_UNREACHABLE   while (false)