Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

rtkinputsql.h

00001 /*<<<<<COPYRIGHT*/
00002 /*
00003  * RTK The report toolkit
00004  * Copyright (C) 2003 Francisco Santiago Capel Torres
00005 
00006  * rtkinputsql.h RTK standard sql input object
00007  * 
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  */
00019 /*>>>>>COPYRIGHT*/
00020 #ifndef RTKINPUTSQL_H
00021 #define RTKINPUTSQL_H
00022 
00023 #include <qsqldatabase.h>
00024 #include <qsqlquery.h>
00025 #include <qsqlerror.h>
00026 
00027 #include "rtkinput.h"
00028 
00029 
00030 namespace RTK
00031 {
00032 
00033 class InputSql : public Input
00034 {
00035         /*<<<<<INPUTSQL_CONSTRUCTOR*/
00036 public:
00037         InputSql(const String& sqldriver = String::null, const String& host = String::null, 
00038                 int port = 0, const String& user = String::null, const String& password = String::null, 
00039                 const String& database = String::null, const String& from = String::null, const String& where = String::null, const String& orderby = String::null,
00040         const String& name = String::null, const String& driver = String::null)
00041         :Input(name, driver),
00042         mSqlDriver(sqldriver), mHost(host), 
00043                 mPort(port), mUser(user), mPassword(password), 
00044                 mDatabase(database), mFrom(from), mWhere(where), mOrderBy(orderby)
00045 /*>>>>>INPUTSQL_CONSTRUCTOR*/
00046                         , pQuery( 0 ), mExternalQuery( false )
00047         {};
00048 
00049         ~InputSql();
00050 
00051         virtual void setQuery( QSqlQuery *query );
00052         virtual bool init();
00053         virtual bool next();
00054         virtual Variant getValue( uint i );
00055         virtual Variant getValue( const String &/*fldname*/ );
00056 
00057         /*<<<<<INPUTSQL_GETSET*/
00058 public:
00059         const String& getSqlDriver() const { return mSqlDriver; };
00060         void setSqlDriver(const String& sqldriver) { mSqlDriver = sqldriver; };
00061         const String& getHost() const { return mHost; };
00062         void setHost(const String& host) { mHost = host; };
00063         int getPort() const { return mPort; };
00064         void setPort(int port) { mPort = port; };
00065         const String& getUser() const { return mUser; };
00066         void setUser(const String& user) { mUser = user; };
00067         const String& getPassword() const { return mPassword; };
00068         void setPassword(const String& password) { mPassword = password; };
00069         const String& getDatabase() const { return mDatabase; };
00070         void setDatabase(const String& database) { mDatabase = database; };
00071         const String& getFrom() const { return mFrom; };
00072         void setFrom(const String& from) { mFrom = from; };
00073         const String& getWhere() const { return mWhere; };
00074         void setWhere(const String& where) { mWhere = where; };
00075         const String& getOrderBy() const { return mOrderBy; };
00076         void setOrderBy(const String& orderby) { mOrderBy = orderby; };
00077 protected:
00078         String mSqlDriver;
00079         String mHost;
00080         int mPort;
00081         String mUser;
00082         String mPassword;
00083         String mDatabase;
00084         String mFrom;
00085         String mWhere;
00086         String mOrderBy;
00087 /*>>>>>INPUTSQL_GETSET*/
00088 private:
00089         int fieldPos( const String &name ) const;
00090 
00091         QSqlQuery *pQuery;
00092         bool mExternalQuery;
00093         int handleError( QSqlDatabase *db, QSqlError dberr );
00094         QValueList<String>mFieldNames;
00095         QValueList<Variant::Type>mFieldTypes;
00096 
00097 };
00098 
00099 }; // namespace
00100 
00101 #endif
00102 

Generated on Tue Feb 22 14:44:37 2005 for RTK. Report ToolKit by  doxygen 1.3.9.1