Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
visualization
HepRep
src
GZIPOutputStreamBuffer.cc
Go to the documentation of this file.
1
// Copyright FreeHEP, 2005.
2
3
#include "
cheprep/GZIPOutputStreamBuffer.h
"
4
9
namespace
cheprep {
10
11
using namespace
std;
12
13
GZIPOutputStreamBuffer::GZIPOutputStreamBuffer
( streambuf *aBuffer)
14
:
DeflateOutputStreamBuffer
(aBuffer),
15
open
(false) {
16
17
init
(
true
);
18
}
19
20
void
GZIPOutputStreamBuffer::setFilename
(
const
string
&
name
) {
21
filename =
name
;
22
}
23
24
void
GZIPOutputStreamBuffer::setComment
(
const
string
&
c
) {
25
comment =
c
;
26
}
27
28
void
GZIPOutputStreamBuffer::close
() {
29
if
(!open)
return
;
30
31
finish
();
32
writeTrailer();
33
34
open = false ;
35
}
36
37
GZIPOutputStreamBuffer::~GZIPOutputStreamBuffer
() {
38
close
() ;
39
}
40
41
int
GZIPOutputStreamBuffer::overflow
(
int
c
) {
42
if
(!open) {
43
writeHeader();
44
open =
true
;
45
}
46
return
DeflateOutputStreamBuffer::overflow
( c ) ;
47
}
48
49
void
GZIPOutputStreamBuffer::writeHeader() {
50
unsigned
char
flag = 0x00;
51
flag |= (filename ==
""
) ? 0x00 : 0x08;
52
flag |= (comment ==
""
) ? 0x00 : 0x10;
53
54
putUB
(0x1f);
// Magic #
55
putUB
(0x8b);
// Magic #
56
putUB
(0x08);
// Deflater.DEFLATED
57
putUB
(flag);
// FLG
58
putUI
(0x00000000);
// MTIME
59
putUB
(0x00);
// XFLG
60
putUB
(0x00);
// OS
61
62
if
(filename !=
""
) {
63
putS
(filename);
// Filename
64
putUB
(0x00);
65
}
66
67
if
(comment !=
""
) {
68
putS
(comment);
// Comment
69
putUB
(0x00);
70
}
71
}
72
73
void
GZIPOutputStreamBuffer::writeTrailer() {
74
putUI
(
getCRC
());
75
putUI
(
getSize
());
76
}
77
78
}
// cheprep
Generated on Sat May 25 2013 14:34:14 for Geant4 by
1.8.4