1#ifndef PQXX_H_COMPOSITE
2#define PQXX_H_COMPOSITE
4#if !defined(PQXX_HEADER_PRE)
5# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
8#include "pqxx/internal/array-composite.hxx"
9#include "pqxx/internal/concat.hxx"
10#include "pqxx/util.hxx"
34template<
typename... T>
36 pqxx::internal::encoding_group enc, std::string_view
text, T &...fields)
38 static_assert(
sizeof...(fields) > 0);
41 auto const data{std::data(
text)};
42 auto const size{std::size(
text)};
46 std::size_t here{0}, next{scan(data, size, here)};
47 if (next != 1 or data[here] !=
'(')
49 internal::concat(
"Invalid composite value string: ",
text)};
54 constexpr auto num_fields{
sizeof...(fields)};
56 (pqxx::internal::specialize_parse_composite_field<T>(enc)(
57 index,
text, here, fields, num_fields - 1),
59 if (here != std::size(
text))
61 "Composite value did not end at the closing parenthesis: '",
text,
63 if (
text[here - 1] !=
')')
65 "Composive value did not end in parenthesis: '",
text,
"'")};
75template<
typename... T>
94template<
typename... T>
95[[nodiscard]]
inline std::size_t
98 constexpr auto num{
sizeof...(fields)};
108 if constexpr (num == 0)
111 return 1 + (pqxx::internal::size_composite_field_buffer(fields) + ...) +
122template<
typename... T>
127 "Buffer space may not be enough to represent composite value."};
129 constexpr auto num_fields{
sizeof...(fields)};
130 if constexpr (num_fields == 0)
132 constexpr char empty[]{
"()"};
133 std::memcpy(begin, empty, std::size(empty));
134 return begin + std::size(empty);
140 (pqxx::internal::write_composite_field<T>(pos, end, fields), ...);
143 if constexpr (num_fields > 1)
The home of all libpqxx classes, functions, templates, etc.
Definition array.hxx:33
char * composite_into_buf(char *begin, char *end, T const &...fields)
Render a series of values as a single composite SQL value.
Definition composite.hxx:123
std::size_t composite_size_buffer(T const &...fields) noexcept
Estimate the buffer size needed to represent a value of a composite type.
Definition composite.hxx:96
void parse_composite(pqxx::internal::encoding_group enc, std::string_view text, T &...fields)
Parse a string representation of a value of a composite type.
Definition composite.hxx:35
Internal items for libpqxx' own use. Do not use these yourself.
Definition composite.hxx:84
PQXX_PURE glyph_scanner_func * get_glyph_scanner(encoding_group enc)
Definition encodings.cxx:180
constexpr char empty_composite_str[]
Definition composite.hxx:85
Value conversion failed, e.g. when converting "Hello" to int.
Definition except.hxx:283