Kea
1.9.9-git
|
#include <pgsql_exchange.h>
Public Member Functions | |
void | add (const char *value) |
Adds a char array to bind array based. More... | |
void | add (const std::string &value) |
Adds an string value to the bind array. More... | |
void | add (const std::vector< uint8_t > &data) |
Adds a vector of binary data to the bind array. More... | |
void | add (const uint8_t *data, const size_t len) |
Adds a buffer of binary data to the bind array. More... | |
void | add (const bool &value) |
Adds a boolean value to the bind array. More... | |
void | add (const uint8_t &byte) |
Adds a uint8_t value to the bind array. More... | |
void | add (const isc::asiolink::IOAddress &addr) |
Adds the given IOAddress value to the bind array. More... | |
template<typename T > | |
void | add (const T &value) |
Adds the given value to the bind array. More... | |
void | addNull (const int format=PsqlBindArray::TEXT_FMT) |
Adds a NULL value to the bind array. More... | |
void | addTempString (const std::string &str) |
Binds the given string to the bind array. More... | |
bool | empty () const |
Indicates it the array is empty. More... | |
std::vector< ConstStringPtr > | getBoundStrs () |
size_t | size () const |
Fetches the number of entries in the array. More... | |
std::string | toText () const |
Dumps the contents of the array to a string. More... | |
Public Attributes | |
std::vector< int > | formats_ |
Vector of "format" for each value. More... | |
std::vector< int > | lengths_ |
Vector of data lengths for each value. More... | |
std::vector< const char * > | values_ |
Vector of pointers to the data values. More... | |
Static Public Attributes | |
static const int | BINARY_FMT = 1 |
Format value for binary data. More... | |
static const char * | FALSE_STR = "FALSE" |
Constant string passed to DB for boolean false values. More... | |
static const int | TEXT_FMT = 0 |
Format value for text data. More... | |
static const char * | TRUE_STR = "TRUE" |
Constant string passed to DB for boolean true values. More... | |
Definition at line 44 of file pgsql_exchange.h.
void isc::db::PsqlBindArray::add | ( | const char * | value | ) |
Adds a char array to bind array based.
Adds a TEXT_FMT value to the end of the bind array, using the given char* as the data source. The value is expected to be NULL terminated. The caller is responsible for ensuring that value remains in scope until the bind array has been discarded.
value | char array containing the null-terminated text to add. |
DbOperationError | if value is NULL. |
Definition at line 26 of file pgsql_exchange.cc.
References formats_, isc_throw, lengths_, TEXT_FMT, and values_.
Referenced by add(), addTempString(), isc::dhcp::PgSqlLease4Exchange::createBindForSend(), isc::dhcp::PgSqlLease6Exchange::createBindForSend(), isc::dhcp::PgSqlLeaseMgr::deleteLease(), isc::dhcp::PgSqlLeaseMgr::getLease4(), isc::dhcp::PgSqlLeaseMgr::getLease6(), isc::dhcp::PgSqlLeaseMgr::getLeases4(), isc::dhcp::PgSqlLeaseMgr::getLeases6(), isc::dhcp::PgSqlLeaseStatsQuery::start(), isc::dhcp::PgSqlLeaseMgr::updateLease4(), and isc::dhcp::PgSqlLeaseMgr::updateLease6().
void isc::db::PsqlBindArray::add | ( | const std::string & | value | ) |
Adds an string value to the bind array.
Adds a TEXT formatted value to the end of the bind array using the given string as the data source. The caller is responsible for ensuring that string parameter remains in scope until the bind array has been discarded.
value | std::string containing the value to add. |
Definition at line 36 of file pgsql_exchange.cc.
void isc::db::PsqlBindArray::add | ( | const std::vector< uint8_t > & | data | ) |
Adds a vector of binary data to the bind array.
Adds a BINARY_FMT value to the end of the bind array using the given vector as the data source. NOTE this does not replicate the vector, so it must remain in scope until the bind array is destroyed.
data | vector of binary bytes. |
Definition at line 42 of file pgsql_exchange.cc.
References BINARY_FMT, formats_, lengths_, and values_.
void isc::db::PsqlBindArray::add | ( | const uint8_t * | data, |
const size_t | len | ||
) |
Adds a buffer of binary data to the bind array.
Adds a BINARY_FMT value to the end of the bind array using the given vector as the data source. NOTE this does not replicate the buffer, so it must remain in scope until the bind array is destroyed.
data | buffer of binary data. |
len | number of bytes of data in buffer |
DbOperationError | if data is NULL. |
Definition at line 48 of file pgsql_exchange.cc.
References BINARY_FMT, formats_, isc_throw, lengths_, and values_.
void isc::db::PsqlBindArray::add | ( | const bool & | value | ) |
Adds a boolean value to the bind array.
Converts the given boolean value to its corresponding to PostgreSQL string value and adds it as a TEXT_FMT value to the bind array. This creates an internally scoped string.
value | the boolean value to add. |
Definition at line 58 of file pgsql_exchange.cc.
References add(), FALSE_STR, and TRUE_STR.
void isc::db::PsqlBindArray::add | ( | const uint8_t & | byte | ) |
Adds a uint8_t value to the bind array.
Converts the given uint8_t value to its corresponding numeric string literal and adds it as a TEXT_FMT value to the bind array. This creates an internally scoped string.
byte | the one byte value to add. |
Definition at line 62 of file pgsql_exchange.cc.
References addTempString().
void isc::db::PsqlBindArray::add | ( | const isc::asiolink::IOAddress & | addr | ) |
Adds the given IOAddress value to the bind array.
Converts the IOAddress, based on its protocol family, to the corresponding string literal and adds it as a TEXT_FMT value to the bind array. This creates an internally scoped string.
addr | IP address value to add. |
Definition at line 69 of file pgsql_exchange.cc.
References addTempString(), isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().
|
inline |
Adds the given value to the bind array.
Converts the given value to its corresponding string literal boost::lexical_cast and adds it as a TEXT_FMT value to the bind array. This is intended primarily for numeric types. This creates an internally scoped string.
value | data value to add. |
Definition at line 157 of file pgsql_exchange.h.
References addTempString().
void isc::db::PsqlBindArray::addNull | ( | const int | format = PsqlBindArray::TEXT_FMT | ) |
Adds a NULL value to the bind array.
This should be used whenever the value for a parameter specified in the SQL statement should be NULL.
Definition at line 78 of file pgsql_exchange.cc.
void isc::db::PsqlBindArray::addTempString | ( | const std::string & | str | ) |
Binds the given string to the bind array.
Prior to add the given string the vector of exchange values, it duplicated as a ConstStringPtr and saved internally. This guarantees the string remains in scope until the PsqlBindArray is destroyed, without the caller maintaining the string values.
str | string value to add. |
Definition at line 89 of file pgsql_exchange.cc.
References add().
Referenced by add().
|
inline |
Indicates it the array is empty.
Definition at line 72 of file pgsql_exchange.h.
|
inline |
Definition at line 178 of file pgsql_exchange.h.
|
inline |
Fetches the number of entries in the array.
Definition at line 65 of file pgsql_exchange.h.
Referenced by isc::dhcp::PgSqlLeaseStatsQuery::start().
std::string isc::db::PsqlBindArray::toText | ( | ) | const |
Dumps the contents of the array to a string.
Definition at line 94 of file pgsql_exchange.cc.
References formats_, lengths_, TEXT_FMT, and values_.
Referenced by isc::dhcp::PgSqlLeaseMgr::updateLease6().
|
static |
|
static |
Constant string passed to DB for boolean false values.
Definition at line 61 of file pgsql_exchange.h.
Referenced by add().
std::vector<int> isc::db::PsqlBindArray::formats_ |
Vector of "format" for each value.
A value of 0 means the value is text, 1 means the value is binary.
Definition at line 51 of file pgsql_exchange.h.
Referenced by add(), addNull(), isc::dhcp::PgSqlLeaseStatsQuery::start(), and toText().
std::vector<int> isc::db::PsqlBindArray::lengths_ |
Vector of data lengths for each value.
Definition at line 48 of file pgsql_exchange.h.
Referenced by add(), addNull(), isc::dhcp::PgSqlLeaseStatsQuery::start(), and toText().
|
static |
Format value for text data.
Definition at line 54 of file pgsql_exchange.h.
|
static |
Constant string passed to DB for boolean true values.
Definition at line 59 of file pgsql_exchange.h.
Referenced by add().
std::vector<const char *> isc::db::PsqlBindArray::values_ |
Vector of pointers to the data values.
Definition at line 46 of file pgsql_exchange.h.
Referenced by add(), addNull(), isc::dhcp::PgSqlLeaseStatsQuery::start(), and toText().