set HIDE_UNDOC_RELATIONS to NO /grmpf/
[senf.git] / Utils / hexdump.ct
index 40aa12d..513b1a4 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
 // Copyright (C) 2007
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Stefan Bund <g0dil@berlios.de>
 //
 // 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 <boost/io/ios_state.hpp>
 #include <iomanip> 
 
 //#include "hexdump.mpp"
 ///////////////////////////////cc.p////////////////////////////////////////
 
 template <class Iterator>
-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) {
@@ -44,14 +47,14 @@ prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& str
                 ascii = "";
             }
             stream << "  "
-                      << std::hex << std::setw(4) << std::setfill('0')
-                      << offset << ' ';
+                   << 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);
+               << unsigned(*i);
         ascii += (*i >= ' ' && *i < 126) ? *i : '.';
     }
     if (!ascii.empty()) {
@@ -62,7 +65,6 @@ prefix_ void senf::hexdump(Iterator i, Iterator const & i_end, std::ostream& str
         }
         stream << "  " << ascii << "\n";
     }
-    stream << std::dec;
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////