Loading...
Searching...
No Matches
statement_parameters.hxx
#ifndef PQXX_H_STATEMENT_PARAMETER
#define PQXX_H_STATEMENT_PARAMETER
#include <cstring>
#include <iterator>
#include <string>
#include <vector>
#include "pqxx/binarystring.hxx"
#include "pqxx/strconv.hxx"
#include "pqxx/util.hxx"
namespace pqxx::internal
{
template<typename ITERATOR>
constexpr inline auto const iterator_identity{
[](decltype(*std::declval<ITERATOR>()) x) { return x; }};
template<typename IT, typename ACCESSOR = decltype(iterator_identity<IT>)>
class dynamic_params
{
public:
constexpr dynamic_params(IT begin, IT end) :
m_begin(begin), m_end(end), m_accessor(iterator_identity<IT>)
{}
constexpr dynamic_params(IT begin, IT end, ACCESSOR &acc) :
m_begin(begin), m_end(end), m_accessor(acc)
{}
template<typename C>
explicit constexpr dynamic_params(C &container) :
dynamic_params(std::begin(container), std::end(container))
{}
template<typename C>
explicit constexpr dynamic_params(C &container, ACCESSOR &acc) :
dynamic_params(std::begin(container), std::end(container), acc)
{}
constexpr IT begin() const noexcept { return m_begin; }
constexpr IT end() const noexcept { return m_end; }
constexpr auto access(decltype(*std::declval<IT>()) value) const
-> decltype(std::declval<ACCESSOR>()(value))
{
return m_accessor(value);
}
private:
IT const m_begin, m_end;
ACCESSOR m_accessor = iterator_identity<IT>;
};
struct PQXX_LIBEXPORT c_params
{
c_params() = default;
c_params(c_params const &) = delete;
c_params(c_params &&) = default;
void reserve(std::size_t n) &;
std::vector<char const *> values;
std::vector<int> lengths;
std::vector<format> formats;
};
} // namespace pqxx::internal
#endif
pqxx::internal::dynamic_params
Definition statement_parameters.hxx:36
pqxx::internal::dynamic_params::dynamic_params
constexpr dynamic_params(C &container)
Wrap a container.
Definition statement_parameters.hxx:54
pqxx::internal::dynamic_params::dynamic_params
constexpr dynamic_params(IT begin, IT end)
Wrap a sequence of pointers or iterators.
Definition statement_parameters.hxx:39
pqxx::internal::dynamic_params::dynamic_params
constexpr dynamic_params(C &container, ACCESSOR &acc)
Wrap a container.
Definition statement_parameters.hxx:64
pqxx::internal::dynamic_params::dynamic_params
constexpr dynamic_params(IT begin, IT end, ACCESSOR &acc)
Wrap a sequence of pointers or iterators.
Definition statement_parameters.hxx:48
pqxx::internal
Internal items for libpqxx' own use. Do not use these yourself.
Definition encodings.cxx:33
pqxx::internal::c_params
Internal type: encode statement parameters.
Definition statement_parameters.hxx:95
pqxx::internal::c_params::c_params
c_params(c_params const &)=delete
Copying these objects is pointless and expensive. Don't do it.
pqxx::internal::c_params::lengths
std::vector< int > lengths
As used by libpq: lengths of non-null arguments, in bytes.
Definition statement_parameters.hxx:107
pqxx::internal::c_params::formats
std::vector< format > formats
As used by libpq: effectively boolean "is this a binary parameter?".
Definition statement_parameters.hxx:109
pqxx::internal::c_params::values
std::vector< char const * > values
As used by libpq: pointers to parameter values.
Definition statement_parameters.hxx:105