public static ReadUInt ( Stream s ) : |
||
s | Stream | |
Результат |
public static VInt ReadUInt(Stream s)
{
int b = s.ReadByte();
if (b<0) throw new EndOfStreamException();
int len = CheckLength(b);
var bin = new byte[len];
bin[0] = (byte)b;
long res = b;
for (var i=1; i<len; i++) {
b = s.ReadByte();
if (b<0) throw new EndOfStreamException();
bin[i] = (byte)b;
res = (res<<8) | (byte)b;
}
res &= (1<<(7*len))-1;
return new VInt(res, bin);
}
public static Element ReadHeader(Stream s) { var id = VInt.ReadUInt(s); var sz = VInt.ReadUInt(s); return(new Element(id, sz)); }