00001 /* 00002 * This file is part of the Standard Portable Library (SPL). 00003 * 00004 * SPL is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * SPL is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with SPL. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef _sqlliteconnection_h 00018 #define _sqlliteconnection_h 00019 00020 #include <spl/types.h> 00021 #include <spl/Debug.h> 00022 #include <spl/data/Connection.h> 00023 #include <spl/RefCountPtr.h> 00024 #include <spl/String.h> 00025 #include <spl/WeakReference.h> 00026 00033 class SqlLiteConnection; 00034 typedef RefCountPtrCast<SqlLiteConnection, Connection, ConnectionPtr> SqlLiteConnectionPtr; 00035 typedef WeakReference<SqlLiteConnection, SqlLiteConnectionPtr> SqlLiteConnectionRef; 00036 00040 class SqlLiteConnection : public Connection 00041 { 00042 private: 00043 // Copy constructor doesn't make sense for this class 00044 inline SqlLiteConnection(const SqlLiteConnection& con) : Connection("", "", "", "") {} 00045 inline void operator =(const SqlLiteConnection& con) {} 00046 00047 protected: 00048 void *m_db; //< Actually a pointer to sqlite3 00049 00050 public: 00051 SqlLiteConnection(const String& databaseFilename); 00052 virtual ~SqlLiteConnection(); 00053 00055 virtual void Open(); 00056 00058 virtual void Close(); 00059 00061 virtual void ChangeDatabase(const String& dbFilename); 00062 00063 virtual TransactionPtr BeginTransaction(); 00064 virtual CommandPtr CreateCommand(); 00065 virtual CommandPtr CreateCommand(const String& cmdText); 00066 00067 virtual int ExecuteNonQuery(const String& sql); 00068 virtual RecordSetPtr ExecuteQuery(const String& sql); 00069 00071 virtual void RegisterThread(); 00072 00074 virtual void RegisterThreadExit(); 00075 00077 virtual void AllowOutOfOrderCommandParameters(bool allow); 00078 00079 #if defined(DEBUG) 00080 virtual void CheckMem() const; 00081 virtual void ValidateMem() const; 00082 #endif 00083 }; 00084 00085 REGISTER_TYPEOF( 430, SqlLiteConnection ); 00086 REGISTER_TYPEOF( 432, SqlLiteConnectionPtr ); 00087 REGISTER_TYPEOF( 434, SqlLiteConnectionRef ); 00088 00091 #endif