0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-30 04:38:52 +02:00

ircd::net: Add operator! to hostport; minor cleanup.

This commit is contained in:
Jason Volk 2018-01-22 02:06:43 -08:00
parent c0fa317475
commit 4c62e0c24e

View file

@ -27,10 +27,8 @@ namespace ircd::net
struct hostport; struct hostport;
uint16_t port(const hostport &); uint16_t port(const hostport &);
const string_view &host(const hostport &);
const auto &host(const hostport &); string_view &host(hostport &);
auto &host(hostport &);
string_view string(const mutable_buffer &out, const hostport &); string_view string(const mutable_buffer &out, const hostport &);
} }
@ -53,6 +51,8 @@ struct ircd::net::hostport
string_view port {"8448"}; string_view port {"8448"};
uint16_t portnum {0}; uint16_t portnum {0};
bool operator!() const;
hostport(const string_view &host, const string_view &port) hostport(const string_view &host, const string_view &port)
:host{host} :host{host}
,port{port} ,port{port}
@ -74,13 +74,21 @@ struct ircd::net::hostport
friend std::ostream &operator<<(std::ostream &, const hostport &); friend std::ostream &operator<<(std::ostream &, const hostport &);
}; };
inline auto & inline bool
ircd::net::hostport::operator!()
const
{
static const hostport defaults{};
return net::host(*this) == net::host(defaults);
}
inline ircd::string_view &
ircd::net::host(hostport &hp) ircd::net::host(hostport &hp)
{ {
return hp.host; return hp.host;
} }
inline const auto & inline const ircd::string_view &
ircd::net::host(const hostport &hp) ircd::net::host(const hostport &hp)
{ {
return hp.host; return hp.host;