ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
GZIPOutputStreamBuffer.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file GZIPOutputStreamBuffer.cc
1
// Copyright FreeHEP, 2005.
2
3
#include "
cheprep/GZIPOutputStreamBuffer.h
"
4
8
namespace
cheprep {
9
10
using namespace
std;
11
12
GZIPOutputStreamBuffer::GZIPOutputStreamBuffer
( streambuf *aBuffer)
13
:
DeflateOutputStreamBuffer
(aBuffer),
14
open
(
false
) {
15
16
init
(
true
);
17
}
18
19
void
GZIPOutputStreamBuffer::setFilename
(
const
string
&
name
) {
20
filename
=
name
;
21
}
22
23
void
GZIPOutputStreamBuffer::setComment
(
const
string
&
c
) {
24
comment
=
c
;
25
}
26
27
void
GZIPOutputStreamBuffer::close
() {
28
if
(!
open
)
return
;
29
30
finish
();
31
writeTrailer
();
32
33
open
=
false
;
34
}
35
36
GZIPOutputStreamBuffer::~GZIPOutputStreamBuffer
() {
37
close
() ;
38
}
39
40
int
GZIPOutputStreamBuffer::overflow
(
int
c
) {
41
if
(!
open
) {
42
writeHeader
();
43
open
=
true
;
44
}
45
return
DeflateOutputStreamBuffer::overflow
( c ) ;
46
}
47
48
void
GZIPOutputStreamBuffer::writeHeader
() {
49
unsigned
char
flag = 0x00;
50
flag |= (
filename
==
""
) ? 0x00 : 0x08;
51
flag |= (
comment
==
""
) ? 0x00 : 0x10;
52
53
putUB
(0x1f);
// Magic #
54
putUB
(0x8b);
// Magic #
55
putUB
(0x08);
// Deflater.DEFLATED
56
putUB
(flag);
// FLG
57
putUI
(0x00000000);
// MTIME
58
putUB
(0x00);
// XFLG
59
putUB
(0x00);
// OS
60
61
if
(
filename
!=
""
) {
62
putS
(
filename
);
// Filename
63
putUB
(0x00);
64
}
65
66
if
(
comment
!=
""
) {
67
putS
(
comment
);
// Comment
68
putUB
(0x00);
69
}
70
}
71
72
void
GZIPOutputStreamBuffer::writeTrailer
() {
73
putUI
(
getCRC
());
74
putUI
(
getSize
());
75
}
76
77
}
// cheprep
geant4
tree
geant4-10.6-release
source
visualization
HepRep
src
GZIPOutputStreamBuffer.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:55
using
1.8.2 with
ECCE GitHub integration