libpqxx  v4.0-1
C++ library for PostgreSQL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pqxx::prepare::invocation Class Reference

Helper class for passing parameters to, and executing, prepared statements. More...

#include <prepared_statement.hxx>

Inheritance diagram for pqxx::prepare::invocation:
Collaboration diagram for pqxx::prepare::invocation:

Public Member Functions

 invocation (transaction_base &, const PGSTD::string &statement)
 
result exec () const
 Execute! More...
 
bool exists () const
 Has a statement of this name been defined? More...
 
invocationoperator() ()
 Pass null parameter. More...
 
template<typename T >
invocationoperator() (const T &v)
 Pass parameter value. More...
 
invocationoperator() (const binarystring &v)
 Pass binary parameter value for a BYTEA field. More...
 
template<typename T >
invocationoperator() (const T &v, bool nonnull)
 Pass parameter value. More...
 
invocationoperator() (const binarystring &v, bool nonnull)
 Pass binary parameter value for a BYTEA field. More...
 
template<typename T >
invocationoperator() (T *v, bool nonnull=true)
 Pass C-style parameter string, or null if pointer is null. More...
 
invocationoperator() (const char *v, bool nonnull=true)
 Pass C-style string parameter, or null if pointer is null. More...
 

Private Member Functions

void add_binary_param (const binarystring &b, bool nonnull)
 
void add_param ()
 
template<typename T >
void add_param (const T &v, bool nonnull)
 
int marshall (scoped_array< const char * > &values, scoped_array< int > &lengths, scoped_array< int > &binaries) const
 Marshall parameter values into C-style arrays for passing to libpq. More...
 
invocationoperator= (const invocation &)
 Not allowed. More...
 
invocationsetparam (const PGSTD::string &, bool nonnull)
 

Private Attributes

transaction_basem_home
 
PGSTD::vector< bool > m_nonnull
 
const PGSTD::string m_statement
 
PGSTD::vector< PGSTD::string > m_values
 

Detailed Description

Helper class for passing parameters to, and executing, prepared statements.

Constructor & Destructor Documentation

pqxx::prepare::invocation::invocation ( transaction_base ,
const PGSTD::string &  statement 
)

Member Function Documentation

void pqxx::internal::statement_parameters::add_binary_param ( const binarystring b,
bool  nonnull 
)
inlineprotectedinherited

References pqxx::binarystring::str().

Here is the call graph for this function:

void pqxx::internal::statement_parameters::add_param ( )
inlineprotectedinherited
template<typename T >
void pqxx::internal::statement_parameters::add_param ( const T &  v,
bool  nonnull 
)
inlineprotectedinherited

References pqxx::to_string().

Here is the call graph for this function:

result pqxx::prepare::invocation::exec ( ) const

Execute!

bool pqxx::prepare::invocation::exists ( ) const

Has a statement of this name been defined?

int pqxx::internal::statement_parameters::marshall ( scoped_array< const char * > &  values,
scoped_array< int > &  lengths,
scoped_array< int > &  binaries 
) const
protectedinherited

Marshall parameter values into C-style arrays for passing to libpq.

invocation& pqxx::prepare::invocation::operator() ( )
inline

Pass null parameter.

template<typename T >
invocation& pqxx::prepare::invocation::operator() ( const T &  v)
inline

Pass parameter value.

Parameters
vparameter value; will be represented as a string internally.
invocation& pqxx::prepare::invocation::operator() ( const binarystring v)
inline

Pass binary parameter value for a BYTEA field.

Parameters
vbinary string; will be passed on directly in binary form.
template<typename T >
invocation& pqxx::prepare::invocation::operator() ( const T &  v,
bool  nonnull 
)
inline

Pass parameter value.

Parameters
vparameter value (will be represented as a string internally).
nonnullreplaces value with null if set to false.
invocation& pqxx::prepare::invocation::operator() ( const binarystring v,
bool  nonnull 
)
inline

Pass binary parameter value for a BYTEA field.

Parameters
vbinary string; will be passed on directly in binary form.
nonnulldetermines whether to pass a real value, or NULL.
template<typename T >
invocation& pqxx::prepare::invocation::operator() ( T *  v,
bool  nonnull = true 
)
inline

Pass C-style parameter string, or null if pointer is null.

This version is for passing C-style strings; it's a template, so any pointer type that to_string accepts will do.

Warning
Be very careful with the special constant NULL! Since NULL in C++ is an int, not a pointer, a value of NULL would cause the wrong version of this template to be invoked. To all intents and purposes it would look like you were trying to pass a regular zero as an integer value, instead of a null string. This is not a problem with pointer variables that may happen to be NULL, since in that case the value's type is not subject to any confusion. So if you know at compile time that you want to pass a null value, use the zero-argument version of this operator; if you don't want to do that, at least add a second argument of false to make clear that you want a null, not a zero.
Parameters
vparameter value (will be represented as a C++ string internally)
nonnullreplaces value with null if set to false
invocation& pqxx::prepare::invocation::operator() ( const char *  v,
bool  nonnull = true 
)
inline

Pass C-style string parameter, or null if pointer is null.

This duplicates the pointer-to-template-argument-type version of the operator, but helps compilers with less advanced template implementations disambiguate calls where C-style strings are passed.

invocation& pqxx::prepare::invocation::operator= ( const invocation )
private

Not allowed.

invocation& pqxx::prepare::invocation::setparam ( const PGSTD::string &  ,
bool  nonnull 
)
private

Member Data Documentation

transaction_base& pqxx::prepare::invocation::m_home
private
PGSTD::vector<bool> pqxx::prepare::invocation::m_nonnull
private
const PGSTD::string pqxx::prepare::invocation::m_statement
private
PGSTD::vector<PGSTD::string> pqxx::prepare::invocation::m_values
private

The documentation for this class was generated from the following file: