Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The SQLiteValue and SQLiteContext classes should implement the ISQLiteNativeHandle interface. Work in progress on documentation for the virtual tables support classes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | virtualTables |
Files: | files | file ages | folders |
SHA1: |
c8d209d5f40dafbffd99d404e03fc462 |
User & Date: | mistachkin 2013-06-24 22:49:45.864 |
Context
2013-06-24
| ||
22:50 | Merge updates from trunk. check-in: d4f5e0a0ef user: mistachkin tags: virtualTables | |
22:49 | The SQLiteValue and SQLiteContext classes should implement the ISQLiteNativeHandle interface. Work in progress on documentation for the virtual tables support classes. check-in: c8d209d5f4 user: mistachkin tags: virtualTables | |
2013-06-22
| ||
20:05 | Also update error message wording. check-in: f01efa4daa user: mistachkin tags: virtualTables | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | /// The modules created using this connection. /// </summary> protected Dictionary<string, SQLiteModule> _modules; #endif /////////////////////////////////////////////////////////////////////////////////////////////// internal SQLite3( SQLiteDateFormats fmt, DateTimeKind kind, string fmtString, IntPtr db, string fileName, bool ownHandle | > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /// The modules created using this connection. /// </summary> protected Dictionary<string, SQLiteModule> _modules; #endif /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Constructs the object used to interact with the SQLite core library /// using the UTF-8 text encoding. /// </summary> /// <param name="fmt"> /// The DateTime format to be used when converting string values to a /// DateTime and binding DateTime parameters. /// </param> /// <param name="kind"> /// The <see cref="DateTimeKind" /> to be used when creating DateTime /// values. /// </param> /// <param name="fmtString"> /// The format string to be used when parsing and formatting DateTime /// values. /// </param> /// <param name="db"> /// The native handle to be associated with the database connection. /// </param> /// <param name="fileName"> /// The fully qualified file name associated with <paramref name="db "/>. /// </param> /// <param name="ownHandle"> /// Non-zero if the newly created object instance will need to dispose /// of <paramref name="db" /> when it is no longer needed. /// </param> internal SQLite3( SQLiteDateFormats fmt, DateTimeKind kind, string fmtString, IntPtr db, string fileName, bool ownHandle |
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 | //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// #if INTEROP_VIRTUAL_TABLE if (_modules != null) { foreach (KeyValuePair<string, SQLiteModule> pair in _modules) { SQLiteModule module = pair.Value; if (module == null) | > > > > > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// #if INTEROP_VIRTUAL_TABLE // // NOTE: If any modules were created, attempt to dispose of // them now. This code is designed to avoid throwing // exceptions unless the Dispose method of the module // itself throws an exception. // if (_modules != null) { foreach (KeyValuePair<string, SQLiteModule> pair in _modules) { SQLiteModule module = pair.Value; if (module == null) |
︙ | ︙ | |||
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | internal override bool IsOpen() { return (_sql != null) && !_sql.IsInvalid && !_sql.IsClosed; } internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool) { if (_sql != null) Close(true); if (_sql != null) throw new SQLiteException("connection handle is still active"); _usePool = usePool; _fileName = strFilename; if (usePool) | > > > > > > > > > > | 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 | internal override bool IsOpen() { return (_sql != null) && !_sql.IsInvalid && !_sql.IsClosed; } internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool) { // // NOTE: If the database connection is currently open, attempt to // close it now. This must be done because the file name or // other parameters that may impact the underlying database // connection may have changed. // if (_sql != null) Close(true); // // NOTE: If the connection was not closed successfully, throw an // exception now. // if (_sql != null) throw new SQLiteException("connection handle is still active"); _usePool = usePool; _fileName = strFilename; if (usePool) |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3_UTF16.cs.
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | using System.Runtime.InteropServices; /// <summary> /// Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode) /// </summary> internal sealed class SQLite3_UTF16 : SQLite3 { internal SQLite3_UTF16( SQLiteDateFormats fmt, DateTimeKind kind, string fmtString, IntPtr db, string fileName, bool ownHandle | > > > > > > > > > > > > > > > > > > > > > > > > > > | 17 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 | using System.Runtime.InteropServices; /// <summary> /// Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode) /// </summary> internal sealed class SQLite3_UTF16 : SQLite3 { /// <summary> /// Constructs the object used to interact with the SQLite core library /// using the UTF-8 text encoding. /// </summary> /// <param name="fmt"> /// The DateTime format to be used when converting string values to a /// DateTime and binding DateTime parameters. /// </param> /// <param name="kind"> /// The <see cref="DateTimeKind" /> to be used when creating DateTime /// values. /// </param> /// <param name="fmtString"> /// The format string to be used when parsing and formatting DateTime /// values. /// </param> /// <param name="db"> /// The native handle to be associated with the database connection. /// </param> /// <param name="fileName"> /// The fully qualified file name associated with <paramref name="db "/>. /// </param> /// <param name="ownHandle"> /// Non-zero if the newly created object instance will need to dispose /// of <paramref name="db" /> when it is no longer needed. /// </param> internal SQLite3_UTF16( SQLiteDateFormats fmt, DateTimeKind kind, string fmtString, IntPtr db, string fileName, bool ownHandle |
︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | return Marshal.PtrToStringUni(b); else return Marshal.PtrToStringUni(b, nbytelen / 2); } internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool) { if (_sql != null) Close(true); if (_sql != null) throw new SQLiteException("connection handle is still active"); _usePool = usePool; _fileName = strFilename; if (usePool) | > > > > > > > > > > | 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 | return Marshal.PtrToStringUni(b); else return Marshal.PtrToStringUni(b, nbytelen / 2); } internal override void Open(string strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, int maxPoolSize, bool usePool) { // // NOTE: If the database connection is currently open, attempt to // close it now. This must be done because the file name or // other parameters that may impact the underlying database // connection may have changed. // if (_sql != null) Close(true); // // NOTE: If the connection was not closed successfully, throw an // exception now. // if (_sql != null) throw new SQLiteException("connection handle is still active"); _usePool = usePool; _fileName = strFilename; if (usePool) |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteModule.cs.
︙ | ︙ | |||
9 10 11 12 13 14 15 | using System.Globalization; using System.Runtime.InteropServices; using System.Text; namespace System.Data.SQLite { #region SQLiteContext Helper Class | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 9 10 11 12 13 14 15 16 17 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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 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 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 | using System.Globalization; using System.Runtime.InteropServices; using System.Text; namespace System.Data.SQLite { #region SQLiteContext Helper Class /// <summary> /// This class represents a context from the SQLite core library that can /// be passed to the sqlite3_result_*() and associated functions. /// </summary> public sealed class SQLiteContext : ISQLiteNativeHandle { #region Private Data /// <summary> /// The native context handle. /// </summary> private IntPtr pContext; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs an instance of this class using the specified native /// context handle. /// </summary> /// <param name="pContext"> /// The native context handle to use. /// </param> internal SQLiteContext(IntPtr pContext) { this.pContext = pContext; } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Members /// <summary> /// Returns the underlying SQLite native handle associated with this /// object instance. /// </summary> public virtual IntPtr NativeHandle { get { return pContext; } } #endregion /////////////////////////////////////////////////////////////////////// #region Public Methods /// <summary> /// Sets the context result to NULL. /// </summary> public void SetNull() { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); UnsafeNativeMethods.sqlite3_result_null(pContext); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="System.Double" /> /// value. /// </summary> /// <param name="value"> /// The <see cref="System.Double" /> value to use. /// </param> public void SetDouble(double value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); #if !PLATFORM_COMPACTFRAMEWORK UnsafeNativeMethods.sqlite3_result_double(pContext, value); #elif !SQLITE_STANDARD UnsafeNativeMethods.sqlite3_result_double_interop(pContext, ref value); #else throw new NotImplementedException(); #endif } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="System.Int32" /> /// value. /// </summary> /// <param name="value"> /// The <see cref="System.Int32" /> value to use. /// </param> public void SetInt(int value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); UnsafeNativeMethods.sqlite3_result_int(pContext, value); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="System.Int64" /> /// value. /// </summary> /// <param name="value"> /// The <see cref="System.Int64" /> value to use. /// </param> public void SetInt64(long value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); #if !PLATFORM_COMPACTFRAMEWORK UnsafeNativeMethods.sqlite3_result_int64(pContext, value); #elif !SQLITE_STANDARD UnsafeNativeMethods.sqlite3_result_int64_interop(pContext, ref value); #else throw new NotImplementedException(); #endif } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="System.String" /> /// value. /// </summary> /// <param name="value"> /// The <see cref="System.String" /> value to use. This value will be /// converted to the UTF-8 encoding prior to being used. /// </param> public void SetString(string value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); byte[] bytes = SQLiteString.GetUtf8BytesFromString(value); if (bytes == null) throw new ArgumentNullException("value"); UnsafeNativeMethods.sqlite3_result_text( pContext, bytes, bytes.Length, (IntPtr)(-1)); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="System.String" /> /// value containing an error message. /// </summary> /// <param name="value"> /// The <see cref="System.String" /> value containing the error message /// text. This value will be converted to the UTF-8 encoding prior to /// being used. /// </param> public void SetError(string value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); byte[] bytes = SQLiteString.GetUtf8BytesFromString(value); if (bytes == null) throw new ArgumentNullException("value"); UnsafeNativeMethods.sqlite3_result_error( pContext, bytes, bytes.Length); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="SQLiteErrorCode" /> /// value. /// </summary> /// <param name="value"> /// The <see cref="SQLiteErrorCode" /> value to use. /// </param> public void SetErrorCode(SQLiteErrorCode value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); UnsafeNativeMethods.sqlite3_result_error_code(pContext, value); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to contain the error code SQLITE_TOOBIG. /// </summary> public void SetErrorTooBig() { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); UnsafeNativeMethods.sqlite3_result_error_toobig(pContext); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to contain the error code SQLITE_NOMEM. /// </summary> public void SetErrorNoMemory() { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); UnsafeNativeMethods.sqlite3_result_error_nomem(pContext); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="System.Byte[]" /> /// value. /// </summary> /// <param name="value"> /// The <see cref="System.Byte[]" /> value to use. /// </param> public void SetBlob(byte[] value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); if (value == null) throw new ArgumentNullException("value"); UnsafeNativeMethods.sqlite3_result_blob( pContext, value, value.Length, (IntPtr)(-1)); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to a BLOB of zeros of the specified size. /// </summary> /// <param name="value"> /// The number of zero bytes to use for the BLOB context result. /// </param> public void SetZeroBlob(int value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); UnsafeNativeMethods.sqlite3_result_zeroblob(pContext, value); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Sets the context result to the specified <see cref="SQLiteValue" />. /// </summary> /// <param name="value"> /// The <see cref="SQLiteValue" /> to use. /// </param> public void SetValue(SQLiteValue value) { if (pContext == IntPtr.Zero) throw new InvalidOperationException(); if (value == null) throw new ArgumentNullException("value"); UnsafeNativeMethods.sqlite3_result_value( pContext, value.NativeHandle); } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteValue Helper Class public sealed class SQLiteValue : ISQLiteNativeHandle { #region Private Data /// <summary> /// The native value handle. /// </summary> private IntPtr pValue; #endregion /////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs an instance of this class using the specified native /// value handle. /// </summary> /// <param name="pContext"> /// The native value handle to use. /// </param> internal SQLiteValue(IntPtr pValue) { this.pValue = pValue; } #endregion /////////////////////////////////////////////////////////////////////// #region Private Methods /// <summary> /// Invalidates the native value handle, thereby preventing further /// access to it from this object instance. /// </summary> private void PreventNativeAccess() { pValue = IntPtr.Zero; } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Members /// <summary> /// Returns the underlying SQLite native handle associated with this /// object instance. /// </summary> public virtual IntPtr NativeHandle { get { return pValue; } } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private bool persisted; /// <summary> /// Returns non-zero if the native SQLite value has been successfully /// persisted as a managed value within this object instance (i.e. the /// <see cref="Value" /> property may then be read successfully). /// </summary> public bool Persisted { get { return persisted; } } /////////////////////////////////////////////////////////////////////// private object value; /// <summary> /// If the managed value for this object instance is available (i.e. it /// has been previously persisted via the <see cref="Persist"/>) method, /// that value is returned; otherwise, an exception is thrown. The /// returned value may be null. /// </summary> public object Value { get { if (!persisted) { throw new InvalidOperationException( "value was not persisted"); } return value; } } #endregion /////////////////////////////////////////////////////////////////////// #region Public Methods /// <summary> /// Gets and returns the type affinity associated with this value. /// </summary> /// <returns> /// The type affinity associated with this value. /// </returns> public TypeAffinity GetTypeAffinity() { if (pValue == IntPtr.Zero) return TypeAffinity.None; return UnsafeNativeMethods.sqlite3_value_type(pValue); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the number of bytes associated with this value, if /// it refers to a UTF-8 encoded string. /// </summary> /// <returns> /// The number of bytes associated with this value. The returned value /// may be zero. /// </returns> public int GetBytes() { if (pValue == IntPtr.Zero) return 0; return UnsafeNativeMethods.sqlite3_value_bytes(pValue); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the <see cref="System.Int32" /> associated with /// this value. /// </summary> /// <returns> /// The <see cref="System.Int32" /> associated with this value. /// </returns> public int GetInt() { if (pValue == IntPtr.Zero) return default(int); return UnsafeNativeMethods.sqlite3_value_int(pValue); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the <see cref="System.Int64" /> associated with /// this value. /// </summary> /// <returns> /// The <see cref="System.Int64" /> associated with this value. /// </returns> public long GetInt64() { if (pValue == IntPtr.Zero) return default(long); #if !PLATFORM_COMPACTFRAMEWORK return UnsafeNativeMethods.sqlite3_value_int64(pValue); #elif !SQLITE_STANDARD long value; UnsafeNativeMethods.sqlite3_value_int64_interop(pValue, out value); return value; #else throw new NotImplementedException(); #endif } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the <see cref="System.Double" /> associated with /// this value. /// </summary> /// <returns> /// The <see cref="System.Double" /> associated with this value. /// </returns> public double GetDouble() { if (pValue == IntPtr.Zero) return default(double); #if !PLATFORM_COMPACTFRAMEWORK return UnsafeNativeMethods.sqlite3_value_double(pValue); #elif !SQLITE_STANDARD double value; UnsafeNativeMethods.sqlite3_value_double_interop(pValue, out value); return value; #else throw new NotImplementedException(); #endif } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the <see cref="System.String" /> associated with /// this value. /// </summary> /// <returns> /// The <see cref="System.String" /> associated with this value. The /// value is converted from the UTF-8 encoding prior to being returned. /// </returns> public string GetString() { if (pValue == IntPtr.Zero) return null; return SQLiteString.StringFromUtf8IntPtr(pValue, GetBytes()); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Gets and returns the <see cref="System.Byte[]" /> associated with /// this value. /// </summary> /// <returns> /// The <see cref="System.Byte[]" /> associated with this value. /// </returns> public byte[] GetBlob() { if (pValue == IntPtr.Zero) return null; return SQLiteMarshal.BytesFromIntPtr(pValue, GetBytes()); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Uses the native value handle to obtain and store the managed value /// for this object instance, thus saving it for later use. The type /// of the managed value is determined by the type affinity of the /// native value. If the type affinity is not recognized by this /// method, no work is done and false is returned. /// </summary> /// <returns> /// Non-zero if the native value was persisted successfully. /// </returns> public bool Persist() { switch (GetTypeAffinity()) { case TypeAffinity.Uninitialized: { value = null; |
︙ | ︙ | |||
360 361 362 363 364 365 366 | #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraintOp Enumeration | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 562 563 564 565 566 567 568 569 570 571 572 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 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 | #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraintOp Enumeration /// <summary> /// These are the allowed values for the operators that are part of a /// constraint term in the WHERE clause of a query that uses a virtual /// table. /// </summary> public enum SQLiteIndexConstraintOp : byte { /// <summary> /// This value represents the equality operator. /// </summary> EqualTo = 2, /// <summary> /// This value represents the greater than operator. /// </summary> GreaterThan = 4, /// <summary> /// This value represents the less than or equal to operator. /// </summary> LessThanOrEqualTo = 8, /// <summary> /// This value represents the less than operator. /// </summary> LessThan = 16, /// <summary> /// This value represents the greater than or equal to operator. /// </summary> GreaterThanOrEqualTo = 32, /// <summary> /// This value represents the MATCH operator. /// </summary> Match = 64 } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraint Helper Class /// <summary> /// This class represents the native sqlite3_index_constraint structure /// from the SQLite core library. /// </summary> public sealed class SQLiteIndexConstraint { #region Internal Constructors /// <summary> /// Constructs an instance of this class using the specified native /// sqlite3_index_constraint structure. /// </summary> /// <param name="constraint"> /// The native sqlite3_index_constraint structure to use. /// </param> internal SQLiteIndexConstraint( UnsafeNativeMethods.sqlite3_index_constraint constraint ) : this(constraint.iColumn, constraint.op, constraint.usable, constraint.iTermOffset) { // do nothing. } #endregion ////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs an instance of this class using the specified field /// values. /// </summary> /// <param name="iColumn"> /// Column on left-hand side of constraint. /// </param> /// <param name="op"> /// Constraint operator (<see cref="SQLiteIndexConstraintOp" />). /// </param> /// <param name="usable"> /// True if this constraint is usable. /// </param> /// <param name="iTermOffset"> /// Used internally - <see cref="ISQLiteManagedModule.BestIndex" /> /// should ignore. /// </param> private SQLiteIndexConstraint( int iColumn, SQLiteIndexConstraintOp op, byte usable, int iTermOffset ) { this.iColumn = iColumn; this.op = op; this.usable = usable; this.iTermOffset = iTermOffset; } #endregion ////////////////////////////////////////////////////////////////////// #region Public Fields /// <summary> /// Column on left-hand side of constraint. /// </summary> public int iColumn; ////////////////////////////////////////////////////////////////////// /// <summary> /// Constraint operator (<see cref="SQLiteIndexConstraintOp" />). /// </summary> public SQLiteIndexConstraintOp op; ////////////////////////////////////////////////////////////////////// /// <summary> /// True if this constraint is usable. /// </summary> public byte usable; ////////////////////////////////////////////////////////////////////// /// <summary> /// Used internally - <see cref="ISQLiteManagedModule.BestIndex" /> /// should ignore. /// </summary> public int iTermOffset; #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexOrderBy Helper Class /// <summary> /// This class represents the native sqlite3_index_orderby structure from /// the SQLite core library. /// </summary> public sealed class SQLiteIndexOrderBy { #region Internal Constructors /// <summary> /// Constructs an instance of this class using the specified native /// sqlite3_index_orderby structure. /// </summary> /// <param name="orderBy"> /// The native sqlite3_index_orderby structure to use. /// </param> internal SQLiteIndexOrderBy( UnsafeNativeMethods.sqlite3_index_orderby orderBy ) : this(orderBy.iColumn, orderBy.desc) { // do nothing. } #endregion ////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs an instance of this class using the specified field /// values. /// </summary> /// <param name="iColumn"> /// Column number. /// </param> /// <param name="desc"> /// True for DESC. False for ASC. /// </param> private SQLiteIndexOrderBy( int iColumn, byte desc ) { this.iColumn = iColumn; this.desc = desc; } #endregion ////////////////////////////////////////////////////////////////////// #region Public Fields /// <summary> /// Column number. /// </summary> public int iColumn; ////////////////////////////////////////////////////////////////////// /// <summary> /// True for DESC. False for ASC. /// </summary> public byte desc; #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexConstraintUsage Helper Class /// <summary> /// This class represents the native sqlite3_index_constraint_usage /// structure from the SQLite core library. /// </summary> public sealed class SQLiteIndexConstraintUsage { #region Internal Constructors /// <summary> /// Constructs an instance of this class using the specified native /// sqlite3_index_constraint_usage structure. /// </summary> /// <param name="constraintUsage"> /// The native sqlite3_index_constraint_usage structure to use. /// </param> internal SQLiteIndexConstraintUsage( UnsafeNativeMethods.sqlite3_index_constraint_usage constraintUsage ) : this(constraintUsage.argvIndex, constraintUsage.omit) { // do nothing. } #endregion ////////////////////////////////////////////////////////////////////// #region Private Constructors /// <summary> /// Constructs an instance of this class using the specified field /// values. /// </summary> /// <param name="argvIndex"> /// If greater than 0, constraint is part of argv to xFilter. /// </param> /// <param name="omit"> /// Do not code a test for this constraint. /// </param> private SQLiteIndexConstraintUsage( int argvIndex, byte omit ) { this.argvIndex = argvIndex; this.omit = omit; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Fields /// <summary> /// If greater than 0, constraint is part of argv to xFilter. /// </summary> public int argvIndex; /////////////////////////////////////////////////////////////////////// /// <summary> /// Do not code a test for this constraint. /// </summary> public byte omit; #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexInputs Helper Class /// <summary> /// This class represents the various inputs provided by the SQLite core /// library to the <see cref="ISQLiteManagedModule.BestIndex" /> method. /// </summary> public sealed class SQLiteIndexInputs { #region Internal Constructors /// <summary> /// Constructs an instance of this class. /// </summary> /// <param name="nConstraint"> /// The number of <see cref="SQLiteIndexConstraint" /> instances to /// pre-allocate space for. /// </param> /// <param name="nOrderBy"> /// The number of <see cref="SQLiteIndexOrderBy" /> instances to /// pre-allocate space for. /// </param> internal SQLiteIndexInputs(int nConstraint, int nOrderBy) { constraints = new SQLiteIndexConstraint[nConstraint]; orderBys = new SQLiteIndexOrderBy[nOrderBy]; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private SQLiteIndexConstraint[] constraints; /// <summary> /// An array of <see cref="SQLiteIndexConstraint" /> object instances, /// each containing information supplied by the SQLite core library. /// </summary> public SQLiteIndexConstraint[] Constraints { get { return constraints; } } /////////////////////////////////////////////////////////////////////// private SQLiteIndexOrderBy[] orderBys; /// <summary> /// An array of <see cref="SQLiteIndexOrderBy" /> object instances, /// each containing information supplied by the SQLite core library. /// </summary> public SQLiteIndexOrderBy[] OrderBys { get { return orderBys; } } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndexOutputs Helper Class /// <summary> /// This class represents the various outputs provided to the SQLite core /// library by the <see cref="ISQLiteManagedModule.BestIndex" /> method. /// </summary> public sealed class SQLiteIndexOutputs { #region Internal Constructors /// <summary> /// Constructs an instance of this class. /// </summary> /// <param name="nConstraint"> /// The number of <see cref="SQLiteIndexConstraintUsage" /> instances /// to pre-allocate space for. /// </param> internal SQLiteIndexOutputs(int nConstraint) { constraintUsages = new SQLiteIndexConstraintUsage[nConstraint]; } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private SQLiteIndexConstraintUsage[] constraintUsages; /// <summary> /// An array of <see cref="SQLiteIndexConstraintUsage" /> object /// instances, each containing information to be supplied to the SQLite /// core library. /// </summary> public SQLiteIndexConstraintUsage[] ConstraintUsages { get { return constraintUsages; } } /////////////////////////////////////////////////////////////////////// private int indexNumber; /// <summary> /// Number used to help identify the selected index. This value will /// later be provided to the <see cref="ISQLiteManagedModule.Filter" /> /// method. /// </summary> public int IndexNumber { get { return indexNumber; } set { indexNumber = value; } } /////////////////////////////////////////////////////////////////////// private string indexString; /// <summary> /// String used to help identify the selected index. This value will /// later be provided to the <see cref="ISQLiteManagedModule.Filter" /> /// method. /// </summary> public string IndexString { get { return indexString; } set { indexString = value; } } /////////////////////////////////////////////////////////////////////// private int needToFreeIndexString; /// <summary> /// Non-zero if the index string must be freed by the SQLite core /// library. /// </summary> public int NeedToFreeIndexString { get { return needToFreeIndexString; } set { needToFreeIndexString = value; } } /////////////////////////////////////////////////////////////////////// private int orderByConsumed; /// <summary> /// True if output is already ordered. /// </summary> public int OrderByConsumed { get { return orderByConsumed; } set { orderByConsumed = value; } } /////////////////////////////////////////////////////////////////////// private double estimatedCost; /// <summary> /// Estimated cost of using this index. /// </summary> public double EstimatedCost { get { return estimatedCost; } set { estimatedCost = value; } } #endregion } #endregion /////////////////////////////////////////////////////////////////////////// #region SQLiteIndex Helper Class /// <summary> /// This class represents the various inputs and outputs used with the /// <see cref="ISQLiteManagedModule.BestIndex" /> method. /// </summary> public sealed class SQLiteIndex { #region Internal Constructors /// <summary> /// /// </summary> /// <param name="nConstraint"> /// /// </param> /// <param name="nOrderBy"> /// /// </param> internal SQLiteIndex( int nConstraint, int nOrderBy ) { inputs = new SQLiteIndexInputs(nConstraint, nOrderBy); outputs = new SQLiteIndexOutputs(nConstraint); } #endregion /////////////////////////////////////////////////////////////////////// #region Public Properties private SQLiteIndexInputs inputs; /// <summary> /// /// </summary> public SQLiteIndexInputs Inputs { get { return inputs; } } /////////////////////////////////////////////////////////////////////// private SQLiteIndexOutputs outputs; /// <summary> /// /// </summary> public SQLiteIndexOutputs Outputs { get { return outputs; } } #endregion } #endregion |
︙ | ︙ | |||
766 767 768 769 770 771 772 773 774 775 776 777 778 779 | } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Members private IntPtr nativeHandle; public virtual IntPtr NativeHandle { get { CheckDisposed(); return nativeHandle; } internal set { nativeHandle = value; } } #endregion | > > > > | 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 | } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Members private IntPtr nativeHandle; /// <summary> /// Returns the underlying SQLite native handle associated with this /// object instance. /// </summary> public virtual IntPtr NativeHandle { get { CheckDisposed(); return nativeHandle; } internal set { nativeHandle = value; } } #endregion |
︙ | ︙ | |||
924 925 926 927 928 929 930 931 932 933 934 935 936 937 | } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Members private IntPtr nativeHandle; public virtual IntPtr NativeHandle { get { CheckDisposed(); return nativeHandle; } internal set { nativeHandle = value; } } #endregion | > > > > | 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 | } #endregion /////////////////////////////////////////////////////////////////////// #region ISQLiteNativeHandle Members private IntPtr nativeHandle; /// <summary> /// Returns the underlying SQLite native handle associated with this /// object instance. /// </summary> public virtual IntPtr NativeHandle { get { CheckDisposed(); return nativeHandle; } internal set { nativeHandle = value; } } #endregion |
︙ | ︙ |