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 "UPCAReader.h"
21 #include <zxing/ReaderException.h>
25 UPCAReader::UPCAReader() : ean13Reader() {
28 Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row) {
29 return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row));
32 Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row, int startGuardRange[]) {
33 return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange));
36 Ref<Result> UPCAReader::decode(Ref<BinaryBitmap> image, DecodeHints hints) {
37 return maybeReturnResult(ean13Reader.decode(image, hints));
40 int UPCAReader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen,
41 std::string& resultString) {
42 return ean13Reader.decodeMiddle(row, startRange, startRangeLen, resultString);
45 Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result) {
49 const std::string& text = (result->getText())->getText();
51 Ref<String> resultString(new String(text.substr(1)));
52 Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(),
53 BarcodeFormat_UPC_A));
59 BarcodeFormat UPCAReader::getBarcodeFormat(){
60 return BarcodeFormat_UPC_A;