#include <gzfstream.h>
Public 型 | |
enum | CompressionLevel { DEFAULT_COMPRESSION = 6, NO_COMPRESSION = 0, BEST_SPEED = 1, BEST_COMPRESSION = 9, DEFAULT_COMPRESSION = -1, NO_COMPRESSION = 0, BEST_SPEED = 1, BEST_COMPRESSION = 9 } |
typical compression level enumeration [詳細] | |
enum | Strategy { DEFAULT_STRATEGY = 0, FILTERED = 1, HUFFMAN_ONLY = 2, RLE = 3 } |
typical compression strategy enumeration. [詳細] | |
Public メソッド | |
gzfilebuf () | |
default constructor. | |
virtual | ~gzfilebuf () |
destructor. | |
bool | is_open () |
check if file is open. | |
gzfilebuf * | open (const char *path, std::ios_base::openmode mode, int level=DEFAULT_COMPRESSION, int strategy=DEFAULT_STRATEGY) |
open the file. | |
gzfilebuf * | close () throw () |
closes the file if opened. | |
Protected メソッド | |
virtual std::streampos | seekoff (std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode mode) |
overrided method. set relative position of internal position pointer | |
virtual std::streampos | seekpos (std::streampos pos, std::ios_base::openmode mode) |
overrided method. seek stream. | |
virtual std::streamsize | showmanyc () |
overrided method. get number of characters availbale in input sequence | |
virtual int | sync () |
synchronize stream buffer | |
virtual std::streambuf::int_type | overflow (std::streambuf::int_type c) |
put character at current put position. | |
virtual std::streambuf::int_type | underflow () |
get current character |
This class implements basic_filebuf for gzipped files. It doesn't yet support seeking (allowed by zlib but slow/limited), putback and read/write access(tricky). Otherwise, it attempts to be a drop-in replacement for the standard file streambuf.
typical compression level enumeration
The list of compresion level defined in zlib.h
typical compression strategy enumeration.
The list of strategy defined in zlib.h
For more details, see deflateInit2 in zlib.h.
rcsc::gzfilebuf::gzfilebuf | ( | ) |
default constructor.
Default constructor creates an internal file buffer using boost::scoped_ptr. This buffer is deleted automatically.
rcsc::gzfilebuf::~gzfilebuf | ( | ) | [virtual] |
destructor.
close opend file delete dynamically allocated internal buffer
bool rcsc::gzfilebuf::is_open | ( | ) |
check if file is open.
gzfilebuf * rcsc::gzfilebuf::open | ( | const char * | path, | |
std::ios_base::openmode | mode, | |||
int | level = DEFAULT_COMPRESSION , |
|||
int | strategy = DEFAULT_STRATEGY | |||
) |
open the file.
path | file path | |
mode | specifies mode of I/O. Only std::ios_base::in or std::ios_base::out can be used. | |
level | compression level(0-9, -1 means default level) | |
strategy | compression strategy. Z_DEFAULT_COMPRESSION, Z_FILTERD, Z_HUFFMAN_ONLY or Z_RLE. For more details, see deflateInit2 in zlib.h. |
gzfilebuf * rcsc::gzfilebuf::close | ( | ) | throw () |
closes the file if opened.
std::streampos rcsc::gzfilebuf::seekoff | ( | std::streamoff | off, | |
std::ios_base::seekdir | way, | |||
std::ios_base::openmode | mode | |||
) | [protected, virtual] |
overrided method. set relative position of internal position pointer
off | offset to move. This is decompressed data size. | |
way | object of type ios_base::seekdir. ios_base::beg (offset from the beginning of the stream's buffer). ios_base::cur (offset from the current position in the stream's buffer). ios_base::cur (offset from the end of the stream's buffer). | |
mode | IO mode |
zlib does not support seeking from 'end'.
std::streampos rcsc::gzfilebuf::seekpos | ( | std::streampos | pos, | |
std::ios_base::openmode | mode | |||
) | [protected, virtual] |
overrided method. seek stream.
pos | position for the position pointer. | |
mode | IO mode |
std::streamsize rcsc::gzfilebuf::showmanyc | ( | ) | [protected, virtual] |
overrided method. get number of characters availbale in input sequence
int rcsc::gzfilebuf::sync | ( | ) | [protected, virtual] |
synchronize stream buffer
0 | data was successfully flushed | |
-1 | failed to synchronize |
std::streambuf::int_type rcsc::gzfilebuf::overflow | ( | std::streambuf::int_type | c | ) | [protected, virtual] |
put character at current put position.
c | this char is put to file. |
std::streambuf::int_type rcsc::gzfilebuf::underflow | ( | ) | [protected, virtual] |
get current character