TF++, Miscellaneous classes and modules in C++:
hexdump.h
Go to the documentation of this file.
1 
38 // include guard
39 #ifndef TF_HEXDUMP_H_VERSION
40 
41 #define TF_HEXDUMP_H_VERSION \
42  "TF_HEXDUMP_H V1.0"
43 
44 #include<iomanip>
45 #include<iostream>
46 #include<ctype.h>
47 
48 namespace tfxx {
49 
50  namespace util {
51 
62  std::ostream& hexdump(const void* pp, const unsigned int& size,
63  std::ostream& os=std::cout,
64  const char& c='.', const unsigned int&n=16);
65 
66  /* ---------------------------------------------------------------------- */
67 
77  template<class C>
78  std::ostream& hexdump(const C& v, std::ostream& os=std::cout,
79  const char& c='.', const unsigned int&n=16)
80  {
81  // provide pointer to object
82  //const unsigned char* p=reinterpret_cast<const unsigned char *>(&v);
83  // size of object
84  const unsigned int size=sizeof(v);
85  // call raw memory hex dump
86  hexdump(&v, size, os, c, n);
87  return os;
88  } // std::ostream& hexdump(const C& v, std::ostream& os=std::cout,
89  // const char& c='.', const int&n=16)
90 
91  } // namespace util
92 
93 } // namespace tfxx
94 
98 #define TFXX_hexdump(V) std::cout << "hex dump of object \"" \
99  << #V << "\":" << std::endl; \
100  tfxx::util::hexdump(V);
101 
102 #endif // TF_HEXDUMP_H_VERSION (includeguard)
103 
104 /* ----- END OF hexdump.h ----- */
std::ostream & hexdump(const void *pp, const unsigned int &size, std::ostream &os, const char &c, const unsigned int &n)
output hex dump of memory area.
Definition: hexdump.cc:44
Namespace containing all code of library libtfxx.