using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using SabreTools.IO.Readers; using SabreTools.Models.ClrMamePro; namespace SabreTools.Serialization { /// /// Deserializer for ClrMamePro metadata files /// public partial class ClrMamePro { /// /// Deserializes a ClrMamePro metadata file to the defined type /// /// Path to the file to deserialize /// Enable quotes on read, false otherwise /// Deserialized data on success, null on failure public static MetadataFile? Deserialize(string path, bool quotes) { using var stream = PathProcessor.OpenStream(path); return Deserialize(stream, quotes); } /// /// Deserializes a ClrMamePro metadata file in a stream to the defined type /// /// Stream to deserialize /// Enable quotes on read, false otherwise /// Deserialized data on success, null on failure public static MetadataFile? Deserialize(Stream? stream, bool quotes) { // If the stream is null if (stream == null) return default; // Setup the reader and output var reader = new ClrMameProReader(stream, Encoding.UTF8) { Quotes = quotes }; var dat = new MetadataFile(); // Loop through and parse out the values string? lastTopLevel = reader.TopLevel; GameBase? game = null; var games = new List(); var releases = new List(); var biosSets = new List(); var roms = new List(); var disks = new List(); var medias = new List(); var samples = new List(); var archives = new List(); var chips = new List(); var videos = new List