2017-11-07 13:56:15 -08:00
|
|
|
|
using System;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
using System.IO;
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
|
|
|
|
|
using SabreTools.Library.DatFiles;
|
|
|
|
|
|
using SabreTools.Library.Tools;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.Library.Reports
|
|
|
|
|
|
{
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Base class for a report output format
|
|
|
|
|
|
/// </summary>
|
2020-06-12 11:59:44 -07:00
|
|
|
|
/// TODO: Can this be overhauled to have all types write like DatFiles?
|
2019-02-08 20:53:13 -08:00
|
|
|
|
public abstract class BaseReport
|
|
|
|
|
|
{
|
|
|
|
|
|
protected DatFile _datFile;
|
|
|
|
|
|
protected StreamWriter _writer;
|
|
|
|
|
|
protected bool _baddumpCol;
|
|
|
|
|
|
protected bool _nodumpCol;
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new report from the input DatFile and the filename
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datfile">DatFile to write out statistics for</param>
|
|
|
|
|
|
/// <param name="filename">Name of the file to write out to</param>
|
|
|
|
|
|
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
|
|
|
|
|
|
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
|
|
|
|
|
public BaseReport(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
_datFile = datfile;
|
|
|
|
|
|
_writer = new StreamWriter(Utilities.TryCreate(filename));
|
|
|
|
|
|
_baddumpCol = baddumpCol;
|
|
|
|
|
|
_nodumpCol = nodumpCol;
|
|
|
|
|
|
}
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new report from the input DatFile and the stream
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datfile">DatFile to write out statistics for</param>
|
|
|
|
|
|
/// <param name="stream">Output stream to write to</param>
|
|
|
|
|
|
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
|
|
|
|
|
|
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
|
|
|
|
|
public BaseReport(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
_datFile = datfile;
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
if (!stream.CanWrite)
|
|
|
|
|
|
throw new ArgumentException(nameof(stream));
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
_writer = new StreamWriter(stream);
|
|
|
|
|
|
_baddumpCol = baddumpCol;
|
|
|
|
|
|
_nodumpCol = nodumpCol;
|
|
|
|
|
|
}
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Replace the DatFile that is being output
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datfile"></param>
|
|
|
|
|
|
public void ReplaceDatFile(DatFile datfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
_datFile = datfile;
|
|
|
|
|
|
}
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write the report to the output stream
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="game">Number of games to use, -1 means use the number of keys</param>
|
|
|
|
|
|
public abstract void Write(long game = -1);
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out the header to the stream, if any exists
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract void WriteHeader();
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out the mid-header to the stream, if any exists
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract void WriteMidHeader();
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out the separator to the stream, if any exists
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract void WriteMidSeparator();
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out the footer-separator to the stream, if any exists
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract void WriteFooterSeparator();
|
2017-11-07 13:56:15 -08:00
|
|
|
|
|
2019-02-08 20:53:13 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out the footer to the stream, if any exists
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract void WriteFooter();
|
|
|
|
|
|
}
|
2017-11-07 13:56:15 -08:00
|
|
|
|
}
|