/// <summary> /// Reads the Double from the current stream and advances the current position of the stream by Double size. /// </summary> public static double ReadDouble(this BinaryReader reader, ColumnMeta meta) { if (meta != null && meta.Bits != -32) { throw new Exception("TypeCode.Double Unknown meta.Bits"); } return(reader.ReadDouble()); }
/// <summary> /// Reads the String from the current stream and advances the current position of the stream by String size. /// </summary> public static string ReadString(this BinaryReader reader, ColumnMeta meta) { if (meta != null && meta.Bits != 0x00) { throw new Exception("TypeCode.String Unknown meta.Bits"); } return(reader.ReadStringNull()); }
/// <summary> /// Reads the Single from the current stream and advances the current position of the stream by Single size. /// </summary> public static float ReadSingle(this BinaryReader reader, ColumnMeta meta) { if (meta != null && meta.Bits != 0x00) { throw new Exception("TypeCode.Single Unknown meta.Bits"); } return(reader.ReadSingle()); }
/// <summary> /// Reads the UInt64 from the current stream and advances the current position of the stream by UInt64 size. /// </summary> public static ulong ReadUInt64(this BinaryReader reader, ColumnMeta meta) { if (meta == null) { return(reader.ReadUInt64()); } else { byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3); ulong u64 = 0; for (int i = 0; i < b.Length; i++) { u64 |= ((ulong)b[i] << i * 8); } return(u64); } }
/// <summary> /// Reads the UInt32 from the current stream and advances the current position of the stream by UInt32 size. /// </summary> public static uint ReadUInt32(this BinaryReader reader, ColumnMeta meta) { if (meta == null) { return(reader.ReadUInt32()); } else { byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3); uint u32 = 0; for (int i = 0; i < b.Length; i++) { u32 |= ((uint)b[i] << i * 8); } return(u32); } }
/// <summary> /// Reads the UInt16 from the current stream and advances the current position of the stream by UInt16 size. /// </summary> public static ushort ReadUInt16(this BinaryReader reader, ColumnMeta meta) { if (meta != null && meta.Bits != 0x10) { throw new Exception("TypeCode.UInt16 Unknown meta.Bits"); } return(reader.ReadUInt16()); //if (meta == null) // return reader.ReadUInt16(); //else //{ // byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3); // ushort u16 = 0; // for (int i = 0; i < b.Length; i++) // u16 |= (ushort)(b[i] << i * 8); // return u16; //} }
/// <summary> /// Reads the UInt8 from the current stream and advances the current position of the stream by UInt8 size. /// </summary> public static byte ReadUInt8(this BinaryReader reader, ColumnMeta meta) { if (meta != null && meta.Bits != 0x18) { throw new Exception("TypeCode.Byte Unknown meta.Bits"); } return(reader.ReadByte()); //if (meta == null) // return reader.ReadByte(); //else //{ // byte[] b = reader.ReadBytes((32 - meta.Bits) >> 3); // byte u8 = 0; // for (int i = 0; i < b.Length; i++) // u8 |= (byte)(b[i] << i * 8); // return u8; //} }