Exemplo n.º 1
0
        public bool Get(byte[] key, out string val)
        {
            IntPtr valptr = IntPtr.Zero;
            int    vallen = 0;

            val = null;
            if (BangDBNative.Get(_connection, key, key.Length, out valptr, out vallen) < 0)
            {
                return(false);
            }

            val = Marshal.PtrToStringAnsi(valptr, vallen);
            BangDBNative.FreeBytes(valptr);
            return(true);
        }
Exemplo n.º 2
0
        public bool Get(string key, out string val)
        {
            if (key == null)
            {
                throw new Exception("key can't be null");
            }
            IntPtr valptr;
            int    vlen;

            val = null;
            if (BangDBNative.Get(_connection, key, key.Length, out valptr, out vlen) < 0)
            {
                return(false);
            }

            val = Marshal.PtrToStringAnsi(valptr, vlen);
            BangDBNative.FreeBytes(valptr);
            return(true);
        }
Exemplo n.º 3
0
/*
 *      public bool Get(long key, out byte[] val)
 *      {
 *          byte[] k = BitConverter.GetBytes(key);
 *          val = Get(k);
 *          return (val == null) ? false : true;
 *      }
 *
 *      public bool Get(long key, out byte[] val, Transaction txn)
 *      {
 *          byte[] k = BitConverter.GetBytes(key);
 *          val = Get(k, txn);
 *          return (val == null) ? false : true;
 *      }
 *
 *      public bool Get(long key, out string val)
 *      {
 *          byte[] k = BitConverter.GetBytes(key);
 *
 *          IntPtr valptr;
 *          int vlen;
 *          if (BangDBNative.Get(_connection, k, k.Length, out valptr, out vlen) < 0)
 *              val = null;
 *          else
 *          {
 *              val = Marshal.PtrToStringAnsi(valptr, vlen);
 *              BangDBNative.FreeBytes(valptr);
 *          }
 *          return (val == null) ? false : true;
 *      }
 *
 *      public bool Get(long key, out string val, Transaction txn)
 *      {
 *          byte[] k = BitConverter.GetBytes(key);
 *
 *          IntPtr valptr;
 *          int vlen;
 *          if (BangDBNative.Get_Tran(_connection, k, k.Length, out valptr, out vlen, txn.GetTranPtr()) < 0)
 *              val = null;
 *          else
 *          {
 *              val = Marshal.PtrToStringAnsi(valptr, vlen);
 *              BangDBNative.FreeBytes(valptr);
 *          }
 *          return (val == null) ? false : true;
 *      }
 */
        public bool Get(string key, out byte[] val)
        {
            if (key == null)
            {
                throw new Exception("key can't be null");
            }
            IntPtr valptr;
            int    vlen;

            val = null;
            if (BangDBNative.Get(_connection, key, key.Length, out valptr, out vlen) < 0)
            {
                return(false);
            }

            val = new byte[vlen];
            System.Runtime.InteropServices.Marshal.Copy(valptr, val, 0, vlen);
            BangDBNative.FreeBytes(valptr);
            return(true);
        }