ModErn Text Analysis
META Enumerates Textual Applications
gzstream.h
Go to the documentation of this file.
1 
10 #ifndef META_UTIL_GZSTREAM_H_
11 #define META_UTIL_GZSTREAM_H_
12 
13 #include <zlib.h>
14 
15 #include <istream>
16 #include <ostream>
17 #include <streambuf>
18 #include <vector>
19 
20 namespace meta
21 {
22 namespace io
23 {
24 
25 class gzstreambuf : public std::streambuf
26 {
27  public:
28  gzstreambuf(const char* filename, const char* openmode,
29  size_t buffer_size = 512);
30 
31  ~gzstreambuf();
32 
33  int_type underflow() override;
34 
35  int_type overflow(int_type ch) override;
36 
37  int sync() override;
38 
39  bool is_open() const;
40 
41  private:
42  std::vector<char> buffer_;
43  gzFile file_;
44 };
45 
46 class gzifstream : public std::istream
47 {
48  public:
49  explicit gzifstream(std::string name);
50 
51  gzstreambuf* rdbuf() const;
52 
53  void flush();
54 
55  private:
56  gzstreambuf buffer_;
57 };
58 
59 class gzofstream : public std::ostream
60 {
61  public:
62  explicit gzofstream(std::string name);
63 
64  gzstreambuf* rdbuf() const;
65 
66  void flush();
67 
68  private:
69  gzstreambuf buffer_;
70 };
71 }
72 }
73 #endif
Definition: gzstream.h:46
Definition: gzstream.h:25
Definition: gzstream.h:59
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
std::string filename(const std::string &path)
Definition: unit_test.h:114