source: trunk/Mars/mbase/MZlib.h@ 10645

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