Kea 2.7.0
isc::db::PgSqlResultRowWorker Class Reference

Convenience class which facilitates fetching column values from a result set row. More...

#include <pgsql_exchange.h>

Public Member Functions

 PgSqlResultRowWorker (const PgSqlResult &r, const int row)
 Constructor.
 
std::string dumpRow ()
 Diagnostic tool which dumps the Result row contents as a string.
 
uint64_t getBigInt (const size_t col)
 Fetches the uint64_t value at the given column.
 
bool getBool (const size_t col)
 Fetches the boolean value at the given column.
 
void getBytes (const size_t col, std::vector< uint8_t > &value)
 Fetches binary data at the given column into a vector.
 
template<typename T >
void getColumnValue (const size_t col, T &value)
 Fetches a text column as the given value type.
 
double getDouble (const size_t col)
 Fetches the floating point value at the given column.
 
isc::asiolink::IOAddress getInet4 (const size_t col)
 Fetches the v4 IP address at the given column.
 
isc::asiolink::IOAddress getInet6 (const size_t col)
 Fetches the v6 IP address at the given column.
 
uint32_t getInt (const size_t col)
 Fetches the uint32_t value at the given column.
 
data::ElementPtr getJSON (const size_t col)
 Fetches a JSON column as an ElementPtr.
 
const char * getRawColumnValue (const size_t col)
 Gets a pointer to the raw column value in a result set row.
 
uint16_t getSmallInt (const size_t col)
 Fetches the uint16_t value at the given column.
 
std::string getString (const size_t col)
 Fetches the column value as a string.
 
boost::posix_time::ptime getTimestamp (const size_t col)
 Fetches a timestamp column as a ptime.
 
isc::util::Triplet< uint32_t > getTriplet (const size_t col)
 Fetches a uint32_t value into a Triplet using a single column value.
 
isc::util::Triplet< uint32_t > getTriplet (const size_t def_col, const size_t min_col, const size_t max_col)
 Fetches a uint32_t value into a Triplet using a three column values: default, minimum, and maximum.
 
bool isColumnNull (const size_t col)
 Indicates whether or not the given column value is null.
 

Detailed Description

Convenience class which facilitates fetching column values from a result set row.

Definition at line 844 of file pgsql_exchange.h.

Constructor & Destructor Documentation

◆ PgSqlResultRowWorker()

isc::db::PgSqlResultRowWorker::PgSqlResultRowWorker ( const PgSqlResult & r,
const int row )

Constructor.

Parameters
rresult set containing the fetched rows of data.
rowzero-based index of the desired row, (e.g. 0 .. n - 1 where n = number of rows in r)
Exceptions
DbOperationErrorif row value is invalid.

Definition at line 663 of file pgsql_exchange.cc.

Member Function Documentation

◆ dumpRow()

std::string isc::db::PgSqlResultRowWorker::dumpRow ( )

Diagnostic tool which dumps the Result row contents as a string.

Returns
A string representation of the row contents.

Definition at line 762 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::dumpRow().

+ Here is the call graph for this function:

◆ getBigInt()

uint64_t isc::db::PgSqlResultRowWorker::getBigInt ( const size_t col)

Fetches the uint64_t value at the given column.

Parameters
colthe column number within the row
Returns
uint64_t containing the column value

Definition at line 701 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ getBool()

bool isc::db::PgSqlResultRowWorker::getBool ( const size_t col)

Fetches the boolean value at the given column.

Parameters
colthe column number within the row
Returns
bool containing the column value.

Definition at line 682 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ getBytes()

void isc::db::PgSqlResultRowWorker::getBytes ( const size_t col,
std::vector< uint8_t > & value )

Fetches binary data at the given column into a vector.

Parameters
colthe column number within the row
[out]valuevector to receive the fetched data.

Definition at line 722 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::convertFromBytea().

+ Here is the call graph for this function:

◆ getColumnValue()

template<typename T >
void isc::db::PgSqlResultRowWorker::getColumnValue ( const size_t col,
T & value )
inline

Fetches a text column as the given value type.

Uses boost::lexicalcast to convert the text column value into a value of type T.

Parameters
colthe column number within the row
[out]valueparameter to receive the converted value

Definition at line 946 of file pgsql_exchange.h.

References isc::db::PgSqlExchange::getColumnValue().

Referenced by getJSON(), and getTimestamp().

+ Here is the call graph for this function:

◆ getDouble()

double isc::db::PgSqlResultRowWorker::getDouble ( const size_t col)

Fetches the floating point value at the given column.

Parameters
colthe column number within the row
Returns
double containing the column value.

Definition at line 689 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ getInet4()

isc::asiolink::IOAddress isc::db::PgSqlResultRowWorker::getInet4 ( const size_t col)

Fetches the v4 IP address at the given column.

This is used to fetch values from inet type columns.

Parameters
colthe column number within the row
Returns
isc::asiolink::IOAddress containing the IPv4 address.

Definition at line 727 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getInetValue4().

+ Here is the call graph for this function:

◆ getInet6()

isc::asiolink::IOAddress isc::db::PgSqlResultRowWorker::getInet6 ( const size_t col)

Fetches the v6 IP address at the given column.

This is used to fetch values from inet type columns.

Parameters
colthe column number within the row
Returns
isc::asiolink::IOAddress containing the IPv6 address.

Definition at line 732 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getInetValue6().

+ Here is the call graph for this function:

◆ getInt()

uint32_t isc::db::PgSqlResultRowWorker::getInt ( const size_t col)

Fetches the uint32_t value at the given column.

Parameters
colthe column number within the row
Returns
uint32_t containing the column value

Definition at line 708 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ getJSON()

data::ElementPtr isc::db::PgSqlResultRowWorker::getJSON ( const size_t col)

Fetches a JSON column as an ElementPtr.

Parameters
colthe column number within the row
Returns
ElementPtr parameter to receive the column value

Definition at line 744 of file pgsql_exchange.cc.

References getColumnValue().

+ Here is the call graph for this function:

◆ getRawColumnValue()

const char * isc::db::PgSqlResultRowWorker::getRawColumnValue ( const size_t col)

Gets a pointer to the raw column value in a result set row.

Given a column return a const char* pointer to the data value in the result set row. The pointer is valid as long as the underlying result set has not been freed. It may point to text or binary data depending on how query was structured. You should not attempt to free this pointer.

Parameters
colthe column number within the row
Returns
a const char* pointer to the column's raw data

Definition at line 696 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getRawColumnValue().

+ Here is the call graph for this function:

◆ getSmallInt()

uint16_t isc::db::PgSqlResultRowWorker::getSmallInt ( const size_t col)

Fetches the uint16_t value at the given column.

Parameters
colthe column number within the row
Returns
uint16_t containing the column value

Definition at line 715 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ getString()

std::string isc::db::PgSqlResultRowWorker::getString ( const size_t col)

Fetches the column value as a string.

Parameters
colthe column number within the row
Returns
std::string containing the column value.

Definition at line 675 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getColumnValue().

+ Here is the call graph for this function:

◆ getTimestamp()

boost::posix_time::ptime isc::db::PgSqlResultRowWorker::getTimestamp ( const size_t col)

Fetches a timestamp column as a ptime.

Parameters
colthe column number within the row
Returns
ptime parameter to receive the converted timestamp

Definition at line 737 of file pgsql_exchange.cc.

References getColumnValue().

+ Here is the call graph for this function:

◆ getTriplet() [1/2]

isc::util::Triplet< uint32_t > isc::db::PgSqlResultRowWorker::getTriplet ( const size_t col)

Fetches a uint32_t value into a Triplet using a single column value.

Parameters
colthe column number within the row If the column is null, the Triplet is returned as unspecified.
Returns
Triplet to receive the column value

Definition at line 751 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getTripletValue().

+ Here is the call graph for this function:

◆ getTriplet() [2/2]

isc::util::Triplet< uint32_t > isc::db::PgSqlResultRowWorker::getTriplet ( const size_t def_col,
const size_t min_col,
const size_t max_col )

Fetches a uint32_t value into a Triplet using a three column values: default, minimum, and maximum.

Parameters
def_colthe column number within the row that contains the default value. If this column is null, the Triplet is returned as unspecified.
min_colthe column number within the row that contains the minimum value.
max_colthe column number within the row that contains the maximum value.
Returns
Triplet to receive the column value

Definition at line 756 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::getTripletValue().

+ Here is the call graph for this function:

◆ isColumnNull()

bool isc::db::PgSqlResultRowWorker::isColumnNull ( const size_t col)

Indicates whether or not the given column value is null.

Parameters
colthe column number within the row
Returns
true if the value is null, false otherwise.

Definition at line 670 of file pgsql_exchange.cc.

References isc::db::PgSqlExchange::isColumnNull().

+ Here is the call graph for this function:

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