forked from Shuhua-Group/ArchaicSeeker2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgzfstream.hpp
77 lines (61 loc) · 1.67 KB
/
gzfstream.hpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* gzfstream.hpp
*
* Created on: Sep 30, 2018
* Author: yuankai
*/
#ifndef GZFSTREAM_HPP_
#define GZFSTREAM_HPP_
# include <iosfwd>
# include <boost/iostreams/categories.hpp>
# include <boost/iostreams/positioning.hpp>
# include <boost/iostreams/stream.hpp>
# include <boost/iostreams/concepts.hpp>
# include <zlib.h>
class igzfd : public boost::iostreams::source
{
public:
typedef char char_type;
typedef boost::iostreams::source_tag category;
igzfd(const std::string& path);
igzfd();
std::streamsize read(char* s, std::streamsize n);
boost::iostreams::stream_offset seek(boost::iostreams::stream_offset off,\
std::ios_base::seekdir way);
int open(const std::string& path);
void close();
private:
gzFile fd;
};
class ogzfd : public boost::iostreams::sink
{
public:
typedef char char_type;
typedef boost::iostreams::sink_tag category;
ogzfd(const std::string& path);
ogzfd();
std::streamsize write(const char* s, std::streamsize n);
boost::iostreams::stream_offset seek(boost::iostreams::stream_offset off,\
std::ios_base::seekdir way);
int open(const std::string& path);
void close();
private:
gzFile fd;
};
class gzifstream : public boost::iostreams::stream<igzfd>
{
public:
gzifstream() : boost::iostreams::stream<igzfd>("") {};
gzifstream(const std::string& path) : boost::iostreams::stream<igzfd>(path) {};
~gzifstream();
int open(const std::string& path);
};
class gzofstream : public boost::iostreams::stream<ogzfd>
{
public:
gzofstream() : boost::iostreams::stream<ogzfd>("") {};
gzofstream(const std::string& path) : boost::iostreams::stream<ogzfd>(path) {};
~gzofstream();
int open(const std::string& path);
};
#endif /* GZFSTREAM_HPP_ */