Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
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();
            }
        }