OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * Exposes ZLib options for input parameters. | 8 * Exposes ZLib options for input parameters. |
9 * | 9 * |
10 * See http://www.zlib.net/manual.html for more documentation. | 10 * See http://www.zlib.net/manual.html for more documentation. |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 * Get a [ZLibDecoder] for decoding `GZip` compressed data. | 268 * Get a [ZLibDecoder] for decoding `GZip` compressed data. |
269 */ | 269 */ |
270 ZLibDecoder get decoder => | 270 ZLibDecoder get decoder => |
271 new ZLibDecoder(windowBits: windowBits, dictionary: dictionary, raw: raw); | 271 new ZLibDecoder(windowBits: windowBits, dictionary: dictionary, raw: raw); |
272 } | 272 } |
273 | 273 |
274 /** | 274 /** |
275 * The [ZLibEncoder] encoder is used by [ZLibCodec] and [GZipCodec] to compress | 275 * The [ZLibEncoder] encoder is used by [ZLibCodec] and [GZipCodec] to compress |
276 * data. | 276 * data. |
277 */ | 277 */ |
278 class ZLibEncoder extends | 278 class ZLibEncoder extends Converter<List<int>, List<int>> { |
279 ChunkedConverter<List<int>, List<int>, List<int>, List<int>> { | |
280 /** | 279 /** |
281 * When true, `GZip` frames will be added to the compressed data. | 280 * When true, `GZip` frames will be added to the compressed data. |
282 */ | 281 */ |
283 final bool gzip; | 282 final bool gzip; |
284 | 283 |
285 /** | 284 /** |
286 * The compression-[level] can be set in the range of `-1..9`, with `6` being | 285 * The compression-[level] can be set in the range of `-1..9`, with `6` being |
287 * the default compression level. Levels above `6` will have higher | 286 * the default compression level. Levels above `6` will have higher |
288 * compression rates at the cost of more CPU and memory usage. Levels below | 287 * compression rates at the cost of more CPU and memory usage. Levels below |
289 * `6` will use less CPU and memory at the cost of lower compression rates. | 288 * `6` will use less CPU and memory at the cost of lower compression rates. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 371 } |
373 return new _ZLibEncoderSink(sink, gzip, level, windowBits, memLevel, | 372 return new _ZLibEncoderSink(sink, gzip, level, windowBits, memLevel, |
374 strategy, dictionary, raw); | 373 strategy, dictionary, raw); |
375 } | 374 } |
376 } | 375 } |
377 | 376 |
378 | 377 |
379 /** | 378 /** |
380 * The [ZLibDecoder] is used by [ZLibCodec] and [GZipCodec] to decompress data. | 379 * The [ZLibDecoder] is used by [ZLibCodec] and [GZipCodec] to decompress data. |
381 */ | 380 */ |
382 class ZLibDecoder extends | 381 class ZLibDecoder extends Converter<List<int>, List<int>> { |
383 ChunkedConverter<List<int>, List<int>, List<int>, List<int>> { | |
384 /** | 382 /** |
385 * Base two logarithm of the window size (the size of the history buffer). It | 383 * Base two logarithm of the window size (the size of the history buffer). It |
386 * should be in the range `8..15`. Larger values result in better compression | 384 * should be in the range `8..15`. Larger values result in better compression |
387 * at the expense of memory usage. The default value is `15`. | 385 * at the expense of memory usage. The default value is `15`. |
388 */ | 386 */ |
389 final int windowBits; | 387 final int windowBits; |
390 | 388 |
391 /** | 389 /** |
392 * Initial compression dictionary. | 390 * Initial compression dictionary. |
393 * | 391 * |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 578 } |
581 | 579 |
582 void _validateZLibStrategy(int strategy) { | 580 void _validateZLibStrategy(int strategy) { |
583 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, | 581 const strategies = const <int>[ZLibOption.STRATEGY_FILTERED, |
584 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, | 582 ZLibOption.STRATEGY_HUFFMAN_ONLY, ZLibOption.STRATEGY_RLE, |
585 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; | 583 ZLibOption.STRATEGY_FIXED, ZLibOption.STRATEGY_DEFAULT]; |
586 if (strategies.indexOf(strategy) == -1) { | 584 if (strategies.indexOf(strategy) == -1) { |
587 throw new ArgumentError("Unsupported 'strategy'"); | 585 throw new ArgumentError("Unsupported 'strategy'"); |
588 } | 586 } |
589 } | 587 } |
OLD | NEW |