summaryrefslogtreecommitdiff
path: root/libodbcpp/column.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-04-07 19:25:52 +0000
committerrandomdan <randomdan@localhost>2010-04-07 19:25:52 +0000
commitde6be7bbb9a2984a514d4076d77d97b054585d7c (patch)
tree29091246152281e91e86f78d975854eb8f5d5e8a /libodbcpp/column.cpp
parentMinor fixes (diff)
downloadlibdbpp-odbc-de6be7bbb9a2984a514d4076d77d97b054585d7c.tar.bz2
libdbpp-odbc-de6be7bbb9a2984a514d4076d77d97b054585d7c.tar.xz
libdbpp-odbc-de6be7bbb9a2984a514d4076d77d97b054585d7c.zip
Add a writeToBuf function and use it
Diffstat (limited to 'libodbcpp/column.cpp')
-rw-r--r--libodbcpp/column.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/libodbcpp/column.cpp b/libodbcpp/column.cpp
index 0d0e6e2..14b12f8 100644
--- a/libodbcpp/column.cpp
+++ b/libodbcpp/column.cpp
@@ -1,3 +1,5 @@
+#include <stdio.h>
+#include <stdlib.h>
#include "column.h"
#include "command.h"
#include "error.h"
@@ -67,5 +69,54 @@ namespace ODBC {
REBIND(float, bindParamF)
REBIND(TimeTypePair, bindParamT)
REBIND(unsigned char *, bindParamS)
-}
+ template <>
+ int
+ _Column<SQLDOUBLE>::writeToBuf(char ** buf, const char * fmt) const
+ {
+ return asprintf(buf, fmt, value);
+ }
+ template <>
+ int
+ _Column<SQLDOUBLE>::writeToBuf(char ** buf) const
+ {
+ return writeToBuf(buf, "%d");
+ }
+ template <>
+ int
+ _Column<SQLINTEGER>::writeToBuf(char ** buf, const char * fmt) const
+ {
+ return asprintf(buf, fmt, value);
+ }
+ template <>
+ int
+ _Column<SQLINTEGER>::writeToBuf(char ** buf) const
+ {
+ return writeToBuf(buf, "%ld");
+ }
+ template <>
+ int
+ _Column<SQLCHAR*>::writeToBuf(char ** buf, const char * fmt) const
+ {
+ return asprintf(buf, fmt, value);
+ }
+ template <>
+ int
+ _Column<SQLCHAR*>::writeToBuf(char ** buf) const
+ {
+ return writeToBuf(buf, "%s");
+ }
+ template <>
+ int
+ _Column<TimeTypePair>::writeToBuf(char ** buf, const char * fmt) const
+ {
+ *buf = (char *)malloc(30);
+ return strftime(*buf, sizeof(buf), fmt, &value.c());
+ }
+ template <>
+ int
+ _Column<TimeTypePair>::writeToBuf(char ** buf) const
+ {
+ return writeToBuf(buf, "%F %T");
+ }
+}