GCS  0.2.3
gu_hexdump.hpp
1 // Copyright (C) 2013 Codership Oy <info@codership.com>
2 
11 #ifndef _GU_HEXDUMP_HPP_
12 #define _GU_HEXDUMP_HPP_
13 
14 #include "gu_types.hpp"
15 
16 #include <ostream>
17 
18 namespace gu {
19 
20 class Hexdump
21 {
22 public:
23 
24  Hexdump (const void* const buf,
25  size_t const size,
26  bool const alpha = false)
27  :
28  buf_ (reinterpret_cast<const byte_t*>(buf)),
29  size_ (size),
30  alpha_(alpha)
31  {}
32 
33  std::ostream& to_stream (std::ostream& os) const;
34 
35  // according to clang C++98 wants copy ctor to be public for temporaries
36  Hexdump (const Hexdump& h) : buf_(h.buf_), size_(h.size_), alpha_(h.alpha_)
37  {}
38 
39 private:
40 
41  const byte_t* const buf_;
42  size_t const size_;
43  bool const alpha_;
44 
45  Hexdump& operator = (const Hexdump&);
46 };
47 
48 inline std::ostream&
49 operator << (std::ostream& os, const Hexdump& h)
50 {
51  return h.to_stream(os);
52 }
53 
54 }
55 
56 #endif /* _GU_HEXDUMP_HPP_ */
Definition: gu_hexdump.hpp:20