// $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
/** \file
\brief hexdump non-inline template implementation */
-//#include "hexdump.ih"
+#include "hexdump.ih"
// Custom includes
-#include <iomanip>
//#include "hexdump.mpp"
#define prefix_
///////////////////////////////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)
{
- unsigned offset (0);
- std::string ascii;
- for (; i != i_end; ++i, ++offset) {
- switch ((offset % block_size)==0) {
- case true:
- if (!ascii.empty()) {
- stream << " " << ascii << "\n";
- ascii = "";
- }
- stream << " "
- << std::hex << std::setw(4) << std::setfill('0')
- << offset << ' ';
- break;
- case false:
- stream << " ";
- ascii += ' ';
- break;
- }
- 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";
- }
- stream << std::dec;
+ detail::HexDumper dumper (stream, block_size);
+ for (; i != i_end; ++i)
+ dumper(*i);
}
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "hexdump.mpp"
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100