Skip to content

Commit 23696ef

Browse files
Adding a partially useful boolean operator function for the ogzfstream
1 parent 658b49a commit 23696ef

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

zlib_wrapper.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,25 @@ struct igzfstream {
3939
gzFile fileobj;
4040
};
4141

42+
igzfstream&
43+
getline(igzfstream &in, std::string &line);
44+
45+
igzfstream&
46+
operator>>(igzfstream &in, std::string &line);
47+
48+
4249
struct ogzfstream {
4350
ogzfstream(const std::string filename) :
4451
fileobj(gzopen(filename.c_str(), "w")) {}
4552
~ogzfstream() {gzclose_w(fileobj);}
46-
/* eof is not a good error indicator for write */
47-
// operator bool() const {return !gzeof(fileobj);}
53+
54+
/* Below: eof is not a good error indicator for output streams and
55+
* we often use this only when checking after opening a file. This
56+
* function needs improving */
57+
operator bool() const {return fileobj != NULL;}
4858
gzFile fileobj;
4959
};
5060

51-
igzfstream&
52-
getline(igzfstream &in, std::string &line);
53-
54-
igzfstream&
55-
operator>>(igzfstream &in, std::string &line);
56-
5761
ogzfstream&
5862
operator<<(ogzfstream &out, const std::string &line);
5963

0 commit comments

Comments
 (0)