1 | #pragma once |
2 | |
3 | #include <string> |
4 | #include <map> |
5 | #include <common/Types.h> |
6 | |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | /** Parse address from string, that can contain host with or without port. |
12 | * If port was not specified and default_port is not zero, default_port is used. |
13 | * Otherwise, an exception is thrown. |
14 | * |
15 | * Examples: |
16 | * yandex.ru - returns "yandex.ru" and default_port |
17 | * yandex.ru:80 - returns "yandex.ru" and 80 |
18 | * [2a02:6b8:a::a]:80 - returns [2a02:6b8:a::a] and 80; note that square brackets remain in returned host. |
19 | */ |
20 | std::pair<std::string, UInt16> parseAddress(const std::string & str, UInt16 default_port); |
21 | |
22 | } |
23 | |