|
@@ -131,7 +131,7 @@ public:
|
|
|
return equals(other);
|
|
|
}
|
|
|
|
|
|
- // \brief Compare addresses for inequality
|
|
|
+ /// \brief Compare addresses for inequality
|
|
|
///
|
|
|
/// \param other Address to compare against.
|
|
|
///
|
|
@@ -140,7 +140,40 @@ public:
|
|
|
return (!equals(other));
|
|
|
}
|
|
|
|
|
|
- // \brief Compare addresses for inequality
|
|
|
+ /// \brief Checks if one address is smaller than the other
|
|
|
+ ///
|
|
|
+ /// \param other Address to compare against.
|
|
|
+ ///
|
|
|
+ /// \return true if this address is smaller than the other address.
|
|
|
+ ///
|
|
|
+ /// It is useful for comparing which address is bigger.
|
|
|
+ /// Operations within one protocol family are obvious.
|
|
|
+ /// Comparisons between v4 and v6 will allways return v4
|
|
|
+ /// being smaller. This follows boost::asio::ip implementation
|
|
|
+ bool smaller_than(const IOAddress& other) const {
|
|
|
+ if (this->getFamily() < other.getFamily()) {
|
|
|
+ return (true);
|
|
|
+ }
|
|
|
+ if (this->getFamily() > other.getFamily()) {
|
|
|
+ return (false);
|
|
|
+ }
|
|
|
+ if (this->getFamily() == AF_INET6) {
|
|
|
+ return (this->asio_address_.to_v6() < other.asio_address_.to_v6());
|
|
|
+ } else {
|
|
|
+ return (this->asio_address_.to_v4() < other.asio_address_.to_v4());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// \brief Checks if one address is smaller than the other
|
|
|
+ ///
|
|
|
+ /// \param other Address to compare against.
|
|
|
+ ///
|
|
|
+ /// See \ref smaller_than method for details.
|
|
|
+ bool operator<(const IOAddress& other) const {
|
|
|
+ return (smaller_than(other));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// \brief Compare addresses for inequality
|
|
|
///
|
|
|
/// \param other Address to compare against.
|
|
|
///
|