libpqxx: pqxx::prepare::invocation Class Reference

libpqxx 4.0.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
pqxx::prepare::invocation Class Reference

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

`#include <prepared_statement.hxx>`

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

## Detailed Description

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

## Constructor & Destructor Documentation

pqxx::prepare::invocation::invocation | ( | transaction_base & | home,
|  | const std::string & | statement
| ) |  |

## Member Function Documentation

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

Execute!

References pqxx::internal::scoped_array< T >::get().

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

Has a statement of this name been defined?

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

Pass null parameter.

template<typename T >

invocation& pqxx::prepare::invocation::operator() | ( | const T & | v | ) |

Pass parameter value.

Parameters

  v | parameter value; will be represented as a string internally.

invocation& pqxx::prepare::invocation::operator() | ( | const binarystring & | v | ) |

Pass binary parameter value for a BYTEA field.

Parameters

  v | binary string; will be passed on directly in binary form.

template<typename T >

invocation& pqxx::prepare::invocation::operator() | ( | const T & | v,
|  | bool | nonnull
| ) |  |

Pass parameter value.

Parameters

  v | parameter value (will be represented as a string internally).
  nonnull | replaces value with null if set to false.

invocation& pqxx::prepare::invocation::operator() | ( | const binarystring & | v,
|  | bool | nonnull
| ) |  |

Pass binary parameter value for a BYTEA field.

Parameters

  v | binary string; will be passed on directly in binary form.
  nonnull | determines whether to pass a real value, or NULL.

template<typename T >

invocation& pqxx::prepare::invocation::operator() | ( | T * | v,
|  | bool | nonnull = `true`
| ) |  |

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

  v | parameter value (will be represented as a C++ string internally)
  nonnull | replaces value with null if set to `false`

invocation& pqxx::prepare::invocation::operator() | ( | const char * | v,
|  | bool | nonnull = `true`
| ) |  |

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.

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

- prepared_statement.hxx
- prepared_statement.cxx