1 | #include "ReplicatedMergeTreeAddress.h" |
---|---|
2 | #include <IO/ReadBufferFromString.h> |
3 | #include <IO/WriteBufferFromString.h> |
4 | #include <IO/Operators.h> |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | |
10 | void ReplicatedMergeTreeAddress::writeText(WriteBuffer & out) const |
11 | { |
12 | out |
13 | << "host: "<< escape << host << '\n' |
14 | << "port: "<< replication_port << '\n' |
15 | << "tcp_port: "<< queries_port << '\n' |
16 | << "database: "<< escape << database << '\n' |
17 | << "table: "<< escape << table << '\n' |
18 | << "scheme: "<< escape << scheme << '\n'; |
19 | |
20 | } |
21 | |
22 | void ReplicatedMergeTreeAddress::readText(ReadBuffer & in) |
23 | { |
24 | in |
25 | >> "host: ">> escape >> host >> "\n" |
26 | >> "port: ">> replication_port >> "\n" |
27 | >> "tcp_port: ">> queries_port >> "\n" |
28 | >> "database: ">> escape >> database >> "\n" |
29 | >> "table: ">> escape >> table >> "\n"; |
30 | |
31 | if (!in.eof()) |
32 | in >> "scheme: ">> escape >> scheme >> "\n"; |
33 | else |
34 | scheme = "http"; |
35 | } |
36 | |
37 | String ReplicatedMergeTreeAddress::toString() const |
38 | { |
39 | WriteBufferFromOwnString out; |
40 | writeText(out); |
41 | return out.str(); |
42 | } |
43 | |
44 | void ReplicatedMergeTreeAddress::fromString(const String & str) |
45 | { |
46 | ReadBufferFromString in(str); |
47 | readText(in); |
48 | } |
49 | } |
50 |