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;
50class const_result_iterator;
51class const_reverse_result_iterator;
52class const_reverse_row_iterator;
53class const_row_iterator;
54class dbtransaction;
55// 9.0: Remove this.
56class errorhandler;
57class field;
58class largeobjectaccess;
60struct range_error;
61class result;
62class row;
63class stream_from;
64class transaction_base;
65
67
69enum class format : int
70{
71 text = 0,
72 binary = 1,
73};
74
75
77
79template<typename TYPE>
80using strip_t = std::remove_cv_t<std::remove_reference_t<TYPE>>;
81
82
83#if defined(PQXX_HAVE_CONCEPTS)
85
88template<std::ranges::range CONTAINER>
90#else // PQXX_HAVE_CONCEPTS
92
95template<typename CONTAINER>
97#endif // PQXX_HAVE_CONCEPTS
98
99
100#if defined(PQXX_HAVE_CONCEPTS)
102template<typename STRING>
103concept char_string = std::ranges::contiguous_range<STRING> and
104 std::same_as<strip_t<value_type<STRING>>, char>;
105
107template<typename RANGE>
108concept char_strings =
109 std::ranges::range<RANGE> and char_string<strip_t<value_type<RANGE>>>;
110
112template<typename DATA>
113concept potential_binary =
114 std::ranges::contiguous_range<DATA> and (sizeof(value_type<DATA>) == 1);
115#endif // PQXX_HAVE_CONCEPTS
116
117
118// C++20: Retire these compatibility definitions.
119#if defined(PQXX_HAVE_CONCEPTS)
120
122
125# define PQXX_RANGE_ARG std::ranges::range
126
128
131# define PQXX_CHAR_STRING_ARG pqxx::char_string
132
134
137# define PQXX_CHAR_STRINGS_ARG pqxx::char_strings
138
139#else // PQXX_HAVE_CONCEPTS
140
142
145# define PQXX_RANGE_ARG typename
146
148
151# define PQXX_CHAR_STRING_ARG typename
152
154
157# define PQXX_CHAR_STRINGS_ARG typename
158
159#endif // PQXX_HAVE_CONCEPTS
160
162
165{};
166
168
171{};
172
173} // namespace pqxx
174#endif
Binary data corresponding to PostgreSQL's "BYTEA" binary-string type.
Definition binarystring.hxx:58
Definition errorhandler.hxx:46
Definition notification.hxx:57
Result set containing data returned by a query or command.
Definition result.hxx:92
Something is out of range, similar to std::out_of_range.
Definition except.hxx:326
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
std::size_t field_size_type
Number of bytes in a field of database data.
Definition types.hxx:40
int64_t large_object_size_type
Number of bytes in a large object.
Definition types.hxx:43
int result_size_type
Number of rows in a result set.
Definition types.hxx:28
int row_size_type
Number of fields in a row of database data.
Definition types.hxx:34
strip_t< decltype(*std::begin(std::declval< CONTAINER >()))> value_type
The type of a container's elements.
Definition types.hxx:96
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition types.hxx:80
int row_difference_type
Difference between row sizes.
Definition types.hxx:37
int result_difference_type
Difference between result sizes.
Definition types.hxx:31
format
Format code: is data text or binary?
Definition types.hxx:70
Marker for stream_from constructors: "stream from query.".
Definition types.hxx:171
Marker for stream_from constructors: "stream from table.".
Definition types.hxx:165