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