45 inline void hex_dump(
const void* aData, std::size_t aLength, std::basic_ostream<Elem, Traits>& aStream, std::size_t aWidth = 16)
47 const char*
const start =
static_cast<const char*
>(aData);
48 const char*
const end = start + aLength;
49 const char* line = start;
54 aStream << std::hex << line - start <<
" : ";
55 std::size_t lineLength = std::min(aWidth,
static_cast<std::size_t
>(end - line));
56 for (std::size_t pass = 1; pass <= 2; ++pass)
58 for (
const char* next = line; next != end && next != line + aWidth; ++next)
64 aStream << (ch < 32 ?
'.' : ch);
71 aStream << std::hex << std::uppercase << static_cast<int>(
static_cast<unsigned char>(ch));
75 if (pass == 1 && lineLength != aWidth)
76 aStream << std::string(aWidth - lineLength,
' ');
80 line = line + lineLength;