ClickHouse/dbms/src/IO/tests/write_buffer.cpp

48 lines
800 B
C++
Raw Normal View History

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