ClickHouse/dbms/IO/tests/write_buffer.cpp

48 lines
943 B
C++
Raw Normal View History

2010-06-01 13:35:09 +00:00
#include <string>
#include <iostream>
#include <sstream>
#include <Core/Types.h>
#include <IO/WriteHelpers.h>
#include <IO/WriteBufferFromOStream.h>
2010-06-01 13:35:09 +00:00
2017-12-01 18:36:55 +00:00
int main(int, char **)
2010-06-01 13:35:09 +00:00
{
try
{
DB::Int64 a = -123456;
DB::Float64 b = 123.456;
DB::String c = "вася пе\tтя";
DB::String d = "'xyz\\";
2010-06-01 13:35:09 +00:00
std::stringstream s;
2010-06-01 13:35:09 +00:00
{
DB::WriteBufferFromOStream out(s);
2010-06-01 13:35:09 +00:00
DB::writeIntText(a, out);
DB::writeChar(' ', out);
DB::writeFloatText(b, out);
DB::writeChar(' ', out);
DB::writeEscapedString(c, out);
DB::writeChar('\t', out);
2010-06-01 13:35:09 +00:00
DB::writeQuotedString(d, out);
DB::writeChar('\n', out);
}
2010-06-01 13:35:09 +00:00
std::cout << s.str();
}
catch (const DB::Exception & e)
{
std::cerr << e.what() << ", " << e.displayText() << std::endl;
return 1;
}
2010-06-01 13:35:09 +00:00
return 0;
2010-06-01 13:35:09 +00:00
}