libpqxx
The C++ client library for PostgreSQL
Loading...
Searching...
No Matches
types.hxx
1/* Basic type aliases and forward declarations.
2 *
3 * Copyright (c) 2000-2024, Jeroen T. Vermeulen
4 *
5 * See COPYING for copyright license. If you did not receive a file called
6 * COPYING with this source code, please notify the distributor of this
7 * mistake, or contact the author.
8 */
9#ifndef PQXX_H_TYPES
10#define PQXX_H_TYPES
11
12#if !defined(PQXX_HEADER_PRE)
13# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
14#endif
15
16#include <cstddef>
17#include <cstdint>
18#include <iterator>
19
20#if defined(PQXX_HAVE_CONCEPTS) && __has_include(<ranges>)
21# include <ranges>
22#endif
23
24
25namespace pqxx
26{
28using result_size_type = int;
29
32
34using row_size_type = int;
35
38
40using field_size_type = std::size_t;
41
43using large_object_size_type = int64_t;
44
45
46// Forward declarations, to help break compilation dependencies.
47// These won't necessarily include all classes in libpqxx.
48class binarystring;
49class connection;
54class dbtransaction;
55class field;
58struct range_error;
59class result;
60class row;
61class stream_from;
63
65
67enum class format : int
68{
69 text = 0,
70 binary = 1,
71};
72
73
75
77template<typename TYPE>
78using strip_t = std::remove_cv_t<std::remove_reference_t<TYPE>>;
79
80
81#if defined(PQXX_HAVE_CONCEPTS)
83
86template<std::ranges::range CONTAINER>
88#else // PQXX_HAVE_CONCEPTS
90
93template<typename CONTAINER>
95#endif // PQXX_HAVE_CONCEPTS
96
97
98#if defined(PQXX_HAVE_CONCEPTS)
100template<typename STRING>
101concept char_string = std::ranges::contiguous_range<STRING> and
102 std::same_as<strip_t<value_type<STRING>>, char>;
103
105template<typename RANGE>
106concept char_strings =
107 std::ranges::range<RANGE> and char_string<strip_t<value_type<RANGE>>>;
108
110template<typename DATA>
111concept potential_binary =
112 std::ranges::contiguous_range<DATA> and (sizeof(value_type<DATA>) == 1);
113#endif // PQXX_HAVE_CONCEPTS
114
115
116// C++20: Retire these compatibility definitions.
117#if defined(PQXX_HAVE_CONCEPTS)
118
120
123# define PQXX_RANGE_ARG std::ranges::range
124
126
129# define PQXX_CHAR_STRING_ARG pqxx::char_string
130
132
135# define PQXX_CHAR_STRINGS_ARG pqxx::char_strings
136
137#else // PQXX_HAVE_CONCEPTS
138
140
143# define PQXX_RANGE_ARG typename
144
146
149# define PQXX_CHAR_STRING_ARG typename
150
152
155# define PQXX_CHAR_STRINGS_ARG typename
156
157#endif // PQXX_HAVE_CONCEPTS
158
160
163{};
164
166
169{};
170
171} // namespace pqxx
172#endif
Connection to a database.
Definition connection.hxx:230
Iterator for rows in a result. Use as result::const_iterator.
Definition result_iterator.hxx:33
Reverse iterator for result. Use as result::const_reverse_iterator.
Definition result_iterator.hxx:194
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition row.hxx:406
Iterator for fields in a row. Use as row::const_iterator.
Definition row.hxx:291
Reference to a field in a result set.
Definition field.hxx:35
Accessor for large object's contents.
Definition largeobject.hxx:154
Definition notification.hxx:57
Result set containing data returned by a query or command.
Definition result.hxx:73
Reference to one row in a result.
Definition row.hxx:47
Stream data from the database.
Definition stream_from.hxx:79
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type.
Definition binarystring.hxx:58
Something is out of range, similar to std::out_of_range.
Definition except.hxx:326
Abstract transaction base class: bracket transactions on the database.
Definition dbtransaction.hxx:54
Interface definition (and common code) for "transaction" classes.
Definition transaction_base.hxx:150
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
int row_size_type
Number of fields in a row of database data.
Definition types.hxx:34
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition types.hxx:78
int row_difference_type
Difference between row sizes.
Definition types.hxx:37
std::size_t field_size_type
Number of bytes in a field of database data.
Definition types.hxx:40
int result_difference_type
Difference between result sizes.
Definition types.hxx:31
strip_t< decltype(*std::begin(std::declval< CONTAINER >()))> value_type
The type of a container's elements.
Definition types.hxx:94
int result_size_type
Number of rows in a result set.
Definition types.hxx:28
int64_t large_object_size_type
Number of bytes in a large object.
Definition types.hxx:43
format
Format code: is data text or binary?
Definition types.hxx:68
Marker for stream_from constructors: "stream from query.".
Definition types.hxx:169
Marker for stream_from constructors: "stream from table.".
Definition types.hxx:163