1 // Copyright 2018 Google
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #import <Foundation/Foundation.h>
17 /// This is a copy of Google Toolbox for Mac library to avoid creating an extra framework.
19 // NOTE: For 64bit, none of these apis handle input sizes >32bits, they will return nil when given
20 // such data. To handle data of that size you really should be streaming it rather then doing it all
23 @interface NSData (GULGzip)
25 /// Returns an data as the result of decompressing the payload of |data|.The data to decompress must
26 /// be a gzipped payloads.
27 + (NSData *)gul_dataByInflatingGzippedData:(NSData *)data error:(NSError **)error;
29 /// Returns an compressed data with the result of gzipping the payload of |data|. Uses the default
30 /// compression level.
31 + (NSData *)gul_dataByGzippingData:(NSData *)data error:(NSError **)error;
33 FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorDomain;
34 FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorKey; // NSNumber
35 FOUNDATION_EXPORT NSString *const GULNSDataZlibRemainingBytesKey; // NSNumber
37 typedef NS_ENUM(NSInteger, GULNSDataZlibError) {
38 GULNSDataZlibErrorGreaterThan32BitsToCompress = 1024,
39 // An internal zlib error.
40 // GULNSDataZlibErrorKey will contain the error value.
41 // NSLocalizedDescriptionKey may contain an error string from zlib.
42 // Look in zlib.h for list of errors.
43 GULNSDataZlibErrorInternal,
44 // There was left over data in the buffer that was not used.
45 // GULNSDataZlibRemainingBytesKey will contain number of remaining bytes.
46 GULNSDataZlibErrorDataRemaining