source: releases/Mars.2014.05.26/mbase/MBzlib2.h@ 18564

Last change on this file since 18564 was 7819, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 1.5 KB
Line 
1#ifndef MARS_MBzlib2
2#define MARS_MBzlib2
3
4#ifndef ROOT_TObject
5#include <TObject.h>
6#endif
7
8#ifdef __CINT__
9typedef void *BZFILE;
10#else
11#include <bzlib.h>
12#endif
13
14#include <iostream> // base classes for MLog
15
16class MBzlib2 : public std::streambuf, virtual public std::istream, public TObject
17{
18private:
19 static const int fgBufferSize = 47+256; // size of data buff totals 512 bytes under g++ for igzstream at the end.
20
21 BZFILE *fFile; // file handle for compressed file
22 char fBuffer[fgBufferSize]; // data buffer
23
24 int flush_buffer();
25 int underflow();
26 int sync();
27
28public:
29 MBzlib2() : istream(this), fFile(0)
30 {
31 setp(fBuffer, fBuffer+fgBufferSize-1);
32 setg(fBuffer+4, fBuffer+4, fBuffer+4);
33 }
34 MBzlib2(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 ~MBzlib2() { MBzlib2::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(MBzlib2, 0) // A C++ wrapper to istream zlib files
54};
55
56#endif
Note: See TracBrowser for help on using the repository browser.