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{text.data()};
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>
68 parse_composite(pqxx::internal::encoding_group::MONOBYTE, text, fields...);
84 template<
typename... T>
87 constexpr
auto num{
sizeof...(fields)};
97 if constexpr (
sizeof...(fields) == 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"