1#pragma once
2
3#include <ostream>
4
5#include <DataTypes/IDataType.h>
6
7
8namespace DB
9{
10
11class DataTypeString final : public IDataType
12{
13public:
14 using FieldType = String;
15 static constexpr bool is_parametric = false;
16
17 DataTypeString(const String & type_name_ = "String") : type_name(type_name_) {}
18
19 String doGetName() const override { return type_name; }
20
21 const char * getFamilyName() const override
22 {
23 return "String";
24 }
25
26 TypeIndex getTypeId() const override { return TypeIndex::String; }
27
28 void serializeBinary(const Field & field, WriteBuffer & ostr) const override;
29 void deserializeBinary(Field & field, ReadBuffer & istr) const override;
30 void serializeBinary(const IColumn & column, size_t row_num, WriteBuffer & ostr) const override;
31 void deserializeBinary(IColumn & column, ReadBuffer & istr) const override;
32
33 void serializeBinaryBulk(const IColumn & column, WriteBuffer & ostr, size_t offset, size_t limit) const override;
34 void deserializeBinaryBulk(IColumn & column, ReadBuffer & istr, size_t limit, double avg_value_size_hint) const override;
35
36 void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
37 void deserializeWholeText(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
38
39 void serializeTextEscaped(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
40 void deserializeTextEscaped(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
41
42 void serializeTextQuoted(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
43 void deserializeTextQuoted(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
44
45 void serializeTextJSON(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
46 void deserializeTextJSON(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
47
48 void serializeTextXML(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
49
50 void serializeTextCSV(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings &) const override;
51 void deserializeTextCSV(IColumn & column, ReadBuffer & istr, const FormatSettings &) const override;
52
53 void serializeProtobuf(const IColumn & column, size_t row_num, ProtobufWriter & protobuf, size_t & value_index) const override;
54 void deserializeProtobuf(IColumn & column, ProtobufReader & protobuf, bool allow_add_row, bool & row_added) const override;
55
56 MutableColumnPtr createColumn() const override;
57
58 Field getDefault() const override;
59
60 bool equals(const IDataType & rhs) const override;
61
62 bool isParametric() const override { return false; }
63 bool haveSubtypes() const override { return false; }
64 bool isComparable() const override { return true; }
65 bool canBeComparedWithCollation() const override { return true; }
66 bool isValueUnambiguouslyRepresentedInContiguousMemoryRegion() const override { return true; }
67 bool isCategorial() const override { return true; }
68 bool canBeInsideNullable() const override { return true; }
69 bool canBeInsideLowCardinality() const override { return true; }
70
71private:
72 const String type_name;
73};
74
75}
76