1 #ifndef PQXX_H_COMPOSITE
2 #define PQXX_H_COMPOSITE
4 #include "pqxx/internal/compiler-internal-pre.hxx"
6 #include "pqxx/internal/array-composite.hxx"
7 #include "pqxx/internal/concat.hxx"
8 #include "pqxx/util.hxx"
32 template<
typename... T>
34 pqxx::internal::encoding_group enc, std::string_view text, T &...fields)
36 static_assert(
sizeof...(fields) > 0);
39 auto const data{std::data(
text)};
40 auto const size{std::size(
text)};
44 std::size_t here{0}, next{scan(data, size, here)};
45 if (next != 1 or data[here] !=
'(')
47 internal::concat(
"Invalid composite value string: ",
text)};
51 constexpr
auto num_fields{
sizeof...(fields)};
53 (pqxx::internal::parse_composite_field(
54 index,
text, here, fields, scan, num_fields - 1),
65 template<
typename... T>
84 template<
typename... T>
87 constexpr
auto num{
sizeof...(fields)};
97 if constexpr (num == 0)
100 return 1 + (pqxx::internal::size_composite_field_buffer(fields) + ...) +
111 template<
typename... T>
116 "Buffer space may not be enough to represent composite value."};
118 constexpr
auto num_fields{
sizeof...(fields)};
119 if constexpr (num_fields == 0)
121 constexpr
char empty[]{
"()"};
122 std::memcpy(begin, empty, std::size(empty));
123 return begin + std::size(empty);
129 (pqxx::internal::write_composite_field<T>(pos, end, fields), ...);
132 if constexpr (num_fields > 1)
139 #include "pqxx/internal/compiler-internal-post.hxx"
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:26
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:112
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:85
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:33
Internal items for libpqxx' own use. Do not use these yourself.
Definition: composite.hxx:74
PQXX_PURE glyph_scanner_func * get_glyph_scanner(encoding_group enc)
Definition: encodings.cxx:716
constexpr char empty_composite_str[]
Definition: composite.hxx:75
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:179