10 #include <hilti/rt/extension-points.h> 11 #include <hilti/rt/types/address.h> 12 #include <hilti/rt/util.h> 17 HILTI_RT_ENUM(Protocol, Undef = 0, TCP, UDP, ICMP);
39 explicit Port(
const std::string&
port) { _parse(port); }
46 Port& operator=(
const Port&) =
default;
47 Port& operator=(
Port&&) noexcept =
default;
50 auto port()
const {
return _port; }
55 bool operator==(
const Port& other)
const {
return _port == other._port && _protocol == other._protocol; }
56 bool operator!=(
const Port& other)
const {
return ! (*
this == other); }
57 bool operator<(
const Port& other)
const {
58 return std::tie(_port, _protocol) < std::tie(other._port, other._protocol);
65 operator std::string()
const;
69 void _parse(
const std::string&
port);
72 Protocol _protocol = Protocol::Undef;
75 namespace detail::adl {
76 extern std::string
to_string(
const Protocol& x, adl::tag );
77 inline std::string
to_string(
const Port& x, adl::tag ) {
return x; };
80 inline std::ostream& operator<<(std::ostream& out,
const Protocol& x) {
85 inline std::ostream& operator<<(std::ostream& out,
const Port& x) {
std::string to_string(T &&x)
Definition: extension-points.h:26
auto protocol() const
Definition: port.h:53
Port(uint16_t port, Protocol protocol)
Definition: port.h:27
Port(const std::string &port)
Definition: port.h:39
auto port() const
Definition: port.h:50