aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Common/parseAddress.h
blob: 297934a637905405df3898b6c406cd44c2b3cdb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

#include <string>
#include <map>
#include <base/types.h>


namespace DB
{

/** Parse address from string, that can contain host with or without port.
  * If port was not specified and default_port is not zero, default_port is used.
  * Otherwise, an exception is thrown.
  *
  * Examples:
  *  clickhouse.com - returns "clickhouse.com" and default_port
  *  clickhouse.com:80 - returns "clickhouse.com" and 80
  *  [2a02:6b8:a::a]:80 - returns [2a02:6b8:a::a] and 80; note that square brackets remain in returned host.
  */
std::pair<std::string, UInt16> parseAddress(const std::string & str, UInt16 default_port);

}