5 * Copyright 2010 ZXing authors All rights reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <zxing/DecodeHints.h>
21 #include <zxing/common/IllegalArgumentException.h>
24 DecodeHints::DecodeHints() {
28 DecodeHints::DecodeHints(DecodeHintType init) {
32 DecodeHints::~DecodeHints() {
33 // if DecodeHintType requires a destructor in the future, call it here
36 void DecodeHints::addFormat(BarcodeFormat toadd) {
38 case BarcodeFormat_QR_CODE: hints |= BARCODEFORMAT_QR_CODE_HINT; break;
39 case BarcodeFormat_DATA_MATRIX: hints |= BARCODEFORMAT_DATA_MATRIX_HINT; break;
40 case BarcodeFormat_UPC_E: hints |= BARCODEFORMAT_UPC_E_HINT; break;
41 case BarcodeFormat_UPC_A: hints |= BARCODEFORMAT_UPC_A_HINT; break;
42 case BarcodeFormat_EAN_8: hints |= BARCODEFORMAT_EAN_8_HINT; break;
43 case BarcodeFormat_EAN_13: hints |= BARCODEFORMAT_EAN_13_HINT; break;
44 case BarcodeFormat_CODE_128: hints |= BARCODEFORMAT_CODE_128_HINT; break;
45 case BarcodeFormat_CODE_39: hints |= BARCODEFORMAT_CODE_39_HINT; break;
46 case BarcodeFormat_ITF: hints |= BARCODEFORMAT_ITF_HINT; break;
47 default: throw IllegalArgumentException("Unrecognizd barcode format");
51 bool DecodeHints::containsFormat(BarcodeFormat tocheck) const {
52 DecodeHintType checkAgainst;
54 case BarcodeFormat_QR_CODE: checkAgainst = BARCODEFORMAT_QR_CODE_HINT; break;
55 case BarcodeFormat_DATA_MATRIX: checkAgainst = BARCODEFORMAT_DATA_MATRIX_HINT; break;
56 case BarcodeFormat_UPC_E: checkAgainst = BARCODEFORMAT_UPC_E_HINT; break;
57 case BarcodeFormat_UPC_A: checkAgainst = BARCODEFORMAT_UPC_A_HINT; break;
58 case BarcodeFormat_EAN_8: checkAgainst = BARCODEFORMAT_EAN_8_HINT; break;
59 case BarcodeFormat_EAN_13: checkAgainst = BARCODEFORMAT_EAN_13_HINT; break;
60 case BarcodeFormat_CODE_128: checkAgainst = BARCODEFORMAT_CODE_128_HINT; break;
61 case BarcodeFormat_CODE_39: checkAgainst = BARCODEFORMAT_CODE_39_HINT; break;
62 case BarcodeFormat_ITF: checkAgainst = BARCODEFORMAT_ITF_HINT; break;
63 default: throw IllegalArgumentException("Unrecognizd barcode format");
65 return (hints & checkAgainst);
68 void DecodeHints::setTryHarder(bool toset) {
70 hints |= TRYHARDER_HINT;
72 hints &= ~TRYHARDER_HINT;
76 bool DecodeHints::getTryHarder() const {
77 return (hints & TRYHARDER_HINT);