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>."
34 template<
typename... T>
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] !=
'(')
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,
"'")};
75 template<
typename... T>
94 template<
typename... T>
95 [[nodiscard]]
inline std::size_t
98 constexpr
auto num{
sizeof...(fields)};
108 if constexpr (num == 0)
122 template<
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)
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
PQXX_LIBEXPORT glyph_scanner_func * get_glyph_scanner(encoding_group)
Look up the glyph scanner function for a given encoding group.
constexpr char empty_composite_str[]
Definition: composite.hxx:85
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: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