mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 01:07:57 +00:00
Add hash function to URL
This commit is contained in:
@@ -103,6 +103,36 @@ private:
|
|||||||
String m_userinfo;
|
String m_userinfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** URL comparisons. */
|
||||||
|
/** @{ */
|
||||||
|
inline bool operator== (URL const& lhs, URL const& rhs) { return lhs.full() == rhs.full(); }
|
||||||
|
inline bool operator!= (URL const& lhs, URL const& rhs) { return ! (lhs.full() == rhs.full()); }
|
||||||
|
inline bool operator< (URL const& lhs, URL const& rhs) { return lhs.full() < rhs.full(); }
|
||||||
|
inline bool operator> (URL const& lhs, URL const& rhs) { return rhs.full() < lhs.full(); }
|
||||||
|
inline bool operator<= (URL const& lhs, URL const& rhs) { return ! (rhs.full() < lhs.full()); }
|
||||||
|
inline bool operator>= (URL const& lhs, URL const& rhs) { return ! (lhs.full() < rhs.full()); }
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
extern std::size_t hash_value (beast::URL const& url);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct hash;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct hash <beast::URL>
|
||||||
|
{
|
||||||
|
std::size_t operator() (beast::URL const& v) const
|
||||||
|
{ return beast::hash_value (v); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ URL::URL ()
|
|||||||
: m_port (0)
|
: m_port (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
URL::URL (
|
URL::URL (
|
||||||
String scheme_,
|
String scheme_,
|
||||||
String host_,
|
String host_,
|
||||||
@@ -154,5 +153,14 @@ String URL::full () const
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
std::size_t hash_value (URL const& v)
|
||||||
|
{
|
||||||
|
return std::size_t (v.full().hash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// boost::hash support
|
||||||
Reference in New Issue
Block a user