wasCSharpSQLite – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 *************************************************************************
3 ** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
4 ** C#-SQLite is an independent reimplementation of the SQLite software library
5 *************************************************************************
6 */
7  
8 using System;
9 using System.Text;
10 using HANDLE = System.IntPtr;
11 using i16 = System.Int16;
12 using sqlite3_int64 = System.Int64;
13 using u32 = System.UInt32;
14  
15  
16 namespace Community.CsharpSqlite
17 {
18 using DbPage = Sqlite3.PgHdr;
19 using sqlite3_pcache = Sqlite3.PCache1;
20 using sqlite3_stmt = Sqlite3.Vdbe;
21 using sqlite3_value = Sqlite3.Mem;
22  
23 public partial class Sqlite3
24 {
25 public delegate void dxAuth( object pAuthArg, int b, string c, string d, string e, string f );
26 public delegate int dxBusy( object pBtShared, int iValue );
27 public delegate void dxFreeAux( object pAuxArg );
28 public delegate int dxCallback( object pCallbackArg, sqlite3_int64 argc, object p2, object p3 );
29 public delegate void dxalarmCallback( object pNotUsed, sqlite3_int64 iNotUsed, int size );
30 public delegate void dxCollNeeded( object pCollNeededArg, sqlite3 db, int eTextRep, string collationName );
31 public delegate int dxCommitCallback( object pCommitArg );
32 public delegate int dxCompare( object pCompareArg, int size1, string Key1, int size2, string Key2 );
33 public delegate bool dxCompare4( string Key1, int size1, string Key2, int size2 );
34 public delegate void dxDel( ref string pDelArg ); // needs ref
35 public delegate void dxDelCollSeq( ref object pDelArg ); // needs ref
36 public delegate void dxLog( object pLogArg, int i, string msg );
37 public delegate void dxLogcallback( object pCallbackArg, int argc, string p2 );
38 public delegate void dxProfile( object pProfileArg, string msg, sqlite3_int64 time );
39 public delegate int dxProgress( object pProgressArg );
40 public delegate void dxRollbackCallback( object pRollbackArg );
41 public delegate void dxTrace( object pTraceArg, string msg );
42 public delegate void dxUpdateCallback( object pUpdateArg, int b, string c, string d, sqlite3_int64 e );
43 public delegate int dxWalCallback( object pWalArg, sqlite3 db, string zDb, int nEntry );
44  
45 /*
46 * FUNCTIONS
47 *
48 */
49 public delegate void dxFunc( sqlite3_context ctx, int intValue, sqlite3_value[] value );
50 public delegate void dxStep( sqlite3_context ctx, int intValue, sqlite3_value[] value );
51 public delegate void dxFinal( sqlite3_context ctx );
52 public delegate void dxFDestroy( object pArg );
53 //
54 public delegate string dxColname( sqlite3_value pVal );
55 public delegate int dxFuncBtree( Btree p );
56 public delegate int dxExprTreeFunction( ref int pArg, Expr pExpr );
57 public delegate int dxExprTreeFunction_NC( NameContext pArg, ref Expr pExpr );
58 public delegate int dxExprTreeFunction_OBJ( object pArg, Expr pExpr );
59 /*
60 VFS Delegates
61 */
62 public delegate int dxClose( sqlite3_file File_ID );
63 public delegate int dxCheckReservedLock( sqlite3_file File_ID, ref int pRes );
64 public delegate int dxDeviceCharacteristics( sqlite3_file File_ID );
65 public delegate int dxFileControl( sqlite3_file File_ID, int op, ref sqlite3_int64 pArgs );
66 public delegate int dxFileSize( sqlite3_file File_ID, ref long size );
67 public delegate int dxLock( sqlite3_file File_ID, int locktype );
68 public delegate int dxRead( sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset );
69 public delegate int dxSectorSize( sqlite3_file File_ID );
70 public delegate int dxSync( sqlite3_file File_ID, int flags );
71 public delegate int dxTruncate( sqlite3_file File_ID, sqlite3_int64 size );
72 public delegate int dxUnlock( sqlite3_file File_ID, int locktype );
73 public delegate int dxWrite( sqlite3_file File_ID, byte[] buffer, int amount, sqlite3_int64 offset );
74 public delegate int dxShmMap( sqlite3_file File_ID, int iPg, int pgsz, int pInt, out object pvolatile );
75 public delegate int dxShmLock( sqlite3_file File_ID, int offset, int n, int flags );
76 public delegate void dxShmBarrier( sqlite3_file File_ID );
77 public delegate int dxShmUnmap( sqlite3_file File_ID, int deleteFlag );
78 /*
79 sqlite_vfs Delegates
80 */
81 public delegate int dxOpen( sqlite3_vfs vfs, string zName, sqlite3_file db, int flags, out int pOutFlags );
82 public delegate int dxDelete( sqlite3_vfs vfs, string zName, int syncDir );
83 public delegate int dxAccess( sqlite3_vfs vfs, string zName, int flags, out int pResOut );
84 public delegate int dxFullPathname( sqlite3_vfs vfs, string zName, int nOut, StringBuilder zOut );
85 public delegate HANDLE dxDlOpen( sqlite3_vfs vfs, string zFilename );
86 public delegate int dxDlError( sqlite3_vfs vfs, int nByte, string zErrMsg );
87 public delegate HANDLE dxDlSym( sqlite3_vfs vfs, HANDLE data, string zSymbol );
88 public delegate int dxDlClose( sqlite3_vfs vfs, HANDLE data );
89 public delegate int dxRandomness( sqlite3_vfs vfs, int nByte, byte[] buffer );
90 public delegate int dxSleep( sqlite3_vfs vfs, int microseconds );
91 public delegate int dxCurrentTime( sqlite3_vfs vfs, ref double currenttime );
92 public delegate int dxGetLastError( sqlite3_vfs pVfs, int nBuf, ref string zBuf );
93 public delegate int dxCurrentTimeInt64( sqlite3_vfs pVfs, ref sqlite3_int64 pTime );
94 public delegate int dxSetSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr );
95 public delegate int dxGetSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr );
96 public delegate int dxNextSystemCall( sqlite3_vfs pVfs, string zName, sqlite3_int64 sqlite3_syscall_ptr );
97  
98 /*
99 * Pager Delegates
100 */
101  
102 public delegate void dxDestructor( DbPage dbPage ); /* Call this routine when freeing pages */
103 public delegate int dxBusyHandler( object pBusyHandlerArg );
104 public delegate void dxReiniter( DbPage dbPage ); /* Call this routine when reloading pages */
105  
106 public delegate void dxFreeSchema( Schema schema );
107  
108 #if SQLITE_HAS_CODEC
109 public delegate byte[] dxCodec( codec_ctx pCodec, byte[] D, uint pageNumber, int X ); //void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
110 public delegate void dxCodecSizeChng( codec_ctx pCodec, int pageSize, i16 nReserve ); //void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
111 public delegate void dxCodecFree( ref codec_ctx pCodec ); //void (*xCodecFree)(void); /* Destructor for the codec */
112 #endif
113  
114 //Module
115 public delegate void dxDestroy( ref PgHdr pDestroyArg );
116 public delegate int dxStress( object obj, PgHdr pPhHdr );
117  
118 //sqlite3_module
119 public delegate int smdxCreateConnect( sqlite3 db, object pAux, int argc, string[] constargv, out sqlite3_vtab ppVTab, out string pError );
120 public delegate int smdxBestIndex( sqlite3_vtab pVTab, ref sqlite3_index_info pIndex );
121 public delegate int smdxDisconnect( ref object pVTab );
122 public delegate int smdxDestroy(ref object pVTab );
123 public delegate int smdxOpen( sqlite3_vtab pVTab, out sqlite3_vtab_cursor ppCursor );
124 public delegate int smdxClose( ref sqlite3_vtab_cursor pCursor );
125 public delegate int smdxFilter( sqlite3_vtab_cursor pCursor, int idxNum, string idxStr, int argc, sqlite3_value[] argv );
126 public delegate int smdxNext( sqlite3_vtab_cursor pCursor );
127 public delegate int smdxEof( sqlite3_vtab_cursor pCursor );
128 public delegate int smdxColumn( sqlite3_vtab_cursor pCursor, sqlite3_context p2, int p3 );
129 public delegate int smdxRowid( sqlite3_vtab_cursor pCursor, out sqlite3_int64 pRowid );
130 public delegate int smdxUpdate( sqlite3_vtab pVTab, int p1, sqlite3_value[] p2, out sqlite3_int64 p3 );
131 public delegate int smdxFunction ( sqlite3_vtab pVTab );
132 public delegate int smdxFindFunction( sqlite3_vtab pVtab, int nArg, string zName, ref dxFunc pxFunc, ref object ppArg );
133 public delegate int smdxRename( sqlite3_vtab pVtab, string zNew );
134 public delegate int smdxFunctionArg (sqlite3_vtab pVTab, int nArg );
135  
136 //AutoExtention
137 public delegate int dxInit( sqlite3 db, ref string zMessage, sqlite3_api_routines sar );
138 #if !SQLITE_OMIT_VIRTUALTABLE
139 public delegate int dmxCreate(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7);
140 public delegate int dmxConnect(sqlite3 db, object pAux, int argc, string p4, object argv, sqlite3_vtab ppVTab, char p7);
141 public delegate int dmxBestIndex(sqlite3_vtab pVTab, ref sqlite3_index_info pIndexInfo);
142 public delegate int dmxDisconnect(sqlite3_vtab pVTab);
143 public delegate int dmxDestroy(sqlite3_vtab pVTab);
144 public delegate int dmxOpen(sqlite3_vtab pVTab, sqlite3_vtab_cursor ppCursor);
145 public delegate int dmxClose(sqlite3_vtab_cursor pCursor);
146 public delegate int dmxFilter(sqlite3_vtab_cursor pCursor, int idmxNum, string idmxStr, int argc, sqlite3_value argv);
147 public delegate int dmxNext(sqlite3_vtab_cursor pCursor);
148 public delegate int dmxEof(sqlite3_vtab_cursor pCursor);
149 public delegate int dmxColumn(sqlite3_vtab_cursor pCursor, sqlite3_context ctx, int i3);
150 public delegate int dmxRowid(sqlite3_vtab_cursor pCursor, sqlite3_int64 pRowid);
151 public delegate int dmxUpdate(sqlite3_vtab pVTab, int i2, sqlite3_value sv3, sqlite3_int64 v4);
152 public delegate int dmxBegin(sqlite3_vtab pVTab);
153 public delegate int dmxSync(sqlite3_vtab pVTab);
154 public delegate int dmxCommit(sqlite3_vtab pVTab);
155 public delegate int dmxRollback(sqlite3_vtab pVTab);
156 public delegate int dmxFindFunction(sqlite3_vtab pVtab, int nArg, string zName);
157 public delegate int dmxRename(sqlite3_vtab pVtab, string zNew);
158 #endif
159 //Faults
160 public delegate void void_function();
161  
162 //Mem Methods
163 public delegate int dxMemInit( object o );
164 public delegate void dxMemShutdown( object o );
165 public delegate byte[] dxMalloc( int nSize );
166 public delegate int[] dxMallocInt( int nSize );
167 public delegate Mem dxMallocMem( Mem pMem );
168 public delegate void dxFree( ref byte[] pOld );
169 public delegate void dxFreeInt( ref int[] pOld );
170 public delegate void dxFreeMem( ref Mem pOld );
171 public delegate byte[] dxRealloc( byte[] pOld, int nSize );
172 public delegate int dxSize( byte[] pArray );
173 public delegate int dxRoundup( int nSize );
174  
175 //Mutex Methods
176 public delegate int dxMutexInit();
177 public delegate int dxMutexEnd();
178 public delegate sqlite3_mutex dxMutexAlloc( int iNumber );
179 public delegate void dxMutexFree( sqlite3_mutex sm );
180 public delegate void dxMutexEnter( sqlite3_mutex sm );
181 public delegate int dxMutexTry( sqlite3_mutex sm );
182 public delegate void dxMutexLeave( sqlite3_mutex sm );
183 public delegate bool dxMutexHeld( sqlite3_mutex sm );
184 public delegate bool dxMutexNotheld( sqlite3_mutex sm );
185  
186 public delegate object dxColumn( sqlite3_stmt pStmt, int i );
187 public delegate int dxColumn_I( sqlite3_stmt pStmt, int i );
188  
189 // Walker Methods
190 public delegate int dxExprCallback( Walker W, ref Expr E ); /* Callback for expressions */
191 public delegate int dxSelectCallback( Walker W, Select S ); /* Callback for SELECTs */
192  
193  
194 // pcache Methods
195 public delegate int dxPC_Init( object NotUsed );
196 public delegate void dxPC_Shutdown( object NotUsed );
197 public delegate sqlite3_pcache dxPC_Create( int szPage, bool bPurgeable );
198 public delegate void dxPC_Cachesize( sqlite3_pcache pCache, int nCachesize );
199 public delegate int dxPC_Pagecount( sqlite3_pcache pCache );
200 public delegate PgHdr dxPC_Fetch( sqlite3_pcache pCache, u32 key, int createFlag );
201 public delegate void dxPC_Unpin( sqlite3_pcache pCache, PgHdr p2, bool discard );
202 public delegate void dxPC_Rekey( sqlite3_pcache pCache, PgHdr p2, u32 oldKey, u32 newKey );
203 public delegate void dxPC_Truncate( sqlite3_pcache pCache, u32 iLimit );
204 public delegate void dxPC_Destroy( ref sqlite3_pcache pCache );
205  
206 public delegate void dxIter( PgHdr p );
207  
208  
209 #if NET_35 || NET_40
210 //API Simplifications -- Actions
211 public static Action<sqlite3_context, String, Int32, dxDel> ResultBlob = sqlite3_result_blob;
212 public static Action<sqlite3_context, Double> ResultDouble = sqlite3_result_double;
213 public static Action<sqlite3_context, String, Int32> ResultError = sqlite3_result_error;
214 public static Action<sqlite3_context, Int32> ResultErrorCode = sqlite3_result_error_code;
215 public static Action<sqlite3_context> ResultErrorNoMem = sqlite3_result_error_nomem;
216 public static Action<sqlite3_context> ResultErrorTooBig = sqlite3_result_error_toobig;
217 public static Action<sqlite3_context, Int32> ResultInt = sqlite3_result_int;
218 public static Action<sqlite3_context, Int64> ResultInt64 = sqlite3_result_int64;
219 public static Action<sqlite3_context> ResultNull = sqlite3_result_null;
220 public static Action<sqlite3_context, String, Int32, dxDel> ResultText = sqlite3_result_text;
221 public static Action<sqlite3_context, String, Int32, Int32, dxDel> ResultText_Offset = sqlite3_result_text;
222 public static Action<sqlite3_context, sqlite3_value> ResultValue = sqlite3_result_value;
223 public static Action<sqlite3_context, Int32> ResultZeroblob = sqlite3_result_zeroblob;
224 public static Action<sqlite3_context, Int32, String> SetAuxdata = sqlite3_set_auxdata;
225  
226 //API Simplifications -- Functions
227 public delegate Int32 FinalizeDelegate( sqlite3_stmt pStmt );
228 public static FinalizeDelegate Finalize = sqlite3_finalize;
229  
230 public static Func<sqlite3_stmt, Int32> ClearBindings = sqlite3_clear_bindings;
231 public static Func<sqlite3_stmt, Int32, Byte[]> ColumnBlob = sqlite3_column_blob;
232 public static Func<sqlite3_stmt, Int32, Int32> ColumnBytes = sqlite3_column_bytes;
233 public static Func<sqlite3_stmt, Int32, Int32> ColumnBytes16 = sqlite3_column_bytes16;
234 public static Func<sqlite3_stmt, Int32> ColumnCount = sqlite3_column_count;
235 public static Func<sqlite3_stmt, Int32, String> ColumnDecltype = sqlite3_column_decltype;
236 public static Func<sqlite3_stmt, Int32, Double> ColumnDouble = sqlite3_column_double;
237 public static Func<sqlite3_stmt, Int32, Int32> ColumnInt = sqlite3_column_int;
238 public static Func<sqlite3_stmt, Int32, Int64> ColumnInt64 = sqlite3_column_int64;
239 public static Func<sqlite3_stmt, Int32, String> ColumnName = sqlite3_column_name;
240 public static Func<sqlite3_stmt, Int32, String> ColumnText = sqlite3_column_text;
241 public static Func<sqlite3_stmt, Int32, Int32> ColumnType = sqlite3_column_type;
242 public static Func<sqlite3_stmt, Int32, sqlite3_value> ColumnValue = sqlite3_column_value;
243 public static Func<sqlite3_stmt, Int32> DataCount = sqlite3_data_count;
244 public static Func<sqlite3_stmt, Int32> Reset = sqlite3_reset;
245 public static Func<sqlite3_stmt, Int32> Step = sqlite3_step;
246  
247 public static Func<sqlite3_stmt, Int32, Byte[], Int32, dxDel, Int32> BindBlob = sqlite3_bind_blob;
248 public static Func<sqlite3_stmt, Int32, Double, Int32> BindDouble = sqlite3_bind_double;
249 public static Func<sqlite3_stmt, Int32, Int32, Int32> BindInt = sqlite3_bind_int;
250 public static Func<sqlite3_stmt, Int32, Int64, Int32> BindInt64 = sqlite3_bind_int64;
251 public static Func<sqlite3_stmt, Int32, Int32> BindNull = sqlite3_bind_null;
252 public static Func<sqlite3_stmt, Int32> BindParameterCount = sqlite3_bind_parameter_count;
253 public static Func<sqlite3_stmt, String, Int32> BindParameterIndex = sqlite3_bind_parameter_index;
254 public static Func<sqlite3_stmt, Int32, String> BindParameterName = sqlite3_bind_parameter_name;
255 public static Func<sqlite3_stmt, Int32, String, Int32, dxDel, Int32> BindText = sqlite3_bind_text;
256 public static Func<sqlite3_stmt, Int32, sqlite3_value, Int32> BindValue = sqlite3_bind_value;
257 public static Func<sqlite3_stmt, Int32, Int32, Int32> BindZeroblob = sqlite3_bind_zeroblob;
258  
259 public delegate Int32 OpenDelegate( string zFilename, out sqlite3 ppDb );
260 public static Func<sqlite3, Int32> Close = sqlite3_close;
261 public static Func<sqlite3_stmt, sqlite3> DbHandle = sqlite3_db_handle;
262 public static Func<sqlite3, String> Errmsg = sqlite3_errmsg;
263 public static OpenDelegate Open = sqlite3_open;
264 public static Func<sqlite3, sqlite3_stmt, sqlite3_stmt> NextStmt = sqlite3_next_stmt;
265 public static Func<Int32> Shutdown = sqlite3_shutdown;
266 public static Func<sqlite3_stmt, Int32, Int32, Int32> StmtStatus = sqlite3_stmt_status;
267  
268 public delegate Int32 PrepareDelegate( sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, ref string pzTail );
269 public delegate Int32 PrepareDelegateNoTail( sqlite3 db, String zSql, Int32 nBytes, ref sqlite3_stmt ppStmt, Int32 iDummy );
270 public static PrepareDelegate Prepare = sqlite3_prepare;
271 public static PrepareDelegate PrepareV2 = sqlite3_prepare_v2;
272 public static PrepareDelegateNoTail PrepareV2NoTail = sqlite3_prepare_v2;
273  
274 public static Func<sqlite3_context, Int32, Mem> AggregateContext = sqlite3_aggregate_context;
275 public static Func<sqlite3_context, Int32, Object> GetAuxdata = sqlite3_get_auxdata;
276 public static Func<sqlite3_context, sqlite3> ContextDbHandle = sqlite3_context_db_handle;
277 public static Func<sqlite3_context, Object> UserData = sqlite3_user_data;
278  
279 public static Func<sqlite3_value, Byte[]> ValueBlob = sqlite3_value_blob;
280 public static Func<sqlite3_value, Int32> ValueBytes = sqlite3_value_bytes;
281 public static Func<sqlite3_value, Int32> ValueBytes16 = sqlite3_value_bytes16;
282 public static Func<sqlite3_value, Double> ValueDouble = sqlite3_value_double;
283 public static Func<sqlite3_value, Int32> ValueInt = sqlite3_value_int;
284 public static Func<sqlite3_value, Int64> ValueInt64 = sqlite3_value_int64;
285 public static Func<sqlite3_value, String> ValueText = sqlite3_value_text;
286 public static Func<sqlite3_value, Int32> ValueType = sqlite3_value_type;
287 #endif
288  
289 }
290 }
291 #if( NET_35 && !NET_40) || WINDOWS_PHONE
292 namespace System
293 {
294 // Summary:
295 // Encapsulates a method that has four parameters and does not return a value.
296 //
297 // Parameters:
298 // arg1:
299 // The first parameter of the method that this delegate encapsulates.
300 //
301 // arg2:
302 // The second parameter of the method that this delegate encapsulates.
303 //
304 // arg3:
305 // The third parameter of the method that this delegate encapsulates.
306 //
307 // arg4:
308 // The fourth parameter of the method that this delegate encapsulates.
309 //
310 // arg5:
311 // The fifth parameter of the method that this delegate encapsulates.
312 //
313 // Type parameters:
314 // T1:
315 // The type of the first parameter of the method that this delegate encapsulates.
316 //
317 // T2:
318 // The type of the second parameter of the method that this delegate encapsulates.
319 //
320 // T3:
321 // The type of the third parameter of the method that this delegate encapsulates.
322 //
323 // T4:
324 // The type of the fourth parameter of the method that this delegate encapsulates.
325 //
326 // T5:
327 // The type of the fifth parameter of the method that this delegate encapsulates.
328 public delegate void Action<T1, T2, T3, T4, T5>( T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 );
329  
330 // Summary:
331 // Encapsulates a method that has three parameters and returns a value of the
332 // type specified by the TResult parameter.
333 //
334 // Parameters:
335 // arg1:
336 // The first parameter of the method that this delegate encapsulates.
337 //
338 // arg2:
339 // The second parameter of the method that this delegate encapsulates.
340 //
341 // arg3:
342 // The third parameter of the method that this delegate encapsulates.
343 //
344 // arg4:
345 // The fourth parameter of the method that this delegate encapsulates.
346 //
347 // arg5:
348 // The fifth parameter of the method that this delegate encapsulates.
349 //
350 // Type parameters:
351 // T1:
352 // The type of the first parameter of the method that this delegate encapsulates.
353 //
354 // T2:
355 // The type of the second parameter of the method that this delegate encapsulates.
356 //
357 // T3:
358 // The type of the third parameter of the method that this delegate encapsulates.
359 //
360 // T4:
361 // The type of the fourth parameter of the method that this delegate encapsulates.
362 //
363 // T5:
364 // The type of the fifth parameter of the method that this delegate encapsulates.
365 //
366 // TResult:
367 // The type of the return value of the method that this delegate encapsulates.
368 //
369 // Returns:
370 // The return value of the method that this delegate encapsulates.
371 public delegate TResult Func<T1, T2, T3, T4, TResult>( T1 arg1, T2 arg2, T3 arg3, T4 arg4 );
372 public delegate TResult Func<T1, T2, T3, T4, T5, TResult>( T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 );
373 }
374 #endif