24 #ifndef STATICLIB_IO_HEX_HPP
25 #define STATICLIB_IO_HEX_HPP
50 if (plain.empty())
return std::string();
57 return std::move(sink.get_string());
77 if (hexstr.empty())
return std::string();
81 return std::move(sink.get_string());
97 if (hexstr.empty() || plain.empty())
return std::string();
100 auto pretty = std::string();
101 for (
size_t i = 0; i < hexstr.length() - 1; i += 2 ) {
102 if (pretty.length() > 0) {
103 pretty.push_back(
' ');
105 pretty.push_back(hexstr[i]);
106 pretty.push_back(hexstr[i + 1]);
110 auto clean = std::string();
111 for (
size_t i = 0; i < plain.length(); i++) {
113 if (ch < 32 || std::isspace(ch)) {
114 clean.push_back(
' ');
121 return pretty +
" [" + clean +
"]";
136 if (hexstr.empty())
return std::string();
153 if (plain.empty())
return std::string();