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();
            }
        }
        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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
        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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
     }
 }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }