MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / BufferToHexText

Function BufferToHexText

Libs/flatbuffers/util.h:659–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

IntToStringHexFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected