Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / hexdump.ct
index 513b1a4..76abf99 100644 (file)
 /** \file
     \brief hexdump non-inline template implementation */
 
-//#include "hexdump.ih"
+#include "hexdump.ih"
 
 // Custom includes
-#include <boost/io/ios_state.hpp>
-#include <iomanip> 
 
 //#include "hexdump.mpp"
 #define prefix_
@@ -37,34 +35,9 @@ template <class Iterator>
 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////////////////////////////////////////