Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GZIPOutputStreamBuffer.cc
Go to the documentation of this file.
1 // Copyright FreeHEP, 2005.
2 
4 
5 /**
6  * @author Mark Donszelmann
7  * @version $Id: GZIPOutputStreamBuffer.cc 66373 2012-12-18 09:41:34Z gcosmo $
8  */
9 namespace cheprep {
10 
11  using namespace std;
12 
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 
29  if (!open) return;
30 
31  finish();
32  writeTrailer();
33 
34  open = false ;
35  }
36 
38  close() ;
39  }
40 
42  if (!open) {
43  writeHeader();
44  open = true;
45  }
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
const XML_Char * name
void setFilename(const std::string &filename)
void setComment(const std::string &comment)
GZIPOutputStreamBuffer(std::streambuf *outbuf)