mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Wire through "stats only" parsing, version 1 (nw)
This commit is contained in:
@@ -91,7 +91,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
|
||||
@@ -132,7 +132,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// We want to process the entire subtree of the machine
|
||||
case "software":
|
||||
ReadSoftware(xtr.ReadSubtree(), filename, indexId);
|
||||
ReadSoftware(xtr.ReadSubtree(), statsOnly, filename, indexId);
|
||||
|
||||
// Skip the software now that we've processed it
|
||||
xtr.Skip();
|
||||
@@ -164,9 +164,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// Read software information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a software 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 ReadSoftware(XmlReader reader, string filename, int indexId)
|
||||
private void ReadSoftware(XmlReader reader, bool statsOnly, string filename, int indexId)
|
||||
{
|
||||
// If we have an empty software, skip it
|
||||
if (reader == null)
|
||||
@@ -220,7 +221,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
});
|
||||
}, statsOnly);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -236,7 +237,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
});
|
||||
}, statsOnly);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -249,7 +250,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
containsItems = ReadPart(reader.ReadSubtree(), machine, part, filename, indexId);
|
||||
containsItems = ReadPart(reader.ReadSubtree(), machine, part, statsOnly, filename, indexId);
|
||||
|
||||
// Skip the part now that we've processed it
|
||||
reader.Skip();
|
||||
@@ -276,7 +277,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
blank.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
ParseAddHelper(blank);
|
||||
ParseAddHelper(blank, statsOnly);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,9 +287,10 @@ namespace SabreTools.DatFiles.Formats
|
||||
/// <param name="reader">XmlReader representing a part block</param>
|
||||
/// <param name="machine">Machine information to pass to contained items</param>
|
||||
/// <param name="part">Part information to pass to contained items</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 bool ReadPart(XmlReader reader, Machine machine, Part part, string filename, int indexId)
|
||||
private bool ReadPart(XmlReader reader, Machine machine, Part part, bool statsOnly, string filename, int indexId)
|
||||
{
|
||||
// If we have an empty port, skip it
|
||||
if (reader == null)
|
||||
@@ -422,7 +424,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
item.CopyMachineInformation(machine);
|
||||
|
||||
// Finally add each item
|
||||
key = ParseAddHelper(item);
|
||||
key = ParseAddHelper(item, statsOnly);
|
||||
}
|
||||
|
||||
return items.Any();
|
||||
|
||||
Reference in New Issue
Block a user