added operator< to AMQP::Address
This commit is contained in:
parent
5c002774de
commit
b25bd583a3
|
|
@ -216,7 +216,7 @@ public:
|
||||||
// logins must match
|
// logins must match
|
||||||
if (_login != that._login) return false;
|
if (_login != that._login) return false;
|
||||||
|
|
||||||
// hostname must match, but are nt case sensitive
|
// hostname must match, but are not case sensitive
|
||||||
if (strcasecmp(_hostname.data(), that._hostname.data()) != 0) return false;
|
if (strcasecmp(_hostname.data(), that._hostname.data()) != 0) return false;
|
||||||
|
|
||||||
// portnumber must match
|
// portnumber must match
|
||||||
|
|
@ -237,6 +237,29 @@ public:
|
||||||
return !operator==(that);
|
return !operator==(that);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparison operator that is useful if addresses have to be ordered
|
||||||
|
* @param that
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
bool operator<(const Address &that) const
|
||||||
|
{
|
||||||
|
// compare logins
|
||||||
|
if (_login != that._login) return _login < that._login;
|
||||||
|
|
||||||
|
// hostname must match, but are not case sensitive
|
||||||
|
int result = strcasecmp(_hostname.data(), that._hostname.data());
|
||||||
|
|
||||||
|
// if hostnames are not equal, we know the result
|
||||||
|
if (result != 0) return result < 0;
|
||||||
|
|
||||||
|
// portnumber must match
|
||||||
|
if (_port != that._port) return _port < that._port;
|
||||||
|
|
||||||
|
// and finally compare the vhosts
|
||||||
|
return _vhost < that._vhost;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Friend function to allow writing the address to a stream
|
* Friend function to allow writing the address to a stream
|
||||||
* @param stream
|
* @param stream
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,20 @@ public:
|
||||||
return !operator==(that);
|
return !operator==(that);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparison operator
|
||||||
|
* @param that
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
bool operator<(const Login &that) const
|
||||||
|
{
|
||||||
|
// compare users
|
||||||
|
if (_user != that._user) return _user < that._user;
|
||||||
|
|
||||||
|
// compare passwords
|
||||||
|
return _password < that._password;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Friend function to allow writing the login to a stream
|
* Friend function to allow writing the login to a stream
|
||||||
* @param stream
|
* @param stream
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue