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); }
/// <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); }
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); }
public static short GetShort(byte[] dat, Pointer p) { short num = BitConverter.ToInt16(dat, p.Advance(2)); return(num); }
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); }
public static bool GetBool(byte[] dat, Pointer p) { bool val = BitConverter.ToBoolean(dat, p.Advance(1)); return(val); }
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); }
public static uint GetUInt(byte[] dat, Pointer p) { uint num = BitConverter.ToUInt32(dat, p.Advance(4)); return(num); }
public static double GetDouble(byte[] dat, Pointer p) { double num = BitConverter.ToDouble(dat, p.Advance(8)); return(num); }
public static float GetSingle(byte[] dat, Pointer p) { float num = BitConverter.ToSingle(dat, p.Advance(4)); return(num); }
public static byte GetByte(byte[] dat, Pointer p) { return(dat[p.Advance(1)]); }
public static void AddByte(ref byte[] dat, Pointer p, byte bt) { EnsureBufferSize(ref dat, p, 1); dat[p.Advance(1)] = bt; }
public static long GetLong(byte[] dat, Pointer p) { long num = BitConverter.ToInt64(dat, p.Advance(8)); return(num); }
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); }