28 #ifndef WEBSOCKETPP_UTILITIES_HPP
29 #define WEBSOCKETPP_UTILITIES_HPP
31 #include <websocketpp/common/stdint.hpp>
37 namespace websocketpp {
48 template<
typename charT>
54 my_equal(std::locale
const & loc ) : m_loc(loc) {}
63 bool operator()(charT ch1, charT ch2) {
64 return std::toupper(ch1, m_loc) == std::toupper(ch2, m_loc);
67 std::locale
const & m_loc;
77 struct nocase_compare {
78 bool operator() (
unsigned char const & c1,
unsigned char const & c2)
const {
79 return tolower (c1) < tolower (c2);
82 bool operator() (std::string
const & s1, std::string
const & s2)
const {
83 return std::lexicographical_compare
84 (s1.begin (), s1.end (),
85 s2.begin (), s2.end (),
101 typename T::const_iterator ci_find_substr(T
const & haystack, T
const & needle,
102 std::locale
const & loc = std::locale())
104 return std::search( haystack.begin(), haystack.end(),
105 needle.begin(), needle.end(), my_equal<
typename T::value_type>(loc) );
123 typename T::const_iterator ci_find_substr(T
const & haystack,
124 typename T::value_type
const * needle,
typename T::size_type size,
125 std::locale
const & loc = std::locale())
127 return std::search( haystack.begin(), haystack.end(),
128 needle, needle+size, my_equal<
typename T::value_type>(loc) );
136 std::string to_lower(std::string
const & in);
146 std::string string_replace_all(std::string subject, std::string
const & search,
147 std::string
const & replace);
155 std::string to_hex(std::string
const & input);
164 std::string to_hex(uint8_t
const * input, size_t length);
173 std::string to_hex(
char const * input, size_t length);
178 #include <websocketpp/impl/utilities_impl.hpp>