28 #ifndef WEBSOCKETPP_UTILITIES_IMPL_HPP 29 #define WEBSOCKETPP_UTILITIES_IMPL_HPP 37 inline std::string
to_lower(std::string
const & in) {
39 std::transform(out.begin(),out.end(),out.begin(),::tolower);
43 inline std::string
to_hex(std::string
const & input) {
45 std::string hex =
"0123456789ABCDEF";
47 for (size_t i = 0; i < input.size(); i++) {
48 output += hex[(input[i] & 0xF0) >> 4];
49 output += hex[input[i] & 0x0F];
56 inline std::string
to_hex(uint8_t
const * input, size_t length) {
58 std::string hex =
"0123456789ABCDEF";
60 for (size_t i = 0; i < length; i++) {
61 output += hex[(input[i] & 0xF0) >> 4];
62 output += hex[input[i] & 0x0F];
69 inline std::string
to_hex(
const char* input,size_t length) {
70 return to_hex(
reinterpret_cast<
const uint8_t*>(input),length);
74 search, std::string
const & replace)
77 while((pos = subject.find(search, pos)) != std::string::npos) {
78 subject.replace(pos, search.length(), replace);
79 pos += replace.length();
std::string string_replace_all(std::string subject, std::string const &search, std::string const &replace)
Replace all occurrances of a substring with another.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
std::string to_hex(std::string const &input)
Convert std::string to ascii printed string of hex digits.
std::string to_hex(uint8_t const *input, size_t length)
Convert byte array (uint8_t) to ascii printed string of hex digits.
std::string to_hex(const char *input, size_t length)
Convert char array to ascii printed string of hex digits.
std::string to_lower(std::string const &in)
Convert a string to lowercase.
Generic non-websocket specific utility functions and data structures.