00001 // LICENSE: (Please see the file COPYING for details) 00002 // 00003 // NUS - Nemesis Utilities System: A C++ application development framework 00004 // Copyright (C) 2006, 2008 Otavio Rodolfo Piske 00005 // 00006 // This file is part of NUS 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Lesser General Public 00010 // License as published by the Free Software Foundation version 2.1 00011 // of the License. 00012 // 00013 // This library 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 GNU 00016 // Lesser General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU Lesser General Public 00019 // License along with this library; if not, write to the Free Software 00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 // 00022 #ifndef NSQL_H_ 00023 #define NSQL_H_ 00024 00025 #include "nobject.h" 00026 #include "nstring.h" 00027 #include "nhostaddress.h" 00028 #include "nsqlquery.h" 00029 #include "nsqlrecord.h" 00030 00040 class NSql: public NObject { 00041 public: 00045 NSql(void); 00046 00053 NSql(const NString &user, const NString &pass, 00054 const NHostAddress &host); 00055 00056 00064 NSql(const NString &user, const NString &pass, 00065 const NHostAddress &host, nint16 port); 00066 00067 00071 virtual ~NSql(void); 00072 00077 virtual void setUser(const NString &user); 00078 00083 virtual void setPassword(const NString &pass); 00084 00089 virtual void setHost(const NHostAddress &host); 00090 00095 virtual void setPort(nint16 port); 00096 00101 virtual void setDatabase(const NString &database); 00102 00103 00108 virtual NString getUser(void) const; 00109 00114 virtual NString getPassword(void) const; 00115 00120 virtual NHostAddress getHost(void) const; 00121 00126 virtual nint16 getPort(void) const; 00127 00132 virtual NString getDatabase(void) const; 00133 00134 00138 virtual void connectToHost(void) = 0; 00139 00143 virtual void disconnectFromHost(void) = 0; 00144 00145 00151 virtual bool execSql(const NSqlQuery &query) = 0; 00152 00153 00158 virtual NSqlRecord *getNext(void) = 0; 00159 00160 00165 virtual NSqlRecord *getPrevious(void) = 0; 00166 00171 virtual NSqlRecord *getFirst(void) = 0; 00172 00177 virtual NSqlRecord *getLast(void) = 0; 00178 00179 00184 virtual NString getError(void) const = 0; 00185 00186 protected: 00187 NString m_user; 00188 NString m_password; 00189 NHostAddress m_host; 00190 nint16 m_port; 00191 NString m_database; 00192 00193 void setRecordData(NSqlRecord *record, const NString &rowName, 00194 const NVtype &rowData); 00195 00196 private: 00197 NSql(const NSql &other); 00198 NSql &operator=(const NSql &rhs); 00199 }; 00200 00201 #endif // NSQL_H_