// * Sun Jul 19 17:54:39 JST 2015 Naoyuki Sawa
// - Win32僾儘僕僃僋僩梡偺SQLite僒億乕僩儌僕儏乕儖偱偡丅
//   test.win/extclip.h傪嶲徠偟偰偔偩偝偄丅
// - 尰帪揰偱偼丄P/ECE僾儘僕僃僋僩偱偼巊梡偟傑偣傫丅
//   傕偟彨棃丄P/ECE偱SQLite偑摦嶌偡傞傛偆偵弌棃偨傜丄巊梡偡傞偐傕抦傟傑偣傫丅
#ifndef __RECORDSET_H__
/****************************************************************************
 *	
 ****************************************************************************/
int sqlite_compile_vprintf(sqlite* db, const char* sqlFormat, const char** pzTail, sqlite_vm** ppVm, char** pzErrmsg, va_list ap);
int sqlite_compile_printf(sqlite* db, const char* sqlFormat, const char** pzTail, sqlite_vm** ppVm, char** pzErrmsg, ...);
/****************************************************************************
 *	
 ****************************************************************************/
typedef struct _ST_Recordset_r {
	sqlite_vm*		vm;		//壖憐儅僔儞
	int			nCol;		//僇儔儉悢
	const char**		aVal;		//僇儔儉抣偺攝楍
	const char**		aCol;		//僇儔儉柤偺攝楍
} ST_Recordset_r;
/*--------------------------------------------------------------------------*/
ST_Recordset_r* Recordset_Open(sqlite* db, const char* sSql, ...);
void Recordset_Close(ST_Recordset_r* rs);
ST_Recordset_r* Recordset_Next(ST_Recordset_r* rs);
/*--------------------------------------------------------------------------*/
int Recordset_Count(ST_Recordset_r* rs);
int Recordset_ColNI(ST_Recordset_r* rs, const char* sNam);			//Name仺Index
int Recordset_ColVI(ST_Recordset_r* rs, const char* sFmt, va_list ap);		//va_list仺Index
int Recordset_ColFI(ST_Recordset_r* rs, const char* sNam, ...);			//NameFormat仺Index
const char* Recordset_ColIN(ST_Recordset_r* rs, int iIdx);			//Index仺Name
/*--------------------------------------------------------------------------*/
int Recordset_GetIN(ST_Recordset_r* rs, int iIdx);				//Index仺Numeric
int Recordset_GetNN(ST_Recordset_r* rs, const char* sNam);			//Name仺Numeric
int Recordset_GetVN(ST_Recordset_r* rs, const char* sFmt, va_list ap);		//va_list仺Numeric
int Recordset_GetFN(ST_Recordset_r* rs, const char* sFmt, ...);			//Format仺Numeric
const char* Recordset_GetIT(ST_Recordset_r* rs, int iIdx);			//Index仺Text
const char* Recordset_GetNT(ST_Recordset_r* rs, const char* sNam);		//Name仺Text
const char* Recordset_GetVT(ST_Recordset_r* rs, const char* sFmt, va_list ap);	//va_list仺Text
const char* Recordset_GetFT(ST_Recordset_r* rs, const char* sFmt, ...);		//Format仺Text
/****************************************************************************
 *	
 ****************************************************************************/
typedef struct _ST_Recordset_w {
	sqlite*			db;		//僨乕僞儀乕僗
	char*			sTbl;		//僥乕僽儖柤
	ght_hash_table_t*	ht;		//僴僢僔儏僥乕僽儖	僇儔儉柤仺僇儔儉抣
} ST_Recordset_w;
/*--------------------------------------------------------------------------*/
ST_Recordset_w* Recordset_New(sqlite* db, const char* sTbl);
void Recordset_Cancel(ST_Recordset_w* rs);
void Recordset_Insert(ST_Recordset_w* rs);
void Recordset_Update(ST_Recordset_w* rs, const char* sWhere/*NULL壜*/, ...);
/*--------------------------------------------------------------------------*/
void Recordset_SetNN(ST_Recordset_w* rs, int iNum, const char* sNam);					//Name仼Numeric
void Recordset_SetVN(ST_Recordset_w* rs, int iNum, const char* sFmt, va_list ap);			//va_list仼Numeric
void Recordset_SetFN(ST_Recordset_w* rs, int iNum, const char* sFmt, ...);				//Format仼Numeric
void Recordset_SetNT(ST_Recordset_w* rs, const char* sTxt/*NULL壜*/, const char* sNam);			//Name仼Text
void Recordset_SetVT(ST_Recordset_w* rs, const char* sTxt/*NULL壜*/, const char* sFmt, va_list ap);	//va_list仼Text
void Recordset_SetFT(ST_Recordset_w* rs, const char* sTxt/*NULL壜*/, const char* sFmt, ...);		//Format仼Text
void Recordset_SetNE(ST_Recordset_w* rs, const char* sExp, const char* sNam);				//Name仼Expr
void Recordset_SetVE(ST_Recordset_w* rs, const char* sExp, const char* sFmt, va_list ap);		//va_list仼Expr
void Recordset_SetFE(ST_Recordset_w* rs, const char* sExp, const char* sFmt, ...);			//Format仼Expr
#endif//__RECORDSET_H__
