From b49e5993550f6c762b03a8de70ff7bf70a3ad011 Mon Sep 17 00:00:00 2001 From: Erwin Nindl Date: Tue, 11 Dec 2007 13:53:03 +0000 Subject: added pretty buffer print --- buffer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'buffer.cpp') diff --git a/buffer.cpp b/buffer.cpp index 11387da..f0d7940 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -180,17 +180,20 @@ Buffer::operator u_int8_t*() // just for write/read tun return buf_; } -void Buffer::printHexDump() const +std::string Buffer::getHexDump() const { char text[10]; + std::string ret = ""; for( u_int32_t index = 0; index < length_; index++ ) { std::sprintf(text, "%#4x", buf_[index]); - std::cout << text << " "; + ret += text; + ret += ""; if( ((index+1) % 10) == 0 ) - std::cout << std::endl; + ret += '\n'; } + return ret; } Buffer Buffer::operator^(const Buffer &xor_by) const -- cgit v1.2.3