///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.Column" /> method.
        /// </summary>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.Column" /> method.
        /// </param>
        /// <param name="context">
        /// See the <see cref="ISQLiteManagedModule.Column" /> method.
        /// </param>
        /// <param name="index">
        /// See the <see cref="ISQLiteManagedModule.Column" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.Column" /> method.
        /// </returns>
        public override SQLiteErrorCode Column(
            SQLiteVirtualTableCursor cursor,
            SQLiteContext context,
            int index
            )
        {
            CheckDisposed();

            SQLiteVirtualTableCursorEnumerator enumeratorCursor =
                cursor as SQLiteVirtualTableCursorEnumerator;

            if (enumeratorCursor == null)
            {
                return(CursorTypeMismatchError(cursor,
                                               typeof(SQLiteVirtualTableCursorEnumerator)));
            }

            if (enumeratorCursor.EndOfEnumerator)
            {
                return(CursorEndOfEnumeratorError(cursor));
            }

            object current = enumeratorCursor.Current;

            if (current != null)
            {
                context.SetString(GetStringFromObject(cursor, current));
            }
            else
            {
                context.SetNull();
            }

            return(SQLiteErrorCode.Ok);
        }
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.RowId" /> method.
        /// </summary>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.RowId" /> method.
        /// </param>
        /// <param name="rowId">
        /// See the <see cref="ISQLiteManagedModule.RowId" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.RowId" /> method.
        /// </returns>
        public override SQLiteErrorCode RowId(
            SQLiteVirtualTableCursor cursor,
            ref long rowId
            )
        {
            CheckDisposed();

            SQLiteVirtualTableCursorEnumerator enumeratorCursor =
                cursor as SQLiteVirtualTableCursorEnumerator;

            if (enumeratorCursor == null)
            {
                return(CursorTypeMismatchError(cursor,
                                               typeof(SQLiteVirtualTableCursorEnumerator)));
            }

            if (enumeratorCursor.EndOfEnumerator)
            {
                return(CursorEndOfEnumeratorError(cursor));
            }

            object current = enumeratorCursor.Current;

            rowId = GetRowIdFromObject(cursor, current);
            return(SQLiteErrorCode.Ok);
        }
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.Open" /> method.
        /// </summary>
        /// <param name="table">
        /// See the <see cref="ISQLiteManagedModule.Open" /> method.
        /// </param>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.Open" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.Open" /> method.
        /// </returns>
        public override SQLiteErrorCode Open(
            SQLiteVirtualTable table,
            ref SQLiteVirtualTableCursor cursor
            )
        {
            CheckDisposed();

            cursor = new SQLiteVirtualTableCursorEnumerator(
                table, enumerable.GetEnumerator());

            return(SQLiteErrorCode.Ok);
        }
Example #4
0
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.Eof" /> method.
        /// </summary>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.Eof" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.Eof" /> method.
        /// </returns>
        public override bool Eof(
            SQLiteVirtualTableCursor cursor
            )
        {
            CheckDisposed();

            SQLiteVirtualTableCursorEnumerator enumeratorCursor =
                cursor as SQLiteVirtualTableCursorEnumerator;

            if (enumeratorCursor == null)
            {
                return(ResultCodeToEofResult(CursorTypeMismatchError(cursor)));
            }

            return(enumeratorCursor.EndOfEnumerator);
        }
Example #5
0
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.Close" /> method.
        /// </summary>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.Close" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.Close" /> method.
        /// </returns>
        public override SQLiteErrorCode Close(
            SQLiteVirtualTableCursor cursor
            )
        {
            CheckDisposed();

            SQLiteVirtualTableCursorEnumerator enumeratorCursor =
                cursor as SQLiteVirtualTableCursorEnumerator;

            if (enumeratorCursor == null)
            {
                return(CursorTypeMismatchError(cursor));
            }

            enumeratorCursor.Close();
            return(SQLiteErrorCode.Ok);
        }
Example #6
0
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.Next" /> method.
        /// </summary>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.Next" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.Next" /> method.
        /// </returns>
        public override SQLiteErrorCode Next(
            SQLiteVirtualTableCursor cursor
            )
        {
            CheckDisposed();

            SQLiteVirtualTableCursorEnumerator enumeratorCursor =
                cursor as SQLiteVirtualTableCursorEnumerator;

            if (enumeratorCursor == null)
            {
                return(CursorTypeMismatchError(cursor));
            }

            if (enumeratorCursor.EndOfEnumerator)
            {
                return(CursorEndOfEnumeratorError(cursor));
            }

            enumeratorCursor.MoveNext(); /* IGNORED */
            return(SQLiteErrorCode.Ok);
        }
Example #7
0
        ///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// See the <see cref="ISQLiteManagedModule.Filter" /> method.
        /// </summary>
        /// <param name="cursor">
        /// See the <see cref="ISQLiteManagedModule.Filter" /> method.
        /// </param>
        /// <param name="indexNumber">
        /// See the <see cref="ISQLiteManagedModule.Filter" /> method.
        /// </param>
        /// <param name="indexString">
        /// See the <see cref="ISQLiteManagedModule.Filter" /> method.
        /// </param>
        /// <param name="values">
        /// See the <see cref="ISQLiteManagedModule.Filter" /> method.
        /// </param>
        /// <returns>
        /// See the <see cref="ISQLiteManagedModule.Filter" /> method.
        /// </returns>
        public override SQLiteErrorCode Filter(
            SQLiteVirtualTableCursor cursor,
            int indexNumber,
            string indexString,
            SQLiteValue[] values
            )
        {
            CheckDisposed();

            SQLiteVirtualTableCursorEnumerator enumeratorCursor =
                cursor as SQLiteVirtualTableCursorEnumerator;

            if (enumeratorCursor == null)
            {
                return(CursorTypeMismatchError(cursor));
            }

            enumeratorCursor.Filter(indexNumber, indexString, values);
            enumeratorCursor.Reset();    /* NO RESULT */
            enumeratorCursor.MoveNext(); /* IGNORED */

            return(SQLiteErrorCode.Ok);
        }