1 | #ifndef MARS_MZlib
|
---|
2 | #define MARS_MZlib
|
---|
3 |
|
---|
4 | #ifndef ROOT_TObject
|
---|
5 | #include <TObject.h> // Needed for ClassDef
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | #ifdef __CINT__
|
---|
9 | typedef void *gzFile;
|
---|
10 | #else
|
---|
11 | #include <zlib.h>
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | #include <istream> // base classes for MLog
|
---|
15 |
|
---|
16 | class MZlib : public std::streambuf, public std::istream
|
---|
17 | {
|
---|
18 | private:
|
---|
19 | static const int fgBufferSize = 3276804; // maximum size of a fact event + 4
|
---|
20 |
|
---|
21 | gzFile fFile; // file handle for compressed file
|
---|
22 | char fBuffer[fgBufferSize]; // data buffer
|
---|
23 |
|
---|
24 | int underflow();
|
---|
25 |
|
---|
26 | public:
|
---|
27 | MZlib() : istream(this), fFile(0)
|
---|
28 | {
|
---|
29 | setg(fBuffer+4, fBuffer+4, fBuffer+4);
|
---|
30 | }
|
---|
31 | MZlib(const char *name) : istream(this), fFile(0)
|
---|
32 | {
|
---|
33 | setg(fBuffer+4, fBuffer+4, fBuffer+4);
|
---|
34 | open(name);
|
---|
35 | }
|
---|
36 | ~MZlib() { MZlib::close(); }
|
---|
37 |
|
---|
38 | int is_open() { return fFile!=0; }
|
---|
39 |
|
---|
40 | void open(const char* name);
|
---|
41 | void close();
|
---|
42 |
|
---|
43 | # if (__GNUC__>2)
|
---|
44 | std::streambuf::pos_type seekoff(std::streambuf::off_type, std::ios_base::seekdir,
|
---|
45 | std::ios_base::openmode = std::ios_base::in);
|
---|
46 | std::streambuf::pos_type seekpos(std::streambuf::pos_type,
|
---|
47 | std::ios_base::openmode = std::ios_base::in);
|
---|
48 | # else
|
---|
49 | std::streampos seekoff(std::streamoff, int, int = std::ios::in);
|
---|
50 | // std::streampos seekpos(std::streampos, int = std::ios::in);
|
---|
51 | # endif
|
---|
52 |
|
---|
53 | ClassDef(MZlib, 0) // A C++ wrapper to istream zlib files
|
---|
54 | };
|
---|
55 |
|
---|
56 | #endif
|
---|