public unsafe static uint ReadUInt32(byte[] fromBuffer, int numberOfBits, int readBitOffset) { if (numberOfBits == 32 && readBitOffset % 8 == 0) { return(*(uint *)(fromBuffer[readBitOffset / 8])); } if (numberOfBits <= 8) { return((uint)BytesUtil.ReadByte(fromBuffer, numberOfBits, readBitOffset)); } uint num = (uint)BytesUtil.ReadByte(fromBuffer, 8, readBitOffset); numberOfBits -= 8; readBitOffset += 8; if (numberOfBits <= 8) { return(num | (uint)((uint)BytesUtil.ReadByte(fromBuffer, numberOfBits, readBitOffset) << 8)); } num |= (uint)((uint)BytesUtil.ReadByte(fromBuffer, 8, readBitOffset) << 8); numberOfBits -= 8; readBitOffset += 8; if (numberOfBits <= 8) { uint num2 = (uint)BytesUtil.ReadByte(fromBuffer, numberOfBits, readBitOffset); num2 <<= 16; return(num | num2); } num |= (uint)((uint)BytesUtil.ReadByte(fromBuffer, 8, readBitOffset) << 16); numberOfBits -= 8; readBitOffset += 8; return(num | (uint)((uint)BytesUtil.ReadByte(fromBuffer, numberOfBits, readBitOffset) << 24)); }
public byte ReadByte() { int num = this.bitPosition + 8; if (this.overflow_ || num > this.endBitPosition) { this.overflow_ = true; return(0); } byte result = BytesUtil.ReadByte(this.dataBytes, 8, this.bitPosition); this.bitPosition = num; return(result); }
public bool ReadBoolean() { int num = this.bitPosition + 1; if (this.overflow_ || num > this.endBitPosition) { this.overflow_ = true; return(false); } byte b = BytesUtil.ReadByte(this.dataBytes, 1, this.bitPosition); this.bitPosition = num; return(b > 0); }