diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-09-16 18:41:45 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-09-16 18:41:45 +0200 |
| commit | 264ec99e7bae08710449262e609c20ad76383615 (patch) | |
| tree | 03bfa9c124d138dfbb3e2fd7d22992de5e17a89a /include | |
| parent | 694855d5f59e8b0a5bc4419b9a409f9ed7609daa (diff) | |
| download | Project-Tick-264ec99e7bae08710449262e609c20ad76383615.tar.gz Project-Tick-264ec99e7bae08710449262e609c20ad76383615.zip | |
Changes to deflate_streambuf and ozlibstream constructors
Diffstat (limited to 'include')
| -rw-r--r-- | include/io/izlibstream.h | 3 | ||||
| -rw-r--r-- | include/io/ozlibstream.h | 33 |
2 files changed, 20 insertions, 16 deletions
diff --git a/include/io/izlibstream.h b/include/io/izlibstream.h index 6d58d56b86..43d2d2c02e 100644 --- a/include/io/izlibstream.h +++ b/include/io/izlibstream.h @@ -38,7 +38,8 @@ public: * @param input the istream to wrap * @param bufsize the size of the internal buffers * @param window_bits the base two logarithm of the maximum window size that - * zlib will use. This parameter also determines which type of input to expect. + * zlib will use. + * This parameter also determines which type of input to expect. * The default argument will autodetect between zlib and gzip data. * Refer to the zlib documentation of inflateInit2 for more details. * diff --git a/include/io/ozlibstream.h b/include/io/ozlibstream.h index 0e19aaaa2b..0be792d482 100644 --- a/include/io/ozlibstream.h +++ b/include/io/ozlibstream.h @@ -29,12 +29,21 @@ namespace zlib /** * @brief Stream buffer used by zlib::ozlibstream - * @see ozlibstream + * @sa ozlibstream */ class deflate_streambuf : public std::streambuf { public: - explicit deflate_streambuf(std::ostream& output, int level = -1, int window_bits = 15, int mem_level = 8, int strategy = Z_DEFAULT_STRATEGY); + /** + * @param output the ostream to wrap + * @param bufsize the size of the internal buffers + * @param level the compression level, ranges from 0 to 9 + * + * Refer to the zlib documentation of deflateInit2 for details about the arguments. + * + * @throw zlib_error if zlib encounters a problem during initialization + */ + explicit deflate_streambuf(std::ostream& output, size_t bufsize = 32768, int level = Z_DEFAULT_COMPRESSION, int window_bits = 15, int mem_level = 8, int strategy = Z_DEFAULT_STRATEGY); ~deflate_streambuf() noexcept; std::ostream& get_ostr() const { return os; } @@ -56,28 +65,22 @@ private: * * This ostream wraps another ostream. Data written to an ozlibstream will be * deflated (compressed) with zlib and written to the wrapped ostream. + * + * @sa deflate_streambuf */ class ozlibstream : public std::ostream { public: /** * @param output the ostream to wrap - * @param level the compression level. Ranges from 0 to 9, or -1 for the default - * @param gzip_header whether to write a gzip header rather than a zlib header + * @param level the compression level, ranges from 0 to 9 + * @param gzip if true, the output will be in gzip format rather than zlib + * @param bufsize the size of the internal buffers */ - explicit ozlibstream(std::ostream& output, int level, bool gzip): - ozlibstream(output, level, 15 + (gzip ? 16 : 0)) + explicit ozlibstream(std::ostream& output, int level = Z_DEFAULT_COMPRESSION, bool gzip = false, size_t bufsize = 32768): + std::ostream(&buf), buf(output, level, bufsize, 15 + (gzip ? 16 : 0)) {} - /** - * @param output the ostream to wrap - * @param level the compression level. Ranges from 0 to 9, or -1 for the default - * - * Refer to the zlib documentation of deflateInit2 for a detailed explanation of the arguments. - */ - explicit ozlibstream(std::ostream& output, int level = -1, int window_bits = 15, int mem_level = 8, int strategy = Z_DEFAULT_STRATEGY): - std::ostream(&buf), buf(output, level, window_bits, mem_level, strategy) - {} ///@return the wrapped ostream std::ostream& get_ostr() const { return buf.get_ostr(); } |
