summaryrefslogtreecommitdiff
path: root/libodbcpp/column.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-08-30 17:34:02 +0000
committerrandomdan <randomdan@localhost>2010-08-30 17:34:02 +0000
commit685587ddb7af3a943a1dd5837fcfeeb779cf15b1 (patch)
treea376a877feb1b1689481655844648a20a884d4f8 /libodbcpp/column.cpp
parentFix early assign of insCmd in sqlmerge (diff)
downloadlibdbpp-odbc-685587ddb7af3a943a1dd5837fcfeeb779cf15b1.tar.bz2
libdbpp-odbc-685587ddb7af3a943a1dd5837fcfeeb779cf15b1.tar.xz
libdbpp-odbc-685587ddb7af3a943a1dd5837fcfeeb779cf15b1.zip
Remove lots of overkill variations of string stuff and have a vector<char> deal with the memory
Diffstat (limited to 'libodbcpp/column.cpp')
-rw-r--r--libodbcpp/column.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/libodbcpp/column.cpp b/libodbcpp/column.cpp
index 8237535..6e517a6 100644
--- a/libodbcpp/column.cpp
+++ b/libodbcpp/column.cpp
@@ -34,7 +34,6 @@ ODBC_DEFAULT_COLUMN_CAST(SQLINTEGER, long long);
ODBC_DEFAULT_COLUMN_CAST(SQLINTEGER, int);
ODBC_DEFAULT_COLUMN_CAST(SQLDOUBLE, double);
ODBC_DEFAULT_COLUMN_CAST(SQLDOUBLE, float);
-ODBC_DEFAULT_COLUMN_CAST(SQLCHAR*, const unsigned char *);
ODBC::Column::operator Glib::ustring() const {
return Glib::ustring((const char *)((dynamic_cast<const _Column<SQLCHAR*>& >(*this)).value));
}
@@ -75,11 +74,13 @@ namespace ODBC {
REBIND(double, bindParamF)
REBIND(float, bindParamF)
REBIND(SQL_TIMESTAMP_STRUCT, bindParamT)
- template<> void _Column<unsigned char *>::rebind(Command * cmd, unsigned int col) const \
+
+ template<>
+ void
+ _Column<SQLCHARVEC>::rebind(Command * cmd, unsigned int col) const \
{
- cmd->bindParamS(col, (const char *)value);
+ cmd->bindParamS(col, &value[0]);
}
-
template <>
int
_Column<SQLDOUBLE>::writeToBuf(char ** buf, const char * fmt) const
@@ -136,30 +137,30 @@ namespace ODBC {
}
template <>
int
- _Column<SQLCHAR*>::writeToBuf(char ** buf, const char * fmt) const
+ _Column<SQLCHARVEC>::writeToBuf(char ** buf, const char * fmt) const
{
- return asprintf(buf, fmt, value);
+ return asprintf(buf, fmt, &value[0]);
}
template <>
int
- _Column<SQLCHAR*>::writeToBuf(char ** buf) const
+ _Column<SQLCHARVEC>::writeToBuf(char ** buf) const
{
return writeToBuf(buf, "%s");
}
template <>
const Glib::ustring &
- _Column<SQLCHAR*>::compose() const
+ _Column<SQLCHARVEC>::compose() const
{
if (!composeCache) {
- composeCache = new Glib::ustring((const char *)value);
+ composeCache = new Glib::ustring((const char *)&value[0]);
}
return *composeCache;
}
template <>
Glib::ustring
- _Column<SQLCHAR*>::compose(const Glib::ustring & fmt) const
+ _Column<SQLCHARVEC>::compose(const Glib::ustring & fmt) const
{
- return Glib::ustring::compose(fmt, value);
+ return Glib::ustring::compose(fmt, &value[0]);
}
template <>
int