14#if !defined(PQXX_HEADER_PRE)
15# error "Include libpqxx headers as <pqxx/header>, not <pqxx/header.hxx>."
39 template<
typename... Args>
constexpr params(Args &&...args)
41 reserve(
sizeof...(args));
42 append_pack(std::forward<Args>(args)...);
52 void reserve(std::size_t n) &;
56 [[nodiscard]]
auto size() const noexcept {
return m_params.size(); }
80 void append(std::string
const &) &;
83 void append(std::string &&) &;
89 void append(bytes_view) &;
95 void append(bytes
const &) &;
97#if defined(PQXX_HAVE_CONCEPTS) && defined(PQXX_HAVE_RANGES)
102 template<binary DATA>
void append(DATA
const &data) &
104 append(bytes_view{std::data(data), std::size(data)});
109 void append(bytes &&) &;
115 void append(binarystring
const &value) &;
118 template<
typename IT,
typename ACCESSOR>
119 void append(pqxx::internal::dynamic_params<IT, ACCESSOR>
const &value) &
121 for (
auto ¶m : value) append(value.access(param));
124 void append(params
const &value) &;
126 void append(params &&value) &;
130 template<
typename TYPE>
void append(TYPE
const &value) &
133 if constexpr (nullness<strip_t<TYPE>>::always_null)
136 m_params.emplace_back();
140 m_params.emplace_back();
144 m_params.emplace_back(entry{
to_string(value)});
149 template<PQXX_RANGE_ARG RANGE>
void append_multi(RANGE
const &range) &
151#if defined(PQXX_HAVE_CONCEPTS) && defined(PQXX_HAVE_RANGES)
152 if constexpr (std::ranges::sized_range<RANGE>)
153 reserve(std::size(*
this) + std::size(range));
155 for (
auto &value : range) append(value);
168 pqxx::internal::c_params make_c_params()
const;
172 template<
typename Arg,
typename... More>
173 void append_pack(Arg &&arg, More &&...args)
175 this->append(std::forward<Arg>(arg));
177 append_pack(std::forward<More>(args)...);
181 constexpr void append_pack() noexcept {}
187 std::variant<std::nullptr_t, zview, std::string, bytes_view, bytes>;
188 std::vector<entry> m_params;
190 static constexpr std::string_view s_overflow{
191 "Statement parameter length overflow."sv};
211 (std::numeric_limits<COUNTER>::max)()};
215 static constexpr auto initial{
"$1\0"sv};
216 initial.copy(std::data(m_buf), std::size(initial));
225 return zview{std::data(m_buf), m_len};
234 std::string
get()
const {
return std::string(std::data(m_buf), m_len); }
241 "Too many parameters in one statement: limit is ",
max_params,
".")};
244 if (m_current % 10 == 0)
249 char *
const data{std::data(m_buf)};
251 data + 1, data + std::size(m_buf), m_current)};
264 COUNTER
count() const noexcept {
return m_current; }
268 COUNTER m_current = 1;
281 std::array<char, std::numeric_limits<COUNTER>::digits10 + 3> m_buf;
291[[deprecated(
"Use the params class instead.")]]
constexpr inline auto
300[[deprecated(
"Use the params class instead.")]]
constexpr inline auto
303 using IT =
typename C::const_iterator;
311template<
typename C,
typename ACCESSOR>
312[[deprecated(
"Use the params class instead.")]]
constexpr inline auto
315 using IT =
decltype(std::begin(container));
Definition statement_parameters.hxx:36
static constexpr unsigned int max_params
Maximum number of parameters we support.
Definition params.hxx:210
COUNTER count() const noexcept
Return the current placeholder number. The initial placeholder is 1.
Definition params.hxx:264
std::string get() const
Read the current placeholder text, as a std::string.
Definition params.hxx:234
placeholders()
Definition params.hxx:213
constexpr zview view() const &noexcept
Read an ephemeral version of the current placeholder text.
Definition params.hxx:223
void next() &
Move on to the next parameter.
Definition params.hxx:237
Marker-type wrapper: zero-terminated std::string_view.
Definition zview.hxx:38
Something is out of range, similar to std::out_of_range.
Definition except.hxx:326
std::string concat(TYPE... item)
Efficiently combine a bunch of items into one big string.
Definition concat.hxx:31
auto ssize(T const &c)
Transitional: std::ssize(), or custom implementation if not available.
Definition util.hxx:555
Definition params.hxx:288
constexpr auto make_dynamic_params(IT begin, IT end)
Definition params.hxx:292
The home of all libpqxx classes, functions, templates, etc.
Definition array.cxx:27
std::string to_string(T const &value)
Definition conversions.hxx:1249
constexpr void ignore_unused(T &&...) noexcept
Suppress compiler warning about an unused item.
Definition util.hxx:144
constexpr bool is_null(TYPE const &value) noexcept
Is value null?
Definition strconv.hxx:516
TO check_cast(FROM value, std::string_view description)
Cast a numeric value to another type, or throw if it underflows/overflows.
Definition util.hxx:153
static char * into_buf(char *begin, char *end, TYPE const &value)
Write value's string representation into buffer at begin.