17#ifndef _FGE_C_IDENTITY_HPP_INCLUDED
18#define _FGE_C_IDENTITY_HPP_INCLUDED
20#include "C_ipAddress.hpp"
33 Port _port{FGE_ANYPORT};
35 [[nodiscard]]
inline bool operator==(
Identity const& right)
const
37 return (this->_ip == right._ip) && (this->_port == right._port);
40 [[nodiscard]]
inline std::string toString()
const
42 return this->_ip.
toString().value_or(
"UNDEFINED") +
":" + std::to_string(this->_port);
53 inline std::size_t operator()(
Identity const&
id)
const
55 auto const h1 = std::hash<IpAddress>{}(
id._ip);
56 auto const h2 = std::hash<Port>{}(
id._port);
57 return h1 ^ (h2 << 1);
A class to represent an IP address.
Definition C_ipAddress.hpp:57
std::optional< std::string > toString() const
Get the ip address in a string format.
A class to hash an Identity (useful for std::unordered_map or other containers)
Definition C_identity.hpp:52
A class to represent a client or server identity with an IP address and a port.
Definition C_identity.hpp:31