Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
buffer.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file buffer.cc
1
#include "
buffer.h
"
2
#include "
gzbuffer.h
"
3
#include "
lzobuffer.h
"
4
#include "
prdfBuffer.h
"
5
#include "
oncsBuffer.h
"
6
7
8
buffer::buffer
()
9
{
10
11
}
12
13
14
buffer::~buffer
()
15
{}
16
17
18
int
buffer::makeBuffer
(
PHDWORD
*bp,
const
int
allocatedsize,
buffer
**bptr)
19
{
20
if
( bp[1]==
GZBUFFERMARKER
||
buffer::u4swap
(bp[1])==
GZBUFFERMARKER
)
21
{
22
*bptr =
new
gzbuffer
(bp, allocatedsize );
23
return
0;
24
}
25
26
else
if
( bp[1]==
LZO1XBUFFERMARKER
||
buffer::u4swap
(bp[1])==
LZO1XBUFFERMARKER
)
27
{
28
*bptr =
new
lzobuffer
( bp, allocatedsize );
29
return
0;
30
}
31
32
else
if
( bp[1]==
ONCSBUFFERMARKER
||
buffer::u4swap
(bp[1])==
ONCSBUFFERMARKER
)
33
{
34
*bptr =
new
oncsBuffer
( bp, allocatedsize );
35
return
0;
36
}
37
38
else
if
( bp[1]==
BUFFERMARKER
||
buffer::u4swap
(bp[1])==
BUFFERMARKER
)
39
{
40
*bptr =
new
prdfBuffer
( bp, allocatedsize );
41
return
0;
42
}
43
44
*bptr = 0;
45
return
-1;
46
}
47
48
49
50
// ---------------------------------------------------------
51
int
buffer::i4swap
(
const
int
in
)
52
{
53
union
54
{
55
int
i4;
56
char
c
[4];
57
}
i
,o;
58
59
i
.i4 =
in
;
60
o.c[0] =
i
.c[3];
61
o.c[1] =
i
.c[2];
62
o.c[2] =
i
.c[1];
63
o.c[3] =
i
.c[0];
64
return
o.i4;
65
}
66
67
// ---------------------------------------------------------
68
unsigned
int
buffer::u4swap
(
const
unsigned
int
in
)
69
{
70
union
71
{
72
unsigned
int
i4;
73
char
c
[4];
74
}
i
,o;
75
76
i
.i4 =
in
;
77
o.c[0] =
i
.c[3];
78
o.c[1] =
i
.c[2];
79
o.c[2] =
i
.c[1];
80
o.c[3] =
i
.c[0];
81
return
o.i4;
82
}
83
84
85
// ---------------------------------------------------------
86
int
buffer::i22swap
(
const
int
in
)
87
{
88
union
89
{
90
int
i4;
91
char
c
[4];
92
}
i
,o;
93
94
i
.i4 =
in
;
95
o.c[0] =
i
.c[1];
96
o.c[1] =
i
.c[0];
97
o.c[2] =
i
.c[3];
98
o.c[3] =
i
.c[2];
99
return
o.i4;
100
}
101
102
// ---------------------------------------------------------
103
short
buffer::i2swap
(
const
short
in
)
104
{
105
union
106
{
107
short
i2;
108
char
c
[2];
109
}
i
,o;
110
111
i
.i2 =
in
;
112
o.c[0] =
i
.c[1];
113
o.c[1] =
i
.c[0];
114
115
return
o.i2;
116
}
117
118
online_distribution
blob
master
newbasic
buffer.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration