22 #ifndef __M2ETIS_MESSAGE_IPV4KEYPROVIDER_H__
23 #define __M2ETIS_MESSAGE_IPV4KEYPROVIDER_H__
39 std::ostringstream ret;
40 ret << int(ip[0]) <<
"." << int(ip[1]) <<
"." << int(ip[2]) <<
"." << int(ip[3]);
45 return std::to_string(port);
56 for (
int i = 0; i < 4; ++i) {
62 std::ostringstream ret;
63 ret << int(ip[0]) <<
"." << int(ip[1]) <<
"." << int(ip[2]) <<
"." << int(ip[3])<<
":" <<
port;
68 memcpy(&ip, &(key.ip),
sizeof(ip));
72 void setKey(
const std::string & key) {
73 size_t ipend = key.find(
":", 0);
74 std::string locip(key.substr(0, ipend));
76 for (
size_t i = 0; i < 4; ++i) {
77 size_t bytend = key.find(
".", pos);
78 std::stringstream ss(key.substr(pos, bytend));
84 std::stringstream sport(key.substr(ipend + 1, key.length() - ipend - 1));
89 for (
size_t i = 0; i < 4; ++i) {
90 if (ip[i] != rval.ip[i]) {
94 if (port != rval.port) {
102 for (
size_t i = 0; i < 4; ++i) {
103 if (ip[i] != rval.ip[i]) {
104 if (ip[i] < rval.ip[i]) {
111 if (port != rval.port) {
112 if (port < rval.port) {
125 template<
class Archive>
126 void serialize(Archive & ar,
unsigned int ) {
bool equals(const Key< IPv4KeyProvider > &rval) const
void setKey(const Key< IPv4KeyProvider > &key)
std::string ipStr() const
void setKey(const std::string &key)
virtual ~IPv4KeyProvider()
std::string keytoStr() const
friend class boost::serialization::access
bool smaller(const Key< IPv4KeyProvider > &rval) const