aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/io/gzip_stream.h
diff options
context:
space:
mode:
authorkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-08-01 00:38:45 +0000
committerkenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2009-08-01 00:38:45 +0000
commit253a8508047a23e06d46a276480360f76b3cb219 (patch)
tree40d621129b60773a84799edc2d4c34af6d7c675c /src/google/protobuf/io/gzip_stream.h
parent1900c536cd91bae783e6766d3fc016e75061d17c (diff)
downloadprotobuf-253a8508047a23e06d46a276480360f76b3cb219.tar.gz
protobuf-253a8508047a23e06d46a276480360f76b3cb219.tar.bz2
protobuf-253a8508047a23e06d46a276480360f76b3cb219.zip
Allow compression level of GzipOutputStream to be configured.
Diffstat (limited to 'src/google/protobuf/io/gzip_stream.h')
-rw-r--r--src/google/protobuf/io/gzip_stream.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/google/protobuf/io/gzip_stream.h b/src/google/protobuf/io/gzip_stream.h
index 50a2ad70..65dbc5b5 100644
--- a/src/google/protobuf/io/gzip_stream.h
+++ b/src/google/protobuf/io/gzip_stream.h
@@ -117,11 +117,39 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
ZLIB = 2,
};
- // buffer_size and format may be -1 for default of 64kB and GZIP format
- explicit GzipOutputStream(
+ struct Options {
+ // Defaults to GZIP.
+ Format format;
+
+ // What size buffer to use internally. Defaults to 64kB.
+ int buffer_size;
+
+ // A number between 0 and 9, where 0 is no compression and 9 is best
+ // compression. Defaults to Z_DEFAULT_COMPRESSION (see zlib.h).
+ int compression_level;
+
+ // Defaults to Z_DEFAULT_STRATEGY. Can also be set to Z_FILTERED,
+ // Z_HUFFMAN_ONLY, or Z_RLE. See the documentation for deflateInit2 in
+ // zlib.h for definitions of these constants.
+ int compression_strategy;
+
+ Options(); // Initializes with default values.
+ };
+
+ // Create a GzipOutputStream with default options.
+ explicit GzipOutputStream(ZeroCopyOutputStream* sub_stream);
+
+ // Create a GzipOutputStream with the given options.
+ GzipOutputStream(
ZeroCopyOutputStream* sub_stream,
- Format format = GZIP,
- int buffer_size = -1);
+ const Options& options);
+
+ // DEPRECATED: Use one of the above constructors instead.
+ GzipOutputStream(
+ ZeroCopyOutputStream* sub_stream,
+ Format format,
+ int buffer_size = -1) GOOGLE_ATTRIBUTE_DEPRECATED;
+
virtual ~GzipOutputStream();
// Return last error message or NULL if no error.
@@ -161,6 +189,9 @@ class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {
void* input_buffer_;
size_t input_buffer_length_;
+ // Shared constructor code.
+ void Init(ZeroCopyOutputStream* sub_stream, const Options& options);
+
// Do some compression.
// Takes zlib flush mode.
// Returns zlib error code.