extensions/sqlite/driver/SqDriver.h
author Scott Ehlert <ds@alliedmods.net>
Sun Mar 30 07:00:22 2008 +0000 (2008-03-30)
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Spring Cleaning, Part Ichi (1)
Various minor things done to project files
Updated sample extension project file and updated makefile to the new unified version (more changes likely on the way)
Updated regex project file and makefile
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod SQLite Extension
     5  * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     6  * =============================================================================
     7  *
     8  * This program is free software; you can redistribute it and/or modify it under
     9  * the terms of the GNU General Public License, version 3.0, as published by the
    10  * Free Software Foundation.
    11  * 
    12  * This program is distributed in the hope that it will be useful, but WITHOUT
    13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    15  * details.
    16  *
    17  * You should have received a copy of the GNU General Public License along with
    18  * this program.  If not, see <http://www.gnu.org/licenses/>.
    19  *
    20  * As a special exception, AlliedModders LLC gives you permission to link the
    21  * code of this program (as well as its derivative works) to "Half-Life 2," the
    22  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    23  * by the Valve Corporation.  You must obey the GNU General Public License in
    24  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    25  * this exception to all derivative works.  AlliedModders LLC defines further
    26  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    27  * or <http://www.sourcemod.net/license.php>.
    28  *
    29  * Version: $Id$
    30  */
    31 
    32 #ifndef _INCLUDE_SQLITE_SOURCEMOD_DRIVER_H_
    33 #define _INCLUDE_SQLITE_SOURCEMOD_DRIVER_H_
    34 
    35 #include <IDBDriver.h>
    36 #include <IThreader.h>
    37 #include <sh_list.h>
    38 #include <sh_string.h>
    39 #include "sqlite-source/sqlite3.h"
    40 
    41 using namespace SourceMod;
    42 using namespace SourceHook;
    43 
    44 struct SqDbInfo
    45 {
    46 	String path;
    47 	IDatabase *db;
    48 };
    49 
    50 /**
    51  * Tee-hee.. sounds like "screw driver," except maybe if
    52  * Elmer Fudd was saying it.
    53  */
    54 class SqDriver : public IDBDriver
    55 {
    56 public:
    57 	SqDriver();
    58 	void Initialize();
    59 	void Shutdown();
    60 public:
    61 	IDatabase *Connect(const DatabaseInfo *info, bool persistent, char *error, size_t maxlength);
    62 	const char *GetIdentifier();
    63 	const char *GetProductName();
    64 	Handle_t GetHandle();
    65 	IdentityToken_t *GetIdentity();
    66 	bool IsThreadSafe();
    67 	bool InitializeThreadSafety();
    68 	void ShutdownThreadSafety();
    69 public:
    70 	void RemovePersistent(IDatabase *pdb);
    71 private:
    72 	Handle_t m_Handle;
    73 	IMutex *m_pOpenLock;
    74 	List<SqDbInfo> m_Cache;
    75 	bool m_bThreadSafe;
    76 };
    77 
    78 extern SqDriver g_SqDriver;
    79 
    80 unsigned int strncopy(char *dest, const char *src, size_t count);
    81 
    82 #endif //_INCLUDE_SQLITE_SOURCEMOD_DRIVER_H_