14#if !defined(PQXX_HEADER_PRE)
15# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
27#if __has_include(<ranges>)
31#include "pqxx/except.hxx"
32#include "pqxx/util.hxx"
33#include "pqxx/zview.hxx"
79template<
typename TYPE>
90template<
typename TYPE,
typename ENABLE =
void>
struct nullness
197 static inline char *
into_buf(
char *begin,
char *end,
TYPE const &value);
248 static constexpr bool converts_to_string{
false};
249 static constexpr bool converts_from_string{
false};
254 [[
noreturn]]
static char *into_buf(
char *,
char *,
TYPE const &)
338template<
typename ENUM>
361 using impl_type = std::underlying_type_t<ENUM>;
364 static constexpr bool converts_to_string{
true};
365 static constexpr bool converts_from_string{
true};
368 to_buf(
char *begin,
char *end,
ENUM const &value)
373 static constexpr char *into_buf(
char *begin,
char *end,
ENUM const &value)
383 [[
nodiscard]]
static std::size_t size_buffer(
ENUM const &value)
noexcept
390 static constexpr impl_type to_underlying(
ENUM const &value)
noexcept
392 return static_cast<impl_type
>(value);
414#define PQXX_DECLARE_ENUM_CONVERSION(ENUM) \
415 template<> struct string_traits<ENUM> : pqxx::internal::enum_traits<ENUM> \
417 template<> inline std::string_view const type_name<ENUM> \
438template<
typename TYPE>
467template<
typename T>
inline void from_string(std::string_view text,
T &value)
479template<
typename TYPE>
inline std::string to_string(
TYPE const &value);
490template<
typename...
TYPE>
491[[
nodiscard]]
inline std::vector<std::string_view>
494 PQXX_ASSUME(
here <= end);
495 return {[&
here, end](
auto v) {
499 auto len{
static_cast<std::size_t
>(
here - begin) - 1};
500 return std::string_view{begin,
len};
508template<
typename TYPE>
509inline void into_string(
TYPE const &value, std::string &
out);
513template<
typename TYPE>
524template<
typename...
TYPE>
569template<
typename TYPE>
inline constexpr format param_format(
TYPE const &)
585template<
typename TYPE>
594 return {begin, traits::into_buf(begin, end, value) - begin - 1};
598#if defined(PQXX_HAVE_CONCEPTS)
607concept binary = std::ranges::contiguous_range<TYPE>
and
608 std::is_same_v<strip_t<value_type<TYPE>>, std::byte>;
614#include "pqxx/internal/conversions.hxx"
Marker-type wrapper: zero-terminated std::string_view.
Definition zview.hxx:38
Internal items for libpqxx' own use. Do not use these yourself.
Definition encodings.cxx:33
std::string demangle_type_name(char const raw[])
Attempt to demangle std::type_info::name() to something human-readable.
Definition strconv.cxx:233
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
std::string const type_name
A human-readable name for a type, used in error messages and such.
Definition strconv.hxx:80
std::vector< std::string_view > to_buf(char *here, char const *end, TYPE... value)
Convert multiple values to strings inside a single buffer.
Definition strconv.hxx:492
constexpr char array_separator
Element separator between SQL array elements of this type.
Definition strconv.hxx:558
std::size_t size_buffer(TYPE const &...value) noexcept
Estimate how much buffer space is needed to represent values as a string.
Definition strconv.hxx:525
void oops_forbidden_conversion() noexcept
Nonexistent function to indicate a disallowed type conversion.
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
constexpr bool is_null(TYPE const &value) noexcept
Is value null?
Definition strconv.hxx:514
zview generic_to_buf(char *begin, char *end, TYPE const &value)
Implement string_traits<TYPE>::to_buf by calling into_buf.
Definition strconv.hxx:586
T from_string(field const &value)
Convert a field's value to type T.
Definition field.hxx:532
constexpr bool is_unquoted_safe
Can we use this type in arrays and composite types without quoting them?
Definition strconv.hxx:554
constexpr bool is_sql_array
Does this type translate to an SQL array?
Definition strconv.hxx:538
format
Format code: is data text or binary?
Definition types.hxx:68
String traits for a forbidden type conversion.
Definition strconv.hxx:247
Helper class for defining enum conversions.
Definition strconv.hxx:360
Nullness traits describing a type which does not have a null value.
Definition strconv.hxx:113
static constexpr bool always_null
Are all values of this type null?
Definition strconv.hxx:131
static constexpr bool has_null
Does TYPE have a "built-in null value"?
Definition strconv.hxx:125
static constexpr bool is_null(TYPE const &) noexcept
Does a given value correspond to an SQL null value?
Definition strconv.hxx:138
Traits describing a type's "null value," if any.
Definition strconv.hxx:91
static bool is_null(TYPE const &value)
Is value a null?
static TYPE null()
Return a null value.
static bool has_null
Does this type have a null value?
Definition strconv.hxx:93
static bool always_null
Is this type always null?
Definition strconv.hxx:96
Traits class for use in string conversions.
Definition strconv.hxx:153
static TYPE from_string(std::string_view text)
Parse a string representation of a TYPE value.
static std::size_t size_buffer(TYPE const &value) noexcept
Estimate how much buffer space is needed to represent value.
static zview to_buf(char *begin, char *end, TYPE const &value)
Return a string_view representing value, plus terminating zero.
static constexpr bool converts_to_string
Is conversion from TYPE to strings supported?
Definition strconv.hxx:158
static char * into_buf(char *begin, char *end, TYPE const &value)
Write value's string representation into buffer at begin.
static constexpr bool converts_from_string
Is conversion from string_view to TYPE supported?
Definition strconv.hxx:164