using System;
using Volpe.Cafe.IO.DSV;

namespace Volpe.Cafe.IO.CSV
{
    /// <summary>
    /// Represents a writer that can write data to a comma-separated values (CSV) file.
    /// </summary>
    /// <inheritdoc cref="CsvFile" path="/remarks"/>
    [Serializable]
    public class CsvWriter : DsvWriter
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CsvWriter"/> class for the specified file, using the default
        /// encoding and buffer size. If the file exists, it will be appended to if <paramref name="headers"/> is
        /// <c>null</c>; otherwise, it will be overwritten. If the file does not exist, this constructor creates a new
        /// file. When a new file is created, the specified <paramref name="headers"/> will be written to the file.
        /// When a file is opened in append mode, the headers will be read from the existing file.
        /// </summary>
        /// <param name="path">The complete file path to write to.</param>
        /// <param name="headers">
        ///     An array of column headers to write to the file, or null, if appending an existing file.
        /// </param>
        /// <inheritdoc cref="DsvWriter(string, string[], char)" path="/exception"/>
        public CsvWriter(string path, string[] headers) : base(path, headers, CsvFile.Delimiter) { }

        /// <inheritdoc cref="CsvWriter(string, string[])"/>
        /// <inheritdoc cref="DsvWriter(string, string[], char, char, string)" path="/remarks"/>
        protected CsvWriter(string path, string[] headers, char escapeChar, string newLine)
            : base(path, headers, CsvFile.Delimiter, escapeChar, newLine) { }

        /// <inheritdoc/>
        protected override bool NewLineEOF => false;

    }
}
