Parsing to actual class

This commit is contained in:
Matt Nadareski
2020-12-10 13:53:34 -08:00
parent 1269f2088b
commit 743daecd91
13 changed files with 29 additions and 19 deletions

View File

@@ -705,7 +705,7 @@ CREATE TABLE IF NOT EXISTS dat (
// Parse the Dat if possible
logger.User($"Adding from '{dat.Name}'");
DatFile tempdat = DatTool.CreateAndParse(fullpath);
DatFile tempdat = Parser.CreateAndParse(fullpath);
// If the Dat wasn't empty, add the information
SqliteCommand slc = null;

View File

@@ -50,7 +50,7 @@ structure according to the original DAT master directory tree structure.";
foreach (string key in foundDats.Keys)
{
// Get the DAT file associated with the key
DatFile datFile = DatTool.CreateAndParse(Path.Combine(_dats, foundDats[key]));
DatFile datFile = Parser.CreateAndParse(Path.Combine(_dats, foundDats[key]));
// Set the depot values
datFile.Header.InputDepot = new DepotInformation(true, 4);

View File

@@ -59,10 +59,10 @@ in -old DAT file. Ignores those entries in -old that are not in -new.";
DatFile datfile = DatFile.Create();
datfile.Header.Name = name;
datfile.Header.Description = description;
DatTool.ParseInto(datfile, olddat);
Parser.ParseInto(datfile, olddat);
// Diff against the new datfile
DatFile intDat = DatTool.CreateAndParse(newdat);
DatFile intDat = Parser.CreateAndParse(newdat);
DatTool.DiffAgainst(datfile, intDat, false);
DatTool.Write(intDat, outdat);
}

View File

@@ -51,10 +51,10 @@ namespace RombaSharp.Features
}
// Create the encapsulating datfile
DatFile datfile = DatTool.CreateAndParse(olddat);
DatFile datfile = Parser.CreateAndParse(olddat);
// Diff against the new datfile
DatFile intDat = DatTool.CreateAndParse(newdat);
DatFile intDat = Parser.CreateAndParse(newdat);
DatTool.DiffAgainst(datfile, intDat, false);
DatTool.Write(intDat, outdat);
}

View File

@@ -37,7 +37,7 @@ namespace RombaSharp.Features
foreach (string key in foundDats.Keys)
{
// Get the DAT file associated with the key
DatFile datFile = DatTool.CreateAndParse(Path.Combine(_dats, foundDats[key]));
DatFile datFile = Parser.CreateAndParse(Path.Combine(_dats, foundDats[key]));
// Now loop through and see if all of the hash combinations exist in the database
/* ended here */

View File

@@ -450,7 +450,7 @@ namespace SabreTools.DatFiles
var input = inputs[i];
logger.User($"Adding DAT: {input.CurrentPath}");
datFiles[i] = DatFile.Create(datFile.Header.CloneFiltering());
ParseInto(datFiles[i], input, i, keep: true);
Parser.ParseInto(datFiles[i], input, i, keep: true);
});
watch.Stop();

View File

@@ -1425,7 +1425,7 @@ namespace SabreTools.DatFiles
staticLogger.Verbose($"Beginning stat collection for '{file.CurrentPath}'");
List<string> games = new List<string>();
DatFile datdata = DatTool.CreateAndParse(file.CurrentPath);
DatFile datdata = Parser.CreateAndParse(file.CurrentPath);
datdata.Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
// Output single DAT stats (if asked)

View File

@@ -4,12 +4,22 @@ using System.Text.RegularExpressions;
using SabreTools.Core;
using SabreTools.IO;
using SabreTools.Logging;
// This file represents all methods related to parsing from a file
namespace SabreTools.DatFiles
{
public partial class DatTool
public class Parser
{
#region Logging
/// <summary>
/// Logging object
/// </summary>
private static readonly Logger logger = new Logger();
#endregion
/// <summary>
/// Create a DatFile and parse a file into it
/// </summary>

View File

@@ -133,7 +133,7 @@ Reset the internal state: reset();";
// Assume there could be multiple
foreach (ParentablePath datFilePath in datFilePaths)
{
DatTool.ParseInto(datFile, datFilePath, index++);
Parser.ParseInto(datFile, datFilePath, index++);
}
break;

View File

@@ -90,7 +90,7 @@ namespace SabreTools.Features
foreach (ParentablePath datfile in datfilePaths)
{
DatFile datdata = DatFile.Create();
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
// Set depot information
datdata.Header.InputDepot = Header.InputDepot.Clone() as DepotInformation;
@@ -128,7 +128,7 @@ namespace SabreTools.Features
DatFile datdata = DatFile.Create();
foreach (ParentablePath datfile in datfilePaths)
{
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
}
// Set depot information

View File

@@ -55,7 +55,7 @@ namespace SabreTools.Features
{
// Create and fill the new DAT
DatFile internalDat = DatFile.Create(Header);
DatTool.ParseInto(internalDat, file);
Parser.ParseInto(internalDat, file);
// Get the output directory
OutputDir = file.GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));

View File

@@ -161,7 +161,7 @@ namespace SabreTools.Features
// Create a new base DatFile
DatFile datFile = DatFile.Create(Header);
logger.User($"Processing '{Path.GetFileName(inputPath.CurrentPath)}'");
DatTool.ParseInto(datFile, inputPath, keep: true,
Parser.ParseInto(datFile, inputPath, keep: true,
keepext: datFile.Header.DatFormat.HasFlag(DatFormat.TSV)
|| datFile.Header.DatFormat.HasFlag(DatFormat.CSV)
|| datFile.Header.DatFormat.HasFlag(DatFormat.SSV));
@@ -294,7 +294,7 @@ namespace SabreTools.Features
{
// Parse the path to a new DatFile
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true);
Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true);
// Perform additional processing steps
DatTool.ApplyExtras(repDat, Extras);
@@ -319,7 +319,7 @@ namespace SabreTools.Features
{
// Parse the path to a new DatFile
DatFile repDat = DatFile.Create(userInputDat.Header.CloneFiltering());
DatTool.ParseInto(repDat, inputPath, indexId: 1, keep: true);
Parser.ParseInto(repDat, inputPath, indexId: 1, keep: true);
// Perform additional processing steps
DatTool.ApplyExtras(repDat, Extras);

View File

@@ -58,7 +58,7 @@ namespace SabreTools.Features
{
// Parse in from the file
DatFile datdata = DatFile.Create();
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
// Perform additional processing steps
DatTool.ApplyExtras(datdata, Extras);
@@ -104,7 +104,7 @@ namespace SabreTools.Features
DatFile datdata = DatFile.Create();
foreach (ParentablePath datfile in datfilePaths)
{
DatTool.ParseInto(datdata, datfile, int.MaxValue, keep: true);
Parser.ParseInto(datdata, datfile, int.MaxValue, keep: true);
}
// Perform additional processing steps