| @@ -107,104 +107,48 @@ namespace Discord.ETF | |||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (sbyte)ReadLongInternal(type); | return (sbyte)ReadLongInternal(type); | ||||
| } | } | ||||
| public int? ReadNullableSByte() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (sbyte)ReadLongInternal(type); | |||||
| } | |||||
| public uint ReadByte() | public uint ReadByte() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (byte)ReadLongInternal(type); | return (byte)ReadLongInternal(type); | ||||
| } | } | ||||
| public uint? ReadNullableByte() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (byte)ReadLongInternal(type); | |||||
| } | |||||
| public int ReadShort() | public int ReadShort() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (short)ReadLongInternal(type); | return (short)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 uint ReadUShort() | public uint ReadUShort() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (ushort)ReadLongInternal(type); | return (ushort)ReadLongInternal(type); | ||||
| } | } | ||||
| public uint? ReadNullableUShort() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (ushort)ReadLongInternal(type); | |||||
| } | |||||
| public int ReadInt() | public int ReadInt() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (int)ReadLongInternal(type); | return (int)ReadLongInternal(type); | ||||
| } | } | ||||
| public int? ReadNullableInt() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (int)ReadLongInternal(type); | |||||
| } | |||||
| public uint ReadUInt() | public uint ReadUInt() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (uint)ReadLongInternal(type); | return (uint)ReadLongInternal(type); | ||||
| } | } | ||||
| public uint? ReadNullableUInt() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (uint)ReadLongInternal(type); | |||||
| } | |||||
| public long ReadLong() | public long ReadLong() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return ReadLongInternal(type); | return ReadLongInternal(type); | ||||
| } | } | ||||
| public long? ReadNullableLong() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return ReadLongInternal(type); | |||||
| } | |||||
| public ulong ReadULong() | public ulong ReadULong() | ||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (ulong)ReadLongInternal(type); | return (ulong)ReadLongInternal(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 long ReadLongInternal(ETFType type) | public long ReadLongInternal(ETFType type) | ||||
| { | { | ||||
| switch (type) | switch (type) | ||||
| @@ -239,29 +183,86 @@ namespace Discord.ETF | |||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return (float)ReadDoubleInternal(type); | return (float)ReadDoubleInternal(type); | ||||
| } | } | ||||
| public float? ReadNullableSingle() | |||||
| public double ReadDouble() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| return ReadDoubleInternal(type); | |||||
| } | |||||
| public double ReadDoubleInternal(ETFType type) | |||||
| { | |||||
| throw new NotImplementedException(); | |||||
| } | |||||
| public int? ReadNullableSByte() | |||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | ||||
| return (float)ReadDoubleInternal(type); | |||||
| return (sbyte)ReadLongInternal(type); | |||||
| } | } | ||||
| public double ReadDouble() | |||||
| public uint? ReadNullableByte() | |||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| return ReadDoubleInternal(type); | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (byte)ReadLongInternal(type); | |||||
| } | } | ||||
| public double? ReadNullableDouble() | |||||
| public int? ReadNullableShort() | |||||
| { | { | ||||
| _stream.Read(_buffer, 0, 1); | _stream.Read(_buffer, 0, 1); | ||||
| ETFType type = (ETFType)_buffer[0]; | ETFType type = (ETFType)_buffer[0]; | ||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | ||||
| return ReadDoubleInternal(type); | |||||
| return (short)ReadLongInternal(type); | |||||
| } | } | ||||
| public double ReadDoubleInternal(ETFType type) | |||||
| public uint? ReadNullableUShort() | |||||
| { | { | ||||
| throw new NotImplementedException(); | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (ushort)ReadLongInternal(type); | |||||
| } | |||||
| public int? ReadNullableInt() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (int)ReadLongInternal(type); | |||||
| } | |||||
| public uint? ReadNullableUInt() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (uint)ReadLongInternal(type); | |||||
| } | |||||
| public long? ReadNullableLong() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return ReadLongInternal(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 float? ReadNullableSingle() | |||||
| { | |||||
| _stream.Read(_buffer, 0, 1); | |||||
| ETFType type = (ETFType)_buffer[0]; | |||||
| if (type == ETFType.SMALL_ATOM_EXT && ReadNil()) return null; | |||||
| return (float)ReadDoubleInternal(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 string ReadString() | public string ReadString() | ||||