2 * MultiFormatOneDReader.cpp
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 "MultiFormatOneDReader.h"
22 #include <zxing/oned/MultiFormatUPCEANReader.h>
23 #include <zxing/oned/Code39Reader.h>
24 #include <zxing/oned/Code128Reader.h>
25 #include <zxing/oned/ITFReader.h>
26 #include <zxing/ReaderException.h>
30 MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() {
31 if (hints.containsFormat(BarcodeFormat_EAN_13) ||
32 hints.containsFormat(BarcodeFormat_EAN_8) ||
33 hints.containsFormat(BarcodeFormat_UPC_A) ||
34 hints.containsFormat(BarcodeFormat_UPC_E)) {
35 readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
37 if (hints.containsFormat(BarcodeFormat_CODE_39)) {
38 readers.push_back(Ref<OneDReader>(new Code39Reader()));
40 if (hints.containsFormat(BarcodeFormat_CODE_128)) {
41 readers.push_back(Ref<OneDReader>(new Code128Reader()));
43 if (hints.containsFormat(BarcodeFormat_ITF)) {
44 readers.push_back(Ref<OneDReader>(new ITFReader()));
46 if (readers.size() == 0) {
47 readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader(hints)));
48 readers.push_back(Ref<OneDReader>(new Code39Reader()));
49 readers.push_back(Ref<OneDReader>(new Code128Reader()));
50 readers.push_back(Ref<OneDReader>(new ITFReader()));
54 Ref<Result> MultiFormatOneDReader::decodeRow(int rowNumber, Ref<BitArray> row) {
55 int size = readers.size();
56 for (int i = 0; i < size; i++) {
57 OneDReader* reader = readers[i];
58 Ref<Result> result = reader->decodeRow(rowNumber, row);
59 if (!result.empty()) {