2015-12-21 13:15:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <DB/Parsers/IAST.h>
|
|
|
|
#include <DB/Parsers/ASTLiteral.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
class ASTEnumElement : public IAST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
String name;
|
2015-12-28 17:04:29 +00:00
|
|
|
Field value;
|
2015-12-21 13:15:13 +00:00
|
|
|
|
2015-12-28 17:04:29 +00:00
|
|
|
ASTEnumElement(const StringRange range, const String & name, const Field & value)
|
2015-12-21 13:15:13 +00:00
|
|
|
: IAST{range}, name{name}, value {value} {}
|
|
|
|
|
|
|
|
String getID() const override { return "EnumElement"; }
|
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
2016-05-28 15:56:51 +00:00
|
|
|
return std::make_shared<ASTEnumElement>(StringRange(), name, value);
|
2015-12-21 13:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
|
|
|
{
|
|
|
|
frame.need_parens = false;
|
|
|
|
|
|
|
|
const std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
2017-01-06 17:41:19 +00:00
|
|
|
settings.ostr << settings.nl_or_ws << indent_str << '\'' << name << "' = " << applyVisitor(FieldVisitorToString{}, value);
|
2015-12-21 13:15:13 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|