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