Пример #1
0
        public IDbBackupHandle BackupInit(IDbHandle destHandle, string destName, IDbHandle srcHandle, string srcName)
        {
            var    internalDestDb = (DbHandle)destHandle;
            var    internalSrcDb  = (DbHandle)srcHandle;
            IntPtr p;

            if (_useWinSqlite)
            {
                p = WinSQLite3.sqlite3_backup_init(internalDestDb.InternalDbHandle,
                                                   destName,
                                                   internalSrcDb.InternalDbHandle,
                                                   srcName);
            }
            else
            {
                p = SQLite3.sqlite3_backup_init(internalDestDb.InternalDbHandle,
                                                destName,
                                                internalSrcDb.InternalDbHandle,
                                                srcName);
            }

            if (p == IntPtr.Zero)
            {
                return(null);
            }
            else
            {
                return(new DbBackupHandle(p));
            }
        }
Пример #2
0
 public int LibVersionNumber()
 {
     if (_useWinSqlite)
     {
         return(WinSQLite3.sqlite3_libversion_number());
     }
     else
     {
         return(SQLite3.sqlite3_libversion_number());
     }
 }
Пример #3
0
 public int Sleep(int millis)
 {
     if (_useWinSqlite)
     {
         return(WinSQLite3.sqlite3_sleep(millis));
     }
     else
     {
         return(SQLite3.sqlite3_sleep(millis));
     }
 }
Пример #4
0
 public Result Config(ConfigOption option)
 {
     if (_useWinSqlite)
     {
         return((Result)WinSQLite3.Config(option));
     }
     else
     {
         return((Result)SQLite3.Config(option));
     }
 }
Пример #5
0
 public string SourceID()
 {
     if (_useWinSqlite)
     {
         return(Marshal.PtrToStringAnsi(WinSQLite3.sqlite3_sourceid()));
     }
     else
     {
         return(Marshal.PtrToStringAnsi(SQLite3.sqlite3_sourceid()));
     }
 }
Пример #6
0
        public Result Close(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return((Result)WinSQLite3.Close(dbHandle.InternalDbHandle));
            }
            else
            {
                return((Result)SQLite3.Close(dbHandle.InternalDbHandle));
            }
        }
Пример #7
0
        /// <summary>
        /// Creates a SQLite API object for use from WinRT.
        /// </summary>
        /// <param name="tempFolderPath">Optional: Temporary folder path. Defaults to <see cref="Windows.Storage.ApplicationData.Current.TemporaryFolder.Path"/></param>
        /// <param name="useWinSqlite">Optional: Whether to use WinSQLite instead of SQLite. WinSQLite is built-in to Windows 10.0.10586.0 and above. Using it can reduce app size and potentially increase SQLite load time.</param>
        public SQLiteApiWinRT(string tempFolderPath = null, bool useWinSqlite = false)
        {
            _useWinSqlite = useWinSqlite;

            if (_useWinSqlite)
            {
                WinSQLite3.SetDirectory(/*temp directory type*/ 2, tempFolderPath ?? Windows.Storage.ApplicationData.Current.TemporaryFolder.Path);
            }
            else
            {
                SQLite3.SetDirectory(/*temp directory type*/ 2, tempFolderPath ?? Windows.Storage.ApplicationData.Current.TemporaryFolder.Path);
            }
        }
        public int TotalChanges(SQLite.Net.Interop.IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return(WinSQLite3.TotalChanges(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.TotalChanges(dbHandle.InternalDbHandle));
            }
        }
Пример #9
0
        public string ColumnText16(IDbStatement stmt, int index)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(Marshal.PtrToStringUni(WinSQLite3.ColumnText16(dbStatement.InternalStmt, index)));
            }
            else
            {
                return(Marshal.PtrToStringUni(SQLite3.ColumnText16(dbStatement.InternalStmt, index)));
            }
        }
Пример #10
0
        public string ColumnName16(IDbStatement stmt, int index)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(WinSQLite3.ColumnName16(dbStatement.InternalStmt, index));
            }
            else
            {
                return(SQLite3.ColumnName16(dbStatement.InternalStmt, index));
            }
        }
Пример #11
0
        public int BindBlob(IDbStatement stmt, int index, byte[] val, int n, IntPtr free)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(WinSQLite3.BindBlob(dbStatement.InternalStmt, index, val, n, free));
            }
            else
            {
                return(SQLite3.BindBlob(dbStatement.InternalStmt, index, val, n, free));
            }
        }
Пример #12
0
        public double ColumnDouble(IDbStatement stmt, int index)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(WinSQLite3.ColumnDouble(dbStatement.InternalStmt, index));
            }
            else
            {
                return(SQLite3.ColumnDouble(dbStatement.InternalStmt, index));
            }
        }
Пример #13
0
        public ColType ColumnType(IDbStatement stmt, int index)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return((ColType)WinSQLite3.ColumnType(dbStatement.InternalStmt, index));
            }
            else
            {
                return((ColType)SQLite3.ColumnType(dbStatement.InternalStmt, index));
            }
        }
Пример #14
0
        public long LastInsertRowid(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return(WinSQLite3.LastInsertRowid(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.LastInsertRowid(dbHandle.InternalDbHandle));
            }
        }
Пример #15
0
        public Result BusyTimeout(IDbHandle db, int milliseconds)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return((Result)WinSQLite3.BusyTimeout(dbHandle.InternalDbHandle, milliseconds));
            }
            else
            {
                return((Result)SQLite3.BusyTimeout(dbHandle.InternalDbHandle, milliseconds));
            }
        }
Пример #16
0
        public int BackupPagecount(IDbBackupHandle handle)
        {
            var internalBackup = (DbBackupHandle)handle;

            if (_useWinSqlite)
            {
                return(WinSQLite3.sqlite3_backup_pagecount(internalBackup.DbBackupPtr));
            }
            else
            {
                return(SQLite3.sqlite3_backup_pagecount(internalBackup.DbBackupPtr));
            }
        }
Пример #17
0
        public int BindInt(IDbStatement stmt, int index, int val)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(WinSQLite3.BindInt(dbStatement.InternalStmt, index, val));
            }
            else
            {
                return(SQLite3.BindInt(dbStatement.InternalStmt, index, val));
            }
        }
Пример #18
0
        public int BackupRemaining(IDbBackupHandle handle)
        {
            var internalBackup = (DbBackupHandle)handle;

            if (_useWinSqlite)
            {
                return(WinSQLite3.sqlite3_backup_remaining(internalBackup.DbBackupPtr));
            }
            else
            {
                return(SQLite3.sqlite3_backup_remaining(internalBackup.DbBackupPtr));
            }
        }
Пример #19
0
        public Result BackupStep(IDbBackupHandle handle, int pageCount)
        {
            var internalBackup = (DbBackupHandle)handle;

            if (_useWinSqlite)
            {
                return(WinSQLite3.sqlite3_backup_step(internalBackup.DbBackupPtr, pageCount));
            }
            else
            {
                return(SQLite3.sqlite3_backup_step(internalBackup.DbBackupPtr, pageCount));
            }
        }
Пример #20
0
        public Result BackupFinish(IDbBackupHandle handle)
        {
            var internalBackup = (DbBackupHandle)handle;

            if (_useWinSqlite)
            {
                return(WinSQLite3.sqlite3_backup_finish(internalBackup.DbBackupPtr));
            }
            else
            {
                return(SQLite3.sqlite3_backup_finish(internalBackup.DbBackupPtr));
            }
        }
Пример #21
0
        public Result Step(IDbStatement stmt)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return((Result)WinSQLite3.Step(dbStatement.InternalStmt));
            }
            else
            {
                return((Result)SQLite3.Step(dbStatement.InternalStmt));
            }
        }
Пример #22
0
        public int ColumnCount(IDbStatement stmt)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(WinSQLite3.ColumnCount(dbStatement.InternalStmt));
            }
            else
            {
                return(SQLite3.ColumnCount(dbStatement.InternalStmt));
            }
        }
Пример #23
0
        public ExtendedResult ExtendedErrCode(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return(WinSQLite3.sqlite3_extended_errcode(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.sqlite3_extended_errcode(dbHandle.InternalDbHandle));
            }
        }
Пример #24
0
        public string Errmsg16(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return(WinSQLite3.GetErrmsg(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.GetErrmsg(dbHandle.InternalDbHandle));
            }
        }
Пример #25
0
        public int Changes(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return(WinSQLite3.Changes(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.Changes(dbHandle.InternalDbHandle));
            }
        }
Пример #26
0
        public int CreateScalarFunction(IDbHandle dbHandle, IScalarFunction sqliteFunction)
        {
            var internalDbHandle = (DbHandle)dbHandle;

            FuncCallbackExecutor funcCallbackExecutor = null;

            if (_useWinSqlite)
            {
                funcCallbackExecutor = new FuncCallbackExecutor(
                    sqliteFunction,
                    WinSQLite3.GetAnsiString,
                    WinSQLite3.sqlite3_result_int
                    );

                var func = new WinSQLite3.FuncCallback(funcCallbackExecutor.Execute);

                _allocatedGCHandles.Add(GCHandle.Alloc(func));

                return(WinSQLite3.sqlite3_create_function(
                           internalDbHandle.InternalDbHandle,
                           Encoding.UTF8.GetBytes(sqliteFunction.Name),
                           sqliteFunction.ValueGetters.Length,
                           SQLiteEncodings.SQLITE_UTF8,
                           IntPtr.Zero,
                           func,
                           null,
                           null));
            }
            else
            {
                funcCallbackExecutor = new FuncCallbackExecutor(
                    sqliteFunction,
                    SQLite3.GetAnsiString,
                    SQLite3.sqlite3_result_int
                    );

                var func = new SQLite3.FuncCallback(funcCallbackExecutor.Execute);

                _allocatedGCHandles.Add(GCHandle.Alloc(func));

                return(SQLite3.sqlite3_create_function(
                           internalDbHandle.InternalDbHandle,
                           Encoding.UTF8.GetBytes(sqliteFunction.Name),
                           sqliteFunction.ValueGetters.Length,
                           SQLiteEncodings.SQLITE_UTF8,
                           IntPtr.Zero,
                           func,
                           null,
                           null));
            }
        }
Пример #27
0
        public int BindText16(IDbStatement stmt, int index, string val, int n, IntPtr free)
        {
            var dbStatement = (DbStatement)stmt;


            if (_useWinSqlite)
            {
                return(WinSQLite3.BindText(dbStatement.InternalStmt, index, val, n, free));
            }
            else
            {
                return(SQLite3.BindText(dbStatement.InternalStmt, index, val, n, free));
            }
        }
Пример #28
0
        public Result Finalize(IDbStatement stmt)
        {
            var dbStatement = (DbStatement)stmt;
            Sqlite3Statement internalStmt = dbStatement.InternalStmt;

            if (_useWinSqlite)
            {
                return((Result)WinSQLite3.Finalize(internalStmt));
            }
            else
            {
                return((Result)SQLite3.Finalize(internalStmt));
            }
        }
Пример #29
0
        public int BindParameterIndex(IDbStatement stmt, string name)
        {
            var dbStatement = (DbStatement)stmt;


            if (_useWinSqlite)
            {
                return(WinSQLite3.BindParameterIndex(dbStatement.InternalStmt, name));
            }
            else
            {
                return(SQLite3.BindParameterIndex(dbStatement.InternalStmt, name));
            }
        }
Пример #30
0
        public Result Open(byte[] filename, out IDbHandle db, int flags, IntPtr zvfs)
        {
            Sqlite3DatabaseHandle internalDbHandle;
            Result ret;

            if (_useWinSqlite)
            {
                ret = (Result)WinSQLite3.Open(filename, out internalDbHandle, flags, zvfs);
            }
            else
            {
                ret = (Result)SQLite3.Open(filename, out internalDbHandle, flags, zvfs);
            }

            db = new DbHandle(internalDbHandle);
            return(ret);
        }