12 #ifndef AWT_HEXDUMP_HXX
13 #define AWT_HEXDUMP_HXX
25 #ifndef _GLIBCXX_CCTYPE
44 bool is_separate_position(
size_t pos)
const {
return separate && pos && !(pos%separate); }
51 if (hex||ascii) dump_sep(buf);
54 void dump_hex(
GBS_strstruct& buf,
const char *mem,
size_t off,
size_t count,
bool padded)
const {
56 for (i = 0; i<count; ++i) {
57 if (is_separate_position(i)) buf.
put(
' ');
59 if (space) buf.
put(
' ');
62 for (; i<width; ++i) {
63 buf.
nput(
' ', 2+space+is_separate_position(i));
68 void dump_ascii(
GBS_strstruct& buf,
const char *mem,
size_t off,
size_t count)
const {
69 for (
size_t i = 0; i<count; ++i) {
70 if (is_separate_position(i)) buf.
put(
' ');
71 buf.
put(isprint(mem[off+i]) ? mem[off+i] :
'.');
74 void dump_line(
GBS_strstruct& buf,
const char *mem,
size_t off,
size_t count)
const {
75 dump_offset(buf, off);
77 dump_hex(buf, mem, off, count, ascii);
78 if (ascii) dump_sep(buf);
80 if (ascii) dump_ascii(buf, mem, off, count);
83 void dump_wrapped(
GBS_strstruct& buf,
const char *mem,
size_t size)
const {
87 size_t count = size<width ? size : width;
88 dump_line(buf, mem, off, count);
96 MemDump(
bool show_offset_,
bool hex_,
bool ascii_,
size_t width_ = 0,
size_t separate_ = 0,
bool space_ =
true)
97 : show_offset(show_offset_),
108 size_t sections = show_offset+hex+ascii;
110 if (!sections)
return 1;
112 size_t perByte = hex*3+ascii;
113 size_t extraPerLine = (sections-1)*3+1;
114 size_t lines = width ? bytes/width+1 : 1;
116 return bytes*perByte + lines*extraPerLine + 50;
121 if (
wrapped()) dump_wrapped(buf, mem, size);
125 mod.dump_wrapped(buf, mem, size);
134 #error awt_hexdump.hxx included twice
135 #endif // AWT_HEXDUMP_HXX
void cut_tail(size_t byte_count)
void nput(char c, size_t count)
void cat(const char *from)
CONSTEXPR_INLINE char nibble2hex(unsigned char c)
size_t mem_needed_for_dump(size_t bytes) const
void dump_to(GBS_strstruct &buf, const char *mem, size_t size) const
MemDump(bool show_offset_, bool hex_, bool ascii_, size_t width_=0, size_t separate_=0, bool space_=true)
void dump_hexbyte(GBS_strstruct &buf, unsigned char c)