nybbler.h
Go to the documentation of this file.
1 #ifndef cetlib_nybbler_h
2 #define cetlib_nybbler_h
3 
4 // ======================================================================
5 //
6 // nybbler: Half-byte manipulations
7 //
8 // ======================================================================
9 
10 #include <string>
11 
12 namespace cet {
13  class nybbler;
14 }
15 
16 // ======================================================================
17 
18 class cet::nybbler {
19  typedef unsigned char uchar;
21 
22 public:
23  // use compiler's d'tor, copy c'tor, copy assignment
24 
25  nybbler() : s_("") {}
26  explicit nybbler(string const& s) : s_(s) {}
27 
28  string as_hex() const;
29  string as_char() const;
30 
31  nybbler& operator<<(string const&);
32 
33 private:
34  string s_;
35 
36  static uchar msn(char ch); // most significant nybble
37  static uchar lsn(char ch); // least significant nybble
38 
39  static char to_hex(uchar nyb);
40  static uchar to_nyb(char hex);
41 
42 }; // nybbler
43 
44 // ======================================================================
45 
46 #endif /* cetlib_nybbler_h */
47 
48 // Local variables:
49 // mode: c++
50 // End:
static uchar msn(char ch)
Definition: nybbler.cc:45
std::string string
Definition: nybbler.cc:12
nybbler & operator<<(string const &)
Definition: nybbler.cc:118
QTextStream & hex(QTextStream &s)
static char to_hex(uchar nyb)
Definition: nybbler.cc:57
static uchar lsn(char ch)
Definition: nybbler.cc:51
unsigned char uchar
Definition: nybbler.h:19
string s_
Definition: nybbler.h:34
static uchar to_nyb(char hex)
Definition: nybbler.cc:84
nybbler(string const &s)
Definition: nybbler.h:26
string as_char() const
Definition: nybbler.cc:31
std::string string
Definition: nybbler.h:20
string as_hex() const
Definition: nybbler.cc:17
static QCString * s
Definition: config.cpp:1042