1#pragma once
2
3#include <DataTypes/DataTypeCustom.h>
4
5namespace DB
6{
7
8class ReadBuffer;
9class WriteBuffer;
10struct FormatSettings;
11class IColumn;
12
13/** Simple IDataTypeCustomTextSerialization that uses serializeText/deserializeText
14 * for all serialization and deserialization. */
15class DataTypeCustomSimpleTextSerialization : public IDataTypeCustomTextSerialization
16{
17public:
18 virtual ~DataTypeCustomSimpleTextSerialization() override;
19
20 // Methods that subclasses must override in order to get full serialization/deserialization support.
21 virtual void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override = 0;
22 virtual void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings &) const = 0;
23
24 /** Text deserialization without quoting or escaping.
25 */
26 void deserializeWholeText(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
27
28 /** Text serialization with escaping but without quoting.
29 */
30 void serializeTextEscaped(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
31 void deserializeTextEscaped(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
32
33 /** Text serialization as a literal that may be inserted into a query.
34 */
35 void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
36 void deserializeTextQuoted(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
37
38 /** Text serialization for the CSV format.
39 */
40 void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
41 /** delimiter - the delimiter we expect when reading a string value that is not double-quoted
42 * (the delimiter is not consumed).
43 */
44 void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
45
46 /** Text serialization intended for using in JSON format.
47 * force_quoting_64bit_integers parameter forces to brace UInt64 and Int64 types into quotes.
48 */
49 void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
50 void deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
51
52 /** Text serialization for putting into the XML format.
53 */
54 void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const override;
55};
56
57}
58