ClickHouse/dbms/Parsers/ASTNameTypePair.h
Ivan 97f2a2213e
Move all folders inside /dbms one level up (#9974)
* Move some code outside dbms/src folder
* Fix paths
2020-04-02 02:51:21 +03:00

50 lines
1.0 KiB
C++

#pragma once
#include <Parsers/IAST.h>
#include <Common/quoteString.h>
namespace DB
{
/** A pair of the name and type. For example, browser FixedString(2).
*/
class ASTNameTypePair : public IAST
{
public:
/// name
String name;
/// type
ASTPtr type;
/** Get the text that identifies this element. */
String getID(char delim) const override { return "NameTypePair" + (delim + name); }
ASTPtr clone() const override
{
auto res = std::make_shared<ASTNameTypePair>(*this);
res->children.clear();
if (type)
{
res->type = type;
res->children.push_back(res->type);
}
return res;
}
protected:
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
settings.ostr << settings.nl_or_ws << indent_str << backQuoteIfNeed(name) << " ";
type->formatImpl(settings, state, frame);
}
};
}