mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <cstddef>
|
|
#include <Core/Types.h>
|
|
#include <DataTypes/Serializations/ISerialization.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class ReadBuffer;
|
|
class WriteBuffer;
|
|
struct FormatSettings;
|
|
class IColumn;
|
|
|
|
/** 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.
|
|
*/
|
|
class IDataTypeCustomName
|
|
{
|
|
public:
|
|
virtual ~IDataTypeCustomName() = default;
|
|
|
|
virtual String getName() const = 0;
|
|
};
|
|
|
|
using DataTypeCustomNamePtr = std::unique_ptr<const IDataTypeCustomName>;
|
|
|
|
/** Describe a data type customization
|
|
*/
|
|
struct DataTypeCustomDesc
|
|
{
|
|
DataTypeCustomNamePtr name;
|
|
SerializationPtr serialization;
|
|
|
|
explicit DataTypeCustomDesc(
|
|
DataTypeCustomNamePtr name_,
|
|
SerializationPtr serialization_ = nullptr)
|
|
: name(std::move(name_))
|
|
, serialization(std::move(serialization_)) {}
|
|
};
|
|
|
|
using DataTypeCustomDescPtr = std::unique_ptr<DataTypeCustomDesc>;
|
|
|
|
/** A simple implementation of IDataTypeCustomName
|
|
*/
|
|
class DataTypeCustomFixedName : public IDataTypeCustomName
|
|
{
|
|
private:
|
|
String name;
|
|
public:
|
|
explicit DataTypeCustomFixedName(String name_) : name(name_) {}
|
|
String getName() const override { return name; }
|
|
};
|
|
|
|
}
|