diff options
author | randomdan <randomdan@localhost> | 2010-06-11 09:03:42 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2010-06-11 09:03:42 +0000 |
commit | 1df33cc9d9a7804c78788d5717435ede44855ca0 (patch) | |
tree | b78e66de0a9f7d6bb39038d6f628cbc871ffa652 /libodbcpp/column.cpp | |
parent | Initial workings of project2 - renders gentoobrowse homepage (diff) | |
download | libdbpp-odbc-1df33cc9d9a7804c78788d5717435ede44855ca0.tar.bz2 libdbpp-odbc-1df33cc9d9a7804c78788d5717435ede44855ca0.tar.xz libdbpp-odbc-1df33cc9d9a7804c78788d5717435ede44855ca0.zip |
Use Glib::ustring in libodbcpp for data and std::string for non-data
Add support for parameters in SqlViews
Uses parameters to implement category browse and search
Diffstat (limited to 'libodbcpp/column.cpp')
-rw-r--r-- | libodbcpp/column.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/libodbcpp/column.cpp b/libodbcpp/column.cpp index d4b6446..386cbfd 100644 --- a/libodbcpp/column.cpp +++ b/libodbcpp/column.cpp @@ -4,10 +4,10 @@ #include "command.h" #include "error.h" -ODBC::Column::Column(String n, unsigned int i) : +ODBC::Column::Column(const Glib::ustring & n, unsigned int i) : colNo(i), name(n), - fresh(false) + bindSize(0) { } @@ -15,6 +15,12 @@ ODBC::Column::~Column() { } +bool +ODBC::Column::isNull() const +{ + return (bindLen == SQL_NULL_DATA); +} + #define ODBC_DEFAULT_COLUMN_CAST(ctype, rtype) \ ODBC::Column::operator rtype() const { \ return (dynamic_cast<const _Column<ctype>& >(*this)).value; \ @@ -27,7 +33,9 @@ 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_DEFAULT_COLUMN_CAST(SQLCHAR*, String); +ODBC::Column::operator Glib::ustring() const { + return Glib::ustring((const char *)((dynamic_cast<const _Column<SQLCHAR*>& >(*this)).value)); +} ODBC::Column::operator std::string() const { return (const char*)((dynamic_cast<const _Column<SQLCHAR*>& >(*this)).value); } @@ -65,7 +73,10 @@ namespace ODBC { REBIND(double, bindParamF) REBIND(float, bindParamF) REBIND(SQL_TIMESTAMP_STRUCT, bindParamT) - REBIND(unsigned char *, bindParamS) + template<> void _Column<unsigned char *>::rebind(Command * cmd, unsigned int col) const \ + { + cmd->bindParamS(col, (char *)value); + } template <> int |