forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_write_int.cpp
More file actions
43 lines (33 loc) · 858 Bytes
/
Copy pathread_write_int.cpp
File metadata and controls
43 lines (33 loc) · 858 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
40
41
42
43
#include <string>
#include <iostream>
#include <base/types.h>
#include <IO/ReadBufferFromString.h>
#include <IO/WriteBufferFromString.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
int main(int, char **)
{
try
{
Int64 x1 = std::numeric_limits<Int64>::min();
Int64 x2 = 0;
std::string s;
std::cerr << static_cast<Int64>(x1) << std::endl;
{
DB::WriteBufferFromString wb(s);
DB::writeIntText(x1, wb);
}
std::cerr << s << std::endl;
{
DB::ReadBufferFromString rb(s);
DB::readIntText(x2, rb);
}
std::cerr << static_cast<Int64>(x2) << std::endl;
}
catch (const DB::Exception & e)
{
std::cerr << e.what() << ", " << e.displayText() << std::endl;
return 1;
}
return 0;
}