7 #ifndef PGSQL_EXCHANGE_H
8 #define PGSQL_EXCHANGE_H
13 #include <boost/lexical_cast.hpp>
14 #include <boost/noncopyable.hpp>
15 #include <boost/shared_ptr.hpp>
66 return (values_.size());
74 return (values_.empty());
86 void add(
const char* value);
96 void add(
const std::string& value);
106 void add(
const std::vector<uint8_t>& data);
118 void add(
const uint8_t* data,
const size_t len);
127 void add(
const bool& value);
136 void add(
const uint8_t& byte);
157 void add(
const T& value) {
179 return (bound_strs_);
184 std::string
toText()
const;
188 std::vector<ConstStringPtr> bound_strs_;
237 const uint32_t valid_lifetime);
290 const size_t col, std::string& value);
302 const size_t col,
bool &value);
314 const size_t col, uint8_t &value);
353 const size_t col, T& value) {
356 value = boost::lexical_cast<T>(data);
357 }
catch (
const std::exception& ex) {
359 <<
"] for row: " << row <<
" col: " << col <<
","
381 const size_t col, uint8_t* buffer,
382 const size_t buffer_size,
383 size_t &bytes_converted);
402 #endif // PGSQL_EXCHANGE_H
static time_t convertFromDatabaseTime(const std::string &db_time_val)
Converts time stamp from the database to a time_t.
RAII wrapper for PostgreSQL Result sets.
static std::string convertToDatabaseTime(const time_t input_time)
Converts time_t value to a text representation in local time.
std::vector< ConstStringPtr > getBoundStrs()
std::vector< int > formats_
Vector of "format" for each value.
static const int BINARY_FMT
Format value for binary data.
static std::string dumpRow(const PgSqlResult &r, int row)
Diagnostic tool which dumps the Result row contents as a string.
std::string toText() const
Dumps the contents of the array to a string.
static const char * FALSE_STR
Constant string passed to DB for boolean false values.
std::vector< int > lengths_
Vector of data lengths for each value.
bool empty() const
Indicates it the array is empty.
PgSqlExchange(const size_t num_columns=0)
Constructor.
static isc::asiolink::IOAddress getIPv6Value(const PgSqlResult &r, const int row, const size_t col)
Converts a column in a row in a result set into IPv6 address.
Base class for marshalling data to and from PostgreSQL.
std::vector< const char * > values_
Vector of pointers to the data values.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
void addTempString(const std::string &str)
Binds the given string to the bind array.
void add(const char *value)
Adds a char array to bind array based.
boost::shared_ptr< PsqlBindArray > PsqlBindArrayPtr
Defines a smart pointer to PsqlBindArray.
virtual ~PgSqlExchange()
Destructor.
static const int TEXT_FMT
Format value for text data.
static void getColumnValue(const PgSqlResult &r, const int row, const size_t col, std::string &value)
Fetches text column value as a string.
static void getColumnValue(const PgSqlResult &r, const int row, const size_t col, T &value)
Fetches a text column as the given value type.
static bool isColumnNull(const PgSqlResult &r, const int row, const size_t col)
Returns true if a column within a row is null.
size_t size() const
Fetches the number of entries in the array.
static std::string getColumnLabel(const PgSqlResult &r, const size_t col)
Fetches the name of the column in a result set.
void addNull(const int format=PsqlBindArray::TEXT_FMT)
Adds a NULL value to the bind array.
static void convertFromBytea(const PgSqlResult &r, const int row, const size_t col, uint8_t *buffer, const size_t buffer_size, size_t &bytes_converted)
Converts a column in a row in a result set to a binary bytes.
boost::shared_ptr< const std::string > ConstStringPtr
Structure used to bind C++ input values to dynamic SQL parameters The structure contains three vector...
Defines the logger used by the top-level component of kea-dhcp-ddns.
std::vector< std::string > columns_
Stores text labels for columns, currently only used for logging and errors.
void add(const T &value)
Adds the given value to the bind array.
The IOAddress class represents an IP addresses (version agnostic)
static const char * getRawColumnValue(const PgSqlResult &r, const int row, const size_t col)
Gets a pointer to the raw column value in a result set row.
Exception thrown on failure to execute a database function.
static const char * TRUE_STR
Constant string passed to DB for boolean true values.
std::string format(const std::string &format, const std::vector< std::string > &args)
Apply Formatting.