Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
cetlib
cetlib
nybbler.cc
Go to the documentation of this file.
1
// ======================================================================
2
//
3
// nybbler: Half-byte manipulations
4
//
5
// ======================================================================
6
7
#include "
cetlib/nybbler.h
"
8
9
using
cet::nybbler
;
10
11
typedef
unsigned
char
uchar
;
12
typedef
std::string
string
;
13
14
// ======================================================================
15
16
string
17
nybbler::as_hex()
const
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
}
29
30
string
31
nybbler::as_char
()
const
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
}
43
44
uchar
45
nybbler::msn
(
char
ch)
46
{
47
return
(
uchar
(ch) >> 4) & 0xF;
48
}
49
50
uchar
51
nybbler::lsn
(
char
ch)
52
{
53
return
uchar
(ch) & 0xF;
54
}
55
56
char
57
nybbler::to_hex
(
uchar
nyb)
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
}
82
83
uchar
84
nybbler::to_nyb
(
char
hex
)
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
}
116
117
nybbler
&
118
nybbler::operator<<
(
string
const
&
s
)
119
{
120
s_
=
s
;
121
return
*
this
;
122
}
123
124
// ======================================================================
iterator
intermediate_table::iterator iterator
Definition:
intermediate_table.cc:27
cet::nybbler::msn
static uchar msn(char ch)
Definition:
nybbler.cc:45
keras_to_tensorflow.f
f
Definition:
keras_to_tensorflow.py:162
string
std::string string
Definition:
nybbler.cc:12
cet::nybbler::operator<<
nybbler & operator<<(string const &)
Definition:
nybbler.cc:118
const_iterator
intermediate_table::const_iterator const_iterator
Definition:
intermediate_table.cc:28
hex
QTextStream & hex(QTextStream &s)
Definition:
qtextstream.cpp:2024
cet::nybbler::to_hex
static char to_hex(uchar nyb)
Definition:
nybbler.cc:57
uchar
unsigned char uchar
Definition:
nybbler.cc:11
cet::nybbler::lsn
static uchar lsn(char ch)
Definition:
nybbler.cc:51
cet::nybbler::uchar
unsigned char uchar
Definition:
nybbler.h:19
e
const double e
Definition:
gUpMuFluxGen.cxx:165
reco_momentum_tuples.t
t
Definition:
reco_momentum_tuples.py:25
cet::nybbler::s_
string s_
Definition:
nybbler.h:34
cet::nybbler::to_nyb
static uchar to_nyb(char hex)
Definition:
nybbler.cc:84
cet::nybbler
Definition:
nybbler.h:18
cet::nybbler::as_char
string as_char() const
Definition:
nybbler.cc:31
b
static bool * b
Definition:
config.cpp:1043
s
static QCString * s
Definition:
config.cpp:1042
plot_model.r
r
Definition:
plot_model.py:57
nybbler.h
Generated by
1.8.11