1#pragma once
2
3#include <Core/Block.h>
4#include <Formats/FormatSettings.h>
5#include <Processors/Formats/IRowOutputFormat.h>
6
7
8namespace DB
9{
10
11class WriteBuffer;
12
13/** A stream for outputting data in tsv format.
14 */
15class TabSeparatedRowOutputFormat : public IRowOutputFormat
16{
17public:
18 /** with_names - output in the first line a header with column names
19 * with_types - output the next line header with the names of the types
20 */
21 TabSeparatedRowOutputFormat(
22 WriteBuffer & out_,
23 const Block & header_,
24 bool with_names_,
25 bool with_types_,
26 FormatFactory::WriteCallback callback,
27 const FormatSettings & format_settings_);
28
29 String getName() const override { return "TabSeparatedRowOutputFormat"; }
30
31 void writeField(const IColumn & column, const IDataType & type, size_t row_num) override;
32 void writeFieldDelimiter() override;
33 void writeRowEndDelimiter() override;
34 void writePrefix() override;
35 void writeBeforeTotals() override;
36 void writeBeforeExtremes() override;
37
38 /// https://www.iana.org/assignments/media-types/text/tab-separated-values
39 String getContentType() const override { return "text/tab-separated-values; charset=UTF-8"; }
40
41protected:
42
43 bool with_names;
44 bool with_types;
45 const FormatSettings format_settings;
46};
47
48}
49