Line | |
---|
1 | #ifndef MARS_MZlib
|
---|
2 | #define MARS_MZlib
|
---|
3 |
|
---|
4 | #ifndef ROOT_TObject
|
---|
5 | #include <TObject.h>
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #ifdef __CINT__
|
---|
9 | typedef void *gzFile;
|
---|
10 | #else
|
---|
11 | #include <zlib.h>
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | #include <iostream> // base classes for MLog
|
---|
15 |
|
---|
16 | class MZlib : public std::streambuf, virtual public std::istream, public TObject
|
---|
17 | {
|
---|
18 | private:
|
---|
19 | static const int fgBufferSize = 47+256; // size of data buff totals 512 bytes under g++ for igzstream at the end.
|
---|
20 |
|
---|
21 | gzFile fFile; // file handle for compressed file
|
---|
22 | char fBuffer[fgBufferSize]; // data buffer
|
---|
23 |
|
---|
24 | int flush_buffer();
|
---|
25 | int underflow();
|
---|
26 | int sync();
|
---|
27 |
|
---|
28 | public:
|
---|
29 | MZlib() : istream(this), fFile(0)
|
---|
30 | {
|
---|
31 | setp(fBuffer, fBuffer+fgBufferSize-1);
|
---|
32 | setg(fBuffer+4, fBuffer+4, fBuffer+4);
|
---|
33 | }
|
---|
34 | MZlib(const char *name) : istream(this), fFile(0)
|
---|
35 | {
|
---|
36 | setp(fBuffer, fBuffer+fgBufferSize-1);
|
---|
37 | setg(fBuffer+4, fBuffer+4, fBuffer+4);
|
---|
38 |
|
---|
39 | open(name);
|
---|
40 | }
|
---|
41 | ~MZlib() { MZlib::close(); }
|
---|
42 |
|
---|
43 | int is_open() { return fFile!=0; }
|
---|
44 |
|
---|
45 | void open(const char* name);
|
---|
46 | void close();
|
---|
47 |
|
---|
48 | std::streambuf::pos_type seekoff(std::streambuf::off_type, std::ios_base::seekdir,
|
---|
49 | std::ios_base::openmode = std::ios_base::in | std::ios_base::out);
|
---|
50 | //std::streambuf::pos_type seekpos(std::streambuf::pos_type,
|
---|
51 | // std::ios_base::openmode = std::ios_base::in | std::ios_base::out);
|
---|
52 |
|
---|
53 | ClassDef(MZlib, 0) // A C++ wrapper to istream zlib files
|
---|
54 | };
|
---|
55 |
|
---|
56 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.