Skip to content

Commit

Permalink
add keyword arguments to stream constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 committed Jun 11, 2017
1 parent d7a7a80 commit 2bc39f6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 26 deletions.
37 changes: 26 additions & 11 deletions src/compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ end
GzipCompression(;level=$(Z_DEFAULT_COMPRESSION), windowbits=$(Z_DEFAULT_WINDOWBITS))
Create a gzip compression codec.
Arguments
---------
- `level`: compression level (-1..9)
- `windowbits`: size of history buffer (8..15)
"""
function GzipCompression(;level::Integer=Z_DEFAULT_COMPRESSION,
windowbits::Integer=Z_DEFAULT_WINDOWBITS)
Expand All @@ -31,12 +36,12 @@ end
const GzipCompressionStream{S} = TranscodingStream{GzipCompression,S}

"""
GzipCompressionStream(stream::IO)
GzipCompressionStream(stream::IO; kwargs...)
Create a gzip compression stream.
Create a gzip compression stream (see `GzipCompression` for `kwargs`).
"""
function GzipCompressionStream(stream::IO)
return TranscodingStream(GzipCompression(), stream)
function GzipCompressionStream(stream::IO; kwargs...)
return TranscodingStream(GzipCompression(;kwargs...), stream)
end


Expand All @@ -53,6 +58,11 @@ end
ZlibCompression(;level=$(Z_DEFAULT_COMPRESSION), windowbits=$(Z_DEFAULT_WINDOWBITS))
Create a zlib compression codec.
Arguments
---------
- `level`: compression level (-1..9)
- `windowbits`: size of history buffer (8..15)
"""
function ZlibCompression(;level::Integer=Z_DEFAULT_COMPRESSION,
windowbits::Integer=Z_DEFAULT_WINDOWBITS)
Expand All @@ -69,10 +79,10 @@ const ZlibCompressionStream{S} = TranscodingStream{ZlibCompression,S}
"""
ZlibCompressionStream(stream::IO)
Create a zlib compression stream.
Create a zlib compression stream (see `ZlibCompression` for `kwargs`).
"""
function ZlibCompressionStream(stream::IO)
return TranscodingStream(ZlibCompression(), stream)
function ZlibCompressionStream(stream::IO; kwargs...)
return TranscodingStream(ZlibCompression(;kwargs...), stream)
end


Expand All @@ -89,6 +99,11 @@ end
DeflateCompression(;level=$(Z_DEFAULT_COMPRESSION), windowbits=$(Z_DEFAULT_COMPRESSION))
Create a deflate compression codec.
Arguments
---------
- `level`: compression level (-1..9)
- `windowbits`: size of history buffer (8..15)
"""
function DeflateCompression(;level::Integer=Z_DEFAULT_COMPRESSION,
windowbits::Integer=Z_DEFAULT_WINDOWBITS)
Expand All @@ -103,12 +118,12 @@ end
const DeflateCompressionStream{S} = TranscodingStream{DeflateCompression,S}

"""
DeflateCompressionStream(stream::IO)
DeflateCompressionStream(stream::IO; kwargs...)
Create a deflate compression stream.
Create a deflate compression stream (see `DeflateCompression` for `kwargs`).
"""
function DeflateCompressionStream(stream::IO)
return TranscodingStream(DeflateCompression(), stream)
function DeflateCompressionStream(stream::IO; kwargs...)
return TranscodingStream(DeflateCompression(;kwargs...), stream)
end


Expand Down
41 changes: 26 additions & 15 deletions src/decompression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ end
Create a gzip decompressor codec.
This codec detects the compression format (gzip or zlib) from data when
`gziponly` is `false`. Setting `gziponly` to `true` will turn off this format
detection and throw an exception if data are not formatted in gzip.
If `gziponly` is `false`, this codec can decompress the zlib format as well.
Arguments
---------
- `windowbits`: size of history buffer (8..15)
- `gziponly`: flag to inactivate data format detection
"""
function GzipDecompression(;windowbits::Integer=Z_DEFAULT_WINDOWBITS, gziponly::Bool=false)
if !(8 windowbits 15)
Expand All @@ -31,12 +34,12 @@ end
const GzipDecompressionStream{S} = TranscodingStream{GzipDecompression,S}

"""
GzipDecompressionStream(stream::IO)
GzipDecompressionStream(stream::IO; kwargs...)
Create a gzip decompression stream.
Create a gzip decompression stream (see `GzipDecompression` for `kwargs`).
"""
function GzipDecompressionStream(stream::IO)
return TranscodingStream(GzipDecompression(), stream)
function GzipDecompressionStream(stream::IO; kwargs...)
return TranscodingStream(GzipDecompression(;kwargs...), stream)
end


Expand All @@ -52,6 +55,10 @@ end
ZlibDecompression(;windowbits=$(Z_DEFAULT_WINDOWBITS))
Create a zlib decompression codec.
Arguments
---------
- `windowbits`: size of history buffer (8..15)
"""
function ZlibDecompression(;windowbits::Integer=Z_DEFAULT_WINDOWBITS)
if !(8 windowbits 15)
Expand All @@ -63,12 +70,12 @@ end
const ZlibDecompressionStream{S} = TranscodingStream{ZlibDecompression,S}

"""
ZlibDecompressionStream(stream::IO)
ZlibDecompressionStream(stream::IO; kwargs...)
Create a deflate decompression stream.
Create a deflate decompression stream (see `ZlibDecompression` for `kwargs`).
"""
function ZlibDecompressionStream(stream::IO)
return TranscodingStream(ZlibDecompression(), stream)
function ZlibDecompressionStream(stream::IO; kwargs...)
return TranscodingStream(ZlibDecompression(;kwargs...), stream)
end


Expand All @@ -84,6 +91,10 @@ end
DeflateDecompression(;windowbits=$(Z_DEFAULT_WINDOWBITS))
Create a deflate decompression codec.
Arguments
---------
- `windowbits`: size of history buffer (8..15)
"""
function DeflateDecompression(;windowbits::Integer=Z_DEFAULT_WINDOWBITS)
if !(8 windowbits 15)
Expand All @@ -95,12 +106,12 @@ end
const DeflateDecompressionStream{S} = TranscodingStream{DeflateDecompression,S}

"""
DeflateDecompressionStream(stream::IO)
DeflateDecompressionStream(stream::IO; kwargs...)
Create a deflate decompression stream.
Create a deflate decompression stream (see `DeflateDecompression` for `kwargs`).
"""
function DeflateDecompressionStream(stream::IO)
return TranscodingStream(DeflateDecompression(), stream)
function DeflateDecompressionStream(stream::IO; kwargs...)
return TranscodingStream(DeflateDecompression(;kwargs...), stream)
end


Expand Down

0 comments on commit 2bc39f6

Please sign in to comment.