ClickHouse/src/Parsers/formatAST.h

32 lines
630 B
C++
Raw Normal View History

2011-09-04 05:14:52 +00:00
#pragma once
2010-06-28 13:44:42 +00:00
#include <ostream>
#include <Parsers/IAST.h>
2010-06-28 13:44:42 +00:00
namespace DB
{
2020-11-09 16:05:40 +00:00
class WriteBuffer;
2017-05-27 17:29:55 +00:00
/** Takes a syntax tree and turns it back into text.
* In case of INSERT query, the data will be missing.
2010-06-28 13:44:42 +00:00
*/
2020-11-09 16:05:40 +00:00
void formatAST(const IAST & ast, WriteBuffer & buf, bool hilite = true, bool one_line = false);
2010-06-28 13:44:42 +00:00
String serializeAST(const IAST & ast, bool one_line = true);
2020-11-10 18:22:26 +00:00
inline WriteBuffer & operator<<(WriteBuffer & buf, const IAST & ast)
{
formatAST(ast, buf, false, true);
return buf;
}
inline WriteBuffer & operator<<(WriteBuffer & buf, const ASTPtr & ast)
{
formatAST(*ast, buf, false, true);
return buf;
}
2014-10-01 16:38:04 +00:00
2010-06-28 13:44:42 +00:00
}