コード例 #1
0
        public BerkeleyDbError PutPartial(IntPtr pdbc, Byte[] key, Byte[] data, int dataOffset, int dataLength)
        {
            var keyDbt  = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                BerkeleyDbOperation flags;
                if (dataOffset == 0)
                {
                    keyDbt.Init(key);
                    flags = BerkeleyDbOperation.DB_KEYFIRST;
                }
                else
                {
                    keyDbt.flags = db_dbt.DB_DBT_READONLY;
                    flags        = BerkeleyDbOperation.DB_CURRENT;
                }

                dataDbt.Init(data);
                dataDbt.dlen   = (uint)dataLength;
                dataDbt.doff   = (uint)dataOffset;
                dataDbt.flags |= db_dbt.DB_DBT_PARTIAL;

                return((BerkeleyDbError)_put(pdbc, ref keyDbt, ref dataDbt, (uint)flags));
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #2
0
        public BerkeleyDbError Get(IntPtr pdbc, Byte[] key, Byte[] data, BerkeleyDbOperation operation, BerkeleyDbMultiple multiple, out int keySize, out int dataSize)
        {
            var keyDbt  = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                keyDbt.Init(key);
                dataDbt.Init(data.Length);

                var error = (BerkeleyDbError)_get(pdbc, ref keyDbt, ref dataDbt, (uint)operation | (uint)multiple);
                if (error == 0)
                {
                    keyDbt.CopyToArray(key);
                    dataDbt.CopyToArray(data);
                }

                keySize  = (int)keyDbt.size;
                dataSize = (int)dataDbt.size;
                return(error);
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #3
0
        public BerkeleyDbError Put(IntPtr pdb, Byte[] key, Byte[] data, BerkeleyDbWriteMode flags)
        {
            var keyDbt  = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                keyDbt.Init(key);
                dataDbt.Init(data);
                return((BerkeleyDbError)_put(pdb, IntPtr.Zero, ref keyDbt, ref dataDbt, (uint)flags));
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #4
0
        public BerkeleyDbError PutMultipleKey(IntPtr pdb, Byte[] data, BerkeleyDbWriteMode flags)
        {
            var keyDbt  = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                keyDbt.Init(data);
                keyDbt.flags |= db_dbt.DB_DBT_BULK;

                dataDbt.flags |= db_dbt.DB_DBT_READONLY;

                return((BerkeleyDbError)_put(pdb, IntPtr.Zero, ref keyDbt, ref dataDbt, (uint)flags | (int)BerkeleyDbMultiple.DB_MULTIPLE_KEY));
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #5
0
        public BerkeleyDbError Del(IntPtr pdb, Byte[] key, BerkeleyDbDelete flag, BerkeleyDbMultiple multiple)
        {
            var keyDbt = new db_dbt();

            try
            {
                keyDbt.Init(key);
                keyDbt.flags |= db_dbt.DB_DBT_READONLY;
                if (multiple != 0)
                {
                    keyDbt.flags |= db_dbt.DB_DBT_BULK;
                }

                return((BerkeleyDbError)_del(pdb, IntPtr.Zero, ref keyDbt, (uint)flag | (uint)multiple));
            }
            finally
            {
                keyDbt.Dispose();
            }
        }
コード例 #6
0
        public BerkeleyDbError GetPartial(IntPtr pdbc, Byte[] key, Byte[] data, int dataOffset, out int dataSize)
        {
            var keyDbt  = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                BerkeleyDbOperation flags;
                if (dataOffset == 0)
                {
                    keyDbt.Init(key);
                    flags = BerkeleyDbOperation.DB_SET;
                }
                else
                {
                    keyDbt.flags = db_dbt.DB_DBT_READONLY;
                    flags        = BerkeleyDbOperation.DB_CURRENT;
                }

                dataDbt.Init(data);
                dataDbt.dlen   = (uint)data.Length;
                dataDbt.doff   = (uint)dataOffset;
                dataDbt.flags |= db_dbt.DB_DBT_PARTIAL;

                var error = (BerkeleyDbError)_get(pdbc, ref keyDbt, ref dataDbt, (uint)flags);
                if (error == 0)
                {
                    dataDbt.CopyToArray(data);
                }
                dataSize = (int)dataDbt.size;
                return(error);
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #7
0
        public BerkeleyDbError PutMultipleKey(IntPtr pdb, Byte[] data, BerkeleyDbWriteMode flags)
        {
            var keyDbt = new db_dbt();
            var dataDbt = new db_dbt();
            try
            {
                keyDbt.Init(data);
                keyDbt.flags |= db_dbt.DB_DBT_BULK;

                dataDbt.flags |= db_dbt.DB_DBT_READONLY;

                return (BerkeleyDbError)_put(pdb, IntPtr.Zero, ref keyDbt, ref dataDbt, (uint)flags | (int)BerkeleyDbMultiple.DB_MULTIPLE_KEY);
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #8
0
 public BerkeleyDbError Put(IntPtr pdb, Byte[] key, Byte[] data, BerkeleyDbWriteMode flags)
 {
     var keyDbt = new db_dbt();
     var dataDbt = new db_dbt();
     try
     {
         keyDbt.Init(key);
         dataDbt.Init(data);
         return (BerkeleyDbError)_put(pdb, IntPtr.Zero, ref keyDbt, ref dataDbt, (uint)flags);
     }
     finally
     {
         keyDbt.Dispose();
         dataDbt.Dispose();
     }
 }
コード例 #9
0
        public BerkeleyDbError Del(IntPtr pdb, Byte[] key, BerkeleyDbDelete flag, BerkeleyDbMultiple multiple)
        {
            var keyDbt = new db_dbt();
            try
            {
                keyDbt.Init(key);
                keyDbt.flags |= db_dbt.DB_DBT_READONLY;
                if (multiple != 0)
                    keyDbt.flags |= db_dbt.DB_DBT_BULK;

                return (BerkeleyDbError)_del(pdb, IntPtr.Zero, ref keyDbt, (uint)flag | (uint)multiple);
            }
            finally
            {
                keyDbt.Dispose();
            }
        }
コード例 #10
0
        public BerkeleyDbError PutPartial(IntPtr pdbc, Byte[] key, Byte[] data, int dataOffset, int dataLength)
        {
            var keyDbt = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                BerkeleyDbOperation flags;
                if (dataOffset == 0)
                {
                    keyDbt.Init(key);
                    flags = BerkeleyDbOperation.DB_KEYFIRST;
                }
                else
                {
                    keyDbt.flags = db_dbt.DB_DBT_READONLY;
                    flags = BerkeleyDbOperation.DB_CURRENT;
                }

                dataDbt.Init(data);
                dataDbt.dlen = (uint)dataLength;
                dataDbt.doff = (uint)dataOffset;
                dataDbt.flags |= db_dbt.DB_DBT_PARTIAL;

                return (BerkeleyDbError)_put(pdbc, ref keyDbt, ref dataDbt, (uint)flags);
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #11
0
        public BerkeleyDbError GetPartial(IntPtr pdbc, Byte[] key, Byte[] data, int dataOffset, out int dataSize)
        {
            var keyDbt = new db_dbt();
            var dataDbt = new db_dbt();

            try
            {
                BerkeleyDbOperation flags;
                if (dataOffset == 0)
                {
                    keyDbt.Init(key);
                    flags = BerkeleyDbOperation.DB_SET;
                }
                else
                {
                    keyDbt.flags = db_dbt.DB_DBT_READONLY;
                    flags = BerkeleyDbOperation.DB_CURRENT;
                }

                dataDbt.Init(data);
                dataDbt.dlen = (uint)data.Length;
                dataDbt.doff = (uint)dataOffset;
                dataDbt.flags |= db_dbt.DB_DBT_PARTIAL;

                var error = (BerkeleyDbError)_get(pdbc, ref keyDbt, ref dataDbt, (uint)flags);
                if (error == 0)
                    dataDbt.CopyToArray(data);
                dataSize = (int)dataDbt.size;
                return error;
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }
コード例 #12
0
        public BerkeleyDbError Get(IntPtr pdbc, Byte[] key, Byte[] data, BerkeleyDbOperation operation, BerkeleyDbMultiple multiple, out int keySize, out int dataSize)
        {
            var keyDbt = new db_dbt();
            var dataDbt = new db_dbt();
            try
            {
                keyDbt.Init(key);
                dataDbt.Init(data.Length);

                var error = (BerkeleyDbError)_get(pdbc, ref keyDbt, ref dataDbt, (uint)operation | (uint)multiple);
                if (error == 0)
                {
                    keyDbt.CopyToArray(key);
                    dataDbt.CopyToArray(data);
                }

                keySize = (int)keyDbt.size;
                dataSize = (int)dataDbt.size;
                return error;
            }
            finally
            {
                keyDbt.Dispose();
                dataDbt.Dispose();
            }
        }