10 #include <hilti/rt/extension-points.h> 11 #include <hilti/rt/types/address.h> 12 #include <hilti/rt/util.h> 17 enum class Protocol { Undef = 0, TCP, UDP, ICMP };
27 Port(uint16_t port,
Protocol protocol) : _port(port), _protocol(protocol) {}
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); }
62 operator std::string()
const;
66 void _parse(
const std::string& port);
69 Protocol _protocol = Protocol::Undef;
72 namespace detail::adl {
74 inline std::string
to_string(
const Port& x, adl::tag ) {
return x; };
77 inline std::ostream& operator<<(std::ostream& out,
const Protocol& x) {
82 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
Protocol
Definition: port.h:17
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