libpqxx  7.7.1
types.hxx
1 /* Basic type aliases and forward declarations.
2  *
3  * Copyright (c) 2000-2022, 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 
25 namespace pqxx
26 {
28 using result_size_type = int;
29 
32 
34 using row_size_type = int;
35 
37 using row_difference_type = int;
38 
40 using field_size_type = std::size_t;
41 
43 using 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.
48 class binarystring;
49 class connection;
50 class const_result_iterator;
51 class const_reverse_result_iterator;
53 class const_row_iterator;
54 class dbtransaction;
55 class field;
56 class largeobjectaccess;
58 struct range_error;
59 class result;
60 class row;
61 class stream_from;
62 class transaction_base;
63 
65 
68 {};
69 
71 
74 {};
75 
76 
78 
80 enum class format : int
81 {
82  text = 0,
83  binary = 1,
84 };
85 
86 
88 
90 template<typename TYPE>
91 using strip_t = std::remove_cv_t<std::remove_reference_t<TYPE>>;
92 
93 
94 #if defined(PQXX_HAVE_CONCEPTS)
95 
99 template<std::ranges::range CONTAINER>
100 using value_type = decltype(*std::begin(std::declval<CONTAINER>()));
101 #else // PQXX_HAVE_CONCEPTS
102 
106 template<typename CONTAINER>
107 using value_type = decltype(*std::begin(std::declval<CONTAINER>()));
108 #endif // PQXX_HAVE_CONCEPTS
109 
110 
111 #if defined(PQXX_HAVE_CONCEPTS)
112 template<typename STRING>
114 concept char_string = std::ranges::contiguous_range<STRING> and
115  std::same_as < strip_t<value_type<STRING>>,
116 char > ;
117 
119 template<typename RANGE>
120 concept char_strings =
121  std::ranges::range<RANGE> and char_string<strip_t<value_type<RANGE>>>;
122 
124 template<typename DATA>
125 concept potential_binary = std::ranges::contiguous_range<DATA> and
126  (sizeof(value_type<DATA>) == 1);
127 #endif // PQXX_HAVE_CONCEPTS
128 
129 
130 // C++20: Retire these compatibility definitions.
131 #if defined(PQXX_HAVE_CONCEPTS)
132 
134 
137 # define PQXX_RANGE_ARG std::ranges::range
138 
140 
143 # define PQXX_CHAR_STRING_ARG pqxx::char_string
144 
146 
149 # define PQXX_CHAR_STRINGS_ARG pqxx::char_strings
150 
151 #else // PQXX_HAVE_CONCEPTS
152 
154 
157 # define PQXX_RANGE_ARG typename
158 
160 
163 # define PQXX_CHAR_STRING_ARG typename
164 
166 
169 # define PQXX_CHAR_STRINGS_ARG typename
170 
171 #endif // PQXX_HAVE_CONCEPTS
172 } // namespace pqxx
173 #endif
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:201
Stream data from the database.
Definition: stream_from.hxx:73
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:53
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
Reference to one row in a result.
Definition: row.hxx:46
Connection to a database.
Definition: connection.hxx:185
format
Format code: is data text or binary?
Definition: types.hxx:80
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:384
Reference to a field in a result set.
Definition: field.hxx:34
int64_t large_object_size_type
Number of bytes in a large object.
Definition: types.hxx:43
std::size_t field_size_type
Number of bytes in a field of database data.
Definition: types.hxx:40
int row_difference_type
Difference between row sizes.
Definition: types.hxx:37
Definition: notification.hxx:56
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:34
decltype(*std::begin(std::declval< CONTAINER >())) value_type
The type of a container&#39;s elements.
Definition: types.hxx:107
Marker for stream_from constructors: "stream from query.".
Definition: types.hxx:73
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:76
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
Result set containing data returned by a query or command.
Definition: result.hxx:72
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:267
Binary data corresponding to PostgreSQL&#39;s "BYTEA" binary-string type.
Definition: binarystring.hxx:58
Marker for stream_from constructors: "stream from table.".
Definition: types.hxx:67
Accessor for large object&#39;s contents.
Definition: largeobject.hxx:153
int result_difference_type
Difference between result sizes.
Definition: types.hxx:31
int result_size_type
Number of rows in a result set.
Definition: types.hxx:28