Exemple #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));
            }
        }
Exemple #2
0
 public int LibVersionNumber()
 {
     if (_useWinSqlite)
     {
         return(WinSQLite3.sqlite3_libversion_number());
     }
     else
     {
         return(SQLite3.sqlite3_libversion_number());
     }
 }
Exemple #3
0
 public int Sleep(int millis)
 {
     if (_useWinSqlite)
     {
         return(WinSQLite3.sqlite3_sleep(millis));
     }
     else
     {
         return(SQLite3.sqlite3_sleep(millis));
     }
 }
Exemple #4
0
 public Result Config(ConfigOption option)
 {
     if (_useWinSqlite)
     {
         return((Result)WinSQLite3.Config(option));
     }
     else
     {
         return((Result)SQLite3.Config(option));
     }
 }
Exemple #5
0
 public string SourceID()
 {
     if (_useWinSqlite)
     {
         return(Marshal.PtrToStringAnsi(WinSQLite3.sqlite3_sourceid()));
     }
     else
     {
         return(Marshal.PtrToStringAnsi(SQLite3.sqlite3_sourceid()));
     }
 }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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)));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #14
0
        public long LastInsertRowid(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

            if (_useWinSqlite)
            {
                return(WinSQLite3.LastInsertRowid(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.LastInsertRowid(dbHandle.InternalDbHandle));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #22
0
        public int ColumnCount(IDbStatement stmt)
        {
            var dbStatement = (DbStatement)stmt;

            if (_useWinSqlite)
            {
                return(WinSQLite3.ColumnCount(dbStatement.InternalStmt));
            }
            else
            {
                return(SQLite3.ColumnCount(dbStatement.InternalStmt));
            }
        }
Exemple #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));
            }
        }
Exemple #24
0
        public string Errmsg16(IDbHandle db)
        {
            var dbHandle = (DbHandle)db;

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

            if (_useWinSqlite)
            {
                return(WinSQLite3.Changes(dbHandle.InternalDbHandle));
            }
            else
            {
                return(SQLite3.Changes(dbHandle.InternalDbHandle));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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));
            }
        }
Exemple #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);
        }