X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=cpp%2Fcore%2Fsrc%2Fzxing%2Foned%2FMultiFormatUPCEANReader.cpp;h=a5582f0267fa3eeecb1f961a5de53a0a68e689ab;hp=eaa7ed6c5210012d40f7cff9c4d26bf39c5d6fce;hb=ed5e46807ea0847057ff4d8c714b16938005a299;hpb=a26a7880879d983c8d0bbaf2f56391999d12edde diff --git a/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp b/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp index eaa7ed6c..a5582f02 100644 --- a/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp +++ b/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp @@ -28,60 +28,60 @@ #include namespace zxing { - namespace oned { + namespace oned { - MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() { - if (hints.containsFormat(BarcodeFormat_EAN_13)) { - readers.push_back(Ref(new EAN13Reader())); - } else if (hints.containsFormat(BarcodeFormat_UPC_A)) { - readers.push_back(Ref(new UPCAReader())); - } - if (hints.containsFormat(BarcodeFormat_EAN_8)) { - readers.push_back(Ref(new EAN8Reader())); - } - if (hints.containsFormat(BarcodeFormat_UPC_E)) { - readers.push_back(Ref(new UPCEReader())); - } - if (readers.size() == 0) { - readers.push_back(Ref(new EAN13Reader())); - // UPC-A is covered by EAN-13 - readers.push_back(Ref(new EAN8Reader())); - readers.push_back(Ref(new UPCEReader())); - } - } + MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() { + if (hints.containsFormat(BarcodeFormat_EAN_13)) { + readers.push_back(Ref(new EAN13Reader())); + } else if (hints.containsFormat(BarcodeFormat_UPC_A)) { + readers.push_back(Ref(new UPCAReader())); + } + if (hints.containsFormat(BarcodeFormat_EAN_8)) { + readers.push_back(Ref(new EAN8Reader())); + } + if (hints.containsFormat(BarcodeFormat_UPC_E)) { + readers.push_back(Ref(new UPCEReader())); + } + if (readers.size() == 0) { + readers.push_back(Ref(new EAN13Reader())); + // UPC-A is covered by EAN-13 + readers.push_back(Ref(new EAN8Reader())); + readers.push_back(Ref(new UPCEReader())); + } + } - Ref MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref row) { - // Compute this location once and reuse it on multiple implementations - int size = readers.size(); - for (int i = 0; i < size; i++) { - Ref reader = readers[i]; - Ref result = reader->decodeRow(rowNumber, row); - if (result.empty()) { - continue; - } + Ref MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref row) { + // Compute this location once and reuse it on multiple implementations + int size = readers.size(); + for (int i = 0; i < size; i++) { + Ref reader = readers[i]; + Ref result = reader->decodeRow(rowNumber, row); + if (result.empty()) { + continue; + } - // Special case: a 12-digit code encoded in UPC-A is identical to a "0" - // followed by those 12 digits encoded as EAN-13. Each will recognize such a code, - // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0". - // Individually these are correct and their readers will both read such a code - // and correctly call it EAN-13, or UPC-A, respectively. - // - // In this case, if we've been looking for both types, we'd like to call it - // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read - // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A - // result if appropriate. - if (result->getBarcodeFormat() == BarcodeFormat_EAN_13) { - const std::string& text = (result->getText())->getText(); - if (text[0] == '0') { - Ref resultString(new String(text.substr(1))); - Ref res(new Result(resultString, result->getRawBytes(), - result->getResultPoints(), BarcodeFormat_UPC_A)); - return res; - } - } - return result; - } - return Ref(); - } - } + // Special case: a 12-digit code encoded in UPC-A is identical to a "0" + // followed by those 12 digits encoded as EAN-13. Each will recognize such a code, + // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0". + // Individually these are correct and their readers will both read such a code + // and correctly call it EAN-13, or UPC-A, respectively. + // + // In this case, if we've been looking for both types, we'd like to call it + // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read + // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A + // result if appropriate. + if (result->getBarcodeFormat() == BarcodeFormat_EAN_13) { + const std::string& text = (result->getText())->getText(); + if (text[0] == '0') { + Ref resultString(new String(text.substr(1))); + Ref res(new Result(resultString, result->getRawBytes(), + result->getResultPoints(), BarcodeFormat_UPC_A)); + return res; + } + } + return result; + } + return Ref(); + } + } }