types.hxx
/* Basic type aliases and forward declarations.
*
* Copyright (c) 2000-2023, 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.
*/
#ifndef PQXX_H_TYPES
#define PQXX_H_TYPES
#if !defined(PQXX_HEADER_PRE)
# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
#endif
#include <cstddef>
#include <cstdint>
#include <iterator>
#if defined(PQXX_HAVE_CONCEPTS) && __has_include(<ranges>)
# include <ranges>
#endif
namespace pqxx
{
using result_size_type = int;
using result_difference_type = int;
using row_size_type = int;
using row_difference_type = int;
using field_size_type = std::size_t;
using large_object_size_type = int64_t;
// Forward declarations, to help break compilation dependencies.
// These won't necessarily include all classes in libpqxx.
class binarystring;
class connection;
class const_result_iterator;
class const_reverse_result_iterator;
class const_reverse_row_iterator;
class const_row_iterator;
class dbtransaction;
class field;
class largeobjectaccess;
class notification_receiver;
struct range_error;
class result;
class row;
class stream_from;
class transaction_base;
struct from_table_t
{};
struct from_query_t
{};
enum class format : int
{
text = 0,
binary = 1,
};
template<typename TYPE>
using strip_t = std::remove_cv_t<std::remove_reference_t<TYPE>>;
#if defined(PQXX_HAVE_CONCEPTS)
template<std::ranges::range CONTAINER>
using value_type = strip_t<decltype(*std::begin(std::declval<CONTAINER>()))>;
#else // PQXX_HAVE_CONCEPTS
template<typename CONTAINER>
using value_type = strip_t<decltype(*std::begin(std::declval<CONTAINER>()))>;
#endif // PQXX_HAVE_CONCEPTS
#if defined(PQXX_HAVE_CONCEPTS)
template<typename STRING>
concept char_string = std::ranges::contiguous_range<STRING> and
std::same_as<strip_t<value_type<STRING>>, char>;
template<typename RANGE>
concept char_strings =
std::ranges::range<RANGE> and char_string<strip_t<value_type<RANGE>>>;
template<typename DATA>
concept potential_binary = std::ranges::contiguous_range<DATA> and
(sizeof(value_type<DATA>) == 1);
#endif // PQXX_HAVE_CONCEPTS
// C++20: Retire these compatibility definitions.
#if defined(PQXX_HAVE_CONCEPTS)
# define PQXX_RANGE_ARG std::ranges::range
# define PQXX_CHAR_STRING_ARG pqxx::char_string
# define PQXX_CHAR_STRINGS_ARG pqxx::char_strings
#else // PQXX_HAVE_CONCEPTS
# define PQXX_RANGE_ARG typename
# define PQXX_CHAR_STRING_ARG typename
# define PQXX_CHAR_STRINGS_ARG typename
#endif // PQXX_HAVE_CONCEPTS
} // namespace pqxx
#endif
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition array.hxx:33
pqxx::row_size_type
int row_size_type
Number of fields in a row of database data.
Definition types.hxx:34
pqxx::strip_t
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition types.hxx:91
pqxx::row_difference_type
int row_difference_type
Difference between row sizes.
Definition types.hxx:37
pqxx::field_size_type
std::size_t field_size_type
Number of bytes in a field of database data.
Definition types.hxx:40
pqxx::result_difference_type
int result_difference_type
Difference between result sizes.
Definition types.hxx:31
pqxx::value_type
strip_t< decltype(*std::begin(std::declval< CONTAINER >()))> value_type
The type of a container's elements.
Definition types.hxx:107
pqxx::result_size_type
int result_size_type
Number of rows in a result set.
Definition types.hxx:28
pqxx::large_object_size_type
int64_t large_object_size_type
Number of bytes in a large object.
Definition types.hxx:43
pqxx::format
format
Format code: is data text or binary?
Definition types.hxx:81
pqxx::format::text
@ text
pqxx::format::binary
@ binary
pqxx::binarystring
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type.
Definition binarystring.hxx:59
pqxx::connection
Connection to a database.
Definition connection.hxx:253
pqxx::dbtransaction
Abstract transaction base class: bracket transactions on the database.
Definition dbtransaction.hxx:54
pqxx::range_error
Something is out of range, similar to std::out_of_range.
Definition except.hxx:326
pqxx::field
Reference to a field in a result set.
Definition field.hxx:35
pqxx::largeobjectaccess
Accessor for large object's contents.
Definition largeobject.hxx:154
pqxx::notification_receiver
Definition notification.hxx:57
pqxx::result
Result set containing data returned by a query or command.
Definition result.hxx:73
pqxx::row
Reference to one row in a result.
Definition row.hxx:47
pqxx::const_row_iterator
Iterator for fields in a row. Use as row::const_iterator.
Definition row.hxx:283
pqxx::const_reverse_row_iterator
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition row.hxx:398
pqxx::stream_from
Stream data from the database.
Definition stream_from.hxx:79
pqxx::transaction_base
Interface definition (and common code) for "transaction" classes.
Definition transaction_base.hxx:88
pqxx::from_table_t
Marker for stream_from constructors: "stream from table.".
Definition types.hxx:68
pqxx::from_query_t
Marker for stream_from constructors: "stream from query.".
Definition types.hxx:74