dvander@1203: /**
dvander@1203: * vim: set ts=4 :
ds@1330: * =============================================================================
dvander@1226: * SourceMod SQLite Extension
ds@1947: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
dvander@1203: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
dvander@1226: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
dvander@1226: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
dvander@1226: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
dvander@1203: *
dvander@1203: * Version: $Id$
dvander@1203: */
dvander@1203:
dvander@1203: #ifndef _INCLUDE_SQLITE_SOURCEMOD_QUERY_H_
dvander@1203: #define _INCLUDE_SQLITE_SOURCEMOD_QUERY_H_
dvander@1203:
dvander@1203: #include "SqDatabase.h"
dvander@1203: #include "SqResults.h"
dvander@1203:
dvander@1203: class SqQuery :
dvander@1203: public IPreparedQuery
dvander@1203: {
dvander@1203: public:
dvander@1203: SqQuery(SqDatabase *parent, sqlite3_stmt *stmt);
dvander@1203: ~SqQuery();
dvander@1203: public: //IQuery
dvander@1203: IResultSet *GetResultSet();
dvander@1203: bool FetchMoreResults();
dvander@1203: void Destroy();
dvander@1203: public: //IPreparedQuery
dvander@1203: bool BindParamInt(unsigned int param, int num, bool signd=true);
dvander@1203: bool BindParamFloat(unsigned int param, float f);
dvander@1203: bool BindParamNull(unsigned int param);
dvander@1203: bool BindParamString(unsigned int param, const char *text, bool copy);
dvander@1203: bool BindParamBlob(unsigned int param, const void *data, size_t length, bool copy);
dvander@1203: bool Execute();
dvander@1203: const char *GetError(int *errCode=NULL);
dvander@1203: unsigned int GetAffectedRows();
dvander@1203: unsigned int GetInsertID();
dvander@1203: public: //IResultSet
dvander@1203: unsigned int GetRowCount();
dvander@1203: unsigned int GetFieldCount();
dvander@1203: const char *FieldNumToName(unsigned int columnId);
dvander@1203: bool FieldNameToNum(const char *name, unsigned int *columnId);
dvander@1203: bool MoreRows();
dvander@1203: IResultRow *FetchRow();
dvander@1203: IResultRow *CurrentRow();
dvander@1203: bool Rewind();
dvander@1203: DBType GetFieldType(unsigned int field);
dvander@1203: DBType GetFieldDataType(unsigned int field);
dvander@1203: public: //IResultRow
dvander@1203: DBResult GetString(unsigned int columnId, const char **pString, size_t *length);
dvander@1203: DBResult CopyString(unsigned int columnId,
dvander@1203: char *buffer,
dvander@1203: size_t maxlength,
dvander@1203: size_t *written);
dvander@1203: DBResult GetFloat(unsigned int columnId, float *pFloat);
dvander@1203: DBResult GetInt(unsigned int columnId, int *pInt);
dvander@1203: bool IsNull(unsigned int columnId);
dvander@1203: size_t GetDataSize(unsigned int columnId);
dvander@1203: DBResult GetBlob(unsigned int columnId, const void **pData, size_t *length);
dvander@1203: DBResult CopyBlob(unsigned int columnId, void *buffer, size_t maxlength, size_t *written);
dvander@1203: public:
dvander@1203: sqlite3_stmt *GetStmt();
dvander@1203: private:
dvander@1203: SqDatabase *m_pParent;
dvander@1203: sqlite3_stmt *m_pStmt;
dvander@1203: SqResults *m_pResults;
dvander@1203: unsigned int m_ParamCount;
dvander@1203: String m_LastError;
dvander@1203: int m_LastErrorCode;
dvander@1203: unsigned int m_AffectedRows;
dvander@1203: unsigned int m_InsertID;
dvander@1210: unsigned int m_ColCount;
dvander@1203: };
dvander@1203:
dvander@1203: #endif //_INCLUDE_SQLITE_SOURCEMOD_QUERY_H_