Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
cet::nybbler Class Reference

#include <nybbler.h>

Public Member Functions

 nybbler ()
 
 nybbler (string const &s)
 
string as_hex () const
 
string as_char () const
 
nybbleroperator<< (string const &)
 

Private Types

typedef unsigned char uchar
 
typedef std::string string
 

Static Private Member Functions

static uchar msn (char ch)
 
static uchar lsn (char ch)
 
static char to_hex (uchar nyb)
 
static uchar to_nyb (char hex)
 

Private Attributes

string s_
 

Detailed Description

Definition at line 18 of file nybbler.h.

Member Typedef Documentation

typedef std::string cet::nybbler::string
private

Definition at line 20 of file nybbler.h.

typedef unsigned char cet::nybbler::uchar
private

Definition at line 19 of file nybbler.h.

Constructor & Destructor Documentation

cet::nybbler::nybbler ( )
inline

Definition at line 25 of file nybbler.h.

25 : s_("") {}
string s_
Definition: nybbler.h:34
cet::nybbler::nybbler ( string const &  s)
inlineexplicit

Definition at line 26 of file nybbler.h.

26 : s_(s) {}
string s_
Definition: nybbler.h:34
static QCString * s
Definition: config.cpp:1042

Member Function Documentation

string nybbler::as_char ( ) const

Definition at line 31 of file nybbler.cc.

32 {
33  string r(s_.size() / 2, 'x');
34 
35  string::const_iterator f = s_.begin();
36  for (string::iterator t = r.begin(), e = r.end(); t != e; ++t) {
37  *t = to_nyb(*f++) << 4;
38  *t |= to_nyb(*f++);
39  }
40 
41  return r;
42 }
intermediate_table::iterator iterator
intermediate_table::const_iterator const_iterator
const double e
string s_
Definition: nybbler.h:34
static uchar to_nyb(char hex)
Definition: nybbler.cc:84
string nybbler::as_hex ( ) const

Definition at line 17 of file nybbler.cc.

18 {
19  string r(s_.size() * 2, 'x');
20 
21  string::iterator t = r.begin();
22  for (string::const_iterator b = s_.begin(), e = s_.end(); b != e; ++b) {
23  *t++ = to_hex(msn(*b));
24  *t++ = to_hex(lsn(*b));
25  }
26 
27  return r;
28 }
intermediate_table::iterator iterator
static uchar msn(char ch)
Definition: nybbler.cc:45
intermediate_table::const_iterator const_iterator
static char to_hex(uchar nyb)
Definition: nybbler.cc:57
static uchar lsn(char ch)
Definition: nybbler.cc:51
const double e
string s_
Definition: nybbler.h:34
static bool * b
Definition: config.cpp:1043
uchar nybbler::lsn ( char  ch)
staticprivate

Definition at line 51 of file nybbler.cc.

52 {
53  return uchar(ch) & 0xF;
54 }
unsigned char uchar
Definition: nybbler.h:19
uchar nybbler::msn ( char  ch)
staticprivate

Definition at line 45 of file nybbler.cc.

46 {
47  return (uchar(ch) >> 4) & 0xF;
48 }
unsigned char uchar
Definition: nybbler.h:19
nybbler & nybbler::operator<< ( string const &  s)

Definition at line 118 of file nybbler.cc.

119 {
120  s_ = s;
121  return *this;
122 }
string s_
Definition: nybbler.h:34
static QCString * s
Definition: config.cpp:1042
char nybbler::to_hex ( uchar  nyb)
staticprivate

Definition at line 57 of file nybbler.cc.

58 {
59  switch (nyb) {
60  case 0u:
61  case 1u:
62  case 2u:
63  case 3u:
64  case 4u:
65  case 5u:
66  case 6u:
67  case 7u:
68  case 8u:
69  case 9u:
70  return '0' + nyb;
71  case 10u:
72  case 11u:
73  case 12u:
74  case 13u:
75  case 14u:
76  case 15u:
77  return 'A' + nyb - 10u;
78  default:
79  return '?';
80  }
81 }
uchar nybbler::to_nyb ( char  hex)
staticprivate

Definition at line 84 of file nybbler.cc.

85 {
86  switch (hex) {
87  case '0':
88  case '1':
89  case '2':
90  case '3':
91  case '4':
92  case '5':
93  case '6':
94  case '7':
95  case '8':
96  case '9':
97  return hex - '0';
98  case 'a':
99  case 'b':
100  case 'c':
101  case 'd':
102  case 'e':
103  case 'f':
104  return hex - 'a' + 10;
105  case 'A':
106  case 'B':
107  case 'C':
108  case 'D':
109  case 'E':
110  case 'F':
111  return hex - 'A' + 10;
112  default:
113  return '?';
114  }
115 }
QTextStream & hex(QTextStream &s)

Member Data Documentation

string cet::nybbler::s_
private

Definition at line 34 of file nybbler.h.


The documentation for this class was generated from the following files: