//! CSV writer. //! //! Wraps an `Io.Writer` and emits CSV-formatted output. Fields containing //! the delimiter, the quote character, `\r`, or `\n` are automatically //! quoted, with embedded quote characters doubled per RFC 4180. const std = @import("std"); const Io = std.Io; const Dialect = @import("dialect.zig").Dialect; pub const Writer = struct { child_writer: *Io.Writer, dialect: Dialect, // Internal: whether the next write should be preceded by a delimiter // (i.e. we are mid-row). mid_row: bool = false, /// Construct a writer that emits CSV data to `writer`. pub fn init(writer: *Io.Writer, dialect: Dialect) Writer { _ = writer; _ = dialect; @panic("Writer.init unimplemented"); } /// Write a single field. If `end_of_row` is true, a newline is /// emitted after the field; otherwise the dialect's delimiter is /// emitted before the next field. /// /// The field is automatically quoted if its contents require it. pub fn writeField(self: *Writer, data: []const u8, end_of_row: bool) !void { _ = self; _ = data; _ = end_of_row; @panic("Writer.writeField unimplemented"); } /// Convenience: write an entire row in one call. Equivalent to /// calling `writeField` for each element with `end_of_row` set on /// the last one. pub fn writeRow(self: *Writer, fields: []const []const u8) !void { _ = self; _ = fields; @panic("Writer.writeRow unimplemented"); } /// Flushes any pending output to the underlying writer. Must be /// called before discarding the writer to avoid losing buffered /// data. pub fn flush(self: *Writer) !void { _ = self; @panic("Writer.flush unimplemented"); } }; test "Writer: stubs compile" {}