extensions/sqlite/driver/SqQuery.h
changeset 1203 633c25ce6405
child 1210 18e60c8737a2
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/sqlite/driver/SqQuery.h	Sun Jul 29 01:15:31 2007 +0000
     1.3 @@ -0,0 +1,86 @@
     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_QUERY_H_
    1.28 +#define _INCLUDE_SQLITE_SOURCEMOD_QUERY_H_
    1.29 +
    1.30 +#include "SqDatabase.h"
    1.31 +#include "SqResults.h"
    1.32 +
    1.33 +class SqQuery : 
    1.34 +	public IPreparedQuery
    1.35 +{
    1.36 +public:
    1.37 +	SqQuery(SqDatabase *parent, sqlite3_stmt *stmt);
    1.38 +	~SqQuery();
    1.39 +public: //IQuery
    1.40 +	IResultSet *GetResultSet();
    1.41 +	bool FetchMoreResults();
    1.42 +	void Destroy();
    1.43 +public: //IPreparedQuery
    1.44 +	bool BindParamInt(unsigned int param, int num, bool signd=true);
    1.45 +	bool BindParamFloat(unsigned int param, float f);
    1.46 +	bool BindParamNull(unsigned int param);
    1.47 +	bool BindParamString(unsigned int param, const char *text, bool copy);
    1.48 +	bool BindParamBlob(unsigned int param, const void *data, size_t length, bool copy);
    1.49 +	bool Execute();
    1.50 +	const char *GetError(int *errCode=NULL);
    1.51 +	unsigned int GetAffectedRows();
    1.52 +	unsigned int GetInsertID();
    1.53 +public: //IResultSet
    1.54 +	unsigned int GetRowCount();
    1.55 +	unsigned int GetFieldCount();
    1.56 +	const char *FieldNumToName(unsigned int columnId);
    1.57 +	bool FieldNameToNum(const char *name, unsigned int *columnId);
    1.58 +	bool MoreRows();
    1.59 +	IResultRow *FetchRow();
    1.60 +	IResultRow *CurrentRow();
    1.61 +	bool Rewind();
    1.62 +	DBType GetFieldType(unsigned int field);
    1.63 +	DBType GetFieldDataType(unsigned int field);
    1.64 +public: //IResultRow
    1.65 +	DBResult GetString(unsigned int columnId, const char **pString, size_t *length);
    1.66 +	DBResult CopyString(unsigned int columnId, 
    1.67 +		char *buffer, 
    1.68 +		size_t maxlength, 
    1.69 +		size_t *written);
    1.70 +	DBResult GetFloat(unsigned int columnId, float *pFloat);
    1.71 +	DBResult GetInt(unsigned int columnId, int *pInt);
    1.72 +	bool IsNull(unsigned int columnId);
    1.73 +	size_t GetDataSize(unsigned int columnId);
    1.74 +	DBResult GetBlob(unsigned int columnId, const void **pData, size_t *length);
    1.75 +	DBResult CopyBlob(unsigned int columnId, void *buffer, size_t maxlength, size_t *written);
    1.76 +public:
    1.77 +	sqlite3_stmt *GetStmt();
    1.78 +private:
    1.79 +	SqDatabase *m_pParent;
    1.80 +	sqlite3_stmt *m_pStmt;
    1.81 +	SqResults *m_pResults;
    1.82 +	unsigned int m_ParamCount;
    1.83 +	String m_LastError;
    1.84 +	int m_LastErrorCode;
    1.85 +	unsigned int m_AffectedRows;
    1.86 +	unsigned int m_InsertID;
    1.87 +};
    1.88 +
    1.89 +#endif //_INCLUDE_SQLITE_SOURCEMOD_QUERY_H_