Wire through "stats only" parsing, version 1 (nw)

This commit is contained in:
Matt Nadareski
2020-12-23 13:55:09 -08:00
parent 5253ca05ab
commit 0f4a4ed585
19 changed files with 116 additions and 90 deletions

View File

@@ -191,7 +191,7 @@ namespace SabreTools.DatFiles.Formats
}
/// <inheritdoc/>
public override void ParseFile(string filename, int indexId, bool keep, bool throwOnError = false)
public override void ParseFile(string filename, int indexId, bool keep, bool statsOnly = false, bool throwOnError = false)
{
// Prepare all internal variables
XmlReader xtr = XmlReader.Create(filename, new XmlReaderSettings
@@ -242,7 +242,7 @@ namespace SabreTools.DatFiles.Formats
// We want to process the entire subtree of the machine
case "game": // Some older DATs still use "game"
case "machine":
ReadMachine(xtr.ReadSubtree(), filename, indexId);
ReadMachine(xtr.ReadSubtree(), statsOnly, filename, indexId);
// Skip the machine now that we've processed it
xtr.Skip();
@@ -274,9 +274,10 @@ namespace SabreTools.DatFiles.Formats
/// Read machine information
/// </summary>
/// <param name="reader">XmlReader representing a machine block</param>
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
/// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param>
private void ReadMachine(XmlReader reader, string filename, int indexId)
private void ReadMachine(XmlReader reader, bool statsOnly, string filename, int indexId)
{
// If we have an empty machine, skip it
if (reader == null)
@@ -761,7 +762,7 @@ namespace SabreTools.DatFiles.Formats
foreach (DatItem datItem in datItems)
{
datItem.CopyMachineInformation(machine);
ParseAddHelper(datItem);
ParseAddHelper(datItem, statsOnly);
}
}
@@ -780,7 +781,7 @@ namespace SabreTools.DatFiles.Formats
blank.CopyMachineInformation(machine);
// Now process and add the rom
ParseAddHelper(blank);
ParseAddHelper(blank, statsOnly);
}
}