diff --git a/include/address.h b/include/address.h index fb7581d..870f699 100644 --- a/include/address.h +++ b/include/address.h @@ -186,6 +186,37 @@ public: // done return str; } + + /** + * Comparison operator + * @param that + * @return bool + */ + bool operator==(const Address &that) const + { + // logins must match + if (_login != that._login) return false; + + // hostname must match, but are nt case sensitive + if (strcasecmp(_hostname.data(), that._hostname.data()) != 0) return false; + + // portnumber must match + if (_port != that._port) return false; + + // and finally the vhosts, they must match too + return _vhost == that._vhost; + } + + /** + * Comparison operator + * @param that + * @return bool + */ + bool operator!=(const Address &that) const + { + // the opposite of operator== + return !operator==(that); + } }; /** diff --git a/include/login.h b/include/login.h index d3cc34e..f68f1aa 100644 --- a/include/login.h +++ b/include/login.h @@ -97,6 +97,29 @@ public: // append other elements return result.append(_user).append("\0",1).append(_password); } + + /** + * Comparison operator + * @param that + * @return bool + */ + bool operator==(const Login &that) const + { + // username and password must match + return _user == that._user && _password == that._password; + } + + /** + * Comparison operator + * @param that + * @return bool + */ + bool operator!=(const Login &that) const + { + // the opposite of operator== + return !operator==(that); + } + }; /**