X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2Fhexdump.ct;h=513b1a45ca0f5cbce7023ebc6176d680e3108f66;hb=6684208965aac5a93db01bcd189bc5c501f04c2c;hp=350c8c5b8f464ebe9f0deeee2b1833d8d12c6a14;hpb=9cd0c7d8fc22ecf342c5d2a45980c245b827a67f;p=senf.git diff --git a/Utils/hexdump.ct b/Utils/hexdump.ct index 350c8c5..513b1a4 100644 --- a/Utils/hexdump.ct +++ b/Utils/hexdump.ct @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 // it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ //#include "hexdump.ih" // Custom includes +#include #include //#include "hexdump.mpp" @@ -33,28 +34,27 @@ ///////////////////////////////cc.p//////////////////////////////////////// template -prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& stream, unsigned block_size=16) +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) { - switch ((offset % block_size)==0) { - case true: + if ((offset % block_size) == 0) { if (!ascii.empty()) { stream << " " << ascii << "\n"; ascii = ""; } stream << " " - << std::hex << std::setw(4) << std::setfill('0') - << offset << ' '; - break; - case false: + << std::hex << std::setw(4) << std::setfill('0') + << offset << ' '; + } else if ((offset % block_size) == block_size/2) { stream << " "; ascii += ' '; - break; } stream << ' ' << std::hex << std::setw(2) << std::setfill('0') - << unsigned(*i); + << unsigned(*i); ascii += (*i >= ' ' && *i < 126) ? *i : '.'; } if (!ascii.empty()) { @@ -65,14 +65,13 @@ prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& str } stream << " " << ascii << "\n"; } - stream << std::dec; } ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "hexdump.mpp" - + // Local Variables: // mode: c++ // fill-column: 100