GULNSData+zlib.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2018 Google
  2. //
  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
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  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.
  14. #import <Foundation/Foundation.h>
  15. /// This is a copy of Google Toolbox for Mac library to avoid creating an extra framework.
  16. // NOTE: For 64bit, none of these apis handle input sizes >32bits, they will return nil when given
  17. // such data. To handle data of that size you really should be streaming it rather then doing it all
  18. // in memory.
  19. @interface NSData (GULGzip)
  20. /// Returns an data as the result of decompressing the payload of |data|.The data to decompress must
  21. /// be a gzipped payloads.
  22. + (NSData *)gul_dataByInflatingGzippedData:(NSData *)data error:(NSError **)error;
  23. /// Returns an compressed data with the result of gzipping the payload of |data|. Uses the default
  24. /// compression level.
  25. + (NSData *)gul_dataByGzippingData:(NSData *)data error:(NSError **)error;
  26. FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorDomain;
  27. FOUNDATION_EXPORT NSString *const GULNSDataZlibErrorKey; // NSNumber
  28. FOUNDATION_EXPORT NSString *const GULNSDataZlibRemainingBytesKey; // NSNumber
  29. typedef NS_ENUM(NSInteger, GULNSDataZlibError) {
  30. GULNSDataZlibErrorGreaterThan32BitsToCompress = 1024,
  31. // An internal zlib error.
  32. // GULNSDataZlibErrorKey will contain the error value.
  33. // NSLocalizedDescriptionKey may contain an error string from zlib.
  34. // Look in zlib.h for list of errors.
  35. GULNSDataZlibErrorInternal,
  36. // There was left over data in the buffer that was not used.
  37. // GULNSDataZlibRemainingBytesKey will contain number of remaining bytes.
  38. GULNSDataZlibErrorDataRemaining
  39. };
  40. @end