Skip to content

Commit a500449

Browse files
committed
ios: rename DecodeHints -> ReaderOptions
See zxing-cpp#678
1 parent 45e2070 commit a500449

File tree

6 files changed

+31
-32
lines changed

6 files changed

+31
-32
lines changed

wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
#import <CoreGraphics/CoreGraphics.h>
77
#import <CoreImage/CoreImage.h>
88
#import "ZXIResult.h"
9-
#import "ZXIDecodeHints.h"
9+
#import "ZXIReaderOptions.h"
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

1313
@interface ZXIBarcodeReader : NSObject
14-
@property(nonatomic, strong) ZXIDecodeHints *hints;
14+
@property(nonatomic, strong) ZXIReaderOptions *options;
1515

16-
-(instancetype)initWithHints:(ZXIDecodeHints*)options;
16+
-(instancetype)initWithOptions:(ZXIReaderOptions*)options;
1717

1818
-(nullable NSArray<ZXIResult *> *)readCIImage:(nonnull CIImage *)image
1919
error:(NSError *__autoreleasing _Nullable *)error;

wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm

+14-15
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ @interface ZXIBarcodeReader()
4141
@implementation ZXIBarcodeReader
4242

4343
- (instancetype)init {
44-
return [self initWithHints: [[ZXIDecodeHints alloc] init]];
44+
return [self initWithOptions: [[ZXIReaderOptions alloc] init]];
4545
}
4646

47-
- (instancetype)initWithHints:(ZXIDecodeHints*)hints{
47+
- (instancetype)initWithOptions:(ZXIReaderOptions*)options{
4848
self = [super init];
4949
self.ciContext = [[CIContext alloc] initWithOptions:@{kCIContextWorkingColorSpace: [NSNull new]}];
50-
self.hints = hints;
50+
self.options = options;
5151
return self;
5252
}
5353

@@ -117,29 +117,28 @@ - (instancetype)initWithHints:(ZXIDecodeHints*)hints{
117117
return [self readImageView:imageView error:error];
118118
}
119119

120-
+ (DecodeHints)DecodeHintsFromZXIOptions:(ZXIDecodeHints*)hints {
120+
+ (DecodeHints)DecodeHintsFromZXIReaderOptions:(ZXIReaderOptions*)options {
121121
BarcodeFormats formats;
122-
for(NSNumber* flag in hints.formats) {
122+
for(NSNumber* flag in options.formats) {
123123
formats.setFlag(BarcodeFormatFromZXIFormat((ZXIFormat)flag.integerValue));
124124
}
125125
DecodeHints resultingHints = DecodeHints()
126-
.setTryRotate(hints.tryRotate)
127-
.setTryHarder(hints.tryHarder)
128-
.setTryInvert(hints.tryInvert)
129-
.setTryDownscale(hints.tryDownscale)
130-
.setTryCode39ExtendedMode(hints.tryCode39ExtendedMode)
131-
.setValidateCode39CheckSum(hints.validateCode39CheckSum)
132-
.setValidateITFCheckSum(hints.validateITFCheckSum)
133-
134126
.setFormats(formats)
135-
.setMaxNumberOfSymbols(hints.maxNumberOfSymbols);
127+
.setTryRotate(options.tryRotate)
128+
.setTryHarder(options.tryHarder)
129+
.setTryInvert(options.tryInvert)
130+
.setTryDownscale(options.tryDownscale)
131+
.setTryCode39ExtendedMode(options.tryCode39ExtendedMode)
132+
.setValidateCode39CheckSum(options.validateCode39CheckSum)
133+
.setValidateITFCheckSum(options.validateITFCheckSum)
134+
.setMaxNumberOfSymbols(options.maxNumberOfSymbols);
136135
return resultingHints;
137136
}
138137

139138
- (NSArray<ZXIResult*> *)readImageView:(ImageView)imageView
140139
error:(NSError *__autoreleasing _Nullable *)error {
141140
try {
142-
Results results = ReadBarcodes(imageView, [ZXIBarcodeReader DecodeHintsFromZXIOptions:self.hints]);
141+
Results results = ReadBarcodes(imageView, [ZXIBarcodeReader DecodeHintsFromZXIReaderOptions:self.options]);
143142
NSMutableArray* zxiResults = [NSMutableArray array];
144143
for (auto result: results) {
145144
[zxiResults addObject:

wrappers/ios/Sources/Wrapper/Reader/ZXIDecodeHints.h wrappers/ios/Sources/Wrapper/Reader/ZXIReaderOptions.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
NS_ASSUME_NONNULL_BEGIN
88

9-
@interface ZXIDecodeHints : NSObject
9+
@interface ZXIReaderOptions : NSObject
10+
/// An array of ZXIFormat
11+
@property(nonatomic, strong) NSArray<NSNumber*> *formats;
1012
@property(nonatomic) BOOL tryHarder;
1113
@property(nonatomic) BOOL tryRotate;
1214
@property(nonatomic) BOOL tryInvert;
@@ -17,10 +19,9 @@ NS_ASSUME_NONNULL_BEGIN
1719
@property(nonatomic) uint8_t downscaleFactor;
1820
@property(nonatomic) uint16_t downscaleThreshold;
1921
@property(nonatomic) NSInteger maxNumberOfSymbols;
20-
/// An array of ZXIFormat
21-
@property(nonatomic, strong) NSArray<NSNumber*> *formats;
2222

23-
- (instancetype)initWithTryHarder:(BOOL)tryHarder
23+
- (instancetype)initWithFormats:(NSArray<NSNumber*>*)formats
24+
tryHarder:(BOOL)tryHarder
2425
tryRotate:(BOOL)tryRotate
2526
tryInvert:(BOOL)tryInvert
2627
tryDownscale:(BOOL)tryDownscale
@@ -29,8 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
2930
validateITFCheckSum:(BOOL)validateITFCheckSum
3031
downscaleFactor:(uint8_t)downscaleFactor
3132
downscaleThreshold:(uint16_t)downscaleThreshold
32-
maxNumberOfSymbols:(NSInteger)maxNumberOfSymbols
33-
formats:(NSArray<NSNumber*>*)formats;
33+
maxNumberOfSymbols:(NSInteger)maxNumberOfSymbols;
3434
@end
3535

3636
NS_ASSUME_NONNULL_END

wrappers/ios/Sources/Wrapper/Reader/ZXIDecodeHints.mm wrappers/ios/Sources/Wrapper/Reader/ZXIReaderOptions.mm

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
#import "ZXIDecodeHints.h"
5+
#import "ZXIReaderOptions.h"
66
#import "DecodeHints.h"
77

8-
@interface ZXIDecodeHints()
8+
@interface ZXIReaderOptions()
99
@property(nonatomic) ZXing::DecodeHints zxingHints;
1010
@end
1111

12-
@implementation ZXIDecodeHints
12+
@implementation ZXIReaderOptions
1313

1414
-(instancetype)init {
1515
self = [super init];
1616
self.zxingHints = ZXing::DecodeHints();
1717
return self;
1818
}
1919

20-
- (instancetype)initWithTryHarder:(BOOL)tryHarder
20+
- (instancetype)initWithFormats:(NSArray<NSNumber*>*)formats
21+
tryHarder:(BOOL)tryHarder
2122
tryRotate:(BOOL)tryRotate
2223
tryInvert:(BOOL)tryInvert
2324
tryDownscale:(BOOL)tryDownscale
@@ -26,8 +27,7 @@ - (instancetype)initWithTryHarder:(BOOL)tryHarder
2627
validateITFCheckSum:(BOOL)validateITFCheckSum
2728
downscaleFactor:(uint8_t)downscaleFactor
2829
downscaleThreshold:(uint16_t)downscaleThreshold
29-
maxNumberOfSymbols:(NSInteger)maxNumberOfSymbols
30-
formats:(NSArray<NSNumber*>*)formats {
30+
maxNumberOfSymbols:(NSInteger)maxNumberOfSymbols {
3131
self = [super init];
3232
self.zxingHints = ZXing::DecodeHints();
3333
self.tryHarder = tryHarder;

wrappers/ios/Sources/Wrapper/UmbrellaHeader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#import "Reader/ZXIPosition.h"
1111
#import "Reader/ZXIPoint.h"
1212
#import "Reader/ZXIGTIN.h"
13-
#import "Reader/ZXIDecodeHints.h"
13+
#import "Reader/ZXIReaderOptions.h"
1414
#import "Writer/ZXIEncodeHints.h"
1515
#import "Writer/ZXIBarcodeWriter.h"
1616
#import "ZXIErrors.h"

zxing-cpp.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Pod::Spec.new do |s|
3131
ss.dependency 'zxing-cpp/Core'
3232
ss.frameworks = 'CoreGraphics', 'CoreImage', 'CoreVideo'
3333
ss.source_files = 'wrappers/ios/Sources/Wrapper/**/*.{h,m,mm}'
34-
ss.public_header_files = 'wrappers/ios/Sources/Wrapper/Reader/{ZXIBarcodeReader,ZXIResult,ZXIPosition,ZXIPoint,ZXIGTIN,ZXIDecodeHints}.h',
34+
ss.public_header_files = 'wrappers/ios/Sources/Wrapper/Reader/{ZXIBarcodeReader,ZXIResult,ZXIPosition,ZXIPoint,ZXIGTIN,ZXIReaderOptions}.h',
3535
'wrappers/ios/Sources/Wrapper/Writer/{ZXIBarcodeWriter,ZXIEncodeHints}.h',
3636
'wrappers/ios/Sources/Wrapper/{ZXIErrors,ZXIFormat}.h'
3737
ss.exclude_files = 'wrappers/ios/Sources/Wrapper/UmbrellaHeader.h'

0 commit comments

Comments
 (0)