diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm b/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm index 1e32566378..c13b150e8c 100644 --- a/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIBarcodeReader.mm @@ -6,11 +6,27 @@ #import "ReadBarcode.h" #import "ImageView.h" #import "Result.h" +#import "GTIN.h" #import "ZXIFormatHelper.h" #import "ZXIPosition+Helper.h" using namespace ZXing; +NSString *stringToNSString(const std::string &text) { + return [[NSString alloc]initWithBytes:text.data() length:text.size() encoding:NSUTF8StringEncoding]; +} + +ZXIGTIN *getGTIN(const Result &result) { + auto country = GTIN::LookupCountryIdentifier(result.text(TextMode::Plain), result.format()); + auto addOn = GTIN::EanAddOn(result); + return country.empty() + ? nullptr + : [[ZXIGTIN alloc]initWithCountry:stringToNSString(country) + addOn:stringToNSString(addOn) + price:stringToNSString(GTIN::Price(addOn)) + issueNumber:stringToNSString(GTIN::IssueNr(addOn))]; +} + @interface ZXIBarcodeReader() @property (nonatomic, strong) CIContext* ciContext; @end @@ -115,16 +131,21 @@ + (DecodeHints)DecodeHintsFromZXIOptions:(ZXIDecodeHints*)hints { NSMutableArray* zxiResults = [NSMutableArray array]; for (auto result: results) { - auto resultText = result.text(); - NSString *text = [[NSString alloc]initWithBytes:resultText.data() length:resultText.size() encoding:NSUTF8StringEncoding]; - - NSData *bytes = [[NSData alloc] initWithBytes:result.bytes().data() length:result.bytes().size()]; [zxiResults addObject: - [[ZXIResult alloc] init:text + [[ZXIResult alloc] init:stringToNSString(result.text()) format:ZXIFormatFromBarcodeFormat(result.format()) - bytes:bytes + bytes:[[NSData alloc] initWithBytes:result.bytes().data() length:result.bytes().size()] position:[[ZXIPosition alloc]initWithPosition: result.position()] - ]]; + orientation:result.orientation() + ecLevel:stringToNSString(result.ecLevel()) + symbologyIdentifier:stringToNSString(result.symbologyIdentifier()) + sequenceSize:result.sequenceSize() + sequenceIndex:result.sequenceIndex() + sequenceId:stringToNSString(result.sequenceId()) + readerInit:result.readerInit() + lineCount:result.lineCount() + gtin:getGTIN(result)] + ]; } return zxiResults; } diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIGTIN.h b/wrappers/ios/Sources/Wrapper/Reader/ZXIGTIN.h new file mode 100644 index 0000000000..0992d845ff --- /dev/null +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIGTIN.h @@ -0,0 +1,22 @@ +// Copyright 2022 KURZ Digital Solutions GmbH +// +// SPDX-License-Identifier: Apache-2.0 + + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface ZXIGTIN : NSObject +@property(nonatomic, nonnull)NSString *country; +@property(nonatomic, nonnull)NSString *addOn; +@property(nonatomic, nonnull)NSString *price; +@property(nonatomic, nonnull)NSString *issueNumber; + +- (instancetype)initWithCountry:(NSString *)country + addOn:(NSString *)addOn + price:(NSString *)price + issueNumber:(NSString *)issueNumber; +@end + +NS_ASSUME_NONNULL_END diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIGTIN.mm b/wrappers/ios/Sources/Wrapper/Reader/ZXIGTIN.mm new file mode 100644 index 0000000000..c0d801d0b6 --- /dev/null +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIGTIN.mm @@ -0,0 +1,20 @@ +// Copyright 2022 KURZ Digital Solutions GmbH +// +// SPDX-License-Identifier: Apache-2.0 + + +#import "ZXIGTIN.h" + +@implementation ZXIGTIN +- (instancetype)initWithCountry:(NSString *)country + addOn:(NSString *)addOn + price:(NSString *)price + issueNumber:(NSString *)issueNumber { + self = [super init]; + self.country = country; + self.addOn = addOn; + self.price = price; + self.issueNumber = issueNumber; + return self; +} +@end diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.h b/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.h index 83d8a4cffc..9c4c4e8a36 100644 --- a/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.h +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.h @@ -5,6 +5,7 @@ #import #import "ZXIFormat.h" #import "ZXIPosition.h" +#import "ZXIGTIN.h" NS_ASSUME_NONNULL_BEGIN @@ -13,11 +14,29 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic, strong) NSData *bytes; @property(nonatomic, strong) ZXIPosition *position; @property(nonatomic) ZXIFormat format; +@property(nonatomic) NSInteger orientation; +@property(nonatomic, strong) NSString *ecLevel; +@property(nonatomic, strong) NSString *symbologyIdentifier; +@property(nonatomic) NSInteger sequenceSize; +@property(nonatomic) NSInteger sequenceIndex; +@property(nonatomic, strong) NSString *sequenceId; +@property(nonatomic) BOOL readerInit; +@property(nonatomic) NSInteger lineCount; +@property(nonatomic, strong) ZXIGTIN *gtin; - (instancetype)init:(NSString *)text format:(ZXIFormat)format bytes:(NSData *)bytes - position:(ZXIPosition *)position; + position:(ZXIPosition *)position + orientation:(NSInteger)orientation + ecLevel:(NSString *)ecLevel + symbologyIdentifier:(NSString *)symbologyIdentifier + sequenceSize:(NSInteger)sequenceSize + sequenceIndex:(NSInteger)sequenceIndex + sequenceId:(NSString *)sequenceId + readerInit:(BOOL)readerInit + lineCount:(NSInteger)lineCount + gtin:(ZXIGTIN *)gtin; @end NS_ASSUME_NONNULL_END diff --git a/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.mm b/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.mm index b84267d2a0..6a80a77d28 100644 --- a/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.mm +++ b/wrappers/ios/Sources/Wrapper/Reader/ZXIResult.mm @@ -8,12 +8,30 @@ @implementation ZXIResult - (instancetype)init:(NSString *)text format:(ZXIFormat)format bytes:(NSData *)bytes - position:(ZXIPosition *)position { + position:(ZXIPosition *)position + orientation:(NSInteger)orientation + ecLevel:(NSString *)ecLevel + symbologyIdentifier:(NSString *)symbologyIdentifier + sequenceSize:(NSInteger)sequenceSize + sequenceIndex:(NSInteger)sequenceIndex + sequenceId:(NSString *)sequenceId + readerInit:(BOOL)readerInit + lineCount:(NSInteger)lineCount + gtin:(ZXIGTIN *)gtin { self = [super init]; self.text = text; self.format = format; self.bytes = bytes; self.position = position; + self.orientation = orientation; + self.ecLevel = ecLevel; + self.symbologyIdentifier = symbologyIdentifier; + self.sequenceSize = sequenceSize; + self.sequenceIndex = sequenceIndex; + self.sequenceId = sequenceId; + self.readerInit = readerInit; + self.lineCount = lineCount; + self.gtin = gtin; return self; } @end diff --git a/wrappers/ios/Sources/Wrapper/UmbrellaHeader.h b/wrappers/ios/Sources/Wrapper/UmbrellaHeader.h index d76dc767c4..b14dc9b5df 100644 --- a/wrappers/ios/Sources/Wrapper/UmbrellaHeader.h +++ b/wrappers/ios/Sources/Wrapper/UmbrellaHeader.h @@ -9,6 +9,7 @@ #import "Reader/ZXIResult.h" #import "Reader/ZXIPosition.h" #import "Reader/ZXIPoint.h" +#import "Reader/ZXIGTIN.h" #import "Reader/ZXIDecodeHints.h" #import "Writer/ZXIEncodeHints.h" #import "Writer/ZXIBarcodeWriter.h" diff --git a/zxing-cpp.podspec b/zxing-cpp.podspec index 23da89b8b8..02997d19c0 100644 --- a/zxing-cpp.podspec +++ b/zxing-cpp.podspec @@ -31,7 +31,7 @@ Pod::Spec.new do |s| ss.dependency 'zxing-cpp/Core' ss.frameworks = 'CoreGraphics', 'CoreImage', 'CoreVideo' ss.source_files = 'wrappers/ios/Sources/Wrapper/**/*.{h,m,mm}' - ss.public_header_files = 'wrappers/ios/Sources/Wrapper/Reader/{ZXIBarcodeReader,ZXIResult,ZXIPosition,ZXIPoint,ZXIDecodeHints}.h', + ss.public_header_files = 'wrappers/ios/Sources/Wrapper/Reader/{ZXIBarcodeReader,ZXIResult,ZXIPosition,ZXIPoint,ZXIGTIN,ZXIDecodeHints}.h', 'wrappers/ios/Sources/Wrapper/Writer/{ZXIBarcodeWriter,ZXIEncodeHints}.h', 'wrappers/ios/Sources/Wrapper/{ZXIErrors,ZXIFormat}.h' ss.exclude_files = 'wrappers/ios/Sources/Wrapper/UmbrellaHeader.h' pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy