5 * Created by Lukasz Warchol on 10-01-25.
6 * Copyright 2010 ZXing authors All rights reserved.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include "UPCAReader.h"
22 #include <zxing/ReaderException.h>
26 UPCAReader::UPCAReader() : ean13Reader() {
29 Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row){
30 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));
35 Ref<Result> UPCAReader::decode(Ref<BinaryBitmap> image, DecodeHints hints){
36 return maybeReturnResult(ean13Reader.decode(image, hints));
39 int UPCAReader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
40 return ean13Reader.decodeMiddle(row, startRange, startRangeLen, resultString);
43 Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result){
44 const std::string& text = (result->getText())->getText();
46 Ref<String> resultString(new String(text.substr(1)));
47 Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(), BarcodeFormat_UPC_A));
50 throw ReaderException("Not UPC-A barcode.");
55 BarcodeFormat UPCAReader::getBarcodeFormat(){
56 return BarcodeFormat_UPC_A;