| 1 | #include <string> |
| 2 | |
| 3 | #include <iostream> |
| 4 | #include <sstream> |
| 5 | |
| 6 | #include <Core/Types.h> |
| 7 | #include <IO/WriteHelpers.h> |
| 8 | #include <IO/WriteBufferFromOStream.h> |
| 9 | |
| 10 | |
| 11 | int main(int, char **) |
| 12 | { |
| 13 | try |
| 14 | { |
| 15 | DB::Int64 a = -123456; |
| 16 | DB::Float64 b = 123.456; |
| 17 | DB::String c = "вася пе\tтя" ; |
| 18 | DB::String d = "'xyz\\" ; |
| 19 | |
| 20 | std::stringstream s; |
| 21 | |
| 22 | { |
| 23 | DB::WriteBufferFromOStream out(s); |
| 24 | |
| 25 | DB::writeIntText(a, out); |
| 26 | DB::writeChar(' ', out); |
| 27 | |
| 28 | DB::writeFloatText(b, out); |
| 29 | DB::writeChar(' ', out); |
| 30 | |
| 31 | DB::writeEscapedString(c, out); |
| 32 | DB::writeChar('\t', out); |
| 33 | |
| 34 | DB::writeQuotedString(d, out); |
| 35 | DB::writeChar('\n', out); |
| 36 | } |
| 37 | |
| 38 | std::cout << s.str(); |
| 39 | } |
| 40 | catch (const DB::Exception & e) |
| 41 | { |
| 42 | std::cerr << e.what() << ", " << e.displayText() << std::endl; |
| 43 | return 1; |
| 44 | } |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |