You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ZXDecodeHints.m 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXDecodeHints.h"
  17. #import "ZXResultPointCallback.h"
  18. @interface ZXDecodeHints ()
  19. @property (nonatomic, strong, readonly) NSMutableArray *barcodeFormats;
  20. @end
  21. @implementation ZXDecodeHints
  22. - (id)init {
  23. if (self = [super init]) {
  24. _barcodeFormats = [NSMutableArray array];
  25. }
  26. return self;
  27. }
  28. + (id)hints {
  29. return [[self alloc] init];
  30. }
  31. - (id)copyWithZone:(NSZone *)zone {
  32. ZXDecodeHints *result = [[[self class] allocWithZone:zone] init];
  33. if (result) {
  34. result.assumeCode39CheckDigit = self.assumeCode39CheckDigit;
  35. result.allowedLengths = [self.allowedLengths copy];
  36. for (NSNumber *formatNumber in self.barcodeFormats) {
  37. [result addPossibleFormat:[formatNumber intValue]];
  38. }
  39. result.encoding = self.encoding;
  40. result.other = self.other;
  41. result.pureBarcode = self.pureBarcode;
  42. result.returnCodaBarStartEnd = self.returnCodaBarStartEnd;
  43. result.resultPointCallback = self.resultPointCallback;
  44. result.tryHarder = self.tryHarder;
  45. }
  46. return result;
  47. }
  48. - (void)addPossibleFormat:(ZXBarcodeFormat)format {
  49. [self.barcodeFormats addObject:[NSNumber numberWithInt:format]];
  50. }
  51. - (BOOL)containsFormat:(ZXBarcodeFormat)format {
  52. return [self.barcodeFormats containsObject:[NSNumber numberWithInt:format]];
  53. }
  54. - (int)numberOfPossibleFormats {
  55. return (int)self.barcodeFormats.count;
  56. }
  57. - (void)removePossibleFormat:(ZXBarcodeFormat)format {
  58. [self.barcodeFormats removeObject:[NSNumber numberWithInt:format]];
  59. }
  60. @end