libpqxx  7.7.0
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 #include <cstddef>
13 #include <cstdint>
14 #include <iterator>
15 
16 #if defined(PQXX_HAVE_CONCEPTS) && __has_include(<ranges>)
17 # include <ranges>
18 #endif
19 
20 
21 namespace pqxx
22 {
24 using result_size_type = int;
25 
28 
30 using row_size_type = int;
31 
33 using row_difference_type = int;
34 
36 using field_size_type = std::size_t;
37 
39 using large_object_size_type = int64_t;
40 
41 
42 // Forward declarations, to help break compilation dependencies.
43 // These won't necessarily include all classes in libpqxx.
44 class binarystring;
45 class connection;
46 class const_result_iterator;
47 class const_reverse_result_iterator;
49 class const_row_iterator;
50 class dbtransaction;
51 class field;
52 class largeobjectaccess;
54 struct range_error;
55 class result;
56 class row;
57 class stream_from;
58 class transaction_base;
59 
61 
64 {};
65 
67 
70 {};
71 
72 
74 
76 enum class format : int
77 {
78  text = 0,
79  binary = 1,
80 };
81 
82 
84 
86 template<typename TYPE>
87 using strip_t = std::remove_cv_t<std::remove_reference_t<TYPE>>;
88 
89 
90 #if defined(PQXX_HAVE_CONCEPTS)
91 
95 template<std::ranges::range CONTAINER>
96 using value_type = decltype(*std::begin(std::declval<CONTAINER>()));
97 #else // PQXX_HAVE_CONCEPTS
98 
102 template<typename CONTAINER>
103 using value_type = decltype(*std::begin(std::declval<CONTAINER>()));
104 #endif // PQXX_HAVE_CONCEPTS
105 
106 
107 #if defined(PQXX_HAVE_CONCEPTS)
108 template<typename STRING>
110 concept char_string = std::ranges::contiguous_range<STRING> and
111  std::same_as < strip_t<value_type<STRING>>,
112 char > ;
113 
115 template<typename RANGE>
116 concept char_strings =
117  std::ranges::range<RANGE> and char_string<strip_t<value_type<RANGE>>>;
118 
120 template<typename DATA>
121 concept potential_binary = std::ranges::contiguous_range<DATA> and
122  (sizeof(value_type<DATA>) == 1);
123 #endif // PQXX_HAVE_CONCEPTS
124 
125 
126 // C++20: Retire these compatibility definitions.
127 #if defined(PQXX_HAVE_CONCEPTS)
128 
130 
133 # define PQXX_RANGE_ARG std::ranges::range
134 
136 
139 # define PQXX_CHAR_STRING_ARG pqxx::char_string
140 
142 
145 # define PQXX_CHAR_STRINGS_ARG pqxx::char_strings
146 
147 #else // PQXX_HAVE_CONCEPTS
148 
150 
153 # define PQXX_RANGE_ARG typename
154 
156 
159 # define PQXX_CHAR_STRING_ARG typename
160 
162 
165 # define PQXX_CHAR_STRINGS_ARG typename
166 
167 #endif // PQXX_HAVE_CONCEPTS
168 } // namespace pqxx
169 #endif
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:189
Stream data from the database.
Definition: stream_from.hxx:71
Reference to one row in a result.
Definition: row.hxx:42
Interface definition (and common code) for "transaction" classes.
Definition: transaction_base.hxx:72
Binary data corresponding to PostgreSQL&#39;s "BYTEA" binary-string type.
Definition: binarystring.hxx:54
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:362
Reference to a field in a result set.
Definition: field.hxx:30
Result set containing data returned by a query or command.
Definition: result.hxx:67
Abstract transaction base class: bracket transactions on the database.
Definition: dbtransaction.hxx:49
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:255
decltype(*std::begin(std::declval< CONTAINER >())) value_type
The type of a container&#39;s elements.
Definition: types.hxx:103
format
Format code: is data text or binary?
Definition: types.hxx:76
Marker for stream_from constructors: "stream from table.".
Definition: types.hxx:63
int result_size_type
Number of rows in a result set.
Definition: types.hxx:24
Definition: notification.hxx:52
int row_difference_type
Difference between row sizes.
Definition: types.hxx:33
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:22
std::remove_cv_t< std::remove_reference_t< TYPE > > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: types.hxx:87
Marker for stream_from constructors: "stream from query.".
Definition: types.hxx:69
std::size_t field_size_type
Number of bytes in a field of database data.
Definition: types.hxx:36
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:30
Accessor for large object&#39;s contents.
Definition: largeobject.hxx:149
int result_difference_type
Difference between result sizes.
Definition: types.hxx:27
int64_t large_object_size_type
Number of bytes in a large object.
Definition: types.hxx:39
Connection to a database.
Definition: connection.hxx:180