|
libpqxx
The C++ client library for PostgreSQL
|
Build a parameter list for a parameterised or prepared statement. More...
#include <params.hxx>
Public Member Functions | |
| params ()=default | |
| template<typename... Args> | |
| constexpr | params (Args &&...args) |
Pre-populate a params with args. Feel free to add more later. More... | |
| void | reserve (std::size_t n)& |
Pre-allocate room for at least n parameters. More... | |
| auto | size () const noexcept |
Get the number of parameters currently in this params. More... | |
| auto | ssize () const |
| Get the number of parameters (signed). More... | |
| void | append ()& |
| Append a null value. More... | |
| void | append (zview)& |
| Append a non-null zview parameter. More... | |
| void | append (std::string const &)& |
| Append a non-null string parameter. More... | |
| void | append (std::string &&)& |
| Append a non-null string parameter. More... | |
| void | append (bytes_view)& |
| Append a non-null binary parameter. More... | |
| void | append (bytes const &)& |
| Append a non-null binary parameter. More... | |
| void | append (bytes &&)& |
| Append a non-null binary parameter. More... | |
| void | append (binarystring const &value)& |
| template<typename IT , typename ACCESSOR > | |
| void | append (pqxx::internal::dynamic_params< IT, ACCESSOR > const &value)& |
| Append all parameters from value. More... | |
| void | append (params const &value)& |
| void | append (params &&value)& |
| template<typename TYPE > | |
| void | append (TYPE const &value)& |
| template<typename RANGE > | |
| void | append_multi (RANGE const &range)& |
Append all elements of range as parameters. More... | |
| pqxx::internal::c_params | make_c_params () const |
For internal use: Generate a params object for use in calls. More... | |
Build a parameter list for a parameterised or prepared statement.
When calling a parameterised statement or a prepared statement, in many cases you can pass parameters into the statement in the form of a pqxx::params object.
|
default |
|
inline |
Pre-populate a params with args. Feel free to add more later.
| void pqxx::params::append | ( | ) |
Append a null value.
| void pqxx::params::append | ( | zview | value | ) |
Append a non-null zview parameter.
The underlying data must stay valid for as long as the params remains active.
| void pqxx::params::append | ( | std::string const & | value | ) |
Append a non-null string parameter.
Copies the underlying data into internal storage. For best efficiency, use the zview variant if you can, or std::move()
| void pqxx::params::append | ( | std::string && | value | ) |
Append a non-null string parameter.
| void pqxx::params::append | ( | bytes_view | value | ) |
Append a non-null binary parameter.
The underlying data must stay valid for as long as the params remains active.
| void pqxx::params::append | ( | bytes const & | value | ) |
Append a non-null binary parameter.
Copies the underlying data into internal storage. For best efficiency, use the pqxx::bytes_view variant if you can, or std::move().
| void pqxx::params::append | ( | bytes && | value | ) |
Append a non-null binary parameter.
| void pqxx::params::append | ( | binarystring const & | value | ) |
The binarystring must stay valid for as long as the params remains active.
|
inline |
Append all parameters from value.
| void pqxx::params::append | ( | params const & | value | ) |
| void pqxx::params::append | ( | params && | value | ) |
|
inline |
Append a non-null parameter, converting it to its string representation.
|
inline |
Append all elements of range as parameters.
| pqxx::internal::c_params pqxx::params::make_c_params | ( | ) | const |
For internal use: Generate a params object for use in calls.
The params object encapsulates the pointers which we will need to pass to libpq when calling a parameterised or prepared statement.
The pointers in the params will refer to storage owned by either the params object, or the caller. This is not a problem because a c_params object is guaranteed to live only while the call is going on. As soon as we climb back out of that call tree, we're done with that data.
| void pqxx::params::reserve | ( | std::size_t | n | ) |
Pre-allocate room for at least n parameters.
This is not needed, but it may improve efficiency.
Reserve space if you're going to add parameters individually, and you've got some idea of how many there are going to be. It may save some memory re-allocations.
|
inlinenoexcept |
Get the number of parameters currently in this params.
|
inline |
Get the number of parameters (signed).
Unlike size(), this is not yet noexcept. That's because C++17's std::vector does not have a ssize() member function. These member functions are noexcept, but std::size() and std::ssize() are not.