4 // Copyright 2007-2008 Google Inc.
6 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
7 // use this file except in compliance with the License. You may obtain a copy
10 // http://www.apache.org/licenses/LICENSE-2.0
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 // License for the specific language governing permissions and limitations under
19 #import <Foundation/Foundation.h>
20 #import "GTMDefines.h"
22 /// Helpers for dealing w/ zlib inflate/deflate calls.
23 @interface NSData (GTMZLibAdditions)
25 /// Return an autoreleased NSData w/ the result of gzipping the bytes.
27 // Uses the default compression level.
28 + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
29 length:(NSUInteger)length;
31 /// Return an autoreleased NSData w/ the result of gzipping the payload of |data|.
33 // Uses the default compression level.
34 + (NSData *)gtm_dataByGzippingData:(NSData *)data;
36 /// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level.
38 // |level| can be 1-9, any other values will be clipped to that range.
39 + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
40 length:(NSUInteger)length
41 compressionLevel:(int)level;
43 /// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level.
44 + (NSData *)gtm_dataByGzippingData:(NSData *)data
45 compressionLevel:(int)level;
47 // NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one
48 // you really want to create. (the inflate api will handle either)
50 /// Return an autoreleased NSData w/ the result of deflating the bytes.
52 // Uses the default compression level.
53 + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
54 length:(NSUInteger)length;
56 /// Return an autoreleased NSData w/ the result of deflating the payload of |data|.
58 // Uses the default compression level.
59 + (NSData *)gtm_dataByDeflatingData:(NSData *)data;
61 /// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level.
63 // |level| can be 1-9, any other values will be clipped to that range.
64 + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
65 length:(NSUInteger)length
66 compressionLevel:(int)level;
68 /// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level.
69 + (NSData *)gtm_dataByDeflatingData:(NSData *)data
70 compressionLevel:(int)level;
73 /// Return an autoreleased NSData w/ the result of decompressing the bytes.
75 // The bytes to decompress can be zlib or gzip payloads.
76 + (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
77 length:(NSUInteger)length;
79 /// Return an autoreleased NSData w/ the result of decompressing the payload of |data|.
81 // The data to decompress can be zlib or gzip payloads.
82 + (NSData *)gtm_dataByInflatingData:(NSData *)data;