Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

db.DbQuery_ODBC.h

00001 /*----------------------------------------------------------------------------
00002   SWORD 2000 - Software With Objects for Rapid Development
00003   Copyright (C) 2003 Eric NICOLAS
00004   ----------------------------------------------------------------------------
00005   SWORD is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU Lesser General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   SWORD is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public License
00016   along with SWORD; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018   --------------------------------------------------------------------------*/
00019 #ifndef _SWORD_DB_DBQUERY_ODBC_
00020 #define _SWORD_DB_DBQUERY_ODBC_
00021 
00022 // This is available only if you have enabled the "db.odbc" feature
00023 #ifdef HAVE_DB_ODBC
00024 
00025 #include "sword/db.DbQuery.h"
00026 #include "sword/db.DbConnection_ODBC.h"
00027 #include <map>
00028 
00029 namespace sword {
00030 
00031   class SWORDDECL DbQuery_ODBC : public DbQuery {
00032   public:
00033     DbQuery_ODBC(DbConnection_ODBC* con, int timeout = 120);
00034     virtual ~DbQuery_ODBC();
00035 
00036     virtual bool exec(const std::string& sql, bool reportWarningsAsErrors = true);
00037     virtual bool nextRow();
00038     virtual bool nextSet();
00039     virtual int  columns();
00040 
00041     virtual Variant     get(word column);
00042     virtual Variant     get(const std::string& column);
00043 
00044   private:
00045     DbConnection_ODBC* con_;
00046     SQLHSTMT           dbs_;
00047     int                columns_;
00048     // columns type description
00049     typedef std::vector<Variant::Type> ColumnTypes;
00050     ColumnTypes        columnTypes_;
00051     bool               columnTypesReady_;
00052     // columns names
00053     typedef std::vector<std::string> ColumnNames;
00054     ColumnNames        columnNames_;
00055     typedef std::map<std::string, word> ColumnPositions;
00056     ColumnPositions    columnPositions_;
00057     // row data
00058     typedef std::vector<Variant> RowData;
00059     RowData            row_;
00060     bool               rowReady_;
00061 
00062     void reportError_(const std::string& message);
00063     bool firstRow_();
00064     bool nextSet_();
00065 
00066     void fetchRow_();
00067     void fetchColumnTypes_();
00068 
00069     word columnPosition_(const std::string& columnName);
00070   };
00071 
00072 } // namespace sword
00073 
00074 #endif // HAVE_DB_ODBC
00075 
00076 #endif // _SWORD_DB_DBQUERY_ODBC_

Generated on Tue Dec 23 20:08:56 2003 for SWORD by doxygen1.3-rc2