ClickHouse/dbms/src/Parsers/ASTEnumElement.h

40 lines
876 B
C++
Raw Normal View History

#pragma once
2018-12-19 17:57:51 +00:00
#include "IAST.h"
#include <Core/Field.h>
#include <Common/FieldVisitors.h>
namespace DB
{
class ASTEnumElement : public IAST
{
public:
String name;
Field value;
2018-02-26 03:37:08 +00:00
ASTEnumElement(const String & name, const Field & value)
: name{name}, value {value} {}
2018-12-19 17:57:51 +00:00
String getID(char) const override { return "EnumElement"; }
ASTPtr clone() const override
{
2018-02-26 03:37:08 +00:00
return std::make_shared<ASTEnumElement>(name, value);
}
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, ' ');
settings.ostr << settings.nl_or_ws << indent_str << '\'' << name << "' = " << applyVisitor(FieldVisitorToString{}, value);
}
};
}