public static void Read(this IO.EndianReader s, out Vector2f v) { v = new Vector2f( s.ReadSingle(), // I s.ReadSingle() // J ); }
/// <summary>Read a <typeparamref name="TEnum"/> value from a stream</summary> /// <param name="s">Stream to read from</param> /// <param name="value">Enum value read from the stream</param> /// <remarks> /// Uses <typeparamref name="TEnum"/>'s underlying <see cref="TypeCode"/> to /// decide how big of a numeric type to read from the stream. /// </remarks> public static void Read(IO.EndianReader s, out TEnum value) { Contract.Requires(s != null); ulong stream_value; switch (Reflection.EnumUtil <TEnum> .UnderlyingTypeCode) { case TypeCode.Byte: case TypeCode.SByte: stream_value = s.ReadByte(); break; case TypeCode.Int16: case TypeCode.UInt16: stream_value = s.ReadUInt16(); break; case TypeCode.Int32: case TypeCode.UInt32: stream_value = s.ReadUInt32(); break; case TypeCode.Int64: case TypeCode.UInt64: stream_value = s.ReadUInt64(); break; default: throw new Debug.UnreachableException(); } value = Reflection.EnumValue <TEnum> .FromUInt64(stream_value); }
public static void Read(this IO.EndianReader s, out Plane3f v) { v = new Plane3f( s.ReadSingle(), // X s.ReadSingle(), // Y s.ReadSingle(), // Z s.ReadSingle() // D ); }
public static void Read(this IO.EndianReader s, out QuaternionF v) { v = new QuaternionF( s.ReadSingle(), // I s.ReadSingle(), // J s.ReadSingle(), // K s.ReadSingle() // W ); }
public static void Read(this IO.EndianReader s, out Guid value, bool respectEndian = true) { if (respectEndian) { uint a = s.ReadUInt32(); ushort b = s.ReadUInt16(); ushort c = s.ReadUInt16(); byte d = s.ReadByte(); byte e = s.ReadByte(); byte f = s.ReadByte(); byte g = s.ReadByte(); byte h = s.ReadByte(); byte i = s.ReadByte(); byte j = s.ReadByte(); byte k = s.ReadByte(); value = new Guid(a, b, c, d, e, f, g, h, i, j, k); } else { value = new Guid(s.ReadBytes(16)); } }
/// <summary> /// Read a serializable value type from an endian stream /// </summary> /// <typeparam name="T">Value type implementing <see cref="IO.IEndianStreamable"/></typeparam> /// <param name="s"></param> /// <param name="value"></param> public static void ReadObject <T>(this IO.EndianReader s, out T value) where T : struct, IO.IEndianStreamable { value = new T(); value.Read(s); }
// no Write(length) override public static void Read(this IO.EndianReader s, out string value, Text.StringStorageEncoding encoding) { value = s.ReadString(encoding); }
// no Write(length) override public static void Read(this IO.EndianReader s, out string value, Memory.Strings.StringStorage storage) { value = s.ReadString(storage); }
public static void Read(this IO.EndianReader s, out string value) { value = s.ReadString(); }
public static int Read(this byte[] value, IO.EndianReader s, int index, int count) { return(s.Read(value, index, count)); }
public static void Read(this IO.EndianReader s, out int value) => value = s.ReadInt32();
public static void Read(this IO.EndianReader s, out char value) => value = s.ReadChar();
public static void Read(this IO.EndianReader s, out sbyte value) => value = s.ReadSByte();
public static void Read(this IO.EndianReader s, out double value) => value = s.ReadDouble();
public static void Read(this IO.EndianReader s, out float value) => value = s.ReadSingle();
public static void Read(this IO.EndianReader s, out long value) => value = s.ReadInt64();
/// <summary> /// Read a serializable object from an endian stream /// </summary> /// <typeparam name="T">Reference type implementing <see cref="IO.IEndianStreamable"/></typeparam> /// <param name="s"></param> /// <param name="theObj"></param> public static void ReadObject <T>(this IO.EndianReader s, T theObj) where T : class, IO.IEndianStreamable { theObj.Read(s); }
public static int Read(this byte[] value, IO.EndianReader s) { return(s.Read(value, 0, value.Length)); }
public static void Read(this IO.EndianReader s, out bool value) => value = s.ReadBoolean();
public static void Read(this IO.EndianReader s, out short value) => value = s.ReadInt16();