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>."
8#include "pqxx/internal/array-composite.hxx"
9#include "pqxx/internal/concat.hxx"
10#include "pqxx/util.hxx"
34template<
typename...
T>
36 pqxx::internal::encoding_group
enc, std::string_view text,
T &...
fields)
38 static_assert(
sizeof...(fields) > 0);
41 auto const data{std::data(text)};
42 auto const size{std::size(text)};
47 if (next != 1
or data[
here] !=
'(')
56 (pqxx::internal::specialize_parse_composite_field<T>(
enc)(
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,
"'")};
75template<
typename...
T>
85constexpr char empty_composite_str[]{
"()"};
94template<
typename...
T>
98 constexpr auto num{
sizeof...(fields)};
108 if constexpr (
num == 0)
109 return std::size(pqxx::internal::empty_composite_str);
122template<
typename...
T>
127 "Buffer space may not be enough to represent composite value."};
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), ...);
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
PQXX_LIBEXPORT glyph_scanner_func * get_glyph_scanner(encoding_group)
Look up the glyph scanner function for a given encoding group.
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
constexpr char array_separator
Element separator between SQL array elements of this type.
Definition strconv.hxx:559
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