#include <genesis/utils/io/gzip_stream.hpp>
Inherits StrictFStreamHolder< StrictIFStream >, and istream.
Input file stream that offers on-the-fly gzip-decompression if needed.
The class accesses an internal std::ifstream. This can be used to open a file and read decompressed data from it.
If auto_detect
is true
(default), the class seamlessly auto-detects whether the source stream is compressed or not. The following compressed streams are detected:
1F 8B
. See GZip format.78 01
, 78 9C
, or 78 DA
. See answer here.If none of these formats are detected, the class assumes the input is not compressed, and it produces a plain copy of the source stream. In order to fully work for compressed files however, we always use std::ios_base::binary
for opening. This means that on Windows, end-of-line chars are not properly converted for uncompressed files. See https://github.com/mateidavid/zstr/issues/15 for a workaround for this, for example by using our is_gzip_compressed_file() function before opening the file.
The class is based on the zstr::ifstream class of the excellent zstr library by Matei David; see also our Acknowledgements.
If genesis is compiled without zlib support, constructing an instance of this class will throw an exception.
Definition at line 276 of file gzip_stream.hpp.
Public Member Functions | |
GzipIFStream (std::string const &filename, std::ios_base::openmode mode=std::ios_base::in, bool auto_detect=true, std::size_t buffer_size=GZIP_DEFAULT_BUFFER_SIZE) | |
virtual | ~GzipIFStream () |
|
explicit |
Definition at line 539 of file gzip_stream.cpp.
|
virtual |
Definition at line 554 of file gzip_stream.cpp.