0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 18:18:56 +02:00

ircd::net::hostport: Deinline amalgam constructors.

This commit is contained in:
Jason Volk 2020-02-28 10:18:13 -08:00
parent a8a3166936
commit ac021785a2
2 changed files with 57 additions and 59 deletions

View file

@ -97,65 +97,6 @@ ircd::net::hostport::hostport(const string_view &host,
}
{}
/// Creates a host:service or host:port pair from the single string literally
/// containing the colon deliminated values. If the suffix is a port number
/// then the behavior for the port number constructor applies; if a service
/// string then the service constructor applies; if empty (just a hostname)
/// then service "matrix" is assumed with port 8448 fallback.
inline
ircd::net::hostport::hostport(const string_view &amalgam)
:host
{
rfc3986::host(amalgam)
}
,port
{
rfc3986::port(amalgam)
}
{
// When the amalgam has no port
if(amalgam == host)
{
// set the port to the canon_port; port=0 is bad
port = port?: canon_port;
return;
}
// or a valid integer port
if(port)
return;
// When the port is actually a service string
const auto service
{
rsplit(amalgam, ':').second
};
if(service)
this->service = service;
else
this->port = canon_port;
}
inline
ircd::net::hostport::hostport(const string_view &amalgam,
verbatim_t)
:host
{
rfc3986::host(amalgam)
}
,service
{
amalgam != host && !rfc3986::port(amalgam)?
rsplit(amalgam, ':').second:
string_view{}
}
,port
{
rfc3986::port(amalgam)
}
{}
inline
ircd::net::hostport::operator
bool()

View file

@ -4365,6 +4365,63 @@ ircd::net::canon_service
"matrix"
};
/// Creates a host:service or host:port pair from the single string literally
/// containing the colon deliminated values. If the suffix is a port number
/// then the behavior for the port number constructor applies; if a service
/// string then the service constructor applies; if empty (just a hostname)
/// then service "matrix" is assumed with port 8448 fallback.
ircd::net::hostport::hostport(const string_view &amalgam)
:host
{
rfc3986::host(amalgam)
}
,port
{
rfc3986::port(amalgam)
}
{
// When the amalgam has no port
if(amalgam == host)
{
// set the port to the canon_port; port=0 is bad
port = port?: canon_port;
return;
}
// or a valid integer port
if(port)
return;
// When the port is actually a service string
const auto service
{
rsplit(amalgam, ':').second
};
if(service)
this->service = service;
else
this->port = canon_port;
}
ircd::net::hostport::hostport(const string_view &amalgam,
verbatim_t)
:host
{
rfc3986::host(amalgam)
}
,service
{
amalgam != host && !rfc3986::port(amalgam)?
rsplit(amalgam, ':').second:
string_view{}
}
,port
{
rfc3986::port(amalgam)
}
{}
std::ostream &
ircd::net::operator<<(std::ostream &s, const hostport &t)
{