using System;
using SabreTools.Library.DatFiles;
using SabreTools.Library.Tools;
#if MONO
using System.IO;
#else
using Alphaleonis.Win32.Filesystem;
using FileStream = System.IO.FileStream;
using IOException = System.IO.IOException;
using MemoryStream = System.IO.MemoryStream;
using SearchOption = System.IO.SearchOption;
using SeekOrigin = System.IO.SeekOrigin;
using Stream = System.IO.Stream;
using StreamWriter = System.IO.StreamWriter;
#endif
namespace SabreTools.Library.Reports
{
///
/// Base class for a report output format
///
public abstract class BaseReport
{
protected DatFile _datFile;
protected StreamWriter _writer;
protected bool _baddumpCol;
protected bool _nodumpCol;
///
/// Create a new report from the input DatFile and the filename
///
/// DatFile to write out statistics for
/// Name of the file to write out to
/// True if baddumps should be included in output, false otherwise
/// True if nodumps should be included in output, false otherwise
public BaseReport(DatFile datfile, string filename, bool baddumpCol = false, bool nodumpCol = false)
{
_datFile = datfile;
_writer = new StreamWriter(FileTools.TryCreate(filename));
_baddumpCol = baddumpCol;
_nodumpCol = nodumpCol;
}
///
/// Create a new report from the input DatFile and the stream
///
/// DatFile to write out statistics for
/// Output stream to write to
/// True if baddumps should be included in output, false otherwise
/// True if nodumps should be included in output, false otherwise
public BaseReport(DatFile datfile, Stream stream, bool baddumpCol = false, bool nodumpCol = false)
{
_datFile = datfile;
if (!stream.CanWrite)
{
throw new ArgumentException(nameof(stream));
}
_writer = new StreamWriter(stream);
_baddumpCol = baddumpCol;
_nodumpCol = nodumpCol;
}
///
/// Replace the DatFile that is being output
///
///
public void ReplaceDatFile(DatFile datfile)
{
_datFile = datfile;
}
///
/// Write the report to the output stream
///
/// Number of games to use, -1 means use the number of keys
public abstract void Write(long game = -1);
///
/// Write out the header to the stream, if any exists
///
public abstract void WriteStatsHeader();
///
/// Write out the mid-header to the stream, if any exists
///
public abstract void WriteStatsMidHeader();
///
/// Write out the separator to the stream, if any exists
///
public abstract void WriteStatsMidSeparator();
///
/// Write out the footer-separator to the stream, if any exists
///
public abstract void WriteStatsFooterSeparator();
///
/// Write out the footer to the stream, if any exists
///
public abstract void WriteStatsFooter();
}
}