Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Some cleanup work. Implement the SQLiteValue helper class. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | virtualTables |
Files: | files | file ages | folders |
SHA1: |
33b2470a683dadaa02d60b71f806707c |
User & Date: | mistachkin 2013-06-07 08:32:49.357 |
Context
2013-06-07
| ||
08:50 | Minor adjustments to previous commit. check-in: a900416795 user: mistachkin tags: virtualTables | |
08:32 | Some cleanup work. Implement the SQLiteValue helper class. check-in: 33b2470a68 user: mistachkin tags: virtualTables | |
02:45 | Rename the SQLiteModule class to SQLiteModuleNoop. Adjustments to method and parameter naming conventions. Initial implementation of xOpen virtual table method. check-in: f5c3afbfb1 user: mistachkin tags: virtualTables | |
Changes
Changes to System.Data.SQLite/SQLiteModuleBase.cs.
︙ | ︙ | |||
18 19 20 21 22 23 24 | namespace System.Data.SQLite { public sealed class SQLiteContext { } | | > > > | > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | > > > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | namespace System.Data.SQLite { public sealed class SQLiteContext { } /////////////////////////////////////////////////////////////////////////// public sealed class SQLiteValue { #region Private Data private IntPtr pValue; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors internal SQLiteValue(IntPtr pValue) { this.pValue = pValue; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Methods public TypeAffinity GetTypeAffinity() { return UnsafeNativeMethods.sqlite3_value_type(pValue); } /////////////////////////////////////////////////////////////////////// public int GetBytes() { return UnsafeNativeMethods.sqlite3_value_bytes(pValue); } /////////////////////////////////////////////////////////////////////// public int GetInt() { return UnsafeNativeMethods.sqlite3_value_int(pValue); } /////////////////////////////////////////////////////////////////////// public long GetInt64() { return UnsafeNativeMethods.sqlite3_value_int64(pValue); } /////////////////////////////////////////////////////////////////////// public double GetDouble() { return UnsafeNativeMethods.sqlite3_value_double(pValue); } /////////////////////////////////////////////////////////////////////// public string GetString() { return SQLiteModuleBase.StringFromUtf8IntPtr(pValue, GetBytes()); } /////////////////////////////////////////////////////////////////////// public byte[] GetBlob() { return SQLiteModuleBase.BytesFromIntPtr(pValue, GetBytes()); } #endregion } /////////////////////////////////////////////////////////////////////////// public class SQLiteIndexConstraint { private SQLiteModuleBase.UnsafeNativeMethods2.sqlite3_index_constraint constraint; } /////////////////////////////////////////////////////////////////////////// public class SQLiteIndexOrderBy { private SQLiteModuleBase.UnsafeNativeMethods2.sqlite3_index_orderby orderBy; } /////////////////////////////////////////////////////////////////////////// public class SQLiteIndexConstraintUsage { private SQLiteModuleBase.UnsafeNativeMethods2.sqlite3_index_constraint_usage constraintUsage; } /////////////////////////////////////////////////////////////////////////// public class SQLiteIndex { SQLiteIndexConstraint[] Constraints; SQLiteIndexOrderBy[] OrderBys; SQLiteIndexConstraintUsage[] ConstraintUsages; int idxNum; /* Number used to identify the index */ string idxStr; /* String, possibly obtained from sqlite3_malloc */ int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ int orderByConsumed; /* True if output is already ordered */ double estimatedCost; /* Estimated cost of using this index */ } /////////////////////////////////////////////////////////////////////////// public class SQLiteVirtualTableCursor { internal SQLiteModuleBase.UnsafeNativeMethods2.sqlite3_vtab_cursor cursor; } /////////////////////////////////////////////////////////////////////////// [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int xFunc( IntPtr pContext, int argc, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] IntPtr[] argv ); /////////////////////////////////////////////////////////////////////////// public interface ISQLiteNativeModule { SQLiteErrorCode xCreate(IntPtr pDb, IntPtr pAux, int argc, ref IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError); SQLiteErrorCode xConnect(IntPtr pDb, IntPtr pAux, int argc, ref IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError); SQLiteErrorCode xBestIndex(IntPtr pVtab, IntPtr index); SQLiteErrorCode xDisconnect(IntPtr pVtab); |
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | SQLiteErrorCode xRollback(IntPtr pVtab); SQLiteErrorCode xFindFunction(IntPtr pVtab, int nArg, IntPtr zName, ref xFunc pxFunc, ref IntPtr ppArg); SQLiteErrorCode xRename(IntPtr pVtab, IntPtr zNew); SQLiteErrorCode xSavepoint(IntPtr pVtab, int iSavepoint); SQLiteErrorCode xRelease(IntPtr pVtab, int iSavepoint); SQLiteErrorCode xRollbackTo(IntPtr pVtab, int iSavepoint); } public interface ISQLiteManagedModule { bool Declared { get; } SQLiteErrorCode Create(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error); SQLiteErrorCode Connect(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error); | > > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | SQLiteErrorCode xRollback(IntPtr pVtab); SQLiteErrorCode xFindFunction(IntPtr pVtab, int nArg, IntPtr zName, ref xFunc pxFunc, ref IntPtr ppArg); SQLiteErrorCode xRename(IntPtr pVtab, IntPtr zNew); SQLiteErrorCode xSavepoint(IntPtr pVtab, int iSavepoint); SQLiteErrorCode xRelease(IntPtr pVtab, int iSavepoint); SQLiteErrorCode xRollbackTo(IntPtr pVtab, int iSavepoint); } /////////////////////////////////////////////////////////////////////////// public interface ISQLiteManagedModule { bool Declared { get; } SQLiteErrorCode Create(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error); SQLiteErrorCode Connect(SQLiteConnection connection, IntPtr pClientData, string[] argv, ref string error); |
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 | SQLiteErrorCode Rollback(); SQLiteErrorCode FindFunction(string zName, ref SQLiteFunction function, object[] args); SQLiteErrorCode Rename(string zNew); SQLiteErrorCode Savepoint(int iSavepoint); SQLiteErrorCode Release(int iSavepoint); SQLiteErrorCode RollbackTo(int iSavepoint); } #if NET_40 [SecurityCritical()] #else [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] #endif public abstract class SQLiteModuleBase : ISQLiteManagedModule, ISQLiteNativeModule, IDisposable | > > | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | SQLiteErrorCode Rollback(); SQLiteErrorCode FindFunction(string zName, ref SQLiteFunction function, object[] args); SQLiteErrorCode Rename(string zNew); SQLiteErrorCode Savepoint(int iSavepoint); SQLiteErrorCode Release(int iSavepoint); SQLiteErrorCode RollbackTo(int iSavepoint); } /////////////////////////////////////////////////////////////////////////// #if NET_40 [SecurityCritical()] #else [SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)] #endif public abstract class SQLiteModuleBase : ISQLiteManagedModule, ISQLiteNativeModule, IDisposable |
︙ | ︙ | |||
262 263 264 265 266 267 268 | ref IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xBestIndex( | < < < < < < < < < < < < < < < < < < < < < | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | ref IntPtr[] argv, ref IntPtr pVtab, ref IntPtr pError ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xBestIndex( IntPtr pVtab, IntPtr index ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xDisconnect( IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xDestroy( IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xOpen( IntPtr pVtab, ref IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xClose( IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xFilter( IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr[] argv ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xNext( IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xEof( IntPtr pCursor ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xColumn( IntPtr pCursor, IntPtr pContext, int index ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xRowId( IntPtr pCursor, ref long rowId ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xUpdate( IntPtr pVtab, int nData, ref IntPtr apData, ref long rowId ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xBegin( IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xSync( IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xCommit( IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xRollback( IntPtr pVtab ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xFindFunction( IntPtr pVtab, int nArg, IntPtr zName, ref xFunc pxFunc, ref IntPtr ppArg ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xRename( IntPtr pVtab, IntPtr zNew ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xSavepoint( IntPtr pVtab, int iSavepoint ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xRelease( IntPtr pVtab, int iSavepoint ); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate SQLiteErrorCode xRollbackTo( IntPtr pVtab, int iSavepoint ); private static readonly int SQLITE_INDEX_CONSTRAINT_EQ = 2; private static readonly int SQLITE_INDEX_CONSTRAINT_GT = 4; private static readonly int SQLITE_INDEX_CONSTRAINT_LE = 8; |
︙ | ︙ | |||
483 484 485 486 487 488 489 490 491 492 493 494 495 496 | private static void Free(IntPtr pMemory) { UnsafeNativeMethods.sqlite3_free(pMemory); } /////////////////////////////////////////////////////////////////////// private static int ProbeForUtf8ByteLength(IntPtr pValue, int limit) { int length = 0; if (pValue != IntPtr.Zero) { do | > > > > > > > > > > > > > > > > > | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | private static void Free(IntPtr pMemory) { UnsafeNativeMethods.sqlite3_free(pMemory); } /////////////////////////////////////////////////////////////////////// internal static byte[] BytesFromIntPtr(IntPtr pValue, int length) { if (pValue == IntPtr.Zero) return null; if (length == 0) return new byte[0]; byte[] result = new byte[length]; Marshal.Copy(pValue, result, 0, length); return result; } /////////////////////////////////////////////////////////////////////// private static int ProbeForUtf8ByteLength(IntPtr pValue, int limit) { int length = 0; if (pValue != IntPtr.Zero) { do |
︙ | ︙ | |||
506 507 508 509 510 511 512 | } return length; } /////////////////////////////////////////////////////////////////////// | | > > > > > > > > > < < > > | 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | } return length; } /////////////////////////////////////////////////////////////////////// internal static string StringFromUtf8IntPtr(IntPtr pValue) { int length = ProbeForUtf8ByteLength(pValue, ThirtyBits); return StringFromUtf8IntPtr(pValue, length); } /////////////////////////////////////////////////////////////////////// internal static string StringFromUtf8IntPtr(IntPtr pValue, int length) { if (pValue == IntPtr.Zero) return null; if (length > 0) { byte[] bytes = new byte[length]; Marshal.Copy(pValue, bytes, 0, length); return GetStringFromUtf8Bytes(bytes); } return String.Empty; } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ |