ClickHouse/src/Common/parseAddress.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
632 B
C++
Raw Normal View History

2017-12-28 04:28:05 +00:00
#pragma once
#include <string>
#include <map>
2021-10-02 07:13:14 +00:00
#include <base/types.h>
2017-12-28 04:28:05 +00:00
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:
2022-04-15 22:20:47 +00:00
* clickhouse.com - returns "clickhouse.com" and default_port
* clickhouse.com:80 - returns "clickhouse.com" and 80
2017-12-28 04:28:05 +00:00
* [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);
}