extensions/sqlite/driver/SqDatabase.h
changeset 1203 633c25ce6405
child 1226 478550a4d5ec
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/sqlite/driver/SqDatabase.h	Sun Jul 29 01:15:31 2007 +0000
     1.3 @@ -0,0 +1,60 @@
     1.4 +/**
     1.5 + * vim: set ts=4 :
     1.6 + * ===============================================================
     1.7 + * SourceMod SQLite Driver Extension
     1.8 + * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
     1.9 + * ===============================================================
    1.10 + *
    1.11 + * This program is free software; you can redistribute it and/or
    1.12 + * modify it under the terms of the GNU General Public License
    1.13 + * as published by the Free Software Foundation; either version 2
    1.14 + * of the License, or (at your option) any later version.
    1.15 + * This program is distributed in the hope that it will be useful,
    1.16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.18 + * GNU General Public License for more details.
    1.19 + * 
    1.20 + * You should have received a copy of the GNU General Public License
    1.21 + * along with this program; if not, write to the Free Software
    1.22 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    1.23 + *
    1.24 + * Version: $Id$
    1.25 + */
    1.26 +
    1.27 +#ifndef _INCLUDE_SQLITE_SOURCEMOD_DATABASE_H_
    1.28 +#define _INCLUDE_SQLITE_SOURCEMOD_DATABASE_H_
    1.29 +
    1.30 +#include <IThreader.h>
    1.31 +#include "SqDriver.h"
    1.32 +
    1.33 +class SqDatabase : public IDatabase
    1.34 +{
    1.35 +public:
    1.36 +	SqDatabase(sqlite3 *sq3, bool persistent);
    1.37 +	~SqDatabase();
    1.38 +public:
    1.39 +	bool Close();
    1.40 +	const char *GetError(int *errorCode=NULL);
    1.41 +	bool DoSimpleQuery(const char *query);
    1.42 +	IQuery *DoQuery(const char *query);
    1.43 +	IPreparedQuery *PrepareQuery(const char *query, char *error, size_t maxlength, int *errCode=NULL);
    1.44 +	bool QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newSize);
    1.45 +	unsigned int GetAffectedRows();
    1.46 +	unsigned int GetInsertID();
    1.47 +	bool LockForFullAtomicOperation();
    1.48 +	void UnlockFromFullAtomicOperation();
    1.49 +	void IncReferenceCount();
    1.50 +	IDBDriver *GetDriver();
    1.51 +public:
    1.52 +	sqlite3 *GetDb();
    1.53 +private:
    1.54 +	sqlite3 *m_sq3;
    1.55 +	unsigned int m_refcount;
    1.56 +	IMutex *m_pFullLock;
    1.57 +	IMutex *m_pRefLock;
    1.58 +	bool m_Persistent;
    1.59 +	String m_LastError;
    1.60 +	int m_LastErrorCode;
    1.61 +};
    1.62 +
    1.63 +#endif //_INCLUDE_SQLITE_SOURCEMOD_DATABASE_H_