2015-12-21 13:15:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-12-19 17:57:51 +00:00
|
|
|
#include "IAST.h"
|
2018-11-10 20:09:07 +00:00
|
|
|
#include <Core/Field.h>
|
|
|
|
#include <Common/FieldVisitors.h>
|
2015-12-21 13:15:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class ASTEnumElement : public IAST
|
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
String name;
|
|
|
|
Field value;
|
2015-12-21 13:15:13 +00:00
|
|
|
|
2018-02-26 03:37:08 +00:00
|
|
|
ASTEnumElement(const String & name, const Field & value)
|
|
|
|
: name{name}, value {value} {}
|
2015-12-21 13:15:13 +00:00
|
|
|
|
2018-12-19 17:57:51 +00:00
|
|
|
String getID(char) const override { return "EnumElement"; }
|
2015-12-21 13:15:13 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
2018-02-26 03:37:08 +00:00
|
|
|
return std::make_shared<ASTEnumElement>(name, value);
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2015-12-21 13:15:13 +00:00
|
|
|
|
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
2018-05-17 15:17:07 +00:00
|
|
|
frame.need_parens = false;
|
2015-12-21 13:15:13 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
const std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
|
|
|
settings.ostr << settings.nl_or_ws << indent_str << '\'' << name << "' = " << applyVisitor(FieldVisitorToString{}, value);
|
|
|
|
}
|
2015-12-21 13:15:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|