X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2Fhexdump.ct;h=76abf997d51641ad96612e14ba4614884c83bb5c;hb=412024ed31a4ab4eaea7a4165a434f8efebee325;hp=b9a6fb547cca44434c2a77c9dc3983172a5f9a26;hpb=f73fa16ed5abdce272ac77f8b8b9ef2b9922c266;p=senf.git diff --git a/Utils/hexdump.ct b/Utils/hexdump.ct index b9a6fb5..76abf99 100644 --- a/Utils/hexdump.ct +++ b/Utils/hexdump.ct @@ -1,8 +1,8 @@ // $Id$ // // Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,11 +23,9 @@ /** \file \brief hexdump non-inline template implementation */ -//#include "hexdump.ih" +#include "hexdump.ih" // Custom includes -#include -#include //#include "hexdump.mpp" #define prefix_ @@ -37,34 +35,9 @@ template prefix_ void senf::hexdump(Iterator i, Iterator i_end, std::ostream & stream, unsigned block_size) { - boost::io::ios_all_saver ias (stream); - unsigned offset (0); - std::string ascii; - for (; i != i_end; ++i, ++offset) { - if ((offset % block_size) == 0) { - if (!ascii.empty()) { - stream << " " << ascii << "\n"; - ascii = ""; - } - stream << " " - << std::hex << std::setw(4) << std::setfill('0') - << offset << ' '; - } else if ((offset % block_size) == block_size/2) { - stream << " "; - ascii += ' '; - } - stream << ' ' << std::hex << std::setw(2) << std::setfill('0') - << unsigned(*i); - ascii += (*i >= ' ' && *i < 126) ? *i : '.'; - } - if (!ascii.empty()) { - for (; (offset % block_size) != 0; ++offset) { - if ((offset % block_size) == block_size/2) - stream << " "; - stream << " "; - } - stream << " " << ascii << "\n"; - } + detail::HexDumper dumper (stream, block_size); + for (; i != i_end; ++i) + dumper(*i); } ///////////////////////////////cc.e////////////////////////////////////////