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>."
35template<
typename... T>
39 static_assert(
sizeof...(fields) > 0);
42 auto const data{std::data(
text)};
43 auto const size{std::size(
text)};
47 std::size_t here{0}, next{scan(data, size, here)};
48 if (next != 1 or data[here] !=
'(')
55 constexpr auto num_fields{
sizeof...(fields)};
58 index,
text, here, fields, num_fields - 1),
60 if (here != std::size(
text))
62 "Composite value did not end at the closing parenthesis: '",
text,
64 if (
text[here - 1] !=
')')
66 "Composive value did not end in parenthesis: '",
text,
"'")};
76template<
typename... T>
95template<
typename... T>
96[[nodiscard]]
inline std::size_t
99 constexpr auto num{
sizeof...(fields)};
109 if constexpr (num == 0)
123template<
typename... T>
128 "Buffer space may not be enough to represent composite value."};
130 constexpr auto num_fields{
sizeof...(fields)};
131 if constexpr (num_fields == 0)
133 constexpr char empty[]{
"()"};
134 std::memcpy(begin, empty, std::size(empty));
135 return begin + std::size(empty);
144 if constexpr (num_fields > 1)
Value conversion failed, e.g. when converting "Hello" to int.
Definition except.hxx:283
Internal items for libpqxx' own use. Do not use these yourself.
Definition encodings.cxx:33
std::string concat(TYPE... item)
Efficiently combine a bunch of items into one big string.
Definition concat.hxx:31
std::size_t size_composite_field_buffer(T const &field)
Conservatively estimate buffer size needed for a composite field.
Definition array-composite.hxx:309
encoding_group
Definition encoding_group.hxx:19
@ MONOBYTE
Definition encoding_group.hxx:21
PQXX_LIBEXPORT glyph_scanner_func * get_glyph_scanner(encoding_group)
Look up the glyph scanner function for a given encoding group.
void write_composite_field(char *&pos, char *end, T const &field)
Definition array-composite.hxx:330
composite_field_parser< T > specialize_parse_composite_field(encoding_group enc)
Look up implementation of parse_composite_field for ENC.
Definition array-composite.hxx:274
constexpr char empty_composite_str[]
Definition composite.hxx:86
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
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:124
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:97
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:36
@ text
Definition types.hxx:71