sqlite3_column_blob() private méthode

private sqlite3_column_blob ( IntPtr stmt, int index ) : IntPtr
stmt System.IntPtr
index int
Résultat System.IntPtr
        internal override long GetBytes(SqliteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart,
                                        int nLength)
        {
            int nCopied = nLength;
            int nlen    = UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index);
            var ptr     = UnsafeNativeMethods.sqlite3_column_blob(stmt._sqlite_stmt, index);

            if (bDest == null)
            {
                return(nlen);
            }

            if (nCopied + nStart > bDest.Length)
            {
                nCopied = bDest.Length - nStart;
            }
            if (nCopied + nDataOffset > nlen)
            {
                nCopied = nlen - nDataOffset;
            }

            if (nCopied > 0)
            {
                Array.Copy(ptr, nStart + nDataOffset, bDest, 0, nCopied);
            }
            else
            {
                nCopied = 0;
            }

            return(nCopied);
        }
Exemple #2
0
        internal override long GetBytes(SqliteStatement stmt, int index, int nDataOffset, byte[] bDest, int nStart, int nLength)
        {
            IntPtr ptr;
            int    nlen;
            int    nCopied = nLength;

            nlen = UnsafeNativeMethods.sqlite3_column_bytes(stmt._sqlite_stmt, index);
            ptr  = UnsafeNativeMethods.sqlite3_column_blob(stmt._sqlite_stmt, index);

            if (bDest == null)
            {
                return(nlen);
            }

            if (nCopied + nStart > bDest.Length)
            {
                nCopied = bDest.Length - nStart;
            }
            if (nCopied + nDataOffset > nlen)
            {
                nCopied = nlen - nDataOffset;
            }

            unsafe
            {
                if (nCopied > 0)
                {
                    Marshal.Copy((IntPtr)((byte *)ptr + nDataOffset), bDest, nStart, nCopied);
                }
                else
                {
                    nCopied = 0;
                }
            }

            return(nCopied);
        }