1#pragma once
2
3#include <string>
4#include <Processors/Formats/IOutputFormat.h>
5#include <Formats/FormatSettings.h>
6#include <Core/Block.h>
7
8
9namespace DB
10{
11
12class WriteBuffer;
13
14
15/** A data format designed to simplify the implementation of the ODBC driver.
16 * ODBC driver is designed to be build for different platforms without dependencies from the main code,
17 * so the format is made that way so that it can be as easy as possible to parse it.
18 * A header is displayed with the required information.
19 * The data is then output in the order of the rows. Each value is displayed as follows: length in VarUInt format, then data in text form.
20 */
21class ODBCDriverBlockOutputFormat : public IOutputFormat
22{
23public:
24 ODBCDriverBlockOutputFormat(WriteBuffer & out_, const Block & header_, const FormatSettings & format_settings_);
25
26 String getName() const override { return "ODBCDriverBlockOutputFormat"; }
27
28 void consume(Chunk) override;
29 void finalize() override;
30
31 std::string getContentType() const override { return "application/octet-stream"; }
32
33private:
34 const FormatSettings format_settings;
35 bool prefix_written = false;
36
37 void writePrefixIfNot()
38 {
39 if (!prefix_written)
40 writePrefix();
41
42 prefix_written = true;
43 }
44
45 void writePrefix();
46};
47
48}
49