NSData+BBAGZip.h
2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// NSData+BBAGZip.h
// ZipArchive
//
// Created by Zhu,Yusong on 2018/10/16.
// Copyright © 2018年 Baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BDPFoundationDefines.h"
NS_ASSUME_NONNULL_BEGIN
typedef NSInteger BDPCompressionLevel;
FOUNDATION_EXTERN BDPCompressionLevel const BDPCompressionLevelNoCompressin;
FOUNDATION_EXTERN BDPCompressionLevel const BDPCompressionLevelBestSpeed;
FOUNDATION_EXTERN BDPCompressionLevel const BDPCompressionLevelBestCompression;
FOUNDATION_EXTERN BDPCompressionLevel const BDPCompressionLevelDefaultCompression;
@interface NSData (BBAGZip)
/**
* @brief 默认的 GZip 压缩, level 为 BDPCompressionLevelDefaultCompression, 速度快
*
* @return GZip 压缩后的 NSData
*/
- (nullable NSData *)bba_compressGZip BDP_FOUNDATION_DEPRECATED("please use bdp_compressGZip");
- (nullable NSData *)bdp_compressGZip;
/**
* @brief 性能最好的 GZip 压缩, level 为 BDPCompressionLevelBestCompression, 速度慢
*
* @return GZip 压缩后的 NSData
*/
- (nullable NSData *)bba_bestCompressGZip BDP_FOUNDATION_DEPRECATED("please use bdp_bestCompressGZip");
- (nullable NSData *)bdp_bestCompressGZip;
/**
* @brief GZip 压缩
*
* @param level 压缩 level 推荐 Z_DEFAULT_COMPRESSION 或 Z_BEST_COMPRESSION (分别代表 -1 和 9,注意不要用 0)
* @param outputLength 估计的 output 长度, 如果最后长度与实际 output 不符合,会进行动态调整
* @return GZip 压缩后的 NSData
*
* @note 建议使用上面压缩方法,其 outputLength = self.length / 2
*/
- (nullable NSData *)bba_compressGZipWithCompressionLevel:(int)level estimatedOutputLength:(NSUInteger)outputLength BDP_FOUNDATION_DEPRECATED("please use bdp_compressGZipWithLevel:");
- (nullable NSData *)bdp_compressGZipWithLevel:(BDPCompressionLevel)level;
/**
* @brief GZip 解压
*
* @return GZip 解压后的 NSData
*/
- (nullable NSData *)bba_decompressGZip BDP_FOUNDATION_DEPRECATED("please use bdp_decompressGZip");
- (nullable NSData *)bdp_decompressGZip;
/**
* @brief GZip 解压
*
* @param outputLength outputLength 估计的 output 长度, 如果最后长度与实际 output 不符合,会进行动态调整
* @return GZip 解压后的 NSData
*
* @note 建议调用上面解压方法,其 outputLength = self.length * 2
*/
- (nullable NSData *)bba_decompressGZipWithEstimatedOutputLength:(NSUInteger)outputLength BDP_FOUNDATION_DEPRECATED("please use bdp_decompressGZip");
/**
* @brief 判断是否是 GZip 压缩后的 NSData
*
* @return YES on success
*/
- (BOOL)bba_isCompressedGZipData BDP_FOUNDATION_DEPRECATED("please use bdp_isCompressedGZipData");
- (BOOL)bdp_isCompressedGZipData;
@end
NS_ASSUME_NONNULL_END