public uint ReadUShort() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; return((ushort)ReadLongInternal(type)); }
public double ReadDouble() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; return(ReadDoubleInternal(type)); }
public uint ReadByte() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; return((byte)ReadLongInternal(type)); }
public bool?ReadNullableBool() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; if (type == ETFType.SMALL_ATOM_EXT) { _stream.Read(_buffer, 0, 1); switch (_buffer[0]) //Length { case 3: if (ReadNil()) { return(null); } break; case 4: ReadTrue(); return(true); case 5: ReadFalse(); return(false); } } throw new InvalidDataException(); }
public float ReadSingle() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; return((float)ReadDoubleInternal(type)); }
public long ReadLongInternal(ETFType type) { switch (type) { case ETFType.SMALL_INTEGER_EXT: _stream.Read(_buffer, 0, 1); return(_buffer[0]); case ETFType.INTEGER_EXT: _stream.Read(_buffer, 0, 4); return((_buffer[0] << 24) | (_buffer[1] << 16) | (_buffer[2] << 8) | (_buffer[3])); case ETFType.SMALL_BIG_EXT: _stream.Read(_buffer, 0, 2); bool isPositive = _buffer[0] == 0; byte count = _buffer[1]; int shiftValue = (count - 1) * 8; ulong value = 0; _stream.Read(_buffer, 0, count); for (int i = 0; i < count; i++, shiftValue -= 8) { value = value + _buffer[i] << shiftValue; } if (!isPositive) { return(-(long)value); } else { return((long)value); } } throw new InvalidDataException(); }
public ulong ReadULong() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; return((ulong)ReadLongInternal(type)); }
public int ReadInt() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; return((int)ReadLongInternal(type)); }
public double?ReadNullableDouble() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) { return(null); } return(ReadDoubleInternal(type)); }
public ulong?ReadNullableULong() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) { return(null); } return((ulong)ReadLongInternal(type)); }
public int?ReadNullableShort() { _stream.Read(_buffer, 0, 1); ETFType type = (ETFType)_buffer[0]; if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) { return(null); } return((short)ReadLongInternal(type)); }
public double ReadDoubleInternal(ETFType type) { throw new NotImplementedException(); }