mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 18:14:03 +00:00
50 lines
748 B
C++
50 lines
748 B
C++
#ifndef DBMS_COMMON_ESCAPING_OUTPUT_STREAM_H
|
|
#define DBMS_COMMON_ESCAPING_OUTPUT_STREAM_H
|
|
|
|
#include <ostream>
|
|
|
|
#include <Poco/UnbufferedStreamBuf.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
|
|
/** Поток, который эскейпит всё, что в него пишут.
|
|
*/
|
|
class EscapingStreamBuf : public Poco::UnbufferedStreamBuf
|
|
{
|
|
public:
|
|
EscapingStreamBuf(std::ostream & ostr);
|
|
|
|
protected:
|
|
int writeToDevice(char c);
|
|
|
|
private:
|
|
std::ostream * p_ostr;
|
|
};
|
|
|
|
|
|
class EscapingIOS : public virtual std::ios
|
|
{
|
|
public:
|
|
EscapingIOS(std::ostream & ostr);
|
|
EscapingStreamBuf * rdbuf();
|
|
|
|
protected:
|
|
EscapingStreamBuf buf;
|
|
};
|
|
|
|
|
|
class EscapingOutputStream : public EscapingIOS, public std::ostream
|
|
{
|
|
public:
|
|
EscapingOutputStream(std::ostream & ostr);
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|