25#ifndef MYSQL_HARNESS_HEXIFY_INCLUDED
26#define MYSQL_HARNESS_HEXIFY_INCLUDED
51 for (
auto cur =
reinterpret_cast<const uint8_t *
>(
buf.data()),
52 end = cur +
buf.size();
55 std::array<char, 16L * 3> hexline{
56 '.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
57 '.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
58 '.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
59 '.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' ',
'.',
'.',
' '};
60 std::array<char, 16> printable;
62 for (
auto *hexline_pos = hexline.data(); cur != end && col < 16;
63 ++cur, ++col, hexline_pos += 3) {
66 const auto res = std::to_chars(hexline_pos, hexline_pos + 2, ch, 16);
67 if (res.ptr == hexline_pos + 1) {
69 hexline_pos[1] = std::exchange(hexline_pos[0],
'0');
72 printable[col] = std::isprint(ch) ?
static_cast<char>(ch) :
'.';
75 std::copy(hexline.begin(), hexline.end(), std::back_inserter(out));
79 for (
size_t ndx = 0; ndx < col; ++ndx) {
80 out.push_back(printable[ndx]);
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:354
Definition: buf0block_hint.cc:30
std::string hexify(const T &buf)
hexdump into a string.
Definition: hexify.h:48