示例#1
0
 // uint16
 public static bool read(bintalk.IReader r, ref ushort v, uint maxValue)
 {
     byte[] data; int startId;
     if (!r.read(2, out data, out startId)) return false;
     v = BitConverter.ToUInt16(data, startId);
     return true;
 }
示例#2
0
 // float
 public static bool read(bintalk.IReader r, ref float v, uint maxValue)
 {
     byte[] data; int startId;
     if (!r.read(4, out data, out startId)) return false;
     v = BitConverter.ToSingle(data, startId);
     return true;
 }
示例#3
0
 // uint8
 public static bool read(bintalk.IReader r, ref byte v, uint maxValue)
 {
     byte[] data; int startId;
     if (!r.read(1, out data, out startId))
         return false;
     v = data[startId];
     return true;
 }
示例#4
0
 // binary.
 public static bool read(bintalk.IReader r, ref byte[] v, uint maxValue)
 {
     uint s;
     if (!readDynSize(r, out s) || s > maxValue)
         return false;
     v = new byte[s];
     byte[] data; int startId;
     if(!r.read(s, out data, out startId))
         return false;
     Array.Copy(data, startId, v, 0, s);
     return true;
 }
示例#5
0
 // string.
 public static bool read(bintalk.IReader r, ref string v, uint maxValue)
 {
     uint s;
     if (!readDynSize(r, out s) || s > maxValue)
         return false;
     byte[] data; int startId;
     if(!r.read(s, out data, out startId))
         return false;
     v = Encoding.UTF8.GetString(data, startId, (int)s);
     return true;
 }