public override UInt16 Read(Stream stream) { var value = (UInt16)( (_accessorByte.Read(stream) << 8) | _accessorByte.Read(stream)); return(value); }
// TODO: Rework anything using BinaryPrimitives // (Float / Double with ReverseEndianness and BitConverter) public override Single Read(Stream stream) { var v = _accessorUInt32.Read(stream); unsafe { float value = *((float *)&v); return(value); } }
public override Double Read(Stream stream) { var v = _accessorUInt64.Read(stream); unsafe { double value = *((double *)&v); return(value); } }
public override String Read(Stream stream) { Int32 length = _accessorVarInt.Read(stream); if (length == 0) { return(string.Empty); } var data = _accessorByte.ReadArray(stream, length); var value = Encoding.UTF8.GetString(data); return(value); }
public override UInt64 Read(Stream stream) { var v1 = (ulong)_accessorByte.Read(stream); var v2 = (ulong)_accessorByte.Read(stream); var v3 = (ulong)_accessorByte.Read(stream); var v4 = (ulong)_accessorByte.Read(stream); var v5 = (ulong)_accessorByte.Read(stream); var v6 = (ulong)_accessorByte.Read(stream); var v7 = (ulong)_accessorByte.Read(stream); var v8 = (ulong)_accessorByte.Read(stream); var value = unchecked ( (v1 << 56) | (v2 << 48) | (v3 << 40) | (v4 << 32) | (v5 << 24) | (v6 << 16) | (v7 << 8) | (v8)); return(value); }
public override VarInt Read(Stream stream) { var v = 0; var size = 0; int b; while (((b = _accessorByte.Read(stream)) & 0x80) == 0x80) { if (b == -1) { throw new EndOfStreamException(); } v |= (b & 0x7F) << (size++ *7); if (size > 5) { throw new IOException("VarInt too long. Hehe that's punny."); } } VarInt value = (v | ((b & 0x7F) << (size * 7))); return(value); }
public override Int16 Read(Stream stream) => (Int16)_accessorU16.Read(stream);
public override Int32 Read(Stream stream) => (Int32)_accessorU32.Read(stream);
public override Int64 Read(Stream stream) => (Int64)_accessorU64.Read(stream);
public override Boolean Read(Stream stream) => _accessorByte.Read(stream) == True;
public override SByte Read(Stream stream) => (SByte)_accessorByte.Read(stream);