Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GzFileBuf.h « mert - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb57fcfe7de24109788395510a72c51464944978 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef MERT_GZFILEBUF_H_
#define MERT_GZFILEBUF_H_

#include <streambuf>
#include <zlib.h>

class GzFileBuf : public std::streambuf
{
public:
  explicit GzFileBuf(const char* filename);
  virtual ~GzFileBuf();

protected:
  virtual int_type overflow(int_type c);

  // Read one character
  virtual int_type underflow();

  virtual std::streampos seekpos(
    std::streampos sp,
    std::ios_base::openmode which = std::ios_base::in | std::ios_base::out);

  virtual std::streamsize xsgetn(char* s, std::streamsize num);

  // write multiple characters
  virtual std::streamsize xsputn(const char* s, std::streamsize num);

private:
  gzFile m_gz_file;
  static const unsigned int kBufSize = 1024;
  char m_buf[kBufSize];
};

#endif  // MERT_GZFILEBUF_H_