1 #ifndef PQXX_H_COMPOSITE 2 #define PQXX_H_COMPOSITE 4 #include "pqxx/internal/array-composite.hxx" 5 #include "pqxx/util.hxx" 29 template<
typename... T>
31 pqxx::internal::encoding_group enc, std::string_view text, T &... fields)
33 static_assert(
sizeof...(fields) > 0);
36 auto const data{text.data()};
37 auto const size{std::size(text)};
41 std::size_t here{0}, next{scan(data, size, here)};
42 if (next != 1 or data[here] !=
'(')
44 "Invalid composite value string: " + std::string{data}};
48 constexpr
auto num_fields{
sizeof...(fields)};
50 (pqxx::internal::parse_composite_field(
51 index, text, here, fields, scan, num_fields - 1),
62 template<
typename... T>
65 parse_composite(pqxx::internal::encoding_group::MONOBYTE, text, fields...);
81 template<
typename... T>
84 constexpr
auto num{
sizeof...(fields)};
94 if constexpr (
sizeof...(fields) == 0)
97 return 1 + (pqxx::internal::size_composite_field_buffer(fields) + ...) +
108 template<
typename... T>
113 "Buffer space may not be enough to represent composite value."};
115 constexpr
auto num_fields{
sizeof...(fields)};
116 if constexpr (num_fields == 0)
118 constexpr
char empty[]{
"()"};
119 std::memcpy(begin, empty, std::size(empty));
120 return begin + std::size(empty);
126 (pqxx::internal::write_composite_field<T>(pos, end, fields), ...);
129 if constexpr (num_fields > 1)
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:178
Private namespace for libpqxx's internal use; do not access.
Definition: composite.hxx:70
PQXX_PURE glyph_scanner_func * get_glyph_scanner(encoding_group enc)
Definition: encodings.cxx:688
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:30
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:109
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:82
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
constexpr char empty_composite_str[]
Definition: composite.hxx:72