Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GZIPOutputStreamBuffer.cc
Go to the documentation of this file.
1// Copyright FreeHEP, 2005.
2
4
5/**
6 * @author Mark Donszelmann
7 */
8namespace cheprep {
9
10 using namespace std;
11
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
28 if (!open) return;
29
30 finish();
31 writeTrailer();
32
33 open = false ;
34 }
35
37 close() ;
38 }
39
41 if (!open) {
42 writeHeader();
43 open = true;
44 }
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
void setFilename(const std::string &filename)
void setComment(const std::string &comment)
GZIPOutputStreamBuffer(std::streambuf *outbuf)