forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_escaped_string.cpp
More file actions
39 lines (28 loc) · 819 Bytes
/
Copy pathread_escaped_string.cpp
File metadata and controls
39 lines (28 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <string>
#include <iostream>
#include <IO/ReadHelpers.h>
#include <IO/ReadBufferFromMemory.h>
#include <IO/ConcatReadBuffer.h>
using namespace DB;
int main(int, char **)
try
{
std::string s1 = "abc\\x\n";
std::string s2 = "\tdef";
ReadBufferFromMemory rb1(s1.data(), 3);
ReadBufferFromMemory rb2(s2.data(), s2.size());
ConcatReadBuffer rb3(rb1, rb2);
std::string read_s1;
std::string read_s2;
readEscapedString(read_s1, rb3);
assertChar('\t', rb3);
readEscapedString(read_s2, rb3);
std::cerr << read_s1 << ", " << read_s2 << std::endl;
std::cerr << ((read_s1 == "abc" && read_s2 == "def") ? "Ok." : "Fail.") << std::endl;
return 0;
}
catch (const Exception & e)
{
std::cerr << e.what() << ", " << e.displayText() << std::endl;
return 1;
}