| 652 | } |
| 653 | |
| 654 | inline std::string BufferToHexText(const void *buffer, size_t buffer_size, |
| 655 | size_t max_length, |
| 656 | const std::string &wrapped_line_prefix, |
| 657 | const std::string &wrapped_line_suffix) { |
| 658 | std::string text = wrapped_line_prefix; |
| 659 | size_t start_offset = 0; |
| 660 | const char *s = reinterpret_cast<const char *>(buffer); |
| 661 | for (size_t i = 0; s && i < buffer_size; i++) { |
| 662 | // Last iteration or do we have more? |
| 663 | bool have_more = i + 1 < buffer_size; |
| 664 | text += "0x"; |
| 665 | text += IntToStringHex(static_cast<uint8_t>(s[i]), 2); |
| 666 | if (have_more) { text += ','; } |
| 667 | // If we have more to process and we reached max_length |
| 668 | if (have_more && |
| 669 | text.size() + wrapped_line_suffix.size() >= start_offset + max_length) { |
| 670 | text += wrapped_line_suffix; |
| 671 | text += '\n'; |
| 672 | start_offset = text.size(); |
| 673 | text += wrapped_line_prefix; |
| 674 | } |
| 675 | } |
| 676 | text += wrapped_line_suffix; |
| 677 | return text; |
| 678 | } |
| 679 | |
| 680 | // Remove paired quotes in a string: "text"|'text' -> text. |
| 681 | std::string RemoveStringQuotes(const std::string &s); |
nothing calls this directly
no test coverage detected