Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

hd.cpp

Example: hd.cpp application


#include <iostream>
#include <fstream>
#include "cxxtools/hdstream.h"
#include "cxxtools/arg.h"
#include <algorithm>

class Hexdumper
{
    unsigned offset;

  public:
    explicit Hexdumper(unsigned offset_)
      : offset(offset_)
        { }
    void operator() (const char* file)
    {
      std::ifstream in(file);
      cxxtools::Hdostream hd;
      if (offset)
      {
        in.seekg(offset);
        hd.setOffset(offset);
      }
      hd << in.rdbuf() << std::flush;
    }
};

int main(int argc, char* argv[])
{
  cxxtools::Arg<unsigned> offset(argc, argv, 'o', 0);

  std::for_each(argv + 1, argv + argc, Hexdumper(offset));
}
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6