1 #ifndef PQXX_COMPOSITE_HXX
2 #define PQXX_COMPOSITE_HXX
4 #if !defined(PQXX_HEADER_PRE)
5 # error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
33 template<
typename... T>
36 static constexpr
auto num_fields{
sizeof...(T)};
37 static_assert(num_fields > 0);
39 auto const data{std::data(
text)};
40 auto const size{std::size(
text)};
43 "Cannot parse composite value from empty string.", c.loc};
54 (pqxx::internal::specialize_parse_composite_field<T>(c)(
55 index,
text, here, fields, num_fields - 1, c.loc),
57 if (here != std::size(
text))
60 "Composite value did not end at the closing parenthesis: '{}'.",
text),
62 if (
text[here - 1] !=
')')
81 template<
typename... T>
82 [[nodiscard]]
inline std::size_t
85 constexpr
auto num{
sizeof...(fields)};
95 if constexpr (num == 0)
115 template<
typename... T>
120 "Buffer space may not be enough to represent composite value.", c.loc};
122 constexpr
auto num_fields{
sizeof...(fields)};
123 if constexpr (num_fields == 0)
125 constexpr std::string_view empty{
"()"};
128 pqxx::internal::copy_chars<true>(empty, buf, 0, c.loc) - 1};
135 (pqxx::internal::write_composite_field<T>(buf, pos, fields, c), ...);
138 if constexpr (num_fields > 1)
143 return zview{std::data(buf), pos};
148 template<
typename... T>
150 "Pass conversion_context and std::span<char>, not two pointers.")]]
154 {sl::current()}, std::span<char>{begin, end}, fields...)};
155 return begin + std::size(
text);
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:55
Value conversion failed, e.g. when converting "Hello" to int.
Definition: except.hxx:612
Private namespace for libpqxx's internal use; do not access.
Definition: connection.cxx:333
PQXX_INLINE_COV std::size_t size_composite_field_buffer(T const &field)
Conservatively estimate buffer size needed for a composite field.
Definition: array-composite.hxx:352
constexpr char empty_composite_str[]
Definition: composite.hxx:72
The home of all libpqxx classes, functions, templates, etc.
Definition: array.cxx:26
void parse_composite(ctx c, std::string_view text, T &...fields)
Parse a string representation of a value of a composite type.
Definition: composite.hxx:34
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:83
conversion_context const & ctx
Convenience alias: const reference to a pqxx::conversion_context.
Definition: strconv.hxx:201
zview composite_into_buf(ctx c, std::span< char > buf, T const &...fields)
Render a series of values as a single composite SQL value.
Definition: composite.hxx:116
format
Format code: is data text or binary?
Definition: types.hxx:121