public VariableHeader ReadNextRecordVariableMeta(IBinaryReadStream stream) { RecordType rec = new RecordType(stream.GetInt32()); if (rec == Mutagen.Bethesda.Internals.Constants.Group) { return(this.GroupConstants.VariableMeta(stream.ReadSpan(this.GroupConstants.HeaderLength))); } else { return(this.MajorConstants.VariableMeta(stream.ReadSpan(this.MajorConstants.HeaderLength))); } }
public SubrecordFrame ReadSubrecordFrame(IBinaryReadStream stream, RecordType targetType) { var meta = GetSubrecord(stream); if (meta.RecordType != targetType) { throw new ArgumentException($"Unexpected header type: {meta.RecordType}"); } return(new SubrecordFrame(meta, stream.ReadSpan(meta.TotalLength))); }
public bool TryReadSubrecordFrame(IBinaryReadStream stream, RecordType targetType, out SubrecordFrame frame) { if (!TryGetSubrecord(stream, targetType, out var meta)) { frame = default; return(false); } frame = new SubrecordFrame(meta, stream.ReadSpan(meta.TotalLength)); return(true); }
public bool TryReadMod(IBinaryReadStream stream, out ModHeader header) { if (stream.Remaining < this.ModHeaderLength) { header = default; return(false); } header = new ModHeader(this, stream.ReadSpan(this.ModHeaderLength)); return(true); }
public bool TryReadGroupFrame(IBinaryReadStream stream, out GroupFrame frame, bool checkIsGroup = true) { if (!TryGetGroup(stream, out var meta, checkIsGroup: checkIsGroup)) { frame = default; return(false); } frame = new GroupFrame(meta, stream.ReadSpan(checked ((int)meta.TotalLength))); return(true); }
/// <summary> /// Reads a color from the binary stream. /// The stream will be advanced 4 bytes (or 3 if only 3 remain). /// If the stream has more than 3 bytes, the 4th byte will be interpreted as alpha. /// Will throw an exception if there is not at least 3 bytes remaining. /// </summary> /// <param name="stream">Stream to read from</param> /// <param name="binaryType">Format to read the color as</param> /// <returns>Bytes converted to a Color object</returns> public static Color ReadColor(this IBinaryReadStream stream, ColorBinaryType binaryType) { switch (binaryType) { case ColorBinaryType.NoAlpha: return(ReadColor(stream.ReadSpan(3), binaryType)); case ColorBinaryType.Alpha: return(ReadColor(stream.ReadSpan(4), binaryType)); case ColorBinaryType.NoAlphaFloat: return(ReadColor(stream.ReadSpan(12), binaryType)); case ColorBinaryType.AlphaFloat: return(ReadColor(stream.ReadSpan(16), binaryType)); default: throw new NotImplementedException(); } }
public SubrecordFrame ReadSubrecordFrame(IBinaryReadStream stream) { var meta = GetSubrecord(stream); return(new SubrecordFrame(meta, stream.ReadSpan(meta.TotalLength))); }
public SubrecordHeader ReadSubrecord(IBinaryReadStream stream) => new SubrecordHeader(this, stream.ReadSpan(this.SubConstants.HeaderLength));
public MajorRecordFrame ReadMajorRecordFrame(IBinaryReadStream stream) { var meta = GetMajorRecord(stream); return(new MajorRecordFrame(meta, stream.ReadSpan(checked ((int)meta.TotalLength)))); }
public MajorRecordHeader ReadMajorRecord(IBinaryReadStream stream) => new MajorRecordHeader(this, stream.ReadSpan(this.MajorConstants.HeaderLength));
public GroupFrame ReadGroupFrame(IBinaryReadStream stream) { var meta = GetGroup(stream); return(new GroupFrame(meta, stream.ReadSpan(checked ((int)meta.TotalLength)))); }
public GroupHeader ReadGroup(IBinaryReadStream stream, int offset = 0) => new GroupHeader(this, stream.ReadSpan(this.GroupConstants.HeaderLength, offset));
public ModHeader ReadMod(IBinaryReadStream stream) => new ModHeader(this, stream.ReadSpan(this.ModHeaderLength));
public VariableHeader ReadVariableMeta(IBinaryReadStream stream) => new VariableHeader(this, stream.ReadSpan(this.HeaderLength));