Example #1
0
        public static string GetString(byte[] dat, Pointer p)
        {
            int    wordsLen = BitConverter.ToInt32(dat, p.Advance(4));
            string words    = System.Text.Encoding.UTF8.GetString(dat, p.Advance(wordsLen), wordsLen);

            return(words);
        }
Example #2
0
        /// <summary>
        /// Retr
        /// </summary>
        /// <param name="dat"></param>
        /// <param name="curPointer"></param>
        /// <returns></returns>
        public static byte[] GetBytes(byte[] dat, Pointer curPointer)
        {
            int len = GetInt(dat, curPointer);

            byte[] bytes = new byte[len];
            Util.Copy(dat, curPointer.Advance(len), bytes, 0, len);

            return(bytes);
        }
Example #3
0
        public static void AddString(ref byte[] dat, Pointer curPointer, string words)
        {
            if (words == null)
            {
                words = "";
            }
            byte[] bin = System.Text.Encoding.UTF8.GetBytes(words);
            AddInt(ref dat, curPointer, bin.Length);

            EnsureBufferSize(ref dat, curPointer, bin.Length);
            Util.Copy(bin, 0, dat, curPointer.Advance(bin.Length), bin.Length);
        }
Example #4
0
        public static short GetShort(byte[] dat, Pointer p)
        {
            short num = BitConverter.ToInt16(dat, p.Advance(2));

            return(num);
        }
Example #5
0
 public static void AddShort(ref byte[] dat, Pointer curPointer, short num)
 {
     byte[] bin = BitConverter.GetBytes(num);
     EnsureBufferSize(ref dat, curPointer, bin.Length);
     Util.Copy(bin, 0, dat, curPointer.Advance(bin.Length), bin.Length);
 }
Example #6
0
        public static bool GetBool(byte[] dat, Pointer p)
        {
            bool val = BitConverter.ToBoolean(dat, p.Advance(1));

            return(val);
        }
Example #7
0
 public static void AddBool(ref byte[] dat, Pointer curPointer, bool val)
 {
     byte[] bin = BitConverter.GetBytes(val);
     EnsureBufferSize(ref dat, curPointer, bin.Length);
     Util.Copy(bin, 0, dat, curPointer.Advance(bin.Length), bin.Length);
 }
Example #8
0
        public static uint GetUInt(byte[] dat, Pointer p)
        {
            uint num = BitConverter.ToUInt32(dat, p.Advance(4));

            return(num);
        }
Example #9
0
        public static double GetDouble(byte[] dat, Pointer p)
        {
            double num = BitConverter.ToDouble(dat, p.Advance(8));

            return(num);
        }
Example #10
0
        public static float GetSingle(byte[] dat, Pointer p)
        {
            float num = BitConverter.ToSingle(dat, p.Advance(4));

            return(num);
        }
Example #11
0
 public static byte GetByte(byte[] dat, Pointer p)
 {
     return(dat[p.Advance(1)]);
 }
Example #12
0
 public static void AddByte(ref byte[] dat, Pointer p, byte bt)
 {
     EnsureBufferSize(ref dat, p, 1);
     dat[p.Advance(1)] = bt;
 }
Example #13
0
        public static long GetLong(byte[] dat, Pointer p)
        {
            long num = BitConverter.ToInt64(dat, p.Advance(8));

            return(num);
        }
Example #14
0
 public static void AddBytes(ref byte[] dat, Pointer curPointer, byte[] bytes)
 {
     AddInt(ref dat, curPointer, bytes.Length);
     EnsureBufferSize(ref dat, curPointer, bytes.Length);
     Util.Copy(bytes, 0, dat, curPointer.Advance(bytes.Length), bytes.Length);
 }