28 #ifndef WEBSOCKETPP_UTILITIES_IMPL_HPP
29 #define WEBSOCKETPP_UTILITIES_IMPL_HPP
34 inline std::string
to_lower(std::string
const & in) {
36 std::transform(out.begin(),out.end(),out.begin(),::tolower);
40 inline std::string
to_hex(
const std::string& input) {
42 std::string hex =
"0123456789ABCDEF";
44 for (
size_t i = 0; i < input.size(); i++) {
45 output += hex[(input[i] & 0xF0) >> 4];
46 output += hex[input[i] & 0x0F];
53 inline std::string
to_hex(
const uint8_t* input,
size_t length) {
55 std::string hex =
"0123456789ABCDEF";
57 for (
size_t i = 0; i < length; i++) {
58 output += hex[(input[i] & 0xF0) >> 4];
59 output += hex[input[i] & 0x0F];
66 inline std::string
to_hex(
const char* input,
size_t length) {
67 return to_hex(reinterpret_cast<const uint8_t*>(input),length);
71 search,
const std::string& replace)
74 while((pos = subject.find(search, pos)) != std::string::npos) {
75 subject.replace(pos, search.length(), replace);
76 pos += replace.length();
84 #endif // WEBSOCKETPP_UTILITIES_IMPL_HPP
std::string string_replace_all(std::string subject, const std::string &search, const std::string &replace)
Replace all occurrances of a substring with another.
std::string to_hex(const std::string &input)
Convert std::string to ascii printed string of hex digits.
Namespace for the WebSocket++ project.
std::string to_lower(std::string const &in)
Convert a string to lowercase.