Use SeparatedValueWriter, fix a couple things

This commit is contained in:
Matt Nadareski
2020-06-13 22:15:21 -07:00
parent c32bfc35f9
commit 35d0fab5e1
6 changed files with 292 additions and 200 deletions

View File

@@ -72,7 +72,7 @@ namespace SabreTools.Library.Tools
/// <summary>
/// Write a value row
/// </summary>
public void WriteValues(object[] values)
public void WriteValues(object[] values, bool newline = true)
{
// If the writer can't be used, we error
if (sw == null || !sw.BaseStream.CanWrite)
@@ -106,7 +106,7 @@ namespace SabreTools.Library.Tools
if (Quotes)
sw.Write("\"");
sw.Write(value.ToString());
sw.Write(value?.ToString() ?? string.Empty);
if (Quotes)
sw.Write("\"");
@@ -125,10 +125,35 @@ namespace SabreTools.Library.Tools
}
}
// Add a newline
sw.WriteLine();
// Add a newline, if needed
if (newline)
sw.WriteLine();
}
// Flush the buffer
/// <summary>
/// Write a generic string
/// </summary>
public void WriteString(string value)
{
if (string.IsNullOrEmpty(value))
return;
sw.Write(value);
}
/// <summary>
/// Write a newline
/// </summary>
public void WriteLine()
{
sw.WriteLine();
}
/// <summary>
/// Flush the underlying writer
/// </summary>
public void Flush()
{
sw.Flush();
}