コード例 #1
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        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);
        }
コード例 #2
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        /// <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);
        }
コード例 #3
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        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);
        }
コード例 #4
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        public static short GetShort(byte[] dat, Pointer p)
        {
            short num = BitConverter.ToInt16(dat, p.Advance(2));

            return(num);
        }
コード例 #5
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
 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);
 }
コード例 #6
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        public static bool GetBool(byte[] dat, Pointer p)
        {
            bool val = BitConverter.ToBoolean(dat, p.Advance(1));

            return(val);
        }
コード例 #7
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
 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);
 }
コード例 #8
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        public static uint GetUInt(byte[] dat, Pointer p)
        {
            uint num = BitConverter.ToUInt32(dat, p.Advance(4));

            return(num);
        }
コード例 #9
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        public static double GetDouble(byte[] dat, Pointer p)
        {
            double num = BitConverter.ToDouble(dat, p.Advance(8));

            return(num);
        }
コード例 #10
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        public static float GetSingle(byte[] dat, Pointer p)
        {
            float num = BitConverter.ToSingle(dat, p.Advance(4));

            return(num);
        }
コード例 #11
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
 public static byte GetByte(byte[] dat, Pointer p)
 {
     return(dat[p.Advance(1)]);
 }
コード例 #12
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
 public static void AddByte(ref byte[] dat, Pointer p, byte bt)
 {
     EnsureBufferSize(ref dat, p, 1);
     dat[p.Advance(1)] = bt;
 }
コード例 #13
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
        public static long GetLong(byte[] dat, Pointer p)
        {
            long num = BitConverter.ToInt64(dat, p.Advance(8));

            return(num);
        }
コード例 #14
0
ファイル: BitPacker.cs プロジェクト: Amitkapadi/WISP
 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);
 }