diff options
author | randomdan <randomdan@localhost> | 2014-03-03 20:57:27 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2014-03-03 20:57:27 +0000 |
commit | e267def4f9f2e47402d72b56a45924f0bd2c0a18 (patch) | |
tree | 3384c10e1dbd84247c6d9429ffe3fab4ae398a48 /libodbcpp/param.h | |
parent | Fix slice scanner and split .ice files back into logical blocks (diff) | |
download | libdbpp-odbc-e267def4f9f2e47402d72b56a45924f0bd2c0a18.tar.bz2 libdbpp-odbc-e267def4f9f2e47402d72b56a45924f0bd2c0a18.tar.xz libdbpp-odbc-e267def4f9f2e47402d72b56a45924f0bd2c0a18.zip |
Adds native support for time_duration as a variable type
Pass/retrieve boost::posix_time ptime and time_duration into/out of the db tier
Diffstat (limited to 'libodbcpp/param.h')
-rw-r--r-- | libodbcpp/param.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/libodbcpp/param.h b/libodbcpp/param.h index 661d9b3..37f8d5a 100644 --- a/libodbcpp/param.h +++ b/libodbcpp/param.h @@ -5,6 +5,7 @@ #include <sqlext.h> #include <glibmm/ustring.h> #include "bind.h" +#include <boost/date_time/posix_time/posix_time_types.hpp> namespace ODBC { class Command; @@ -79,6 +80,19 @@ namespace ODBC { protected: Glib::ustring data; }; + class IntervalParam : public Param { + public: + IntervalParam() : Param() { } + IntervalParam(Command * c, unsigned int i) : Param(c, i) { bindLen = size(); } + virtual SQLSMALLINT ctype() const { return SQL_C_INTERVAL_DAY_TO_SECOND; } + virtual SQLSMALLINT stype() const { return SQL_INTERVAL; } + virtual SQLULEN size() const { return sizeof(SQL_INTERVAL); } + virtual SQLINTEGER dp() const { return boost::posix_time::time_res_traits::num_fractional_digits(); } + virtual const void * dataAddress() const { return &data; } + void operator=(const boost::posix_time::time_duration & d); + protected: + SQL_INTERVAL_STRUCT data; + }; class TimeStampParam : public Param { public: TimeStampParam() : Param() { } @@ -86,11 +100,9 @@ namespace ODBC { virtual SQLSMALLINT ctype() const { return SQL_C_TYPE_TIMESTAMP; } virtual SQLSMALLINT stype() const { return SQL_TYPE_TIMESTAMP; } virtual SQLULEN size() const { return sizeof(SQL_TIMESTAMP_STRUCT); } - virtual SQLINTEGER dp() const { return 0; } + virtual SQLINTEGER dp() const { return boost::posix_time::time_res_traits::num_fractional_digits(); } virtual const void * dataAddress() const { return &data; } - void operator=(const time_t & d); - void operator=(const struct tm * d) { data << *d; } - void operator=(const SQL_TIMESTAMP_STRUCT & d) { data = d; } + void operator=(const boost::posix_time::ptime & d); protected: SQL_TIMESTAMP_STRUCT data; }; |