ClickHouse/src/DataTypes/DataTypeCustom.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
#include <memory>
#include <cstddef>
#include <Core/Types.h>
2021-03-09 14:10:28 +00:00
#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;
2021-03-09 14:10:28 +00:00
SerializationPtr serialization;
2020-11-10 12:13:33 +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_)) {}
};
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; }
};
}