10 #define PQXX_TYPES_HXX
12 #if !defined(PQXX_HEADER_PRE)
13 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
20 #include <source_location>
22 #include <string_view>
23 #include <type_traits>
26 #if defined(PQXX_HAVE_STACKTRACE)
27 # include <stacktrace>
30 #if defined(PQXX_HAVE_TYPE_DISPLAY)
38 using sl = std::source_location;
40 #if defined(PQXX_HAVE_STACKTRACE)
42 using st = std::stacktrace;
73 using oid =
unsigned int;
130 template<
typename TYPE>
using strip_t = std::remove_cvref_t<TYPE>;
137 template<std::ranges::range CONTAINER>
138 using value_type = std::remove_cvref_t<std::ranges::range_value_t<CONTAINER>>;
142 template<
typename CHAR>
147 template<
typename STRING>
149 std::same_as<std::remove_cv_t<value_type<STRING>>,
char>;
153 template<
typename RANGE>
155 char_string<std::remove_cv_t<value_type<RANGE>>>;
159 template<
typename DATA>
161 std::ranges::contiguous_range<DATA> and char_sized<value_type<DATA>> and
162 not std::is_reference_v<value_type<DATA>>;
173 concept
binary = std::ranges::contiguous_range<T> and
174 std::same_as<std::remove_cv_t<value_type<T>>, std::byte>;
180 std::ranges::range<T> and
182 std::remove_cvref_t<std::ranges::range_reference_t<T>>, std::byte> and
184 std::remove_cvref_t<std::ranges::range_reference_t<T>>,
char>;
207 not std::is_reference_v<T> and not std::is_pointer_v<T> and
208 not std::ranges::borrowed_range<T>;
232 #if !defined(PQXX_HAVE_TYPE_DISPLAY)
251 #if defined(PQXX_HAVE_TYPE_DISPLAY)
253 template<
typename TYPE>
254 [[deprecated(
"Use name_type() instead.")]]
255 std::string
const type_name{display_string_of(^^TYPE)};
268 template<
typename TYPE>
269 [[deprecated(
"Use name_type() instead.")]]
277 template<
typename TYPE>
inline constexpr std::string_view
name_type() noexcept
279 #if defined(PQXX_HAVE_TYPE_DISPLAY)
281 return display_string_of(^^TYPE);
286 return type_name<TYPE>;
300 PQXX_PURE constexpr
inline std::string_view name_type<std::string>() noexcept
302 return "std::string";
307 name_type<std::string_view>() noexcept
309 return "std::string_view";
314 return "char const *";
351 return "unsigned short";
363 return "unsigned long";
370 return "unsigned long long";
388 return "long double";
393 name_type<std::nullptr_t>() noexcept
395 return "std::nullptr_t";
406 concept
char_type = std::same_as<std::remove_cv_t<T>,
char> or
407 std::same_as<std::remove_cv_t<T>,
signed char> or
408 std::same_as<std::remove_cv_t<T>,
unsigned char>;
415 concept
integer = std::integral<T> and not char_type<T>;
Connection to a database.
Definition: connection.hxx:273
Iterator for rows in a result. Use as result::const_iterator.
Definition: result_iterator.hxx:35
Reverse iterator for result. Use as result::const_reverse_iterator.
Definition: result_iterator.hxx:173
Reverse iterator for a row. Use as row::const_reverse_iterator.
Definition: row.hxx:879
Iterator for fields in a row. Use as row::const_iterator.
Definition: row.hxx:748
Definition: errorhandler.hxx:46
Reference to a field in a result set.
Definition: field.hxx:309
Accessor for large object's contents.
Definition: largeobject.hxx:167
Definition: notification.hxx:60
Result set containing data returned by a query or command.
Definition: result.hxx:101
Reference to one row in a result.
Definition: row.hxx:415
Stream data from the database.
Definition: stream_from.hxx:79
Something is out of range, similar to std::out_of_range.
Definition: except.hxx:651
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:151
Placeholders for libpq declarations.
Definition: util.cxx:298
void PQconninfoOption
Placeholder for libpq's PQconninfoOption type.
Definition: types.hxx:437
void PGconn
Placeholder for libpq's connection type.
Definition: types.hxx:429
void PGresult
Placeholder for libpq's result type.
Definition: types.hxx:431
void(*)(void *, char const *) PQnoticeProcessor
Placeholder for libpq's notice processor type.
Definition: types.hxx:435
void PGnotify
Placeholder for libpq's notification type.
Definition: types.hxx:433
Private namespace for libpqxx's internal use; do not access.
Definition: connection.cxx:333
PQXX_LIBEXPORT PQXX_ZARGS std::string demangle_type_name(char const[]) noexcept
Attempt to demangle std::type_info::name() to something human-readable.
Definition: types.cxx:28
concept integer
Concept: an integral number type.
Definition: types.hxx:415
concept char_type
Concept: one of the "char" types.
Definition: types.hxx:406
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
std::string const type_name
A human-readable name for a type, used in error messages and such.
Definition: types.hxx:270
std::span< std::byte const > bytes_view
Type alias for a view of bytes.
Definition: types.hxx:188
concept not_borrowed
Concept: A value that's not just a reference to values elsewhere.
Definition: types.hxx:206
constexpr PQXX_PURE std::string_view name_type< long long >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:342
concept enum_type
Concept: A C++ enum type.
Definition: types.hxx:213
constexpr PQXX_PURE std::string_view name_type< double >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:380
constexpr PQXX_PURE std::string_view name_type< float >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:374
int row_size_type
Number of fields in a row of database data.
Definition: types.hxx:83
constexpr PQXX_PURE std::string_view name_type< short >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:324
int row_difference_type
Difference between row sizes.
Definition: types.hxx:86
constexpr PQXX_PURE std::string_view name_type< int >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:330
std::remove_cvref_t< TYPE > strip_t
Remove any constness, volatile, and reference-ness from a type.
Definition: types.hxx:130
std::source_location sl
Convenience alias for std::source_location. It's just too long.
Definition: types.hxx:38
std::size_t field_size_type
Number of bytes in a field of database data.
Definition: types.hxx:89
constexpr std::string_view name_type() noexcept
Return human-readable name for TYPE.
Definition: types.hxx:277
concept nonbinary_range
A series of something that's not bytes.
Definition: types.hxx:179
int result_difference_type
Difference between result sizes.
Definition: types.hxx:80
constexpr PQXX_PURE std::string_view name_type< unsigned >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:355
constexpr PQXX_PURE std::string_view name_type< bool >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:318
std::span< std::byte > writable_bytes_view
Type alias for a view of writable bytes.
Definition: types.hxx:192
concept potential_binary
Concept: Anything we might want to treat as binary data.
Definition: types.hxx:160
int result_size_type
Number of rows in a result set.
Definition: types.hxx:77
concept binary
Concept: Binary string, akin to std::string for binary data.
Definition: types.hxx:173
std::remove_cvref_t< std::ranges::range_value_t< CONTAINER > > value_type
The type of a container's elements.
Definition: types.hxx:138
constexpr PQXX_PURE std::string_view name_type< unsigned short >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:349
constexpr PQXX_PURE std::string_view name_type< long >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:336
concept char_sized
A type one byte in size.
Definition: types.hxx:143
constexpr PQXX_PURE std::string_view name_type< unsigned long long >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:368
unsigned int oid
PostgreSQL database row identifier.
Definition: types.hxx:73
constexpr PQXX_PURE std::string_view name_type< unsigned long >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:361
constexpr PQXX_PURE std::string_view name_type< long double >() noexcept
Specialisation to save on startup work.
Definition: types.hxx:386
concept char_strings
Concept: Anything we can iterate to get things we can read as strings.
Definition: types.hxx:154
concept char_string
Concept: Any type that we can read as a string of char.
Definition: types.hxx:148
constexpr PQXX_PURE std::string_view name_type< char const * >() noexcept
Definition: types.hxx:312
int64_t large_object_size_type
Number of bytes in a large object.
Definition: types.hxx:92
format
Format code: is data text or binary?
Definition: types.hxx:121
Marker for stream_from constructors: "stream from query.".
Definition: types.hxx:226
Marker for stream_from constructors: "stream from table.".
Definition: types.hxx:220
There is no std::stacktrace on this system. Use a placeholder.
Definition: types.hxx:46
static constexpr PQXX_PURE stacktrace_placeholder current() noexcept
Placeholder for std::stacktrace::current().
Definition: types.hxx:62
~stacktrace_placeholder() noexcept=default
constexpr stacktrace_placeholder() noexcept=default