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)
string as_char() const
string as_hex() const
static char to_hex(uchar nyb)
nybbler & operator<<(string const &)
const XML_Char * s
Definition: expat.h:262
unsigned char uchar
Definition: nybbler.h:19
string s_
Definition: nybbler.h:34
static uchar lsn(char ch)
nybbler(string const &s)
Definition: nybbler.h:26
std::string string
Definition: nybbler.h:20
static uchar to_nyb(char hex)
enum BeamMode string