2018-12-13 13:41:47 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-03-29 20:04:04 +00:00
|
|
|
#include <memory>
|
2018-12-13 13:41:47 +00:00
|
|
|
#include <cstddef>
|
2019-03-08 16:49:10 +00:00
|
|
|
#include <Core/Types.h>
|
2021-03-09 14:10:28 +00:00
|
|
|
#include <DataTypes/Serializations/ISerialization.h>
|
2018-12-13 13:41:47 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ReadBuffer;
|
|
|
|
class WriteBuffer;
|
|
|
|
struct FormatSettings;
|
|
|
|
class IColumn;
|
|
|
|
|
2019-03-29 20:04:04 +00:00
|
|
|
/** Allow to customize an existing data type and set a different name and/or text serialization/deserialization methods.
|
|
|
|
* See use in IPv4 and IPv6 data types, and also in SimpleAggregateFunction.
|
2018-12-13 13:41:47 +00:00
|
|
|
*/
|
2019-03-29 20:04:04 +00:00
|
|
|
class IDataTypeCustomName
|
2018-12-13 13:41:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-03-12 17:46:38 +00:00
|
|
|
virtual ~IDataTypeCustomName() = default;
|
2019-03-29 20:04:04 +00:00
|
|
|
|
|
|
|
virtual String getName() const = 0;
|
2019-03-08 16:49:10 +00:00
|
|
|
};
|
|
|
|
|
2019-03-29 20:04:04 +00:00
|
|
|
using DataTypeCustomNamePtr = std::unique_ptr<const IDataTypeCustomName>;
|
|
|
|
|
|
|
|
/** Describe a data type customization
|
|
|
|
*/
|
|
|
|
struct DataTypeCustomDesc
|
|
|
|
{
|
|
|
|
DataTypeCustomNamePtr name;
|
2021-03-09 14:10:28 +00:00
|
|
|
SerializationPtr serialization;
|
2020-11-10 12:13:33 +00:00
|
|
|
|
2022-03-12 17:46:38 +00:00
|
|
|
explicit DataTypeCustomDesc(
|
2020-11-10 12:13:33 +00:00
|
|
|
DataTypeCustomNamePtr name_,
|
2021-03-09 14:10:28 +00:00
|
|
|
SerializationPtr serialization_ = nullptr)
|
2020-11-10 12:13:33 +00:00
|
|
|
: name(std::move(name_))
|
2021-03-09 14:10:28 +00:00
|
|
|
, serialization(std::move(serialization_)) {}
|
2019-03-29 20:04:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using DataTypeCustomDescPtr = std::unique_ptr<DataTypeCustomDesc>;
|
|
|
|
|
|
|
|
/** A simple implementation of IDataTypeCustomName
|
|
|
|
*/
|
|
|
|
class DataTypeCustomFixedName : public IDataTypeCustomName
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
String name;
|
|
|
|
public:
|
2022-03-12 17:46:38 +00:00
|
|
|
explicit DataTypeCustomFixedName(String name_) : name(name_) {}
|
2019-03-29 20:04:04 +00:00
|
|
|
String getName() const override { return name; }
|
|
|
|
};
|
|
|
|
|
2019-06-13 10:37:13 +00:00
|
|
|
}
|