From 16f1530c5da03e2199a2ec25256008372b05f8ad Mon Sep 17 00:00:00 2001 From: "nikos.ftylitakis" Date: Thu, 2 Aug 2018 11:59:56 +0300 Subject: [PATCH 01/83] Change CenterComparator and FurthestFromAverageComparator return value from integer to bool to better comply with the std::sort comparator. Fixes the segmentation fault of issue #85 though QZXing is still unable to decode multi-QrCode image. --- .../qrcode/detector/QRFinderPatternFinder.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp b/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp index 0f535f5..3800fbf 100644 --- a/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp +++ b/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp @@ -25,6 +25,9 @@ #include #include +//#include +//#include + using std::sort; using std::max; using std::abs; @@ -50,10 +53,10 @@ public: FurthestFromAverageComparator(float averageModuleSize) : averageModuleSize_(averageModuleSize) { } - int operator()(Ref a, Ref b) { + bool operator()(Ref a, Ref b) { float dA = abs(a->getEstimatedModuleSize() - averageModuleSize_); float dB = abs(b->getEstimatedModuleSize() - averageModuleSize_); - return dA < dB ? -1 : dA == dB ? 0 : 1; + return dA > dB;// ? -1 : dA == dB ? 0 : 1; } }; @@ -63,14 +66,23 @@ public: CenterComparator(float averageModuleSize) : averageModuleSize_(averageModuleSize) { } - int operator()(Ref a, Ref b) { + bool operator()(Ref a, Ref b) { // N.B.: we want the result in descending order ... + if(a.empty() && b.empty()) + return true; + else if(a.empty() && !b.empty()) + return true; + else if(!a.empty() && b.empty()) + return false; + if (a->getCount() != b->getCount()) { - return b->getCount() - a->getCount(); + return a->getCount() < b->getCount(); } else { float dA = abs(a->getEstimatedModuleSize() - averageModuleSize_); float dB = abs(b->getEstimatedModuleSize() - averageModuleSize_); - return dA < dB ? 1 : dA == dB ? 0 : -1; + return dA < dB; + //return dA < dB ? 1 : dA == dB ? 0 : -1; + //return dA < dB ? 1 : (fabs(dA - dB) < std::numeric_limits::epsilon()) ? 0 : -1; } } }; From 501e0f87384cf655e38a7a36f99fb510c4a812dc Mon Sep 17 00:00:00 2001 From: "nikos.ftylitakis" Date: Thu, 2 Aug 2018 12:00:49 +0300 Subject: [PATCH 02/83] minor fix of the value of processingTime property provided by QZXing. --- src/QZXing.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index c89de07..a431099 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -321,6 +321,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo { QTime t; t.start(); + processingTime = -1; Ref res; emit decodingStarted(); @@ -349,6 +350,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo bool hasSucceded = false; try { res = decoder->decode(bb, hints); + processingTime = t.elapsed(); hasSucceded = true; }catch(zxing::Exception &e){} @@ -358,8 +360,9 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo try { res = decoder->decode(bb, hints); + processingTime = t.elapsed(); hasSucceded = true; - } catch(zxing::Exception &e) {} + } catch(zxing::Exception &/*e*/) {} if (tryHarder_ && bb->isRotateSupported()) { Ref bbTmp = bb; @@ -372,7 +375,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo res = decoder->decode(rotatedImage, hints); processingTime = t.elapsed(); hasSucceded = true; - } catch(zxing::Exception &e) {} + } catch(zxing::Exception &/*e*/) {} } } } From 2b380f5483a7b2b9d905a14ab1e3e86f82ad0152 Mon Sep 17 00:00:00 2001 From: Jimmy Morales Date: Tue, 30 Oct 2018 12:16:15 -0500 Subject: [PATCH 03/83] Add explicit namespace to byte class This avoids ambiguous compiler error --- src/zxing/zxing/common/DecoderResult.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zxing/zxing/common/DecoderResult.cpp b/src/zxing/zxing/common/DecoderResult.cpp index 7e429fd..6090ff7 100644 --- a/src/zxing/zxing/common/DecoderResult.cpp +++ b/src/zxing/zxing/common/DecoderResult.cpp @@ -37,7 +37,7 @@ DecoderResult::DecoderResult(ArrayRef rawBytes, Ref text) : rawBytes_(rawBytes), text_(text),charSet_("") {} -ArrayRef DecoderResult::getRawBytes() { +ArrayRef DecoderResult::getRawBytes() { return rawBytes_; } From 26b5ce2fbd1a32acead9f768629e62e3dade9b12 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 16:16:55 +0100 Subject: [PATCH 04/83] Removed multi-line comment warning --- src/zxing/zxing/common/BitMatrix.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/zxing/zxing/common/BitMatrix.h b/src/zxing/zxing/common/BitMatrix.h index 1978793..5b6c6df 100644 --- a/src/zxing/zxing/common/BitMatrix.h +++ b/src/zxing/zxing/common/BitMatrix.h @@ -38,17 +38,6 @@ private: int rowSize; ArrayRef bits; -//#define ZX_LOG_DIGITS(digits) \ -// ((digits == 8) ? 3 : \ -// ((digits == 16) ? 4 : \ -// ((digits == 32) ? 5 : \ -// ((digits == 64) ? 6 : \ -// ((digits == 128) ? 7 : \ -// (-1)))))) - -// static const int logBits = ZX_LOG_DIGITS(bitsPerWord); -// static const int bitsMask = (1 << logBits) - 1; - public: BitMatrix(int dimension); BitMatrix(int width, int height); From b1bf4dfb01a85df2054b5c057cef9d9aee34e93b Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 16:42:05 +0100 Subject: [PATCH 05/83] Fixed header guards triggering 'warning: macro name is a reserved identifier' --- src/zxing/zxing/BarcodeFormat.h | 6 +++--- src/zxing/zxing/BinaryBitmap.h | 6 +++--- src/zxing/zxing/ChecksumException.h | 6 +++--- src/zxing/zxing/DecodeHints.h | 7 ++++--- src/zxing/zxing/Exception.h | 6 +++--- src/zxing/zxing/FormatException.h | 6 +++--- src/zxing/zxing/IllegalStateException.h | 6 +++--- src/zxing/zxing/InvertedLuminanceSource.h | 6 +++--- src/zxing/zxing/LuminanceSource.h | 6 +++--- src/zxing/zxing/MultiFormatReader.h | 7 ++++--- src/zxing/zxing/NotFoundException.h | 6 +++--- src/zxing/zxing/Reader.h | 6 +++--- src/zxing/zxing/ReaderException.h | 6 +++--- src/zxing/zxing/Result.h | 6 +++--- src/zxing/zxing/ResultPoint.h | 6 +++--- src/zxing/zxing/ResultPointCallback.h | 6 +++--- src/zxing/zxing/ZXing.h | 4 ++-- src/zxing/zxing/aztec/decoder/Decoder.h | 6 +++--- src/zxing/zxing/aztec/detector/Detector.h | 6 +++--- src/zxing/zxing/common/Array.h | 6 +++--- src/zxing/zxing/common/BitArray.h | 6 +++--- src/zxing/zxing/common/BitMatrix.h | 6 +++--- src/zxing/zxing/common/BitSource.h | 6 +++--- src/zxing/zxing/common/CharacterSetECI.h | 7 ++++--- src/zxing/zxing/common/Counted.h | 6 +++--- src/zxing/zxing/common/DecoderResult.h | 6 +++--- src/zxing/zxing/common/DetectorResult.h | 6 +++--- src/zxing/zxing/common/GlobalHistogramBinarizer.h | 6 +++--- src/zxing/zxing/common/GreyscaleLuminanceSource.h | 6 +++--- .../zxing/common/GreyscaleRotatedLuminanceSource.h | 6 +++--- src/zxing/zxing/common/GridSampler.h | 6 +++--- src/zxing/zxing/common/HybridBinarizer.h | 6 +++--- src/zxing/zxing/common/IllegalArgumentException.h | 6 +++--- src/zxing/zxing/common/PerspectiveTransform.h | 6 +++--- src/zxing/zxing/common/Point.h | 6 +++--- src/zxing/zxing/common/Str.h | 6 +++--- src/zxing/zxing/common/StringUtils.h | 7 ++++--- src/zxing/zxing/common/Types.h | 6 +++--- src/zxing/zxing/common/detector/JavaMath.h | 7 ++++--- src/zxing/zxing/common/detector/MathUtils.h | 7 ++++--- .../common/detector/MonochromeRectangleDetector.h | 6 +++--- .../zxing/common/detector/WhiteRectangleDetector.h | 7 ++++--- .../zxing/common/reedsolomon/ReedSolomonDecoder.h | 6 +++--- .../zxing/common/reedsolomon/ReedSolomonException.h | 6 +++--- src/zxing/zxing/datamatrix/DataMatrixReader.h | 6 +++--- src/zxing/zxing/datamatrix/Version.h | 6 +++--- src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h | 6 +++--- src/zxing/zxing/datamatrix/decoder/DataBlock.h | 6 +++--- .../zxing/datamatrix/decoder/DecodedBitStreamParser.h | 11 ++++++----- src/zxing/zxing/datamatrix/decoder/Decoder.h | 6 +++--- src/zxing/zxing/datamatrix/detector/CornerPoint.h | 6 +++--- src/zxing/zxing/datamatrix/detector/Detector.h | 6 +++--- src/zxing/zxing/multi/ByQuadrantReader.h | 6 +++--- src/zxing/zxing/multi/GenericMultipleBarcodeReader.h | 6 +++--- src/zxing/zxing/multi/MultipleBarcodeReader.h | 6 +++--- src/zxing/zxing/multi/qrcode/QRCodeMultiReader.h | 6 +++--- src/zxing/zxing/multi/qrcode/detector/MultiDetector.h | 6 +++--- .../multi/qrcode/detector/MultiFinderPatternFinder.h | 6 +++--- src/zxing/zxing/oned/CodaBarReader.h | 6 +++--- src/zxing/zxing/oned/Code128Reader.h | 7 ++++--- src/zxing/zxing/oned/Code39Reader.h | 7 ++++--- src/zxing/zxing/oned/Code93Reader.h | 7 ++++--- src/zxing/zxing/oned/EAN13Reader.h | 7 ++++--- src/zxing/zxing/oned/EAN8Reader.h | 7 ++++--- src/zxing/zxing/oned/ITFReader.h | 7 ++++--- src/zxing/zxing/oned/MultiFormatOneDReader.h | 7 ++++--- src/zxing/zxing/oned/MultiFormatUPCEANReader.h | 7 ++++--- src/zxing/zxing/oned/OneDReader.h | 7 ++++--- src/zxing/zxing/oned/OneDResultPoint.h | 7 ++++--- src/zxing/zxing/oned/UPCAReader.h | 7 ++++--- src/zxing/zxing/oned/UPCEANReader.h | 7 ++++--- src/zxing/zxing/oned/UPCEReader.h | 7 ++++--- src/zxing/zxing/pdf417/PDF417Reader.h | 6 +++--- src/zxing/zxing/pdf417/decoder/BitMatrixParser.h | 6 +++--- .../zxing/pdf417/decoder/DecodedBitStreamParser.h | 6 +++--- src/zxing/zxing/pdf417/decoder/Decoder.h | 6 +++--- src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h | 6 +++--- src/zxing/zxing/pdf417/decoder/ec/ModulusGF.h | 6 +++--- src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h | 6 +++--- src/zxing/zxing/pdf417/detector/Detector.h | 6 +++--- src/zxing/zxing/pdf417/detector/LinesSampler.h | 6 +++--- src/zxing/zxing/qrcode/ErrorCorrectionLevel.h | 6 +++--- src/zxing/zxing/qrcode/FormatInformation.h | 6 +++--- src/zxing/zxing/qrcode/QRCodeReader.h | 6 +++--- src/zxing/zxing/qrcode/Version.h | 6 +++--- src/zxing/zxing/qrcode/decoder/BitMatrixParser.h | 6 +++--- src/zxing/zxing/qrcode/decoder/DataBlock.h | 6 +++--- src/zxing/zxing/qrcode/decoder/DataMask.h | 6 +++--- .../zxing/qrcode/decoder/DecodedBitStreamParser.h | 6 +++--- src/zxing/zxing/qrcode/decoder/Decoder.h | 6 +++--- src/zxing/zxing/qrcode/decoder/Mode.h | 4 ++-- src/zxing/zxing/qrcode/detector/AlignmentPattern.h | 6 +++--- .../zxing/qrcode/detector/AlignmentPatternFinder.h | 6 +++--- src/zxing/zxing/qrcode/detector/Detector.h | 6 +++--- src/zxing/zxing/qrcode/detector/FinderPattern.h | 6 +++--- src/zxing/zxing/qrcode/detector/FinderPatternFinder.h | 6 +++--- src/zxing/zxing/qrcode/detector/FinderPatternInfo.h | 6 +++--- 97 files changed, 312 insertions(+), 291 deletions(-) diff --git a/src/zxing/zxing/BarcodeFormat.h b/src/zxing/zxing/BarcodeFormat.h index 25d92a6..fedb327 100644 --- a/src/zxing/zxing/BarcodeFormat.h +++ b/src/zxing/zxing/BarcodeFormat.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __BARCODE_FORMAT_H__ -#define __BARCODE_FORMAT_H__ +#ifndef ZXING_BARCODE_FORMAT_H +#define ZXING_BARCODE_FORMAT_H /* * BarcodeFormat.h @@ -58,4 +58,4 @@ public: } -#endif // __BARCODE_FORMAT_H__ +#endif // ZXING_BARCODE_FORMAT_H diff --git a/src/zxing/zxing/BinaryBitmap.h b/src/zxing/zxing/BinaryBitmap.h index 00012ee..92e830e 100644 --- a/src/zxing/zxing/BinaryBitmap.h +++ b/src/zxing/zxing/BinaryBitmap.h @@ -1,5 +1,5 @@ -#ifndef __BINARYBITMAP_H__ -#define __BINARYBITMAP_H__ +#ifndef ZXING_BINARYBITMAP_H +#define ZXING_BINARYBITMAP_H /* * BinaryBitmap.h @@ -53,4 +53,4 @@ namespace zxing { } -#endif /* BINARYBITMAP_H_ */ +#endif /* ZXING_BINARYBITMAP_H */ diff --git a/src/zxing/zxing/ChecksumException.h b/src/zxing/zxing/ChecksumException.h index 77f4dfd..07e9502 100644 --- a/src/zxing/zxing/ChecksumException.h +++ b/src/zxing/zxing/ChecksumException.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __CHECKSUM_EXCEPTION_H__ -#define __NOT_FOUND_EXCEPTION_H__ +#ifndef ZXING_CHECKSUM_EXCEPTION_H +#define ZXING_CHECKSUM_EXCEPTION_H /* * Copyright 20011 ZXing authors @@ -31,4 +31,4 @@ namespace zxing { }; } -#endif // __CHECKSUM_EXCEPTION_H__ +#endif // ZXING_CHECKSUM_EXCEPTION_H diff --git a/src/zxing/zxing/DecodeHints.h b/src/zxing/zxing/DecodeHints.h index d11cfa3..b39c5b5 100644 --- a/src/zxing/zxing/DecodeHints.h +++ b/src/zxing/zxing/DecodeHints.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __DECODEHINTS_H_ -#define __DECODEHINTS_H_ +#ifndef ZXING_DECODEHINTS_H +#define ZXING_DECODEHINTS_H /* * DecodeHintType.h * zxing @@ -85,4 +85,5 @@ class DecodeHints { } -#endif +#endif // ZXING_DECODEHINTS_H + diff --git a/src/zxing/zxing/Exception.h b/src/zxing/zxing/Exception.h index f0df1e5..bedc469 100644 --- a/src/zxing/zxing/Exception.h +++ b/src/zxing/zxing/Exception.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __EXCEPTION_H__ -#define __EXCEPTION_H__ +#ifndef ZXING_EXCEPTION_H +#define ZXING_EXCEPTION_H /* * Exception.h @@ -48,4 +48,4 @@ private: } -#endif // __EXCEPTION_H__ +#endif // ZXING_EXCEPTION_H diff --git a/src/zxing/zxing/FormatException.h b/src/zxing/zxing/FormatException.h index 090d79c..e0a2f10 100644 --- a/src/zxing/zxing/FormatException.h +++ b/src/zxing/zxing/FormatException.h @@ -1,5 +1,5 @@ -#ifndef __FORMAT_EXCEPTION_H__ -#define __FORMAT_EXCEPTION_H__ +#ifndef ZXING_FORMAT_EXCEPTION_H +#define ZXING_FORMAT_EXCEPTION_H /* * FormatException.h @@ -34,4 +34,4 @@ public: }; } -#endif // __FORMAT_EXCEPTION_H__ +#endif // ZXING_FORMAT_EXCEPTION_H diff --git a/src/zxing/zxing/IllegalStateException.h b/src/zxing/zxing/IllegalStateException.h index dfaf5f3..dbe50f9 100644 --- a/src/zxing/zxing/IllegalStateException.h +++ b/src/zxing/zxing/IllegalStateException.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ILLEGAL_STATE_EXCEPTION_H__ -#define __ILLEGAL_STATE_EXCEPTION_H__ +#ifndef ZXING_ILLEGAL_STATE_EXCEPTION_H +#define ZXING_ILLEGAL_STATE_EXCEPTION_H /* * Copyright 20011 ZXing authors @@ -32,4 +32,4 @@ public: } -#endif // __ILLEGAL_STATE_EXCEPTION_H__ +#endif // ZXING_ILLEGAL_STATE_EXCEPTION_H diff --git a/src/zxing/zxing/InvertedLuminanceSource.h b/src/zxing/zxing/InvertedLuminanceSource.h index a3f7fbe..1200fca 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.h +++ b/src/zxing/zxing/InvertedLuminanceSource.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __INVERTEDLUMINANCESOURCE_H__ -#define __INVERTEDLUMINANCESOURCE_H__ +#ifndef ZXING_INVERTEDLUMINANCESOURCE_H +#define ZXING_INVERTEDLUMINANCESOURCE_H /* * Copyright 2013 ZXing authors All rights reserved. * @@ -45,4 +45,4 @@ public: } -#endif /* INVERTEDLUMINANCESOURCE_H_ */ +#endif // ZXING_INVERTEDLUMINANCESOURCE_H diff --git a/src/zxing/zxing/LuminanceSource.h b/src/zxing/zxing/LuminanceSource.h index dfe4051..889bf58 100644 --- a/src/zxing/zxing/LuminanceSource.h +++ b/src/zxing/zxing/LuminanceSource.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __LUMINANCESOURCE_H__ -#define __LUMINANCESOURCE_H__ +#ifndef ZXING_LUMINANCESOURCE_H +#define ZXING_LUMINANCESOURCE_H /* * LuminanceSource.h * zxing @@ -59,4 +59,4 @@ class LuminanceSource : public Counted { } -#endif /* LUMINANCESOURCE_H_ */ +#endif // ZXING_LUMINANCESOURCE_H diff --git a/src/zxing/zxing/MultiFormatReader.h b/src/zxing/zxing/MultiFormatReader.h index af07899..13a0d41 100644 --- a/src/zxing/zxing/MultiFormatReader.h +++ b/src/zxing/zxing/MultiFormatReader.h @@ -1,5 +1,5 @@ -#ifndef __MULTI_FORMAT_READER_H__ -#define __MULTI_FORMAT_READER_H__ +#ifndef ZXING_MULTI_FORMAT_READER_H +#define ZXING_MULTI_FORMAT_READER_H /* * MultiFormatBarcodeReader.h @@ -45,4 +45,5 @@ namespace zxing { }; } -#endif +#endif // ZXING_MULTI_FORMAT_READER_H + diff --git a/src/zxing/zxing/NotFoundException.h b/src/zxing/zxing/NotFoundException.h index d443362..695ce94 100644 --- a/src/zxing/zxing/NotFoundException.h +++ b/src/zxing/zxing/NotFoundException.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __NOT_FOUND_EXCEPTION_H__ -#define __NOT_FOUND_EXCEPTION_H__ +#ifndef ZXING_NOT_FOUND_EXCEPTION_H +#define ZXING_NOT_FOUND_EXCEPTION_H /* * Copyright 20011 ZXing authors @@ -32,4 +32,4 @@ public: } -#endif // __NOT_FOUND_EXCEPTION_H__ +#endif // ZXING_NOT_FOUND_EXCEPTION_H diff --git a/src/zxing/zxing/Reader.h b/src/zxing/zxing/Reader.h index 05c741b..9725664 100644 --- a/src/zxing/zxing/Reader.h +++ b/src/zxing/zxing/Reader.h @@ -1,5 +1,5 @@ -#ifndef __READER_H__ -#define __READER_H__ +#ifndef ZXING_READER_H +#define ZXING_READER_H /* * Reader.h @@ -37,4 +37,4 @@ namespace zxing { } -#endif // __READER_H__ +#endif // ZXING_READER_H diff --git a/src/zxing/zxing/ReaderException.h b/src/zxing/zxing/ReaderException.h index b09aea3..804dde4 100644 --- a/src/zxing/zxing/ReaderException.h +++ b/src/zxing/zxing/ReaderException.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __READER_EXCEPTION_H__ -#define __READER_EXCEPTION_H__ +#ifndef ZXING_READER_EXCEPTION_H +#define ZXING_READER_EXCEPTION_H /* * ReaderException.h @@ -34,4 +34,4 @@ class ReaderException : public Exception { } -#endif // __READER_EXCEPTION_H__ +#endif // ZXING_READER_EXCEPTION_H diff --git a/src/zxing/zxing/Result.h b/src/zxing/zxing/Result.h index c5ee04c..c7ba578 100644 --- a/src/zxing/zxing/Result.h +++ b/src/zxing/zxing/Result.h @@ -1,5 +1,5 @@ -#ifndef __RESULT_H__ -#define __RESULT_H__ +#ifndef ZXING_RESULT_H +#define ZXING_RESULT_H /* * Result.h @@ -55,4 +55,4 @@ public: }; } -#endif // __RESULT_H__ +#endif // ZXING_RESULT_H diff --git a/src/zxing/zxing/ResultPoint.h b/src/zxing/zxing/ResultPoint.h index d2d6eae..5934485 100644 --- a/src/zxing/zxing/ResultPoint.h +++ b/src/zxing/zxing/ResultPoint.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __RESULT_POINT_H__ -#define __RESULT_POINT_H__ +#ifndef ZXING_RESULT_POINT_H +#define ZXING_RESULT_POINT_H /* * ResultPoint.h @@ -52,4 +52,4 @@ private: } -#endif // __RESULT_POINT_H__ +#endif // ZXING_RESULT_POINT_H diff --git a/src/zxing/zxing/ResultPointCallback.h b/src/zxing/zxing/ResultPointCallback.h index 2687656..59e3220 100644 --- a/src/zxing/zxing/ResultPointCallback.h +++ b/src/zxing/zxing/ResultPointCallback.h @@ -1,5 +1,5 @@ -#ifndef __RESULT_POINT_CALLBACK_H__ -#define __RESULT_POINT_CALLBACK_H__ +#ifndef ZXING_RESULT_POINT_CALLBACK_H +#define ZXING_RESULT_POINT_CALLBACK_H /* * ResultPointCallback.h @@ -36,4 +36,4 @@ public: } -#endif // __RESULT_POINT_CALLBACK_H__ +#endif // ZXING_RESULT_POINT_CALLBACK_H diff --git a/src/zxing/zxing/ZXing.h b/src/zxing/zxing/ZXing.h index 6d95f2d..cbca440 100644 --- a/src/zxing/zxing/ZXing.h +++ b/src/zxing/zxing/ZXing.h @@ -14,8 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef __ZXING_H_ -#define __ZXING_H_ +#ifndef ZXING_H +#define ZXING_H #define ZXING_ARRAY_LEN(v) ((int)(sizeof(v)/sizeof(v[0]))) #define ZX_LOG_DIGITS(digits) \ diff --git a/src/zxing/zxing/aztec/decoder/Decoder.h b/src/zxing/zxing/aztec/decoder/Decoder.h index d9f5cce..6798b21 100644 --- a/src/zxing/zxing/aztec/decoder/Decoder.h +++ b/src/zxing/zxing/aztec/decoder/Decoder.h @@ -19,8 +19,8 @@ * limitations under the License. */ -#ifndef __ZXING_AZTEC_DECODER_DECODER_H__ -#define __ZXING_AZTEC_DECODER_DECODER_H__ +#ifndef ZXING_AZTEC_DECODER_DECODER_H +#define ZXING_AZTEC_DECODER_DECODER_H #include #include @@ -66,4 +66,4 @@ class Decoder : public Counted { } } -#endif +#endif // ZXING_AZTEC_DECODER_DECODER_H diff --git a/src/zxing/zxing/aztec/detector/Detector.h b/src/zxing/zxing/aztec/detector/Detector.h index 65414ad..0fe6037 100644 --- a/src/zxing/zxing/aztec/detector/Detector.h +++ b/src/zxing/zxing/aztec/detector/Detector.h @@ -19,8 +19,8 @@ * limitations under the License. */ -#ifndef __ZXING_AZTEC_DETECTOR_DETECTOR_H__ -#define __ZXING_AZTEC_DETECTOR_DETECTOR_H__ +#ifndef ZXING_AZTEC_DETECTOR_DETECTOR_H +#define ZXING_AZTEC_DETECTOR_DETECTOR_H #include @@ -89,4 +89,4 @@ class Detector : public Counted { } } -#endif +#endif // ZXING_AZTEC_DETECTOR_DETECTOR_H diff --git a/src/zxing/zxing/common/Array.h b/src/zxing/zxing/common/Array.h index 6f087eb..af3a521 100644 --- a/src/zxing/zxing/common/Array.h +++ b/src/zxing/zxing/common/Array.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ARRAY_H__ -#define __ARRAY_H__ +#ifndef ZXING_ARRAY_H +#define ZXING_ARRAY_H /* * Array.h @@ -170,4 +170,4 @@ public: } // namespace zxing -#endif // __ARRAY_H__ +#endif // ZXING_ARRAY_H diff --git a/src/zxing/zxing/common/BitArray.h b/src/zxing/zxing/common/BitArray.h index f7e57dc..1c9a709 100644 --- a/src/zxing/zxing/common/BitArray.h +++ b/src/zxing/zxing/common/BitArray.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __BIT_ARRAY_H__ -#define __BIT_ARRAY_H__ +#ifndef ZXING_BIT_ARRAY_H +#define ZXING_BIT_ARRAY_H /* * Copyright 2010 ZXing authors. All rights reserved. @@ -100,4 +100,4 @@ std::ostream& operator << (std::ostream&, BitArray const&); } -#endif // __BIT_ARRAY_H__ +#endif // ZXING_BIT_ARRAY_H diff --git a/src/zxing/zxing/common/BitMatrix.h b/src/zxing/zxing/common/BitMatrix.h index 5b6c6df..42bd9bc 100644 --- a/src/zxing/zxing/common/BitMatrix.h +++ b/src/zxing/zxing/common/BitMatrix.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __BIT_MATRIX_H__ -#define __BIT_MATRIX_H__ +#ifndef ZXING_BIT_MATRIX_H +#define ZXING_BIT_MATRIX_H /* * BitMatrix.h @@ -81,4 +81,4 @@ private: } -#endif // __BIT_MATRIX_H__ +#endif // ZXING_BIT_MATRIX_H diff --git a/src/zxing/zxing/common/BitSource.h b/src/zxing/zxing/common/BitSource.h index fb3d930..5566776 100644 --- a/src/zxing/zxing/common/BitSource.h +++ b/src/zxing/zxing/common/BitSource.h @@ -1,5 +1,5 @@ -#ifndef __BIT_SOURCE_H__ -#define __BIT_SOURCE_H__ +#ifndef ZXING_BIT_SOURCE_H +#define ZXING_BIT_SOURCE_H /* * BitSource.h @@ -71,4 +71,4 @@ public: } -#endif // __BIT_SOURCE_H__ +#endif // ZXING_BIT_SOURCE_H diff --git a/src/zxing/zxing/common/CharacterSetECI.h b/src/zxing/zxing/common/CharacterSetECI.h index 4a8c0c1..120e2af 100644 --- a/src/zxing/zxing/common/CharacterSetECI.h +++ b/src/zxing/zxing/common/CharacterSetECI.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __CHARACTERSET_ECI__ -#define __CHARACTERSET_ECI__ +#ifndef ZXING_CHARACTERSET_ECI +#define ZXING_CHARACTERSET_ECI /* * Copyright 2008-2011 ZXing authors @@ -54,4 +54,5 @@ public: } } -#endif +#endif // ZXING_CHARACTERSET_ECI + diff --git a/src/zxing/zxing/common/Counted.h b/src/zxing/zxing/common/Counted.h index 41ac5ec..a52607c 100644 --- a/src/zxing/zxing/common/Counted.h +++ b/src/zxing/zxing/common/Counted.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __COUNTED_H__ -#define __COUNTED_H__ +#ifndef ZXING_COUNTED_H +#define ZXING_COUNTED_H /* * Copyright 2010 ZXing authors All rights reserved. @@ -137,4 +137,4 @@ public: } -#endif // __COUNTED_H__ +#endif // ZXING_COUNTED_H diff --git a/src/zxing/zxing/common/DecoderResult.h b/src/zxing/zxing/common/DecoderResult.h index a31e5f1..a555fa9 100644 --- a/src/zxing/zxing/common/DecoderResult.h +++ b/src/zxing/zxing/common/DecoderResult.h @@ -1,5 +1,5 @@ -#ifndef __DECODER_RESULT_H__ -#define __DECODER_RESULT_H__ +#ifndef ZXING_DECODER_RESULT_H +#define ZXING_DECODER_RESULT_H /* * DecoderResult.h @@ -52,4 +52,4 @@ public: } -#endif // __DECODER_RESULT_H__ +#endif // ZXING_DECODER_RESULT_H diff --git a/src/zxing/zxing/common/DetectorResult.h b/src/zxing/zxing/common/DetectorResult.h index 26b633a..9ae94b9 100644 --- a/src/zxing/zxing/common/DetectorResult.h +++ b/src/zxing/zxing/common/DetectorResult.h @@ -1,5 +1,5 @@ -#ifndef __DETECTOR_RESULT_H__ -#define __DETECTOR_RESULT_H__ +#ifndef ZXING_DETECTOR_RESULT_H +#define ZXING_DETECTOR_RESULT_H /* * DetectorResult.h @@ -40,4 +40,4 @@ public: } -#endif // __DETECTOR_RESULT_H__ +#endif // ZXING_DETECTOR_RESULT_H diff --git a/src/zxing/zxing/common/GlobalHistogramBinarizer.h b/src/zxing/zxing/common/GlobalHistogramBinarizer.h index e60e7fc..c65391c 100644 --- a/src/zxing/zxing/common/GlobalHistogramBinarizer.h +++ b/src/zxing/zxing/common/GlobalHistogramBinarizer.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __GLOBALHISTOGRAMBINARIZER_H__ -#define __GLOBALHISTOGRAMBINARIZER_H__ +#ifndef ZXING_GLOBALHISTOGRAMBINARIZER_H +#define ZXING_GLOBALHISTOGRAMBINARIZER_H /* * GlobalHistogramBinarizer.h * zxing @@ -45,4 +45,4 @@ private: } -#endif /* GLOBALHISTOGRAMBINARIZER_H_ */ +#endif /* ZXING_GLOBALHISTOGRAMBINARIZER_H */ diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.h b/src/zxing/zxing/common/GreyscaleLuminanceSource.h index 20ae936..4c78257 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.h +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __GREYSCALE_LUMINANCE_SOURCE__ -#define __GREYSCALE_LUMINANCE_SOURCE__ +#ifndef ZXING_GREYSCALE_LUMINANCE_SOURCE +#define ZXING_GREYSCALE_LUMINANCE_SOURCE /* * GreyscaleLuminanceSource.h * zxing @@ -50,4 +50,4 @@ public: } -#endif +#endif // ZXING_GREYSCALE_LUMINANCE_SOURCE diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h index 2ef8287..efd60dc 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __GREYSCALE_ROTATED_LUMINANCE_SOURCE__ -#define __GREYSCALE_ROTATED_LUMINANCE_SOURCE__ +#ifndef ZXING_GREYSCALE_ROTATED_LUMINANCE_SOURCE +#define ZXING_GREYSCALE_ROTATED_LUMINANCE_SOURCE /* * GreyscaleRotatedLuminanceSource.h * zxing @@ -43,4 +43,4 @@ public: } -#endif +#endif // ZXING_GREYSCALE_ROTATED_LUMINANCE_SOURCE diff --git a/src/zxing/zxing/common/GridSampler.h b/src/zxing/zxing/common/GridSampler.h index d7f74e5..5014bdd 100644 --- a/src/zxing/zxing/common/GridSampler.h +++ b/src/zxing/zxing/common/GridSampler.h @@ -1,5 +1,5 @@ -#ifndef __GRID_SAMPLER_H__ -#define __GRID_SAMPLER_H__ +#ifndef ZXING_GRID_SAMPLER_H +#define ZXING_GRID_SAMPLER_H /* * GridSampler.h @@ -42,4 +42,4 @@ public: }; } -#endif // __GRID_SAMPLER_H__ +#endif // ZXING_GRID_SAMPLER_H diff --git a/src/zxing/zxing/common/HybridBinarizer.h b/src/zxing/zxing/common/HybridBinarizer.h index b85c4b0..9d1c7f6 100644 --- a/src/zxing/zxing/common/HybridBinarizer.h +++ b/src/zxing/zxing/common/HybridBinarizer.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __HYBRIDBINARIZER_H__ -#define __HYBRIDBINARIZER_H__ +#ifndef ZXING_HYBRIDBINARIZER_H +#define ZXING_HYBRIDBINARIZER_H /* * HybridBinarizer.h * zxing @@ -64,4 +64,4 @@ namespace zxing { } -#endif +#endif // ZXING_HYBRIDBINARIZER_H diff --git a/src/zxing/zxing/common/IllegalArgumentException.h b/src/zxing/zxing/common/IllegalArgumentException.h index 735ab06..4a74b6b 100644 --- a/src/zxing/zxing/common/IllegalArgumentException.h +++ b/src/zxing/zxing/common/IllegalArgumentException.h @@ -1,5 +1,5 @@ -#ifndef __ILLEGAL_ARGUMENT_EXCEPTION_H__ -#define __ILLEGAL_ARGUMENT_EXCEPTION_H__ +#ifndef ZXING_ILLEGAL_ARGUMENT_EXCEPTION_H +#define ZXING_ILLEGAL_ARGUMENT_EXCEPTION_H /* * IllegalArgumentException.h @@ -33,4 +33,4 @@ public: } -#endif // __ILLEGAL_ARGUMENT_EXCEPTION_H__ +#endif // ZXING_ILLEGAL_ARGUMENT_EXCEPTION_H diff --git a/src/zxing/zxing/common/PerspectiveTransform.h b/src/zxing/zxing/common/PerspectiveTransform.h index 43b7fa1..217abe9 100644 --- a/src/zxing/zxing/common/PerspectiveTransform.h +++ b/src/zxing/zxing/common/PerspectiveTransform.h @@ -1,5 +1,5 @@ -#ifndef __PERSPECTIVE_TANSFORM_H__ -#define __PERSPECTIVE_TANSFORM_H__ +#ifndef ZXING_PERSPECTIVE_TANSFORM_H +#define ZXING_PERSPECTIVE_TANSFORM_H /* * PerspectiveTransform.h @@ -46,4 +46,4 @@ public: }; } -#endif // __PERSPECTIVE_TANSFORM_H__ +#endif // ZXING_PERSPECTIVE_TANSFORM_H diff --git a/src/zxing/zxing/common/Point.h b/src/zxing/zxing/common/Point.h index cae032b..036eea7 100644 --- a/src/zxing/zxing/common/Point.h +++ b/src/zxing/zxing/common/Point.h @@ -1,5 +1,5 @@ -#ifndef __POINT_H__ -#define __POINT_H__ +#ifndef ZXING_POINT_H +#define ZXING_POINT_H /* * Point.h @@ -44,4 +44,4 @@ public: Point end; }; } -#endif // POINT_H_ +#endif // ZXING_POINT_H diff --git a/src/zxing/zxing/common/Str.h b/src/zxing/zxing/common/Str.h index adc8d4e..8e8c8b3 100644 --- a/src/zxing/zxing/common/Str.h +++ b/src/zxing/zxing/common/Str.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __STR_H__ -#define __STR_H__ +#ifndef ZXING_STR_H +#define ZXING_STR_H /* * Str.h @@ -48,4 +48,4 @@ public: } -#endif // __COMMON__STRING_H__ +#endif // ZXING_STR_H diff --git a/src/zxing/zxing/common/StringUtils.h b/src/zxing/zxing/common/StringUtils.h index 703e699..efa2555 100644 --- a/src/zxing/zxing/common/StringUtils.h +++ b/src/zxing/zxing/common/StringUtils.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __STRING_UTILS__ -#define __STRING_UTILS__ +#ifndef ZXING_STRING_UTILS_H +#define ZXING_STRING_UTILS_H /* * Copyright (C) 2010-2011 ZXing authors @@ -52,4 +52,5 @@ public: } } -#endif +#endif // ZXING_STRING_UTILS_H + diff --git a/src/zxing/zxing/common/Types.h b/src/zxing/zxing/common/Types.h index 30806b1..cecffe9 100644 --- a/src/zxing/zxing/common/Types.h +++ b/src/zxing/zxing/common/Types.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __TYPES_H__ -#define __TYPES_H__ +#ifndef ZXING_TYPES_H +#define ZXING_TYPES_H #include #include @@ -13,4 +13,4 @@ typedef bool boolean; } -#endif // __COMMON__TYPES_H__ +#endif // ZXING_TYPES_H diff --git a/src/zxing/zxing/common/detector/JavaMath.h b/src/zxing/zxing/common/detector/JavaMath.h index ce99ab7..d6530a5 100644 --- a/src/zxing/zxing/common/detector/JavaMath.h +++ b/src/zxing/zxing/common/detector/JavaMath.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ZXING_COMMON_DETECTOR_MATH_H__ -#define __ZXING_COMMON_DETECTOR_MATH_H__ +#ifndef ZXING_COMMON_DETECTOR_MATH_H +#define ZXING_COMMON_DETECTOR_MATH_H /* * Copyright 2012 ZXing authors All rights reserved. * @@ -40,4 +40,5 @@ class Math { } } -#endif +#endif // ZXING_COMMON_DETECTOR_MATH_H + diff --git a/src/zxing/zxing/common/detector/MathUtils.h b/src/zxing/zxing/common/detector/MathUtils.h index 5884566..900e33c 100644 --- a/src/zxing/zxing/common/detector/MathUtils.h +++ b/src/zxing/zxing/common/detector/MathUtils.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ZXING_COMMON_DETECTOR_MATHUTILS_H__ -#define __ZXING_COMMON_DETECTOR_MATHUTILS_H__ +#ifndef ZXING_COMMON_DETECTOR_MATHUTILS_H +#define ZXING_COMMON_DETECTOR_MATHUTILS_H /* * Copyright 2012 ZXing authors All rights reserved. * @@ -54,4 +54,5 @@ class MathUtils { } } -#endif +#endif // ZXING_COMMON_DETECTOR_MATHUTILS_H + diff --git a/src/zxing/zxing/common/detector/MonochromeRectangleDetector.h b/src/zxing/zxing/common/detector/MonochromeRectangleDetector.h index f32c99d..c26a62c 100644 --- a/src/zxing/zxing/common/detector/MonochromeRectangleDetector.h +++ b/src/zxing/zxing/common/detector/MonochromeRectangleDetector.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __MONOCHROMERECTANGLEDETECTOR_H__ -#define __MONOCHROMERECTANGLEDETECTOR_H__ +#ifndef ZXING_MONOCHROMERECTANGLEDETECTOR_H +#define ZXING_MONOCHROMERECTANGLEDETECTOR_H /* * MonochromeRectangleDetector.h @@ -59,4 +59,4 @@ class MonochromeRectangleDetector : public Counted { } -#endif // __MONOCHROMERECTANGLEDETECTOR_H__ +#endif // ZXING_MONOCHROMERECTANGLEDETECTOR_H diff --git a/src/zxing/zxing/common/detector/WhiteRectangleDetector.h b/src/zxing/zxing/common/detector/WhiteRectangleDetector.h index 9180806..d043e85 100644 --- a/src/zxing/zxing/common/detector/WhiteRectangleDetector.h +++ b/src/zxing/zxing/common/detector/WhiteRectangleDetector.h @@ -1,5 +1,5 @@ -#ifndef __WHITERECTANGLEDETECTOR_H__ -#define __WHITERECTANGLEDETECTOR_H__ +#ifndef ZXING_WHITERECTANGLEDETECTOR_H +#define ZXING_WHITERECTANGLEDETECTOR_H /* * WhiteRectangleDetector.h @@ -56,4 +56,5 @@ class WhiteRectangleDetector : public Counted { }; } -#endif +#endif // ZXING_WHITERECTANGLEDETECTOR_H + diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h b/src/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h index 296a479..80f70a5 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h @@ -1,5 +1,5 @@ -#ifndef __REED_SOLOMON_DECODER_H__ -#define __REED_SOLOMON_DECODER_H__ +#ifndef ZXING_REED_SOLOMON_DECODER_H +#define ZXING_REED_SOLOMON_DECODER_H /* * ReedSolomonDecoder.h @@ -46,4 +46,4 @@ private: }; } -#endif // __REED_SOLOMON_DECODER_H__ +#endif // ZXING_REED_SOLOMON_DECODER_H diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h index 1c01250..b707b6d 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h @@ -1,5 +1,5 @@ -#ifndef __REED_SOLOMON_EXCEPTION_H__ -#define __REED_SOLOMON_EXCEPTION_H__ +#ifndef ZXING_REED_SOLOMON_EXCEPTION_H +#define ZXING_REED_SOLOMON_EXCEPTION_H /* * ReedSolomonException.h @@ -30,4 +30,4 @@ public: }; } -#endif // __REED_SOLOMON_EXCEPTION_H__ +#endif // ZXING_REED_SOLOMON_EXCEPTION_H diff --git a/src/zxing/zxing/datamatrix/DataMatrixReader.h b/src/zxing/zxing/datamatrix/DataMatrixReader.h index e266739..06f8adc 100644 --- a/src/zxing/zxing/datamatrix/DataMatrixReader.h +++ b/src/zxing/zxing/datamatrix/DataMatrixReader.h @@ -1,5 +1,5 @@ -#ifndef __DATA_MATRIX_READER_H__ -#define __DATA_MATRIX_READER_H__ +#ifndef ZXING_DATA_MATRIX_READER_H +#define ZXING_DATA_MATRIX_READER_H /* * DataMatrixReader.h @@ -42,4 +42,4 @@ public: } } -#endif // __DATA_MATRIX_READER_H__ +#endif // ZXING_DATA_MATRIX_READER_H diff --git a/src/zxing/zxing/datamatrix/Version.h b/src/zxing/zxing/datamatrix/Version.h index d8523fe..8412c75 100644 --- a/src/zxing/zxing/datamatrix/Version.h +++ b/src/zxing/zxing/datamatrix/Version.h @@ -1,5 +1,5 @@ -#ifndef __VERSION_H__ -#define __VERSION_H__ +#ifndef ZXING_VERSION_H +#define ZXING_VERSION_H /* * Version.h @@ -84,4 +84,4 @@ private: } } -#endif // __VERSION_H__ +#endif // ZXING_VERSION_H diff --git a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h index 37c4514..78dcf26 100644 --- a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h @@ -1,5 +1,5 @@ -#ifndef __BIT_MATRIX_PARSER_DM_H__ -#define __BIT_MATRIX_PARSER_DM_H__ +#ifndef ZXING_BIT_MATRIX_PARSER_DM_H +#define ZXING_BIT_MATRIX_PARSER_DM_H /* * BitMatrixParser.h @@ -56,4 +56,4 @@ private: } } -#endif // __BIT_MATRIX_PARSER_DM_H__ +#endif // ZXING_BIT_MATRIX_PARSER_DM_H diff --git a/src/zxing/zxing/datamatrix/decoder/DataBlock.h b/src/zxing/zxing/datamatrix/decoder/DataBlock.h index 9ff8dc3..ea82dc0 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataBlock.h +++ b/src/zxing/zxing/datamatrix/decoder/DataBlock.h @@ -1,5 +1,5 @@ -#ifndef __DATA_BLOCK_DM_H__ -#define __DATA_BLOCK_DM_H__ +#ifndef ZXING_DATA_BLOCK_DM_H +#define ZXING_DATA_BLOCK_DM_H /* * DataBlock.h @@ -46,4 +46,4 @@ public: } } -#endif // __DATA_BLOCK_DM_H__ +#endif // ZXING_DATA_BLOCK_DM_H diff --git a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h index 7ee2a6e..301fb64 100644 --- a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h @@ -1,5 +1,5 @@ -#ifndef __DECODED_BIT_STREAM_PARSER_DM_H__ -#define __DECODED_BIT_STREAM_PARSER_DM_H__ +#ifndef ZXING_DECODED_BIT_STREAM_PARSER_DM_H +#define ZXING_DECODED_BIT_STREAM_PARSER_DM_H /* * DecodedBitStreamParser.h @@ -90,15 +90,16 @@ private: int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; return (byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); - }; + } + void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src); public: - DecodedBitStreamParser() { }; + DecodedBitStreamParser() { } Ref decode(ArrayRef bytes); }; } } -#endif // __DECODED_BIT_STREAM_PARSER_DM_H__ +#endif // ZXING_DECODED_BIT_STREAM_PARSER_DM_H diff --git a/src/zxing/zxing/datamatrix/decoder/Decoder.h b/src/zxing/zxing/datamatrix/decoder/Decoder.h index 31c0743..95d7cc3 100644 --- a/src/zxing/zxing/datamatrix/decoder/Decoder.h +++ b/src/zxing/zxing/datamatrix/decoder/Decoder.h @@ -1,5 +1,5 @@ -#ifndef __DECODER_DM_H__ -#define __DECODER_DM_H__ +#ifndef ZXING_DECODER_DM_H +#define ZXING_DECODER_DM_H /* * Decoder.h @@ -46,4 +46,4 @@ public: } } -#endif // __DECODER_DM_H__ +#endif // ZXING_DECODER_DM_H diff --git a/src/zxing/zxing/datamatrix/detector/CornerPoint.h b/src/zxing/zxing/datamatrix/detector/CornerPoint.h index cbf2a7e..5f757da 100644 --- a/src/zxing/zxing/datamatrix/detector/CornerPoint.h +++ b/src/zxing/zxing/datamatrix/detector/CornerPoint.h @@ -1,5 +1,5 @@ -#ifndef __CORNER_FINDER_H__ -#define __CORNER_FINDER_H__ +#ifndef ZXING_CORNER_FINDER_H +#define ZXING_CORNER_FINDER_H /* * CornerPoint.h @@ -40,4 +40,4 @@ namespace zxing { } } -#endif // __CORNER_FINDER_H__ +#endif // ZXING_CORNER_FINDER_H diff --git a/src/zxing/zxing/datamatrix/detector/Detector.h b/src/zxing/zxing/datamatrix/detector/Detector.h index 8e0bf06..ab89337 100644 --- a/src/zxing/zxing/datamatrix/detector/Detector.h +++ b/src/zxing/zxing/datamatrix/detector/Detector.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __DETECTOR_H__ -#define __DETECTOR_H__ +#ifndef ZXING_DETECTOR_H +#define ZXING_DETECTOR_H /* * Detector.h @@ -91,4 +91,4 @@ class Detector: public Counted { } } -#endif // __DETECTOR_H__ +#endif // ZXING_DETECTOR_H diff --git a/src/zxing/zxing/multi/ByQuadrantReader.h b/src/zxing/zxing/multi/ByQuadrantReader.h index 3f7fac6..c61cc41 100644 --- a/src/zxing/zxing/multi/ByQuadrantReader.h +++ b/src/zxing/zxing/multi/ByQuadrantReader.h @@ -1,5 +1,5 @@ -#ifndef __BY_QUADRANT_READER_H__ -#define __BY_QUADRANT_READER_H__ +#ifndef ZXING_BY_QUADRANT_READER_H +#define ZXING_BY_QUADRANT_READER_H /* * Copyright 2011 ZXing authors All rights reserved. @@ -39,4 +39,4 @@ class ByQuadrantReader : public Reader { } } -#endif // __BY_QUADRANT_READER_H__ +#endif // ZXING_BY_QUADRANT_READER_H diff --git a/src/zxing/zxing/multi/GenericMultipleBarcodeReader.h b/src/zxing/zxing/multi/GenericMultipleBarcodeReader.h index ff96ab8..3cb78a2 100644 --- a/src/zxing/zxing/multi/GenericMultipleBarcodeReader.h +++ b/src/zxing/zxing/multi/GenericMultipleBarcodeReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __GENERIC_MULTIPLE_BARCODE_READER_H__ -#define __GENERIC_MULTIPLE_BARCODE_READER_H__ +#ifndef ZXING_GENERIC_MULTIPLE_BARCODE_READER_H +#define ZXING_GENERIC_MULTIPLE_BARCODE_READER_H /* * Copyright 2011 ZXing authors All rights reserved. @@ -48,4 +48,4 @@ class GenericMultipleBarcodeReader : public MultipleBarcodeReader { } } -#endif // __GENERIC_MULTIPLE_BARCODE_READER_H__ +#endif // ZXING_GENERIC_MULTIPLE_BARCODE_READER_H diff --git a/src/zxing/zxing/multi/MultipleBarcodeReader.h b/src/zxing/zxing/multi/MultipleBarcodeReader.h index 9f02adb..d3bd792 100644 --- a/src/zxing/zxing/multi/MultipleBarcodeReader.h +++ b/src/zxing/zxing/multi/MultipleBarcodeReader.h @@ -1,5 +1,5 @@ -#ifndef __MULTIPLE_BARCODE_READER_H__ -#define __MULTIPLE_BARCODE_READER_H__ +#ifndef ZXING_MULTIPLE_BARCODE_READER_H +#define ZXING_MULTIPLE_BARCODE_READER_H /* * Copyright 2011 ZXing authors All rights reserved. @@ -38,4 +38,4 @@ class MultipleBarcodeReader : public Counted { } } -#endif // __MULTIPLE_BARCODE_READER_H__ +#endif // ZXING_MULTIPLE_BARCODE_READER_H diff --git a/src/zxing/zxing/multi/qrcode/QRCodeMultiReader.h b/src/zxing/zxing/multi/qrcode/QRCodeMultiReader.h index be17041..c9037e1 100644 --- a/src/zxing/zxing/multi/qrcode/QRCodeMultiReader.h +++ b/src/zxing/zxing/multi/qrcode/QRCodeMultiReader.h @@ -1,5 +1,5 @@ -#ifndef __QRCODE_MULTI_READER_H__ -#define __QRCODE_MULTI_READER_H__ +#ifndef ZXING_QRCODE_MULTI_READER_H +#define ZXING_QRCODE_MULTI_READER_H /* * Copyright 2011 ZXing authors All rights reserved. @@ -33,4 +33,4 @@ class QRCodeMultiReader: public zxing::qrcode::QRCodeReader, public MultipleBarc } } -#endif // __QRCODE_MULTI_READER_H__ +#endif // ZXING_QRCODE_MULTI_READER_H diff --git a/src/zxing/zxing/multi/qrcode/detector/MultiDetector.h b/src/zxing/zxing/multi/qrcode/detector/MultiDetector.h index 7c9a189..9ebde86 100644 --- a/src/zxing/zxing/multi/qrcode/detector/MultiDetector.h +++ b/src/zxing/zxing/multi/qrcode/detector/MultiDetector.h @@ -1,5 +1,5 @@ -#ifndef __MULTI_DETECTOR_H__ -#define __MULTI_DETECTOR_H__ +#ifndef ZXING_MULTI_DETECTOR_H +#define ZXING_MULTI_DETECTOR_H /* * Copyright 2011 ZXing authors @@ -34,4 +34,4 @@ class MultiDetector : public zxing::qrcode::Detector { } } -#endif // __MULTI_DETECTOR_H__ +#endif // ZXING_MULTI_DETECTOR_H diff --git a/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h b/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h index 4612d72..4e5832d 100644 --- a/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h +++ b/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h @@ -1,5 +1,5 @@ -#ifndef __MULTI_FINDER_PATTERN_FINDER_H__ -#define __MULTI_FINDER_PATTERN_FINDER_H__ +#ifndef ZXING_MULTI_FINDER_PATTERN_FINDER_H +#define ZXING_MULTI_FINDER_PATTERN_FINDER_H /* * Copyright 2011 ZXing authors @@ -44,4 +44,4 @@ class MultiFinderPatternFinder : zxing::qrcode::FinderPatternFinder { } } -#endif // __MULTI_FINDER_PATTERN_FINDER_H__ +#endif // ZXING_MULTI_FINDER_PATTERN_FINDER_H diff --git a/src/zxing/zxing/oned/CodaBarReader.h b/src/zxing/zxing/oned/CodaBarReader.h index 14d1eed..e3d4829 100644 --- a/src/zxing/zxing/oned/CodaBarReader.h +++ b/src/zxing/zxing/oned/CodaBarReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __CODA_BAR_READER_H__ -#define __CODA_BAR_READER_H__ +#ifndef ZXING_CODA_BAR_READER_H +#define ZXING_CODA_BAR_READER_H /* * Copyright 2010 ZXing authors All rights reserved. * @@ -54,4 +54,4 @@ private: } } -#endif +#endif // ZXING_CODA_BAR_READER_H diff --git a/src/zxing/zxing/oned/Code128Reader.h b/src/zxing/zxing/oned/Code128Reader.h index 052f540..1c608fe 100644 --- a/src/zxing/zxing/oned/Code128Reader.h +++ b/src/zxing/zxing/oned/Code128Reader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __CODE_128_READER_H__ -#define __CODE_128_READER_H__ +#ifndef ZXING_CODE_128_READER_H +#define ZXING_CODE_128_READER_H /* * Copyright 2010 ZXing authors All rights reserved. * @@ -45,4 +45,5 @@ public: } } -#endif +#endif // ZXING_CODE_128_READER_H + diff --git a/src/zxing/zxing/oned/Code39Reader.h b/src/zxing/zxing/oned/Code39Reader.h index 4bab3bc..935d241 100644 --- a/src/zxing/zxing/oned/Code39Reader.h +++ b/src/zxing/zxing/oned/Code39Reader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __CODE_39_READER_H__ -#define __CODE_39_READER_H__ +#ifndef ZXING_CODE_39_READER_H +#define ZXING_CODE_39_READER_H /* * Code39Reader.h * ZXing @@ -60,4 +60,5 @@ public: } } -#endif +#endif // ZXING_CODE_39_READER_H + diff --git a/src/zxing/zxing/oned/Code93Reader.h b/src/zxing/zxing/oned/Code93Reader.h index 95c6828..080a09d 100644 --- a/src/zxing/zxing/oned/Code93Reader.h +++ b/src/zxing/zxing/oned/Code93Reader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __CODE_93_READER_H__ -#define __CODE_93_READER_H__ +#ifndef ZXING_CODE_93_READER_H +#define ZXING_CODE_93_READER_H /* * Code93Reader.h * ZXing @@ -55,4 +55,5 @@ private: } } -#endif +#endif // ZXING_CODE_93_READER_H + diff --git a/src/zxing/zxing/oned/EAN13Reader.h b/src/zxing/zxing/oned/EAN13Reader.h index a428225..c6a0e60 100644 --- a/src/zxing/zxing/oned/EAN13Reader.h +++ b/src/zxing/zxing/oned/EAN13Reader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __EAN_13_READER_H__ -#define __EAN_13_READER_H__ +#ifndef ZXING_EAN_13_READER_H +#define ZXING_EAN_13_READER_H /* * EAN13Reader.h @@ -46,4 +46,5 @@ public: } } -#endif +#endif // ZXING_EAN_13_READER_H + diff --git a/src/zxing/zxing/oned/EAN8Reader.h b/src/zxing/zxing/oned/EAN8Reader.h index 7dfaf3a..6e49cea 100644 --- a/src/zxing/zxing/oned/EAN8Reader.h +++ b/src/zxing/zxing/oned/EAN8Reader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __EAN_8_READER_H__ -#define __EAN_8_READER_H__ +#ifndef ZXING_EAN_8_READER_H +#define ZXING_EAN_8_READER_H /* * EAN8Reader.h @@ -44,4 +44,5 @@ class EAN8Reader : public UPCEANReader { } } -#endif +#endif // ZXING_EAN_8_READER_H + diff --git a/src/zxing/zxing/oned/ITFReader.h b/src/zxing/zxing/oned/ITFReader.h index aea279f..fe57146 100644 --- a/src/zxing/zxing/oned/ITFReader.h +++ b/src/zxing/zxing/oned/ITFReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ITF_READER_H__ -#define __ITF_READER_H__ +#ifndef ZXING_ITF_READER_H +#define ZXING_ITF_READER_H /* * Copyright 2010 ZXing authors All rights reserved. @@ -51,4 +51,5 @@ public: } } -#endif +#endif // ZXING_ITF_READER_H + diff --git a/src/zxing/zxing/oned/MultiFormatOneDReader.h b/src/zxing/zxing/oned/MultiFormatOneDReader.h index dae214d..ef5ff07 100644 --- a/src/zxing/zxing/oned/MultiFormatOneDReader.h +++ b/src/zxing/zxing/oned/MultiFormatOneDReader.h @@ -1,5 +1,5 @@ -#ifndef __MULTI_FORMAT_ONED_READER_H__ -#define __MULTI_FORMAT_ONED_READER_H__ +#ifndef ZXING_MULTI_FORMAT_ONED_READER_H +#define ZXING_MULTI_FORMAT_ONED_READER_H /* * MultiFormatOneDReader.h * ZXing @@ -35,4 +35,5 @@ namespace zxing { } } -#endif +#endif // ZXING_MULTI_FORMAT_ONED_READER_H + diff --git a/src/zxing/zxing/oned/MultiFormatUPCEANReader.h b/src/zxing/zxing/oned/MultiFormatUPCEANReader.h index 9e141f9..62720a5 100644 --- a/src/zxing/zxing/oned/MultiFormatUPCEANReader.h +++ b/src/zxing/zxing/oned/MultiFormatUPCEANReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __MULTI_FORMAT_UPC_EAN_READER_H__ -#define __MULTI_FORMAT_UPC_EAN_READER_H__ +#ifndef ZXING_MULTI_FORMAT_UPC_EAN_READER_H +#define ZXING_MULTI_FORMAT_UPC_EAN_READER_H /* * MultiFormatUPCEANReader.h * ZXing @@ -38,4 +38,5 @@ public: } } -#endif +#endif // ZXING_MULTI_FORMAT_UPC_EAN_READER_H + diff --git a/src/zxing/zxing/oned/OneDReader.h b/src/zxing/zxing/oned/OneDReader.h index 63cc4a9..dd67ce8 100644 --- a/src/zxing/zxing/oned/OneDReader.h +++ b/src/zxing/zxing/oned/OneDReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ONED_READER_H__ -#define __ONED_READER_H__ +#ifndef ZXING_ONED_READER_H +#define ZXING_ONED_READER_H /* * OneDReader.h @@ -78,4 +78,5 @@ public: } } -#endif +#endif // ZXING_ONED_READER_H + diff --git a/src/zxing/zxing/oned/OneDResultPoint.h b/src/zxing/zxing/oned/OneDResultPoint.h index 825a04e..024687f 100644 --- a/src/zxing/zxing/oned/OneDResultPoint.h +++ b/src/zxing/zxing/oned/OneDResultPoint.h @@ -1,5 +1,5 @@ -#ifndef __ONED_RESULT_POINT_H__ -#define __ONED_RESULT_POINT_H__ +#ifndef ZXING_ONED_RESULT_POINT_H +#define ZXING_ONED_RESULT_POINT_H /* * OneDResultPoint.h * ZXing @@ -32,4 +32,5 @@ namespace zxing { } } -#endif +#endif // ZXING_ONED_RESULT_POINT_H + diff --git a/src/zxing/zxing/oned/UPCAReader.h b/src/zxing/zxing/oned/UPCAReader.h index 7d80b2d..d8250d2 100644 --- a/src/zxing/zxing/oned/UPCAReader.h +++ b/src/zxing/zxing/oned/UPCAReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __UPCA_READER_H__ -#define __UPCA_READER_H__ +#ifndef ZXING_UPCA_READER_H +#define ZXING_UPCA_READER_H /* * UPCAReader.h * ZXing @@ -47,4 +47,5 @@ public: } } -#endif +#endif // ZXING_UPCA_READER_H + diff --git a/src/zxing/zxing/oned/UPCEANReader.h b/src/zxing/zxing/oned/UPCEANReader.h index 16189ba..452db88 100644 --- a/src/zxing/zxing/oned/UPCEANReader.h +++ b/src/zxing/zxing/oned/UPCEANReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __UPC_EAN_READER_H__ -#define __UPC_EAN_READER_H__ +#ifndef ZXING_UPC_EAN_READER_H +#define ZXING_UPC_EAN_READER_H /* * Copyright 2010 ZXing authors All rights reserved. @@ -85,4 +85,5 @@ public: } } -#endif +#endif // ZXING_UPC_EAN_READER_H + diff --git a/src/zxing/zxing/oned/UPCEReader.h b/src/zxing/zxing/oned/UPCEReader.h index 9578f0e..dedcfba 100644 --- a/src/zxing/zxing/oned/UPCEReader.h +++ b/src/zxing/zxing/oned/UPCEReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __UPC_E_READER_H__ -#define __UPC_E_READER_H__ +#ifndef ZXING_UPC_E_READER_H +#define ZXING_UPC_E_READER_H /* * Copyright 2010 ZXing authors All rights reserved. @@ -44,4 +44,5 @@ public: } } -#endif +#endif // ZXING_UPC_E_READER_H + diff --git a/src/zxing/zxing/pdf417/PDF417Reader.h b/src/zxing/zxing/pdf417/PDF417Reader.h index 73636ba..7c40ead 100644 --- a/src/zxing/zxing/pdf417/PDF417Reader.h +++ b/src/zxing/zxing/pdf417/PDF417Reader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __PDF417_READER_H__ -#define __PDF417_READER_H__ +#ifndef ZXING_PDF417_READER_H +#define ZXING_PDF417_READER_H /* * PDF417Reader.h @@ -46,4 +46,4 @@ class PDF417Reader : public Reader { } } -#endif // __PDF417_READER_H__ +#endif // ZXING_PDF417_READER_H diff --git a/src/zxing/zxing/pdf417/decoder/BitMatrixParser.h b/src/zxing/zxing/pdf417/decoder/BitMatrixParser.h index afc080b..47f2290 100644 --- a/src/zxing/zxing/pdf417/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/pdf417/decoder/BitMatrixParser.h @@ -1,5 +1,5 @@ -#ifndef __BIT_MATRIX_PARSER__PDF_H__ -#define __BIT_MATRIX_PARSER__PDF_H__ +#ifndef ZXING_BIT_MATRIX_PARSER_PDF_H +#define ZXING_BIT_MATRIX_PARSER_PDF_H /* * BitMatrixParser.h / PDF417 @@ -81,4 +81,4 @@ protected: } } -#endif // __BIT_MATRIX_PARSER__PDF_H__ +#endif // ZXING_BIT_MATRIX_PARSER_PDF_H diff --git a/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h index e9aff88..d83bceb 100644 --- a/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __DECODED_BIT_STREAM_PARSER_PD_H__ -#define __DECODED_BIT_STREAM_PARSER_PD_H__ +#ifndef ZXING_DECODED_BIT_STREAM_PARSER_PD_H +#define ZXING_DECODED_BIT_STREAM_PARSER_PD_H /* * Copyright 2010 ZXing authors All rights reserved. @@ -81,4 +81,4 @@ class DecodedBitStreamParser { } /* namespace pdf417 */ } /* namespace zxing */ -#endif // __DECODED_BIT_STREAM_PARSER_PD_H__ +#endif // ZXING_DECODED_BIT_STREAM_PARSER_PD_H diff --git a/src/zxing/zxing/pdf417/decoder/Decoder.h b/src/zxing/zxing/pdf417/decoder/Decoder.h index 304be87..c7733df 100644 --- a/src/zxing/zxing/pdf417/decoder/Decoder.h +++ b/src/zxing/zxing/pdf417/decoder/Decoder.h @@ -1,5 +1,5 @@ -#ifndef __DECOCER_PDF_H__ -#define __DECOCER_PDF_H__ +#ifndef ZXING_DECOCER_PDF_H +#define ZXING_DECOCER_PDF_H /* * Decoder.h @@ -59,4 +59,4 @@ public: } } -#endif // __DECOCER_PDF_H__ +#endif // ZXING_DECOCER_PDF_H diff --git a/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h b/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h index 7ea8c4a..e6c7a16 100644 --- a/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h +++ b/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ERROR_CORRECTION_PDF_H__ -#define __ERROR_CORRECTION_PDF_H__ +#ifndef ZXING_ERROR_CORRECTION_PDF_H +#define ZXING_ERROR_CORRECTION_PDF_H /* * Copyright 2012 ZXing authors * @@ -68,4 +68,4 @@ class ErrorCorrection: public Counted { } } -#endif /* __ERROR_CORRECTION_PDF_H__ */ +#endif /* ZXING_ERROR_CORRECTION_PDF_H */ diff --git a/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.h b/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.h index b4d8b4b..79e666a 100644 --- a/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.h +++ b/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.h @@ -1,5 +1,5 @@ -#ifndef __MODULUS_GF_PDF_H__ -#define __MODULUS_GF_PDF_H__ +#ifndef ZXING_MODULUS_GF_PDF_H +#define ZXING_MODULUS_GF_PDF_H /* * Copyright 2012 ZXing authors * @@ -69,4 +69,4 @@ class ModulusGF { } } -#endif /* __MODULUS_GF_PDF_H__ */ +#endif /* ZXING_MODULUS_GF_PDF_H */ diff --git a/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h b/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h index f3f76a1..ffab558 100644 --- a/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h +++ b/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.h @@ -1,5 +1,5 @@ -#ifndef __MODULUS_GFPOLY_PDF_H__ -#define __MODULUS_GFPOLY_PDF_H__ +#ifndef ZXING_MODULUS_GFPOLY_PDF_H +#define ZXING_MODULUS_GFPOLY_PDF_H /* * Copyright 2012 ZXing authors @@ -65,4 +65,4 @@ class ModulusPoly: public Counted { } } -#endif /* __MODULUS_GFPOLY_PDF_H__ */ +#endif /* ZXING_MODULUS_GFPOLY_PDF_H */ diff --git a/src/zxing/zxing/pdf417/detector/Detector.h b/src/zxing/zxing/pdf417/detector/Detector.h index 874ec5c..d2d9698 100644 --- a/src/zxing/zxing/pdf417/detector/Detector.h +++ b/src/zxing/zxing/pdf417/detector/Detector.h @@ -1,5 +1,5 @@ -#ifndef __DETECTOR_H__ -#define __DETECTOR_H__ +#ifndef ZXING_DETECTOR_H_ +#define ZXING_DETECTOR_H_ /* * Detector.h @@ -103,4 +103,4 @@ public: } } -#endif // __DETECTOR_H__ +#endif // ZXING_DETECTOR_H_ diff --git a/src/zxing/zxing/pdf417/detector/LinesSampler.h b/src/zxing/zxing/pdf417/detector/LinesSampler.h index b2de4bd..648ba3f 100644 --- a/src/zxing/zxing/pdf417/detector/LinesSampler.h +++ b/src/zxing/zxing/pdf417/detector/LinesSampler.h @@ -1,5 +1,5 @@ -#ifndef __LINESSAMPLER_H__ -#define __LINESSAMPLER_H__ +#ifndef ZXING_LINESSAMPLER_H +#define ZXING_LINESSAMPLER_H /* * Copyright 2010 ZXing authors All rights reserved. @@ -119,4 +119,4 @@ public: } } -#endif // __LINESSAMPLER_H__ +#endif // ZXING_LINESSAMPLER_H diff --git a/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h b/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h index 5ad9718..77a6ccd 100644 --- a/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h +++ b/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h @@ -1,5 +1,5 @@ -#ifndef __ERROR_CORRECTION_LEVEL_H__ -#define __ERROR_CORRECTION_LEVEL_H__ +#ifndef ZXING_ERROR_CORRECTION_LEVEL_H +#define ZXING_ERROR_CORRECTION_LEVEL_H /* * ErrorCorrectionLevel.h @@ -52,4 +52,4 @@ public: } } -#endif // __ERROR_CORRECTION_LEVEL_H__ +#endif // ZXING_ERROR_CORRECTION_LEVEL_H diff --git a/src/zxing/zxing/qrcode/FormatInformation.h b/src/zxing/zxing/qrcode/FormatInformation.h index 7770472..6de295f 100644 --- a/src/zxing/zxing/qrcode/FormatInformation.h +++ b/src/zxing/zxing/qrcode/FormatInformation.h @@ -1,5 +1,5 @@ -#ifndef __FORMAT_INFORMATION_H__ -#define __FORMAT_INFORMATION_H__ +#ifndef ZXING_FORMAT_INFORMATION_H +#define ZXING_FORMAT_INFORMATION_H /* * FormatInformation.h @@ -51,4 +51,4 @@ public: } } -#endif // __FORMAT_INFORMATION_H__ +#endif // ZXING_FORMAT_INFORMATION_H diff --git a/src/zxing/zxing/qrcode/QRCodeReader.h b/src/zxing/zxing/qrcode/QRCodeReader.h index d5f9b86..7eda09d 100644 --- a/src/zxing/zxing/qrcode/QRCodeReader.h +++ b/src/zxing/zxing/qrcode/QRCodeReader.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __QR_CODE_READER_H__ -#define __QR_CODE_READER_H__ +#ifndef ZXING_QR_CODE_READER_H +#define ZXING_QR_CODE_READER_H /* * QRCodeReader.h @@ -45,4 +45,4 @@ class QRCodeReader : public Reader { } } -#endif // __QR_CODE_READER_H__ +#endif // ZXING_QR_CODE_READER_H diff --git a/src/zxing/zxing/qrcode/Version.h b/src/zxing/zxing/qrcode/Version.h index 0af4416..987a446 100644 --- a/src/zxing/zxing/qrcode/Version.h +++ b/src/zxing/zxing/qrcode/Version.h @@ -1,5 +1,5 @@ -#ifndef __VERSION_H__ -#define __VERSION_H__ +#ifndef ZXING_VERSION_H +#define ZXING_VERSION_H /* * Version.h @@ -83,4 +83,4 @@ public: } } -#endif // __VERSION_H__ +#endif // ZXING_VERSION_H diff --git a/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h b/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h index ed76f05..5b956f8 100644 --- a/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h @@ -1,5 +1,5 @@ -#ifndef __BIT_MATRIX_PARSER_H__ -#define __BIT_MATRIX_PARSER_H__ +#ifndef ZXING_MATRIX_PARSER_H +#define ZXING_MATRIX_PARSER_H /* * BitMatrixParser.h @@ -57,4 +57,4 @@ private: } } -#endif // __BIT_MATRIX_PARSER_H__ +#endif // ZXING_MATRIX_PARSER_H diff --git a/src/zxing/zxing/qrcode/decoder/DataBlock.h b/src/zxing/zxing/qrcode/decoder/DataBlock.h index 96c76d4..d2c804e 100644 --- a/src/zxing/zxing/qrcode/decoder/DataBlock.h +++ b/src/zxing/zxing/qrcode/decoder/DataBlock.h @@ -1,5 +1,5 @@ -#ifndef __DATA_BLOCK_H__ -#define __DATA_BLOCK_H__ +#ifndef ZXING_DATA_BLOCK_H +#define ZXING_DATA_BLOCK_H /* * DataBlock.h @@ -47,4 +47,4 @@ public: } } -#endif // __DATA_BLOCK_H__ +#endif // ZXING_DATA_BLOCK_H diff --git a/src/zxing/zxing/qrcode/decoder/DataMask.h b/src/zxing/zxing/qrcode/decoder/DataMask.h index fa3088b..46f8c39 100644 --- a/src/zxing/zxing/qrcode/decoder/DataMask.h +++ b/src/zxing/zxing/qrcode/decoder/DataMask.h @@ -1,5 +1,5 @@ -#ifndef __DATA_MASK_H__ -#define __DATA_MASK_H__ +#ifndef ZXING_DATA_MASK_H +#define ZXING_DATA_MASK_H /* * DataMask.h @@ -47,4 +47,4 @@ public: } } -#endif // __DATA_MASK_H__ +#endif // ZXING_DATA_MASK_H diff --git a/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h index 077bf00..f1552af 100644 --- a/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __DECODED_BIT_STREAM_PARSER_H__ -#define __DECODED_BIT_STREAM_PARSER_H__ +#ifndef ZXING_DECODED_BIT_STREAM_PARSER_H +#define ZXING_DECODED_BIT_STREAM_PARSER_H /* * DecodedBitStreamParser.h @@ -69,4 +69,4 @@ public: } } -#endif // __DECODED_BIT_STREAM_PARSER_H__ +#endif // ZXING_DECODED_BIT_STREAM_PARSER_H diff --git a/src/zxing/zxing/qrcode/decoder/Decoder.h b/src/zxing/zxing/qrcode/decoder/Decoder.h index 401cfed..44a418e 100644 --- a/src/zxing/zxing/qrcode/decoder/Decoder.h +++ b/src/zxing/zxing/qrcode/decoder/Decoder.h @@ -1,5 +1,5 @@ -#ifndef __DECODER_H__ -#define __DECODER_H__ +#ifndef ZXING_DECODER_H +#define ZXING_DECODER_H /* * Decoder.h @@ -43,4 +43,4 @@ public: } } -#endif // __DECODER_H__ +#endif // ZXING_DECODER_H diff --git a/src/zxing/zxing/qrcode/decoder/Mode.h b/src/zxing/zxing/qrcode/decoder/Mode.h index 79fb382..dab5f9e 100644 --- a/src/zxing/zxing/qrcode/decoder/Mode.h +++ b/src/zxing/zxing/qrcode/decoder/Mode.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __MODE_H__ -#define __MODE_H__ +#ifndef ZXING_MODE_H +#define ZXING_MODE_H /* * Mode.h diff --git a/src/zxing/zxing/qrcode/detector/AlignmentPattern.h b/src/zxing/zxing/qrcode/detector/AlignmentPattern.h index f95b92a..a506f6a 100644 --- a/src/zxing/zxing/qrcode/detector/AlignmentPattern.h +++ b/src/zxing/zxing/qrcode/detector/AlignmentPattern.h @@ -1,7 +1,7 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __ALIGNMENT_PATTERN_H__ -#define __ALIGNMENT_PATTERN_H__ +#ifndef ZXING_ALIGNMENT_PATTERN_H +#define ZXING_ALIGNMENT_PATTERN_H /* * AlignmentPattern.h @@ -42,4 +42,4 @@ namespace zxing { } } -#endif // __ALIGNMENT_PATTERN_H__ +#endif // ZXING_ALIGNMENT_PATTERN_H diff --git a/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h b/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h index 6bd9487..c04359e 100644 --- a/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h +++ b/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h @@ -1,5 +1,5 @@ -#ifndef __ALIGNMENT_PATTERN_FINDER_H__ -#define __ALIGNMENT_PATTERN_FINDER_H__ +#ifndef ZXING_ALIGNMENT_PATTERN_FINDER_H +#define ZXING_ALIGNMENT_PATTERN_FINDER_H /* * AlignmentPatternFinder.h @@ -65,4 +65,4 @@ private: } } -#endif // __ALIGNMENT_PATTERN_FINDER_H__ +#endif // ZXING_ALIGNMENT_PATTERN_FINDER_H diff --git a/src/zxing/zxing/qrcode/detector/Detector.h b/src/zxing/zxing/qrcode/detector/Detector.h index 05ef044..4447fa5 100644 --- a/src/zxing/zxing/qrcode/detector/Detector.h +++ b/src/zxing/zxing/qrcode/detector/Detector.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __DETECTOR_H__ -#define __DETECTOR_H__ +#ifndef ZXING_DETECTOR_H +#define ZXING_DETECTOR_H /* * Detector.h @@ -66,4 +66,4 @@ public: } } -#endif // __DETECTOR_H__ +#endif // ZXING_DETECTOR_H diff --git a/src/zxing/zxing/qrcode/detector/FinderPattern.h b/src/zxing/zxing/qrcode/detector/FinderPattern.h index 87b61c8..944cb9c 100644 --- a/src/zxing/zxing/qrcode/detector/FinderPattern.h +++ b/src/zxing/zxing/qrcode/detector/FinderPattern.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __FINDER_PATTERN_H__ -#define __FINDER_PATTERN_H__ +#ifndef ZXING_FINDER_PATTERN_H +#define ZXING_FINDER_PATTERN_H /* * FinderPattern.h @@ -45,4 +45,4 @@ namespace zxing { } } -#endif // __FINDER_PATTERN_H__ +#endif // ZXING_FINDER_PATTERN_H diff --git a/src/zxing/zxing/qrcode/detector/FinderPatternFinder.h b/src/zxing/zxing/qrcode/detector/FinderPatternFinder.h index af4a438..c90de19 100644 --- a/src/zxing/zxing/qrcode/detector/FinderPatternFinder.h +++ b/src/zxing/zxing/qrcode/detector/FinderPatternFinder.h @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- -#ifndef __FINDER_PATTERN_FINDER_H__ -#define __FINDER_PATTERN_FINDER_H__ +#ifndef ZXING_FINDER_PATTERN_FINDER_H +#define ZXING_FINDER_PATTERN_FINDER_H /* * FinderPatternFinder.h @@ -77,4 +77,4 @@ public: } } -#endif // __FINDER_PATTERN_FINDER_H__ +#endif // ZXING_FINDER_PATTERN_FINDER_H diff --git a/src/zxing/zxing/qrcode/detector/FinderPatternInfo.h b/src/zxing/zxing/qrcode/detector/FinderPatternInfo.h index 6d13254..b02faa1 100644 --- a/src/zxing/zxing/qrcode/detector/FinderPatternInfo.h +++ b/src/zxing/zxing/qrcode/detector/FinderPatternInfo.h @@ -1,5 +1,5 @@ -#ifndef __FINDER_PATTERN_INFO_H__ -#define __FINDER_PATTERN_INFO_H__ +#ifndef ZXING_FINDER_PATTERN_INFO_H +#define ZXING_FINDER_PATTERN_INFO_H /* * FinderPatternInfo.h @@ -44,4 +44,4 @@ public: } } -#endif // __FINDER_PATTERN_INFO_H__ +#endif // ZXING_FINDER_PATTERN_INFO_H From fac57028e4da9a90850b23564287702aa48f552c Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 16:46:36 +0100 Subject: [PATCH 06/83] Fixed warning about unused parameters in QZXing::decodeSubImageQM when QZXING_QML is not defined --- src/QZXing.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index a431099..2eb1d2d 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -487,6 +487,11 @@ QString QZXing::decodeSubImageQML(const QUrl &imageUrl, img = img.copy(offsetX, offsetY, width, height); return decodeImage(img); #else + Q_UNUSED(imageUrl); + Q_UNUSED(offsetX); + Q_UNUSED(offsetY); + Q_UNUSED(width); + Q_UNUSED(height); return decodeImage(QImage()); #endif //QZXING_QML } From 75b8dc4f9b0216542befddfb1df2386665368028 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 16:53:23 +0100 Subject: [PATCH 07/83] Removed warnings in QZXing.cpp --- src/QZXing.cpp | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 2eb1d2d..2070fa6 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -258,31 +258,31 @@ QRectF getTagRect(const ArrayRef > &resultPoints, const Refsize() < 2) return QRectF(); - + int matrixWidth = bitMatrix->getWidth(); int matrixHeight = bitMatrix->getHeight(); // 1D barcode if (resultPoints->size() == 2) { WhiteRectangleDetector detector(bitMatrix); std::vector > resultRectPoints = detector.detect(); - + if (resultRectPoints.size() != 4) return QRectF(); - qreal xMin = resultPoints[0]->getX(); + qreal xMin = qreal(resultPoints[0]->getX()); qreal xMax = xMin; - for (unsigned int i = 1; i < resultPoints->size(); ++i) { - qreal x = resultPoints[i]->getX(); + for (int i = 1; i < resultPoints->size(); ++i) { + qreal x = qreal(resultPoints[i]->getX()); if (x < xMin) xMin = x; if (x > xMax) xMax = x; } - qreal yMin = resultRectPoints[0]->getY(); + qreal yMin = qreal(resultRectPoints[0]->getY()); qreal yMax = yMin; for (unsigned int i = 1; i < resultRectPoints.size(); ++i) { - qreal y = resultRectPoints[i]->getY(); + qreal y = qreal(resultRectPoints[i]->getY()); if (y < yMin) yMin = y; if (y > yMax) @@ -294,13 +294,13 @@ QRectF getTagRect(const ArrayRef > &resultPoints, const Refsize() == 4) { - qreal xMin = resultPoints[0]->getX(); + qreal xMin = qreal(resultPoints[0]->getX()); qreal xMax = xMin; - qreal yMin = resultPoints[0]->getY(); + qreal yMin = qreal(resultPoints[0]->getY()); qreal yMax = yMin; - for (unsigned int i = 1; i < resultPoints->size(); ++i) { - qreal x = resultPoints[i]->getX(); - qreal y = resultPoints[i]->getY(); + for (int i = 1; i < resultPoints->size(); ++i) { + qreal x = qreal(resultPoints[i]->getX()); + qreal y = qreal(resultPoints[i]->getY()); if (x < xMin) xMin = x; if (x > xMax) @@ -332,7 +332,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo return ""; } - CameraImageWrapper *ciw = NULL; + CameraImageWrapper *ciw = nullptr; if ((maxWidth > 0) || (maxHeight > 0)) ciw = CameraImageWrapper::Factory(image, maxWidth, maxHeight, smoothTransformation); @@ -345,14 +345,14 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo Ref binz( new GlobalHistogramBinarizer(imageRef) ); Ref bb( new BinaryBitmap(binz) ); - DecodeHints hints((int)enabledDecoders); + DecodeHints hints(static_cast(enabledDecoders)); bool hasSucceded = false; try { res = decoder->decode(bb, hints); processingTime = t.elapsed(); hasSucceded = true; - }catch(zxing::Exception &e){} + } catch(zxing::Exception &/*e*/){} if(!hasSucceded) { @@ -440,7 +440,7 @@ QString QZXing::decodeSubImageQML(QObject *item, const int offsetX, const int offsetY, const int width, const int height) { - if(item == NULL) + if(item == nullptr) { processingTime = 0; emit decodingFinished(false); @@ -519,10 +519,10 @@ QImage QZXing::encodeData(const QString& data, Ref bytesRef = barcode->getMatrix(); const std::vector< std::vector >& bytes = bytesRef->getArray(); - image = QImage(bytesRef->getWidth(), bytesRef->getHeight(), QImage::Format_ARGB32); - for(int i=0; igetWidth(); i++) - for(int j=0; jgetHeight(); j++) - image.setPixel(i, j, bytes[j][i] ? + image = QImage(int(bytesRef->getWidth()), int(bytesRef->getHeight()), QImage::Format_ARGB32); + for(size_t i=0; igetWidth(); i++) + for(size_t j=0; jgetHeight(); j++) + image.setPixel(int(i), int(j), bytes[j][i] ? qRgb(0,0,0) : qRgb(255,255,255)); @@ -530,7 +530,6 @@ QImage QZXing::encodeData(const QString& data, break; } case EncoderFormat_INVALID: - default: break; } } catch (std::exception& e) { From 8f631567d4f154b1e0609ef5c7751c1a56a7daa6 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 16:54:26 +0100 Subject: [PATCH 08/83] Removed warnings in BitMatrix.cpp --- src/zxing/zxing/common/BitMatrix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zxing/zxing/common/BitMatrix.cpp b/src/zxing/zxing/common/BitMatrix.cpp index 7f986b1..354c0b3 100644 --- a/src/zxing/zxing/common/BitMatrix.cpp +++ b/src/zxing/zxing/common/BitMatrix.cpp @@ -111,7 +111,7 @@ void BitMatrix::setRow(int y, Ref row) } //change with memcopy - for(size_t i=0; iget(i); } @@ -199,7 +199,7 @@ ArrayRef BitMatrix::getEnclosingRectangle() const } if (x32 * 32 + 31 > right) { int bit = 31; - while (((unsigned)theBits >> (unsigned)bit) == 0) { + while ((unsigned(theBits) >> unsigned(bit)) == 0) { bit--; } if ((x32 * 32 + bit) > right) { From 5195a8d809a7adb91e98d7939302cc37978056f2 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 16:58:15 +0100 Subject: [PATCH 09/83] Removed warnings in BitArray.cpp --- src/zxing/zxing/common/BitArray.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/zxing/zxing/common/BitArray.cpp b/src/zxing/zxing/common/BitArray.cpp index 55bfec3..1dffbd1 100644 --- a/src/zxing/zxing/common/BitArray.cpp +++ b/src/zxing/zxing/common/BitArray.cpp @@ -41,11 +41,13 @@ BitArray::BitArray(int size_) //this could be wrong. TODO: check size value BitArray::BitArray(std::vector other) - : size(other.size()), bits(other.size()) + : size(int(other.size())), bits(int(other.size())) { - for(int i=0; isize-1) / 32); int oldBitsLen = len + 1; for (int i = 0; i < oldBitsLen; i++) { - long x = (long) bits[i]; + long x = long(bits[i]); x = ((x >> 1) & 0x55555555L) | ((x & 0x55555555L) << 1); x = ((x >> 2) & 0x33333333L) | ((x & 0x33333333L) << 2); x = ((x >> 4) & 0x0f0f0f0fL) | ((x & 0x0f0f0f0fL) << 4); x = ((x >> 8) & 0x00ff00ffL) | ((x & 0x00ff00ffL) << 8); x = ((x >> 16) & 0x0000ffffL) | ((x & 0x0000ffffL) << 16); - newBits[len - i] = (int) x; + newBits[len - i] = int(x); } // now correct the int's if the bit size isn't a multiple of 32 if (size != oldBitsLen * 32) { @@ -156,7 +158,7 @@ namespace { int numberOfTrailingZeros(int i) { // HD, Figure 5-14 #if defined(__clang__) || defined(__GNUC__) - return __builtin_ctz(i); + return __builtin_ctz(unsigned(i)); #else int y; if (i == 0) return 32; @@ -179,7 +181,7 @@ int BitArray::getNextSet(int from) { // mask off lesser bits first currentBits &= ~((1 << (from & bitsMask)) - 1); while (currentBits == 0) { - if (++bitsOffset == (int)bits->size()) { + if (++bitsOffset == bits->size()) { return size; } currentBits = bits[bitsOffset]; @@ -197,7 +199,7 @@ int BitArray::getNextUnset(int from) { // mask off lesser bits first currentBits &= ~((1 << (from & bitsMask)) - 1); while (currentBits == 0) { - if (++bitsOffset == (int)bits->size()) { + if (++bitsOffset == bits->size()) { return size; } currentBits = ~bits[bitsOffset]; @@ -241,7 +243,7 @@ void BitArray::ensureCapacity(int size) { ArrayRef newBits = makeArray(size); //memcpy(bits, newBits->, bits->size()); - for (size_t i=0; isize(); ++i) { + for (int i=0; isize(); ++i) { newBits[i] = bits[i]; } bits = newBits; @@ -263,8 +265,8 @@ void BitArray::xor_(const BitArray& other) void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const { - if(array.size() < (numBytes + offset)) - array.resize(numBytes + offset); + if(int(array.size()) < (numBytes + offset)) + array.resize(size_t(numBytes + offset)); for (int i = 0; i < numBytes; i++) { int theByte = 0; @@ -274,7 +276,7 @@ void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int } bitOffset++; } - array[offset + i] = (byte) theByte; + array[size_t(offset + i)] = byte(theByte); } } @@ -282,7 +284,7 @@ const std::string BitArray::toString() const { std::stringstream result;// = new StringBuilder(2 * width * height + 2); - for (size_t i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { if ((i & 0x07) == 0) { result << ' '; } From 1b51a99dd29db09914a31a5e7cf9c03708ec3f72 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 2 Nov 2018 17:04:39 +0100 Subject: [PATCH 10/83] Removed warnings in QrEncoder.cpp --- src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 40 ++++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index 7e092db..4c93cb3 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -39,13 +39,13 @@ int Encoder::calculateMaskPenalty(const ByteMatrix& matrix) Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ecLevel) { - return encode(content, ecLevel, NULL); + return encode(content, ecLevel, nullptr); } Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ecLevel, const EncodeHint* hints) { // Determine what character encoding has been specified by the caller, if any - std::string encoding = hints == NULL ? "" : hints->getCharacterSet(); + std::string encoding = hints == nullptr ? "" : hints->getCharacterSet(); if (encoding == "") encoding = DEFAULT_BYTE_MODE_ENCODING; @@ -61,7 +61,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec if (mode == Mode::BYTE && DEFAULT_BYTE_MODE_ENCODING != encoding) { zxing::common::CharacterSetECI const * eci = zxing::common::CharacterSetECI::getCharacterSetECIByName(encoding); - if (eci != NULL) { + if (eci != nullptr) { appendECI(*eci, headerBits); } } @@ -75,7 +75,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec appendBytes(content, mode, dataBits, encoding); Ref version; - if (hints != NULL/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) { + if (hints != nullptr/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) { version = Version::getVersionForNumber(1); int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); if (!willFit(bitsNeeded, version, ecLevel)) { @@ -88,7 +88,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec BitArray headerAndDataBits; headerAndDataBits.appendBitArray(headerBits); // Find "length" of main segment and write it - int numLetters = (mode == Mode::BYTE) ? dataBits.getSizeInBytes() : content.length(); + int numLetters = (mode == Mode::BYTE) ? dataBits.getSizeInBytes() : int(content.length()); appendLengthInfo(numLetters, *version, mode, headerAndDataBits); // Put data together into the overall payload headerAndDataBits.appendBitArray(dataBits); @@ -103,7 +103,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec Ref finalBits(interleaveWithECBytes(headerAndDataBits, version->getTotalCodewords(), numDataBytes, - ecBlocks.getECBlocks().size())); + int(ecBlocks.getECBlocks().size()))); Ref qrCode(new QRCode); @@ -113,7 +113,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec // Choose the mask pattern and set to "qrCode". int dimension = version->getDimensionForVersion(); - Ref matrix(new ByteMatrix(dimension, dimension)); + Ref matrix(new ByteMatrix(size_t(dimension), size_t(dimension))); int maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix); qrCode->setMaskPattern(maskPattern); @@ -165,7 +165,7 @@ Mode Encoder::chooseMode(const std::string& content, const std::string& encoding bool hasNumeric = false; bool hasAlphanumeric = false; - for (int i = 0; i < content.size(); i++) { + for (size_t i = 0; i < content.size(); i++) { char c = content.at(i); if (c >= '0' && c <= '9') { hasNumeric = true; @@ -375,13 +375,13 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, int size = numDataBytesInBlock[0]; std::vector dataBytes; - dataBytes.resize(size); + dataBytes.resize(size_t(size)); bits.toBytes(8*dataBytesOffset, dataBytes, 0, size); ArrayRef ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); - blocks.push_back(BlockPair(ArrayRef(dataBytes.data(), dataBytes.size()),ecBytes)); //?? please revisit + blocks.push_back(BlockPair(ArrayRef(dataBytes.data(), int(dataBytes.size())), ecBytes)); //?? please revisit maxNumDataBytes = max(maxNumDataBytes, size); - maxNumEcBytes = max(maxNumEcBytes, (int)ecBytes->size()); + maxNumEcBytes = max(maxNumEcBytes, ecBytes->size()); dataBytesOffset += numDataBytesInBlock[0]; } if (numDataBytes != dataBytesOffset) { @@ -422,7 +422,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) { - int numDataBytes = dataBytes.size(); + size_t numDataBytes = dataBytes.size(); std::vector dataBytesCopy(dataBytes); zxing::ReedSolomonEncoder encoder(GenericGF::QR_CODE_FIELD_256); @@ -430,7 +430,7 @@ ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int ArrayRef ecBytes(numEcBytesInBlock); for (int i = 0; i < numEcBytesInBlock; i++) { - ecBytes[i] = dataBytesCopy[numDataBytes + i]; + ecBytes[i] = dataBytesCopy[numDataBytes + size_t(i)]; } return ecBytes; } @@ -486,8 +486,8 @@ void Encoder::appendBytes(const std::string& content, void Encoder::appendNumericBytes( const std::string& content, BitArray& bits) { - int length = content.size(); - int i = 0; + size_t length = content.size(); + size_t i = 0; while (i < length) { int num1 = content.at(i) - '0'; if (i + 2 < length) { @@ -511,8 +511,8 @@ void Encoder::appendNumericBytes( const std::string& content, BitArray& bits) void Encoder::appendAlphanumericBytes(const std::string& content, BitArray& bits) { - int length = content.length(); - int i = 0; + size_t length = content.length(); + size_t i = 0; while (i < length) { int code1 = getAlphanumericCode(content.at(i)); if (code1 == -1) { @@ -544,7 +544,7 @@ void Encoder::append8BitBytes(const std::string& content, BitArray& bits, const // throw WriterException(uee); // } - for (int i=0; i Date: Mon, 5 Nov 2018 13:55:34 +0100 Subject: [PATCH 11/83] Fixed warnings in MaskUtil.cpp --- src/zxing/zxing/qrcode/encoder/MaskUtil.cpp | 70 ++++++++++----------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp index 82a3240..f299f48 100644 --- a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp +++ b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp @@ -1,7 +1,7 @@ #include "MaskUtil.h" #include #include -#include +#include namespace zxing { namespace qrcode { @@ -30,11 +30,11 @@ int MaskUtil::applyMaskPenaltyRule2(const ByteMatrix& matrix) { int penalty = 0; const std::vector >& array = matrix.getArray(); - int width = matrix.getWidth(); - int height = matrix.getHeight(); - for (int y = 0; y < height - 1; y++) { + size_t width = matrix.getWidth(); + size_t height = matrix.getHeight(); + for (size_t y = 0; y < height - 1; y++) { const std::vector& arrayY = array[y]; - for (int x = 0; x < width - 1; x++) { + for (size_t x = 0; x < width - 1; x++) { int value = arrayY[x]; if (value == arrayY[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) { penalty++; @@ -53,30 +53,30 @@ int MaskUtil::applyMaskPenaltyRule3(const ByteMatrix& matrix) { int numPenalties = 0; const std::vector >& array = matrix.getArray(); - int width = matrix.getWidth(); - int height = matrix.getHeight(); + int width = int(matrix.getWidth()); + int height = int(matrix.getHeight()); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { - const std::vector& arrayY = array[y]; // We can at least optimize this access + const std::vector& arrayY = array[size_t(y)]; // We can at least optimize this access if (x + 6 < width && - arrayY[x] == 1 && - arrayY[x + 1] == 0 && - arrayY[x + 2] == 1 && - arrayY[x + 3] == 1 && - arrayY[x + 4] == 1 && - arrayY[x + 5] == 0 && - arrayY[x + 6] == 1 && + arrayY[size_t(x)] == 1 && + arrayY[size_t(x + 1)] == 0 && + arrayY[size_t(x + 2)] == 1 && + arrayY[size_t(x + 3)] == 1 && + arrayY[size_t(x + 4)] == 1 && + arrayY[size_t(x + 5)] == 0 && + arrayY[size_t(x + 6)] == 1 && (isWhiteHorizontal(arrayY, x - 4, x) || isWhiteHorizontal(arrayY, x + 7, x + 11))) { numPenalties++; } if (y + 6 < height && - array[y][x] == 1 && - array[y + 1][x] == 0 && - array[y + 2][x] == 1 && - array[y + 3][x] == 1 && - array[y + 4][x] == 1 && - array[y + 5][x] == 0 && - array[y + 6][x] == 1 && + array[size_t(y)][size_t(x)] == 1 && + array[size_t(y + 1)][size_t(x)] == 0 && + array[size_t(y + 2)][size_t(x)] == 1 && + array[size_t(y + 3)][size_t(x)] == 1 && + array[size_t(y + 4)][size_t(x)] == 1 && + array[size_t(y + 5)][size_t(x)] == 0 && + array[size_t(y + 6)][size_t(x)] == 1 && (isWhiteVertical(array, x, y - 4, y) || isWhiteVertical(array, x, y + 7, y + 11))) { numPenalties++; } @@ -88,9 +88,9 @@ int MaskUtil::applyMaskPenaltyRule3(const ByteMatrix& matrix) bool MaskUtil::isWhiteHorizontal(const std::vector& rowArray, int from, int to) { from = std::max(from, 0); - to = std::min(to, (int)rowArray.size()); + to = std::min(to, int(rowArray.size())); for (int i = from; i < to; i++) { - if (rowArray[i] == 1) { + if (rowArray[size_t(i)] == 1) { return false; } } @@ -100,9 +100,9 @@ bool MaskUtil::isWhiteHorizontal(const std::vector& rowArray, int from, in bool MaskUtil::isWhiteVertical(const std::vector > &array, int col, int from, int to) { from = std::max(from, 0); - to = std::min(to, (int)array.size()); + to = std::min(to, int(array.size())); for (int i = from; i < to; i++) { - if (array[i][col] == 1) { + if (array[size_t(i)][size_t(col)] == 1) { return false; } } @@ -117,9 +117,9 @@ int MaskUtil::applyMaskPenaltyRule4(const ByteMatrix& matrix) { int numDarkCells = 0; const std::vector >& array = matrix.getArray(); - int width = matrix.getWidth(); - int height = matrix.getHeight(); - for (int y = 0; y < height; y++) { + size_t width = matrix.getWidth(); + size_t height = matrix.getHeight(); + for (size_t y = 0; y < height; y++) { const std::vector& arrayY = array[y]; for (size_t x = 0; x < width; x++) { if (arrayY[x] == 1) { @@ -127,7 +127,7 @@ int MaskUtil::applyMaskPenaltyRule4(const ByteMatrix& matrix) } } } - int numTotalCells = matrix.getHeight() * matrix.getWidth(); + int numTotalCells = int(matrix.getHeight() * matrix.getWidth()); int fivePercentVariances = abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells; return fivePercentVariances * N4; } @@ -169,7 +169,7 @@ bool MaskUtil::getDataMaskBit(int maskPattern, int x, int y) intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1; break; default: - throw IllegalArgumentException("Invalid mask pattern: " + maskPattern); + throw IllegalArgumentException("Invalid mask pattern"); } return intermediate == 0; } @@ -181,14 +181,14 @@ bool MaskUtil::getDataMaskBit(int maskPattern, int x, int y) int MaskUtil::applyMaskPenaltyRule1Internal(const ByteMatrix& matrix, bool isHorizontal) { int penalty = 0; - int iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth(); - int jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight(); + int iLimit = int(isHorizontal ? matrix.getHeight() : matrix.getWidth()); + int jLimit = int(isHorizontal ? matrix.getWidth() : matrix.getHeight()); const std::vector >& array = matrix.getArray(); - for (size_t i = 0; i < iLimit; i++) { + for (int i = 0; i < iLimit; i++) { int numSameBitCells = 0; int prevBit = -1; for (int j = 0; j < jLimit; j++) { - int bit = isHorizontal ? array[i][j] : array[j][i]; + int bit = isHorizontal ? array[size_t(i)][size_t(j)] : array[size_t(j)][size_t(i)]; if (bit == prevBit) { numSameBitCells++; } else { From 1dc6534c099a5fcd1a308c8442db102c66719768 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 14:08:16 +0100 Subject: [PATCH 12/83] Fixed warnings in ReedSolomonEncoder.cpp --- .../common/reedsolomon/ReedSolomonEncoder.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp index 85fa1e9..350c059 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp @@ -17,9 +17,9 @@ ReedSolomonEncoder::ReedSolomonEncoder(Ref field) : Ref ReedSolomonEncoder::buildGenerator(int degree) { - if (degree >= cachedGenerators_.size()) { + if (degree >= int(cachedGenerators_.size())) { Ref lastGenerator = cachedGenerators_.at(cachedGenerators_.size() - 1); - for (int d = cachedGenerators_.size(); d <= degree; d++) + for (int d = int(cachedGenerators_.size()); d <= degree; d++) { ArrayRef arrayRef(2); //will this work? arrayRef[0] = 1; @@ -30,7 +30,10 @@ Ref ReedSolomonEncoder::buildGenerator(int degree) lastGenerator = nextGenerator; } } - return cachedGenerators_.at(degree); // ??? wont this through exception? + + // ??? wont this through exception? + // No the elements up to index degree are added above + return cachedGenerators_.at(size_t(degree)); } void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) @@ -39,8 +42,8 @@ void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) throw Exception("No error correction bytes"); } - int dataBytes = toEncode.size();// - ecBytes; - toEncode.resize(toEncode.size()+ecBytes); + int dataBytes = int(toEncode.size());// - ecBytes; + toEncode.resize(toEncode.size() + size_t(ecBytes)); if (dataBytes <= 0) { throw Exception("No data bytes provided"); } @@ -49,7 +52,7 @@ void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) //to-do optimize the following loop for(int i=0; i< dataBytes; i++) - infoCoefficients[i] = toEncode[i]; + infoCoefficients[i] = toEncode[size_t(i)]; Ref info(new GenericGFPoly(field_, infoCoefficients)); info = info->multiplyByMonomial(ecBytes, 1); @@ -57,11 +60,11 @@ void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) ArrayRef coefficients = remainder->getCoefficients(); int numZeroCoefficients = ecBytes - coefficients->size(); for (int i = 0; i < numZeroCoefficients; i++) { - toEncode[dataBytes + i] = 0; + toEncode[size_t(dataBytes + i)] = 0; } - for (size_t i = 0; i < coefficients->size(); i++) - toEncode[dataBytes + numZeroCoefficients + i] = coefficients[i]; + for (int i = 0; i < coefficients->size(); i++) + toEncode[size_t(dataBytes + numZeroCoefficients + i)] = byte(coefficients[int(i)]); } } From 0d67ad245f4a1529cf522cca5425dd841b3256ee Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 14:08:39 +0100 Subject: [PATCH 13/83] Fixed warnings in MatrixUtil.cpp --- src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp b/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp index 4095e30..c8e4311 100644 --- a/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp +++ b/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp @@ -137,18 +137,18 @@ void MatrixUtil::embedTypeInfo(const ErrorCorrectionLevel& ecLevel, int maskPatt // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46). int x1 = TYPE_INFO_COORDINATES[i][0]; int y1 = TYPE_INFO_COORDINATES[i][1]; - matrix.set(x1, y1, bit); + matrix.set(size_t(x1), size_t(y1), bit); if (i < 8) { // Right top corner. - int x2 = matrix.getWidth() - i - 1; + int x2 = int(matrix.getWidth()) - i - 1; int y2 = 8; - matrix.set(x2, y2, bit); + matrix.set(size_t(x2), size_t(y2), bit); } else { // Left bottom corner. int x2 = 8; - int y2 = matrix.getHeight() - 7 + (i - 8); - matrix.set(x2, y2, bit); + int y2 = int(matrix.getHeight()) - 7 + (i - 8); + matrix.set(size_t(x2), size_t(y2), bit); } } } @@ -168,9 +168,9 @@ void MatrixUtil::maybeEmbedVersionInfo(const Version& version, ByteMatrix& matri boolean bit = versionInfoBits.get(bitIndex); bitIndex--; // Left bottom corner. - matrix.set(i, matrix.getHeight() - 11 + j, bit); + matrix.set(size_t(i), size_t(int(matrix.getHeight()) - 11 + j), bit); // Right bottom corner. - matrix.set(matrix.getHeight() - 11 + j, i, bit); + matrix.set(size_t(int(matrix.getHeight()) - 11 + j), size_t(i), bit); } } } @@ -180,18 +180,18 @@ void MatrixUtil::embedDataBits(const BitArray& dataBits, int maskPattern, ByteMa int bitIndex = 0; int direction = -1; // Start from the right bottom cell. - int x = matrix.getWidth() - 1; - int y = matrix.getHeight() - 1; + int x = int(matrix.getWidth()) - 1; + int y = int(matrix.getHeight()) - 1; while (x > 0) { // Skip the vertical timing pattern. if (x == 6) { x -= 1; } - while (y >= 0 && y < matrix.getHeight()) { + while (y >= 0 && y < int(matrix.getHeight())) { for (int i = 0; i < 2; ++i) { int xx = x - i; // Skip the cell if it's not empty. - if (!isEmpty(matrix.get(xx, y))) { + if (!isEmpty(matrix.get(size_t(xx), size_t(y)))) { continue; } boolean bit; @@ -208,7 +208,7 @@ void MatrixUtil::embedDataBits(const BitArray& dataBits, int maskPattern, ByteMa if (maskPattern != -1 && MaskUtil::getDataMaskBit(maskPattern, xx, y)) { bit = !bit; } - matrix.set(xx, y, bit); + matrix.set(size_t(xx), size_t(y), bit); } y += direction; } @@ -218,7 +218,7 @@ void MatrixUtil::embedDataBits(const BitArray& dataBits, int maskPattern, ByteMa } // All bits should be consumed. if (bitIndex != dataBits.getSize()) { - throw zxing::WriterException("Not all bits consumed: " + bitIndex + '/' + dataBits.getSize()); + throw zxing::WriterException("Not all bits consumed"); } } @@ -269,7 +269,7 @@ void MatrixUtil::makeTypeInfoBits(const ErrorCorrectionLevel& ecLevel, int maskP bits.xor_(maskBits); if (bits.getSize() != 15) { // Just in case. - throw WriterException("should not happen but we got: " + bits.getSize()); + throw WriterException("makeTypeInfoBits() failed, should not happen"); } } @@ -282,7 +282,7 @@ void MatrixUtil::makeVersionInfoBits(const Version& version, BitArray& bits) bits.appendBits(bchCode, 12); if (bits.getSize() != 18) { // Just in case. - throw WriterException("should not happen but we got: " + bits.getSize()); + throw WriterException("makeVersionInfoBits() failed, should not happen"); } } @@ -294,11 +294,11 @@ void MatrixUtil::embedTimingPatterns(ByteMatrix& matrix) int bit = (i + 1) % 2; // Horizontal line. if (isEmpty(matrix.get(i, 6))) { - matrix.set(i, 6, (byte)bit); + matrix.set(i, 6, byte(bit)); } // Vertical line. if (isEmpty(matrix.get(6, i))) { - matrix.set(6, i, (byte)bit); + matrix.set(6, i, byte(bit)); } } } @@ -308,7 +308,7 @@ void MatrixUtil::embedDarkDotAtLeftBottomCorner(ByteMatrix& matrix) if (matrix.get(8, matrix.getHeight() - 8) == 0) { throw WriterException(); } - matrix.set(8, matrix.getHeight() - 8, (byte)1); + matrix.set(8, matrix.getHeight() - 8, byte(1)); } void MatrixUtil::embedHorizontalSeparationPattern(int xStart, @@ -316,10 +316,10 @@ void MatrixUtil::embedHorizontalSeparationPattern(int xStart, ByteMatrix& matrix) { for (int x = 0; x < 8; ++x) { - if (!isEmpty(matrix.get(xStart + x, yStart))) { + if (!isEmpty(matrix.get(size_t(xStart + x), size_t(yStart)))) { throw WriterException(); } - matrix.set(xStart + x, yStart, (byte)0); + matrix.set(size_t(xStart + x), size_t(yStart), byte(0)); } } @@ -328,10 +328,10 @@ void MatrixUtil::embedVerticalSeparationPattern(int xStart, ByteMatrix& matrix) { for (int y = 0; y < 7; ++y) { - if (!isEmpty(matrix.get(xStart, yStart + y))) { + if (!isEmpty(matrix.get(size_t(xStart), size_t(yStart + y)))) { throw WriterException(); } - matrix.set(xStart, yStart + y, (byte)0); + matrix.set(size_t(xStart), size_t(yStart + y), byte(0)); } } @@ -339,7 +339,7 @@ void MatrixUtil::embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatr { for (int y = 0; y < 5; ++y) { for (int x = 0; x < 5; ++x) { - matrix.set(xStart + x, yStart + y, (byte)POSITION_ADJUSTMENT_PATTERN[y][x]); + matrix.set(size_t(xStart + x), size_t(yStart + y), byte(POSITION_ADJUSTMENT_PATTERN[y][x])); } } } @@ -348,7 +348,7 @@ void MatrixUtil::embedPositionDetectionPattern(int xStart, int yStart, ByteMatri { for (int y = 0; y < 7; ++y) { for (int x = 0; x < 7; ++x) { - matrix.set(xStart + x, yStart + y, (byte)POSITION_DETECTION_PATTERN[y][x]); + matrix.set(size_t(xStart + x), size_t(yStart + y), byte(POSITION_DETECTION_PATTERN[y][x])); } } } @@ -360,28 +360,28 @@ void MatrixUtil::embedPositionDetectionPatternsAndSeparators(ByteMatrix& matrix) // Left top corner. embedPositionDetectionPattern(0, 0, matrix); // Right top corner. - embedPositionDetectionPattern(matrix.getWidth() - pdpWidth, 0, matrix); + embedPositionDetectionPattern(int(matrix.getWidth()) - pdpWidth, 0, matrix); // Left bottom corner. - embedPositionDetectionPattern(0, matrix.getWidth() - pdpWidth, matrix); + embedPositionDetectionPattern(0, int(matrix.getWidth()) - pdpWidth, matrix); // Embed horizontal separation patterns around the squares. int hspWidth = 8; // Left top corner. embedHorizontalSeparationPattern(0, hspWidth - 1, matrix); // Right top corner. - embedHorizontalSeparationPattern(matrix.getWidth() - hspWidth, + embedHorizontalSeparationPattern(int(matrix.getWidth()) - hspWidth, hspWidth - 1, matrix); // Left bottom corner. - embedHorizontalSeparationPattern(0, matrix.getWidth() - hspWidth, matrix); + embedHorizontalSeparationPattern(0, int(matrix.getWidth()) - hspWidth, matrix); // Embed vertical separation patterns around the squares. int vspSize = 7; // Left top corner. embedVerticalSeparationPattern(vspSize, 0, matrix); // Right top corner. - embedVerticalSeparationPattern(matrix.getHeight() - vspSize - 1, 0, matrix); + embedVerticalSeparationPattern(int(matrix.getHeight()) - vspSize - 1, 0, matrix); // Left bottom corner. - embedVerticalSeparationPattern(vspSize, matrix.getHeight() - vspSize, + embedVerticalSeparationPattern(vspSize, int(matrix.getHeight()) - vspSize, matrix); } @@ -405,7 +405,7 @@ void MatrixUtil::maybeEmbedPositionAdjustmentPatterns(const Version& version, By continue; // If the cell is unset, we embed the position adjustment pattern here. - if (isEmpty(matrix.get(x, y))) { + if (isEmpty(matrix.get(size_t(x), size_t(y)))) { // -2 is necessary since the x/y coordinates point to the center of the pattern, not the // left top corner. embedPositionAdjustmentPattern(x - 2, y - 2, matrix); From 83e107579297f4cc136824453005465a5eb84f69 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 14:11:38 +0100 Subject: [PATCH 14/83] Fixed warning in ImageHandler::extractQImage() when QZXING_QML is not defined --- src/ImageHandler.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ImageHandler.cpp b/src/ImageHandler.cpp index 809d58f..1a26e01 100644 --- a/src/ImageHandler.cpp +++ b/src/ImageHandler.cpp @@ -29,7 +29,7 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY, QQuickItem *item = qobject_cast(imageObj); if (!item || !item->window()->isVisible()) { - qDebug() << "Item is NULL"; + qWarning() << "ImageHandler: item is NULL"; return QImage(); } @@ -52,11 +52,11 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY, QThread::yieldCurrentThread(); } img = result->image(); -#else +#else // QT_VERSION >= 0x050000 QGraphicsObject *item = qobject_cast(imageObj); if (!item) { - qDebug() << "Item is NULL"; + qWarning() << "ImageHandler: item is NULL"; return QImage(); } @@ -65,8 +65,10 @@ QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY, QPainter painter(&img); QStyleOptionGraphicsItem styleOption; item->paint(&painter, &styleOption); -#endif -#endif //defined(QZXING_QML) +#endif // QT_VERSION >= 0x050000 +#else // defined(QZXING_QML) + Q_UNUSED(imageObj); +#endif // defined(QZXING_QML) if (offsetX < 0) offsetX = 0; From d2242ac24a15d2e04eb26c1d5a19e33f277d3cad Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 14:50:45 +0100 Subject: [PATCH 15/83] Fixed XXX has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit in Exception and derived classes Enabled -Wall and -Wextra --- examples/BarcodeEncoder/BarcodeEncoder.pro | 2 + .../QMLBarcodeScanner/QMLBarcodeReader.pro | 2 + .../QZXingDragNDropTest.pro | 2 + examples/QZXingLive/QZXingLive.pro | 2 + src/QZXing.pri | 5 +++ src/QZXing.pro | 3 +- src/zxing/zxing/ChecksumException.cpp | 6 +-- src/zxing/zxing/ChecksumException.h | 7 ++-- src/zxing/zxing/Exception.cpp | 41 +++++++++++++++---- src/zxing/zxing/Exception.h | 14 +++---- src/zxing/zxing/FormatException.cpp | 2 +- src/zxing/zxing/FormatException.h | 2 +- src/zxing/zxing/IllegalStateException.cpp | 30 ++++++++++++++ src/zxing/zxing/IllegalStateException.h | 6 +-- src/zxing/zxing/NotFoundException.cpp | 30 ++++++++++++++ src/zxing/zxing/NotFoundException.h | 6 +-- src/zxing/zxing/ReaderException.cpp | 30 ++++++++++++++ src/zxing/zxing/ReaderException.h | 6 +-- .../zxing/UnsupportedEncodingException.cpp | 30 ++++++++++++++ .../zxing/UnsupportedEncodingException.h | 6 +-- src/zxing/zxing/WriterException.cpp | 30 ++++++++++++++ src/zxing/zxing/WriterException.h | 6 +-- .../zxing/common/IllegalArgumentException.cpp | 2 +- .../zxing/common/IllegalArgumentException.h | 2 +- .../reedsolomon/ReedSolomonException.cpp | 4 +- .../common/reedsolomon/ReedSolomonException.h | 4 +- .../datamatrix/detector/DetectorException.h | 2 +- 27 files changed, 231 insertions(+), 51 deletions(-) create mode 100644 src/zxing/zxing/IllegalStateException.cpp create mode 100644 src/zxing/zxing/NotFoundException.cpp create mode 100644 src/zxing/zxing/ReaderException.cpp create mode 100644 src/zxing/zxing/UnsupportedEncodingException.cpp create mode 100644 src/zxing/zxing/WriterException.cpp diff --git a/examples/BarcodeEncoder/BarcodeEncoder.pro b/examples/BarcodeEncoder/BarcodeEncoder.pro index fecd2ff..7bc3c1e 100644 --- a/examples/BarcodeEncoder/BarcodeEncoder.pro +++ b/examples/BarcodeEncoder/BarcodeEncoder.pro @@ -2,6 +2,8 @@ QT += qml quick CONFIG += c++11 qzxing_qml +gcc:QMAKE_CXXFLAGS += -Wall -Wextra + SOURCES += main.cpp RESOURCES += qml.qrc diff --git a/examples/QMLBarcodeScanner/QMLBarcodeReader.pro b/examples/QMLBarcodeScanner/QMLBarcodeReader.pro index e14e7e1..9a394d7 100644 --- a/examples/QMLBarcodeScanner/QMLBarcodeReader.pro +++ b/examples/QMLBarcodeScanner/QMLBarcodeReader.pro @@ -4,6 +4,8 @@ VERSION = 1.1.0 QT += declarative network +gcc:QMAKE_CXXFLAGS += -Wall -Wextra + !maemo5 { contains(QT_CONFIG, opengl) { # QT += opengl diff --git a/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro b/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro index 7bc5223..ab47305 100644 --- a/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro +++ b/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro @@ -7,6 +7,8 @@ QT += widgets CONFIG += qzxing_qml +gcc:QMAKE_CXXFLAGS += -Wall -Wextra + # Additional import path used to resolve QML modules in Creator's code model QML_IMPORT_PATH = diff --git a/examples/QZXingLive/QZXingLive.pro b/examples/QZXingLive/QZXingLive.pro index 2493c24..26c0054 100644 --- a/examples/QZXingLive/QZXingLive.pro +++ b/examples/QZXingLive/QZXingLive.pro @@ -2,6 +2,8 @@ TEMPLATE = app CONFIG += c++11 qzxing_multimedia +gcc:QMAKE_CXXFLAGS += -Wall -Wextra + CONFIG(debug, debug|release) { CONFIG+=qml_debug } else { diff --git a/src/QZXing.pri b/src/QZXing.pri index d100738..8a8c975 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -166,6 +166,11 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/BinaryBitmap.cpp \ $$PWD/zxing/zxing/Binarizer.cpp \ $$PWD/zxing/zxing/BarcodeFormat.cpp \ + $$PWD/zxing/zxing/ReaderException.cpp \ + $$PWD/zxing/zxing/IllegalStateException.cpp \ + $$PWD/zxing/zxing/NotFoundException.cpp \ + $$PWD/zxing/zxing/UnsupportedEncodingException.cpp \ + $$PWD/zxing/zxing/WriterException.cpp \ $$PWD/zxing/zxing/aztec/AztecReader.cpp \ $$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \ $$PWD/zxing/zxing/common/StringUtils.cpp \ diff --git a/src/QZXing.pro b/src/QZXing.pro index dc1d5f2..8cf5593 100644 --- a/src/QZXing.pro +++ b/src/QZXing.pro @@ -22,6 +22,7 @@ TARGET = QZXing TEMPLATE = lib # CONFIG += staticlib +gcc:QMAKE_CXXFLAGS += -Wall -Wextra DEFINES -= DISABLE_LIBRARY_FEATURES symbian { @@ -66,5 +67,3 @@ OTHER_FILES += \ qtc_packaging/debian_fremantle/control \ qtc_packaging/debian_fremantle/compat \ qtc_packaging/debian_fremantle/changelog - - diff --git a/src/zxing/zxing/ChecksumException.cpp b/src/zxing/zxing/ChecksumException.cpp index 4738185..b9c3c6c 100644 --- a/src/zxing/zxing/ChecksumException.cpp +++ b/src/zxing/zxing/ChecksumException.cpp @@ -23,6 +23,6 @@ using zxing::ChecksumException; -ChecksumException::ChecksumException() throw() {} -ChecksumException::ChecksumException(const char *msg) throw() : ReaderException(msg) {} -ChecksumException::~ChecksumException() throw() {} +ChecksumException::ChecksumException() noexcept {} +ChecksumException::ChecksumException(const char *msg) noexcept : ReaderException(msg) {} +ChecksumException::~ChecksumException() noexcept {} diff --git a/src/zxing/zxing/ChecksumException.h b/src/zxing/zxing/ChecksumException.h index 07e9502..5171248 100644 --- a/src/zxing/zxing/ChecksumException.h +++ b/src/zxing/zxing/ChecksumException.h @@ -23,11 +23,10 @@ namespace zxing { class ChecksumException : public ReaderException { - typedef ReaderException Base; public: - ChecksumException() throw(); - ChecksumException(const char *msg) throw(); - ~ChecksumException() throw(); + ChecksumException() noexcept; + ChecksumException(const char *msg) noexcept; + ~ChecksumException() noexcept; }; } diff --git a/src/zxing/zxing/Exception.cpp b/src/zxing/zxing/Exception.cpp index 2d912a2..2a71cd7 100644 --- a/src/zxing/zxing/Exception.cpp +++ b/src/zxing/zxing/Exception.cpp @@ -26,18 +26,41 @@ using zxing::Exception; +Exception::Exception() noexcept + : message(nullptr) { +} + +Exception::Exception(const char *msg) noexcept + : message(copy(msg)) { +} + +Exception::Exception(const zxing::Exception &that) noexcept + : std::exception(that), + message(copy(that.message)) { +} + +Exception::~Exception() noexcept { + if(message) { + deleteMessage(); + } +} + +const char *Exception::what() const noexcept { + return message ? message : ""; +} + void Exception::deleteMessage() { - delete [] message; + delete [] message; } char const* Exception::copy(char const* msg) { - char* message = 0; - if (msg) { - int l = strlen(msg)+1; - if (l) { - message = new char[l]; - strcpy(message, msg); + char* message = nullptr; + if (msg) { + auto l = strlen(msg)+1; + if (l) { + message = new char[l]; + strcpy(message, msg); + } } - } - return message; + return message; } diff --git a/src/zxing/zxing/Exception.h b/src/zxing/zxing/Exception.h index bedc469..52becaf 100644 --- a/src/zxing/zxing/Exception.h +++ b/src/zxing/zxing/Exception.h @@ -31,15 +31,11 @@ private: char const* const message; public: - Exception() throw() : message(0) {} - Exception(const char* msg) throw() : message(copy(msg)) {} - Exception(Exception const& that) throw() : std::exception(that), message(copy(that.message)) {} - ~Exception() throw() { - if(message) { - deleteMessage(); - } - } - char const* what() const throw() {return message ? message : "";} + Exception() noexcept; + Exception(const char* msg) noexcept; + Exception(Exception const& that) noexcept; + ~Exception() noexcept; + char const* what() const noexcept; private: static char const* copy(char const*); diff --git a/src/zxing/zxing/FormatException.cpp b/src/zxing/zxing/FormatException.cpp index 488b3d4..7115abb 100644 --- a/src/zxing/zxing/FormatException.cpp +++ b/src/zxing/zxing/FormatException.cpp @@ -29,7 +29,7 @@ FormatException::FormatException(const char *msg) : ReaderException(msg) { } -FormatException::~FormatException() throw() { +FormatException::~FormatException() noexcept { } FormatException const& diff --git a/src/zxing/zxing/FormatException.h b/src/zxing/zxing/FormatException.h index e0a2f10..61b846e 100644 --- a/src/zxing/zxing/FormatException.h +++ b/src/zxing/zxing/FormatException.h @@ -28,7 +28,7 @@ class FormatException : public ReaderException { public: FormatException(); FormatException(const char *msg); - ~FormatException() throw(); + ~FormatException() noexcept; static FormatException const& getFormatInstance(); }; diff --git a/src/zxing/zxing/IllegalStateException.cpp b/src/zxing/zxing/IllegalStateException.cpp new file mode 100644 index 0000000..83c23a5 --- /dev/null +++ b/src/zxing/zxing/IllegalStateException.cpp @@ -0,0 +1,30 @@ +/* + * IllegalStateException.cpp + * zxing + * + * Created by Alexander Stillich on 05/11/2018. + * Copyright 2008 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +zxing::IllegalStateException::IllegalStateException() noexcept { +} + +zxing::IllegalStateException::IllegalStateException(const char *msg) noexcept + : ReaderException(msg) { +} + +zxing::IllegalStateException::~IllegalStateException() noexcept { +} diff --git a/src/zxing/zxing/IllegalStateException.h b/src/zxing/zxing/IllegalStateException.h index dbe50f9..bbe43e2 100644 --- a/src/zxing/zxing/IllegalStateException.h +++ b/src/zxing/zxing/IllegalStateException.h @@ -25,9 +25,9 @@ namespace zxing { class IllegalStateException : public ReaderException { public: - IllegalStateException() throw() {} - IllegalStateException(const char *msg) throw() : ReaderException(msg) {} - ~IllegalStateException() throw() {} + IllegalStateException() noexcept; + IllegalStateException(const char *msg) noexcept; + ~IllegalStateException() noexcept; }; } diff --git a/src/zxing/zxing/NotFoundException.cpp b/src/zxing/zxing/NotFoundException.cpp new file mode 100644 index 0000000..f8dcc77 --- /dev/null +++ b/src/zxing/zxing/NotFoundException.cpp @@ -0,0 +1,30 @@ +/* + * IllegalStateException.cpp + * zxing + * + * Created by Alexander Stillich on 05/11/2018. + * Copyright 2008 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +zxing::NotFoundException::NotFoundException() noexcept { +} + +zxing::NotFoundException::NotFoundException(const char *msg) noexcept + : ReaderException(msg) { +} + +zxing::NotFoundException::~NotFoundException() noexcept { +} diff --git a/src/zxing/zxing/NotFoundException.h b/src/zxing/zxing/NotFoundException.h index 695ce94..bb4e923 100644 --- a/src/zxing/zxing/NotFoundException.h +++ b/src/zxing/zxing/NotFoundException.h @@ -25,9 +25,9 @@ namespace zxing { class NotFoundException : public ReaderException { public: - NotFoundException() throw() {} - NotFoundException(const char *msg) throw() : ReaderException(msg) {} - ~NotFoundException() throw() {} + NotFoundException() noexcept; + NotFoundException(const char *msg) noexcept; + ~NotFoundException() noexcept; }; } diff --git a/src/zxing/zxing/ReaderException.cpp b/src/zxing/zxing/ReaderException.cpp new file mode 100644 index 0000000..76a1cd1 --- /dev/null +++ b/src/zxing/zxing/ReaderException.cpp @@ -0,0 +1,30 @@ +/* + * ReaderException.cpp + * zxing + * + * Created by Alexander Stillich on 05/11/2018. + * Copyright 2008 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +zxing::ReaderException::ReaderException() noexcept { +} + +zxing::ReaderException::ReaderException(const char *msg) noexcept + : Exception(msg) { +} + +zxing::ReaderException::~ReaderException() noexcept { +} diff --git a/src/zxing/zxing/ReaderException.h b/src/zxing/zxing/ReaderException.h index 804dde4..64fbfa9 100644 --- a/src/zxing/zxing/ReaderException.h +++ b/src/zxing/zxing/ReaderException.h @@ -27,9 +27,9 @@ namespace zxing { class ReaderException : public Exception { public: - ReaderException() throw() {} - ReaderException(char const* msg) throw() : Exception(msg) {} - ~ReaderException() throw() {} + ReaderException() noexcept; + ReaderException(char const* msg) noexcept; + ~ReaderException() noexcept; }; } diff --git a/src/zxing/zxing/UnsupportedEncodingException.cpp b/src/zxing/zxing/UnsupportedEncodingException.cpp new file mode 100644 index 0000000..b60e1fc --- /dev/null +++ b/src/zxing/zxing/UnsupportedEncodingException.cpp @@ -0,0 +1,30 @@ +/* + * UnsupportedEncodingException.cpp + * zxing + * + * Created by Alexander Stillich on 05/11/2018. + * Copyright 2008 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +zxing::UnsupportedEncodingException::UnsupportedEncodingException() noexcept { +} + +zxing::UnsupportedEncodingException::UnsupportedEncodingException(const char *msg) noexcept + : Exception(msg) { +} + +zxing::UnsupportedEncodingException::~UnsupportedEncodingException() noexcept { +} diff --git a/src/zxing/zxing/UnsupportedEncodingException.h b/src/zxing/zxing/UnsupportedEncodingException.h index cde702e..c3a3d14 100644 --- a/src/zxing/zxing/UnsupportedEncodingException.h +++ b/src/zxing/zxing/UnsupportedEncodingException.h @@ -7,9 +7,9 @@ namespace zxing { class UnsupportedEncodingException : public Exception { public: - UnsupportedEncodingException() throw() {} - UnsupportedEncodingException(char const* msg) throw() : Exception(msg) {} - ~UnsupportedEncodingException() throw() {} + UnsupportedEncodingException() noexcept; + UnsupportedEncodingException(char const* msg) noexcept; + ~UnsupportedEncodingException() noexcept; }; } diff --git a/src/zxing/zxing/WriterException.cpp b/src/zxing/zxing/WriterException.cpp new file mode 100644 index 0000000..1d6560f --- /dev/null +++ b/src/zxing/zxing/WriterException.cpp @@ -0,0 +1,30 @@ +/* + * UnsupportedEncodingException.cpp + * zxing + * + * Created by Alexander Stillich on 05/11/2018. + * Copyright 2008 ZXing authors All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +zxing::WriterException::WriterException() noexcept { +} + +zxing::WriterException::WriterException(const char *msg) noexcept + : Exception(msg) { +} + +zxing::WriterException::~WriterException() noexcept { +} diff --git a/src/zxing/zxing/WriterException.h b/src/zxing/zxing/WriterException.h index c511c8e..cfd5308 100644 --- a/src/zxing/zxing/WriterException.h +++ b/src/zxing/zxing/WriterException.h @@ -7,9 +7,9 @@ namespace zxing { class WriterException : public Exception { public: - WriterException() throw() {} - WriterException(char const* msg) throw() : Exception(msg) {} - ~WriterException() throw() {} + WriterException() noexcept; + WriterException(char const* msg) noexcept; + ~WriterException() noexcept; }; } diff --git a/src/zxing/zxing/common/IllegalArgumentException.cpp b/src/zxing/zxing/common/IllegalArgumentException.cpp index 45c1fa1..3e372c9 100644 --- a/src/zxing/zxing/common/IllegalArgumentException.cpp +++ b/src/zxing/zxing/common/IllegalArgumentException.cpp @@ -24,4 +24,4 @@ using zxing::IllegalArgumentException; IllegalArgumentException::IllegalArgumentException() : Exception() {} IllegalArgumentException::IllegalArgumentException(const char *msg) : Exception(msg) {} -IllegalArgumentException::~IllegalArgumentException() throw() {} +IllegalArgumentException::~IllegalArgumentException() noexcept {} diff --git a/src/zxing/zxing/common/IllegalArgumentException.h b/src/zxing/zxing/common/IllegalArgumentException.h index 4a74b6b..e6c95df 100644 --- a/src/zxing/zxing/common/IllegalArgumentException.h +++ b/src/zxing/zxing/common/IllegalArgumentException.h @@ -28,7 +28,7 @@ class IllegalArgumentException : public Exception { public: IllegalArgumentException(); IllegalArgumentException(const char *msg); - ~IllegalArgumentException() throw(); + ~IllegalArgumentException() noexcept; }; } diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp index 20af025..87367c3 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp @@ -21,10 +21,10 @@ #include namespace zxing { -ReedSolomonException::ReedSolomonException(const char *msg) throw() : +ReedSolomonException::ReedSolomonException(const char *msg) noexcept : Exception(msg) { } -ReedSolomonException::~ReedSolomonException() throw() { +ReedSolomonException::~ReedSolomonException() noexcept { } } diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h index b707b6d..b98adbd 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h @@ -25,8 +25,8 @@ namespace zxing { class ReedSolomonException : public Exception { public: - ReedSolomonException(const char *msg) throw(); - ~ReedSolomonException() throw(); + ReedSolomonException(const char *msg) noexcept; + ~ReedSolomonException() noexcept; }; } diff --git a/src/zxing/zxing/datamatrix/detector/DetectorException.h b/src/zxing/zxing/datamatrix/detector/DetectorException.h index 8002ac9..ddc5eba 100644 --- a/src/zxing/zxing/datamatrix/detector/DetectorException.h +++ b/src/zxing/zxing/datamatrix/detector/DetectorException.h @@ -16,7 +16,7 @@ namespace datamatrix { class DetectorException : public Exception { public: DetectorException(const char *msg); - virtual ~DetectorException() throw(); + virtual ~DetectorException() noexcept; }; } /* namespace nexxera */ } /* namespace zxing */ From 230a796a281e4b820324d118eb97ec72c60fb3a7 Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Mon, 5 Nov 2018 16:05:59 +0200 Subject: [PATCH 16/83] changing 'byte' references to 'zxing::byte'. Triggered by #90. --- src/CameraImageWrapper.cpp | 28 +++++------ src/CameraImageWrapper.h | 14 +++--- src/zxing/zxing/InvertedLuminanceSource.cpp | 12 ++--- src/zxing/zxing/InvertedLuminanceSource.h | 4 +- src/zxing/zxing/LuminanceSource.cpp | 2 +- src/zxing/zxing/LuminanceSource.h | 4 +- src/zxing/zxing/Result.cpp | 4 +- src/zxing/zxing/Result.h | 6 +-- .../zxing/aztec/decoder/AztecDecoder.cpp | 4 +- src/zxing/zxing/common/BitArray.cpp | 4 +- src/zxing/zxing/common/BitArray.h | 2 +- src/zxing/zxing/common/BitSource.h | 4 +- src/zxing/zxing/common/DecoderResult.cpp | 6 +-- src/zxing/zxing/common/DecoderResult.h | 12 ++--- .../zxing/common/GlobalHistogramBinarizer.cpp | 10 ++-- .../zxing/common/GlobalHistogramBinarizer.h | 2 +- .../zxing/common/GreyscaleLuminanceSource.cpp | 10 ++-- .../zxing/common/GreyscaleLuminanceSource.h | 8 ++-- .../GreyscaleRotatedLuminanceSource.cpp | 12 ++--- .../common/GreyscaleRotatedLuminanceSource.h | 8 ++-- src/zxing/zxing/common/HybridBinarizer.cpp | 8 ++-- src/zxing/zxing/common/HybridBinarizer.h | 6 +-- src/zxing/zxing/common/StringUtils.cpp | 6 +-- src/zxing/zxing/common/StringUtils.h | 2 +- .../common/reedsolomon/ReedSolomonEncoder.cpp | 2 +- .../common/reedsolomon/ReedSolomonEncoder.h | 2 +- .../datamatrix/decoder/BitMatrixParser.h | 2 +- .../zxing/datamatrix/decoder/DataBlock.h | 8 ++-- .../decoder/DataMatrixBitMatrixParser.cpp | 16 +++---- .../decoder/DataMatrixDataBlock.cpp | 8 ++-- .../DataMatrixDecodedBitStreamParser.cpp | 48 +++++++++---------- .../datamatrix/decoder/DataMatrixDecoder.cpp | 10 ++-- .../decoder/DecodedBitStreamParser.h | 6 +-- src/zxing/zxing/datamatrix/decoder/Decoder.h | 2 +- src/zxing/zxing/oned/CodaBarReader.cpp | 4 +- src/zxing/zxing/oned/Code128Reader.cpp | 22 ++++----- src/zxing/zxing/oned/Code39Reader.cpp | 12 ++--- src/zxing/zxing/oned/Code93Reader.cpp | 12 ++--- src/zxing/zxing/oned/EAN13Reader.cpp | 6 +-- src/zxing/zxing/oned/EAN8Reader.cpp | 4 +- src/zxing/zxing/oned/ITFReader.cpp | 6 +-- src/zxing/zxing/oned/UPCEANReader.cpp | 2 +- src/zxing/zxing/oned/UPCEReader.cpp | 6 +-- .../decoder/PDF417DecodedBitStreamParser.cpp | 28 +++++------ .../zxing/qrcode/QRFormatInformation.cpp | 2 +- .../zxing/qrcode/decoder/BitMatrixParser.h | 2 +- src/zxing/zxing/qrcode/decoder/DataBlock.h | 8 ++-- .../qrcode/decoder/DecodedBitStreamParser.h | 6 +-- src/zxing/zxing/qrcode/decoder/Decoder.h | 2 +- .../qrcode/decoder/QRBitMatrixParser.cpp | 6 +-- .../zxing/qrcode/decoder/QRDataBlock.cpp | 8 ++-- .../decoder/QRDecodedBitStreamParser.cpp | 24 +++++----- src/zxing/zxing/qrcode/decoder/QRDecoder.cpp | 12 ++--- src/zxing/zxing/qrcode/encoder/BlockPair.h | 10 ++-- src/zxing/zxing/qrcode/encoder/ByteMatrix.cpp | 12 ++--- src/zxing/zxing/qrcode/encoder/ByteMatrix.h | 10 ++-- src/zxing/zxing/qrcode/encoder/Encoder.h | 2 +- src/zxing/zxing/qrcode/encoder/MaskUtil.cpp | 18 +++---- src/zxing/zxing/qrcode/encoder/MaskUtil.h | 4 +- src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp | 14 +++--- src/zxing/zxing/qrcode/encoder/MatrixUtil.h | 2 +- src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 18 +++---- 62 files changed, 272 insertions(+), 272 deletions(-) diff --git a/src/CameraImageWrapper.cpp b/src/CameraImageWrapper.cpp index 659351a..6c15248 100644 --- a/src/CameraImageWrapper.cpp +++ b/src/CameraImageWrapper.cpp @@ -3,7 +3,7 @@ //values based on http://entropymine.com/imageworsener/grayscale/ //round(0,2127*R) -const byte CameraImageWrapper::R_TO_GREYSCALE[256] = { +const zxing::byte CameraImageWrapper::R_TO_GREYSCALE[256] = { 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13, @@ -22,7 +22,7 @@ const byte CameraImageWrapper::R_TO_GREYSCALE[256] = { //values based on http://entropymine.com/imageworsener/grayscale/ //round(0,7152*G) -const byte CameraImageWrapper::G_TO_GREYSCALE[256] = { +const zxing::byte CameraImageWrapper::G_TO_GREYSCALE[256] = { 0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 18, 19, 19, 20, 21, 21, 22, 23, 24, 24, 25, 26, 26, 27, 28, 29, 29, 30, 31, 31, 32, 33, 34, 34, 35, @@ -44,7 +44,7 @@ const byte CameraImageWrapper::G_TO_GREYSCALE[256] = { //values based on http://entropymine.com/imageworsener/grayscale/ //round(0,0722*B) -const byte CameraImageWrapper::B_TO_GREYSCALE[256] = { +const zxing::byte CameraImageWrapper::B_TO_GREYSCALE[256] = { 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, @@ -101,12 +101,12 @@ CameraImageWrapper *CameraImageWrapper::Factory(const QImage &sourceImage, int m return new CameraImageWrapper(sourceImage); } -ArrayRef > CameraImageWrapper::getOriginalImage() +ArrayRef > CameraImageWrapper::getOriginalImage() { return imageBytesPerRow; } -ArrayRef CameraImageWrapper::getRow(int y, ArrayRef row) const +ArrayRef CameraImageWrapper::getRow(int y, ArrayRef row) const { if(delegate) return delegate->getRow(y, row); @@ -114,7 +114,7 @@ ArrayRef CameraImageWrapper::getRow(int y, ArrayRef row) const return getRowP(y, row); } -ArrayRef CameraImageWrapper::getMatrix() const +ArrayRef CameraImageWrapper::getMatrix() const { if(delegate) return delegate->getMatrix(); @@ -162,19 +162,19 @@ Ref CameraImageWrapper::rotateCounterClockwise() const return LuminanceSource::rotateCounterClockwise(); } -ArrayRef CameraImageWrapper::getRowP(int y, ArrayRef row) const +ArrayRef CameraImageWrapper::getRowP(int y, ArrayRef row) const { int width = getWidth(); if (row->size() != width) - row.reset(ArrayRef(width)); + row.reset(ArrayRef(width)); Q_ASSERT(y >= 0 && y < getHeight()); return imageBytesPerRow[y]; } -ArrayRef CameraImageWrapper::getMatrixP() const +ArrayRef CameraImageWrapper::getMatrixP() const { return imageBytes; } @@ -190,18 +190,18 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin) bool needsConvesionToGrayscale = origin.format() != QImage::Format_Grayscale8; QRgb pixel; - byte pixelGrayscale; + zxing::byte pixelGrayscale; const int width = getWidth(); const int height = getHeight(); - imageBytes = ArrayRef(height*width); - imageBytesPerRow = ArrayRef>(height); + imageBytes = ArrayRef(height*width); + imageBytesPerRow = ArrayRef>(height); byte* m = &imageBytes[0]; for(int j=0; j line(width); + ArrayRef line(width); for(int i=0; i > getOriginalImage(); + ArrayRef > getOriginalImage(); Ref getDelegate() { return delegate; } ArrayRef getRow(int y, ArrayRef row) const; @@ -45,7 +45,7 @@ public: Ref invert() const; Ref rotateCounterClockwise() const; - inline byte gray(unsigned int r, unsigned int g, unsigned int b); + inline zxing::byte gray(unsigned int r, unsigned int g, unsigned int b); private: ArrayRef getRowP(int y, ArrayRef row) const; @@ -53,12 +53,12 @@ private: void updateImageAsGrayscale(const QImage &origin); Ref delegate; - ArrayRef> imageBytesPerRow; - ArrayRef imageBytes; + ArrayRef> imageBytesPerRow; + ArrayRef imageBytes; - static const byte B_TO_GREYSCALE[256]; - static const byte G_TO_GREYSCALE[256]; - static const byte R_TO_GREYSCALE[256]; + static const zxing::byte B_TO_GREYSCALE[256]; + static const zxing::byte G_TO_GREYSCALE[256]; + static const zxing::byte R_TO_GREYSCALE[256]; }; #endif //CAMERAIMAGE_H diff --git a/src/zxing/zxing/InvertedLuminanceSource.cpp b/src/zxing/zxing/InvertedLuminanceSource.cpp index 70428d8..859327d 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.cpp +++ b/src/zxing/zxing/InvertedLuminanceSource.cpp @@ -28,21 +28,21 @@ namespace zxing { InvertedLuminanceSource::InvertedLuminanceSource(Ref const& delegate_) : Super(delegate_->getWidth(), delegate_->getHeight()), delegate(delegate_) {} -ArrayRef InvertedLuminanceSource::getRow(int y, ArrayRef row) const { +ArrayRef InvertedLuminanceSource::getRow(int y, ArrayRef row) const { row = delegate->getRow(y, row); int width = getWidth(); for (int i = 0; i < width; i++) { - row[i] = (byte) (255 - (row[i] & 0xFF)); + row[i] = (zxing::byte) (255 - (row[i] & 0xFF)); } return row; } -ArrayRef InvertedLuminanceSource::getMatrix() const { - ArrayRef matrix = delegate->getMatrix(); +ArrayRef InvertedLuminanceSource::getMatrix() const { + ArrayRef matrix = delegate->getMatrix(); int length = getWidth() * getHeight(); - ArrayRef invertedMatrix(length); + ArrayRef invertedMatrix(length); for (int i = 0; i < length; i++) { - invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF)); + invertedMatrix[i] = (zxing::byte) (255 - (matrix[i] & 0xFF)); } return invertedMatrix; } diff --git a/src/zxing/zxing/InvertedLuminanceSource.h b/src/zxing/zxing/InvertedLuminanceSource.h index a3f7fbe..51dbd03 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.h +++ b/src/zxing/zxing/InvertedLuminanceSource.h @@ -30,8 +30,8 @@ private: public: InvertedLuminanceSource(Ref const&); - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; boolean isCropSupported() const; Ref crop(int left, int top, int width, int height) const; diff --git a/src/zxing/zxing/LuminanceSource.cpp b/src/zxing/zxing/LuminanceSource.cpp index 04dc420..1553ced 100644 --- a/src/zxing/zxing/LuminanceSource.cpp +++ b/src/zxing/zxing/LuminanceSource.cpp @@ -52,7 +52,7 @@ Ref LuminanceSource::rotateCounterClockwise45() const } LuminanceSource::operator std::string() const { - ArrayRef row; + ArrayRef row; std::ostringstream oss; for (int y = 0; y < getHeight(); y++) { row = getRow(y, row); diff --git a/src/zxing/zxing/LuminanceSource.h b/src/zxing/zxing/LuminanceSource.h index dfe4051..3fe3443 100644 --- a/src/zxing/zxing/LuminanceSource.h +++ b/src/zxing/zxing/LuminanceSource.h @@ -40,8 +40,8 @@ class LuminanceSource : public Counted { int getHeight() const { return height; } // Callers take ownership of the returned memory and must call delete [] on it themselves. - virtual ArrayRef getRow(int y, ArrayRef row) const = 0; - virtual ArrayRef getMatrix() const = 0; + virtual ArrayRef getRow(int y, ArrayRef row) const = 0; + virtual ArrayRef getMatrix() const = 0; virtual bool isCropSupported() const; virtual Ref crop(int left, int top, int width, int height) const; diff --git a/src/zxing/zxing/Result.cpp b/src/zxing/zxing/Result.cpp index 8bf2ad0..8f66edb 100644 --- a/src/zxing/zxing/Result.cpp +++ b/src/zxing/zxing/Result.cpp @@ -33,7 +33,7 @@ using zxing::BarcodeFormat; namespace zxing { Result::Result(Ref text, - ArrayRef rawBytes, + ArrayRef rawBytes, ArrayRef< Ref > resultPoints, BarcodeFormat format, std::string charSet) : text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet) { @@ -46,7 +46,7 @@ Ref Result::getText() { return text_; } -ArrayRef Result::getRawBytes() { +ArrayRef Result::getRawBytes() { return rawBytes_; } diff --git a/src/zxing/zxing/Result.h b/src/zxing/zxing/Result.h index c5ee04c..7ff7eb9 100644 --- a/src/zxing/zxing/Result.h +++ b/src/zxing/zxing/Result.h @@ -33,19 +33,19 @@ namespace zxing { class Result : public Counted { private: Ref text_; - ArrayRef rawBytes_; + ArrayRef rawBytes_; ArrayRef< Ref > resultPoints_; BarcodeFormat format_; std::string charSet_; public: Result(Ref text, - ArrayRef rawBytes, + ArrayRef rawBytes, ArrayRef< Ref > resultPoints, BarcodeFormat format, std::string charSet = ""); ~Result(); Ref getText(); - ArrayRef getRawBytes(); + ArrayRef getRawBytes(); ArrayRef< Ref > const& getResultPoints() const; ArrayRef< Ref >& getResultPoints(); BarcodeFormat getBarcodeFormat() const; diff --git a/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp b/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp index 441c35e..1939dcd 100644 --- a/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp +++ b/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp @@ -171,9 +171,9 @@ Ref Decoder::decode(Ref detect Ref result = getEncodedData(aCorrectedBits); // std::printf("constructing array\n"); - ArrayRef arrayOut(aCorrectedBits->getSize()); + ArrayRef arrayOut(aCorrectedBits->getSize()); for (int i = 0; i < aCorrectedBits->count(); i++) { - arrayOut[i] = (byte)aCorrectedBits->get(i); + arrayOut[i] = (zxing::byte)aCorrectedBits->get(i); } // std::printf("returning\n"); diff --git a/src/zxing/zxing/common/BitArray.cpp b/src/zxing/zxing/common/BitArray.cpp index 55bfec3..5c73f41 100644 --- a/src/zxing/zxing/common/BitArray.cpp +++ b/src/zxing/zxing/common/BitArray.cpp @@ -261,7 +261,7 @@ void BitArray::xor_(const BitArray& other) } } -void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const +void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const { if(array.size() < (numBytes + offset)) array.resize(numBytes + offset); @@ -274,7 +274,7 @@ void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int } bitOffset++; } - array[offset + i] = (byte) theByte; + array[offset + i] = (zxing::byte) theByte; } } diff --git a/src/zxing/zxing/common/BitArray.h b/src/zxing/zxing/common/BitArray.h index f7e57dc..7375a9e 100644 --- a/src/zxing/zxing/common/BitArray.h +++ b/src/zxing/zxing/common/BitArray.h @@ -74,7 +74,7 @@ public: void xor_(const BitArray& other); - void toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const; + void toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const; const std::string toString() const; diff --git a/src/zxing/zxing/common/BitSource.h b/src/zxing/zxing/common/BitSource.h index fb3d930..4aac591 100644 --- a/src/zxing/zxing/common/BitSource.h +++ b/src/zxing/zxing/common/BitSource.h @@ -35,7 +35,7 @@ namespace zxing { */ class BitSource : public Counted { private: - ArrayRef bytes_; + ArrayRef bytes_; int byteOffset_; int bitOffset_; public: @@ -43,7 +43,7 @@ public: * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. * Bits are read within a byte from most-significant to least-significant bit. */ - BitSource(ArrayRef &bytes) : + BitSource(ArrayRef &bytes) : bytes_(bytes), byteOffset_(0), bitOffset_(0) { } diff --git a/src/zxing/zxing/common/DecoderResult.cpp b/src/zxing/zxing/common/DecoderResult.cpp index 6090ff7..e774df1 100644 --- a/src/zxing/zxing/common/DecoderResult.cpp +++ b/src/zxing/zxing/common/DecoderResult.cpp @@ -24,16 +24,16 @@ using namespace std; using namespace zxing; -DecoderResult::DecoderResult(ArrayRef rawBytes, +DecoderResult::DecoderResult(ArrayRef rawBytes, Ref text, - ArrayRef< ArrayRef >& byteSegments, + ArrayRef< ArrayRef >& byteSegments, string const& ecLevel, string charSet) : rawBytes_(rawBytes), text_(text), byteSegments_(byteSegments), ecLevel_(ecLevel), charSet_(charSet) {} -DecoderResult::DecoderResult(ArrayRef rawBytes, +DecoderResult::DecoderResult(ArrayRef rawBytes, Ref text) : rawBytes_(rawBytes), text_(text),charSet_("") {} diff --git a/src/zxing/zxing/common/DecoderResult.h b/src/zxing/zxing/common/DecoderResult.h index a31e5f1..2168fe0 100644 --- a/src/zxing/zxing/common/DecoderResult.h +++ b/src/zxing/zxing/common/DecoderResult.h @@ -30,22 +30,22 @@ namespace zxing { class DecoderResult : public Counted { private: - ArrayRef rawBytes_; + ArrayRef rawBytes_; Ref text_; - ArrayRef< ArrayRef > byteSegments_; + ArrayRef< ArrayRef > byteSegments_; std::string ecLevel_; std::string charSet_; public: - DecoderResult(ArrayRef rawBytes, + DecoderResult(ArrayRef rawBytes, Ref text, - ArrayRef< ArrayRef >& byteSegments, + ArrayRef< ArrayRef >& byteSegments, std::string const& ecLevel, std::string charSet = ""); - DecoderResult(ArrayRef rawBytes, Ref text); + DecoderResult(ArrayRef rawBytes, Ref text); - ArrayRef getRawBytes(); + ArrayRef getRawBytes(); Ref getText(); std::string charSet(); }; diff --git a/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp b/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp index 4073731..e181d17 100644 --- a/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp +++ b/src/zxing/zxing/common/GlobalHistogramBinarizer.cpp @@ -36,7 +36,7 @@ namespace zxing { const int LUMINANCE_BITS = 5; const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; -const ArrayRef EMPTY (0); +const ArrayRef EMPTY (0); GlobalHistogramBinarizer::GlobalHistogramBinarizer(Ref source) : Binarizer(source), luminances(EMPTY), buckets(LUMINANCE_BUCKETS) {} @@ -45,7 +45,7 @@ GlobalHistogramBinarizer::~GlobalHistogramBinarizer() {} void GlobalHistogramBinarizer::initArrays(int luminanceSize) { if (luminances->size() < luminanceSize) { - luminances = ArrayRef(luminanceSize); + luminances = ArrayRef(luminanceSize); } // for (int x = 0; x < LUMINANCE_BUCKETS; x++) { // buckets[x] = 0; @@ -64,7 +64,7 @@ Ref GlobalHistogramBinarizer::getBlackRow(int y, Ref row) { } initArrays(width); - ArrayRef localLuminances = source.getRow(y, luminances); + ArrayRef localLuminances = source.getRow(y, luminances); if (false) { std::cerr << "gbr " << y << " r "; for(int i=0, e=localLuminances->size(); i < e; ++i) { @@ -108,7 +108,7 @@ Ref GlobalHistogramBinarizer::getBlackMatrix() { ArrayRef localBuckets = buckets; for (int y = 1; y < 5; y++) { int row = height * y / 5; - ArrayRef localLuminances = source.getRow(row, luminances); + ArrayRef localLuminances = source.getRow(row, luminances); int right = (width << 2) / 5; for (int x = width / 5; x < right; x++) { int pixel = localLuminances[x] & 0xff; @@ -118,7 +118,7 @@ Ref GlobalHistogramBinarizer::getBlackMatrix() { int blackPoint = estimateBlackPoint(localBuckets); - ArrayRef localLuminances = source.getMatrix(); + ArrayRef localLuminances = source.getMatrix(); for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { diff --git a/src/zxing/zxing/common/GlobalHistogramBinarizer.h b/src/zxing/zxing/common/GlobalHistogramBinarizer.h index e60e7fc..778945b 100644 --- a/src/zxing/zxing/common/GlobalHistogramBinarizer.h +++ b/src/zxing/zxing/common/GlobalHistogramBinarizer.h @@ -29,7 +29,7 @@ namespace zxing { class GlobalHistogramBinarizer : public Binarizer { private: - ArrayRef luminances; + ArrayRef luminances; ArrayRef buckets; public: GlobalHistogramBinarizer(Ref source); diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp index 9ba8daa..001e6c0 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.cpp @@ -29,7 +29,7 @@ using zxing::LuminanceSource; namespace zxing { GreyscaleLuminanceSource:: -GreyscaleLuminanceSource(ArrayRef greyData, +GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height) @@ -43,13 +43,13 @@ GreyscaleLuminanceSource(ArrayRef greyData, } } -ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef row) const { +ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef row) const { if (y < 0 || y >= this->getHeight()) { throw IllegalArgumentException("Requested row is outside the image."); } int width = getWidth(); if (!row || row->size() < width) { - ArrayRef temp (width); + ArrayRef temp (width); row = temp; } int offset = (y + top_) * dataWidth_ + left_; @@ -57,12 +57,12 @@ ArrayRef GreyscaleLuminanceSource::getRow(int y, ArrayRef row) const return row; } -ArrayRef GreyscaleLuminanceSource::getMatrix() const { +ArrayRef GreyscaleLuminanceSource::getMatrix() const { if (left_ == 0 && top_ == 0 && dataWidth_ == getWidth() && dataHeight_ == getHeight()) { return greyData_; } else { int size = getWidth() * getHeight(); - ArrayRef result (size); + ArrayRef result (size); for (int row = 0; row < getHeight(); row++) { memcpy(&result[row * getWidth()], &greyData_[(top_ + row) * dataWidth_ + left_], getWidth()); } diff --git a/src/zxing/zxing/common/GreyscaleLuminanceSource.h b/src/zxing/zxing/common/GreyscaleLuminanceSource.h index 20ae936..aae1a00 100644 --- a/src/zxing/zxing/common/GreyscaleLuminanceSource.h +++ b/src/zxing/zxing/common/GreyscaleLuminanceSource.h @@ -28,18 +28,18 @@ class GreyscaleLuminanceSource : public LuminanceSource { private: typedef LuminanceSource Super; - ArrayRef greyData_; + ArrayRef greyData_; const int dataWidth_; const int dataHeight_; const int left_; const int top_; public: - GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, + GreyscaleLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height); - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; bool isRotateSupported() const { return true; diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp index ceed28d..2ef3e12 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp @@ -30,7 +30,7 @@ namespace zxing { // be able to traverse the greyData correctly, which does not get // rotated. GreyscaleRotatedLuminanceSource:: -GreyscaleRotatedLuminanceSource(ArrayRef greyData, +GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height) @@ -45,13 +45,13 @@ GreyscaleRotatedLuminanceSource(ArrayRef greyData, } // The API asks for rows, but we're rotated, so we return columns. -ArrayRef -GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const { +ArrayRef +GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const { if (y < 0 || y >= getHeight()) { throw IllegalArgumentException("Requested row is outside the image."); } if (!row || row->size() < getWidth()) { - row = ArrayRef(getWidth()); + row = ArrayRef(getWidth()); } int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_)); using namespace std; @@ -68,8 +68,8 @@ GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const { return row; } -ArrayRef GreyscaleRotatedLuminanceSource::getMatrix() const { - ArrayRef result (getWidth() * getHeight()); +ArrayRef GreyscaleRotatedLuminanceSource::getMatrix() const { + ArrayRef result (getWidth() * getHeight()); for (int y = 0; y < getHeight(); y++) { byte* row = &result[y * getWidth()]; int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_)); diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h index 2ef8287..a97834c 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.h @@ -28,17 +28,17 @@ namespace zxing { class GreyscaleRotatedLuminanceSource : public LuminanceSource { private: typedef LuminanceSource Super; - ArrayRef greyData_; + ArrayRef greyData_; const int dataWidth_; const int left_; const int top_; public: - GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, + GreyscaleRotatedLuminanceSource(ArrayRef greyData, int dataWidth, int dataHeight, int left, int top, int width, int height); - ArrayRef getRow(int y, ArrayRef row) const; - ArrayRef getMatrix() const; + ArrayRef getRow(int y, ArrayRef row) const; + ArrayRef getMatrix() const; }; } diff --git a/src/zxing/zxing/common/HybridBinarizer.cpp b/src/zxing/zxing/common/HybridBinarizer.cpp index 060c715..26d4b5e 100644 --- a/src/zxing/zxing/common/HybridBinarizer.cpp +++ b/src/zxing/zxing/common/HybridBinarizer.cpp @@ -59,7 +59,7 @@ Ref HybridBinarizer::getBlackMatrix() { int width = source.getWidth(); int height = source.getHeight(); if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) { - ArrayRef luminances = source.getMatrix(); + ArrayRef luminances = source.getMatrix(); int subWidth = width >> BLOCK_SIZE_POWER; if ((width & BLOCK_SIZE_MASK) != 0) { subWidth++; @@ -94,7 +94,7 @@ namespace { } void -HybridBinarizer::calculateThresholdForBlock(ArrayRef luminances, +HybridBinarizer::calculateThresholdForBlock(ArrayRef luminances, int subWidth, int subHeight, int width, @@ -130,7 +130,7 @@ HybridBinarizer::calculateThresholdForBlock(ArrayRef luminances, } } -void HybridBinarizer::thresholdBlock(ArrayRef luminances, +void HybridBinarizer::thresholdBlock(ArrayRef luminances, int xoffset, int yoffset, int threshold, @@ -157,7 +157,7 @@ namespace { } -ArrayRef HybridBinarizer::calculateBlackPoints(ArrayRef luminances, +ArrayRef HybridBinarizer::calculateBlackPoints(ArrayRef luminances, int subWidth, int subHeight, int width, diff --git a/src/zxing/zxing/common/HybridBinarizer.h b/src/zxing/zxing/common/HybridBinarizer.h index b85c4b0..f3bbb70 100644 --- a/src/zxing/zxing/common/HybridBinarizer.h +++ b/src/zxing/zxing/common/HybridBinarizer.h @@ -42,19 +42,19 @@ namespace zxing { private: // We'll be using one-D arrays because C++ can't dynamically allocate 2D // arrays - ArrayRef calculateBlackPoints(ArrayRef luminances, + ArrayRef calculateBlackPoints(ArrayRef luminances, int subWidth, int subHeight, int width, int height); - void calculateThresholdForBlock(ArrayRef luminances, + void calculateThresholdForBlock(ArrayRef luminances, int subWidth, int subHeight, int width, int height, ArrayRef blackPoints, Ref const& matrix); - void thresholdBlock(ArrayRefluminances, + void thresholdBlock(ArrayRefluminances, int xoffset, int yoffset, int threshold, diff --git a/src/zxing/zxing/common/StringUtils.cpp b/src/zxing/zxing/common/StringUtils.cpp index e36f6d5..e894765 100644 --- a/src/zxing/zxing/common/StringUtils.cpp +++ b/src/zxing/zxing/common/StringUtils.cpp @@ -67,9 +67,9 @@ StringUtils::guessEncoding(byte* bytes, int length, typedef byte byte; boolean utf8bom = length > 3 && - bytes[0] == (byte) 0xEF && - bytes[1] == (byte) 0xBB && - bytes[2] == (byte) 0xBF; + bytes[0] == (zxing::byte) 0xEF && + bytes[1] == (zxing::byte) 0xBB && + bytes[2] == (zxing::byte) 0xBF; for (int i = 0; i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8); diff --git a/src/zxing/zxing/common/StringUtils.h b/src/zxing/zxing/common/StringUtils.h index 703e699..743ecfa 100644 --- a/src/zxing/zxing/common/StringUtils.h +++ b/src/zxing/zxing/common/StringUtils.h @@ -44,7 +44,7 @@ public: typedef std::map Hashtable; - static std::string guessEncoding(byte *bytes, int length, Hashtable const& hints); + static std::string guessEncoding(zxing::byte *bytes, int length, Hashtable const& hints); static std::string intToStr(int number); }; diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp index 85fa1e9..52a2de7 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp @@ -33,7 +33,7 @@ Ref ReedSolomonEncoder::buildGenerator(int degree) return cachedGenerators_.at(degree); // ??? wont this through exception? } -void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) +void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) { if (ecBytes == 0) { throw Exception("No error correction bytes"); diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h index f8edaf0..adca21f 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h @@ -19,7 +19,7 @@ private: public: ReedSolomonEncoder(Ref field); - void encode(std::vector &toEncode, int ecBytes); + void encode(std::vector &toEncode, int ecBytes); }; } diff --git a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h index 37c4514..5a1549a 100644 --- a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h @@ -41,7 +41,7 @@ private: public: BitMatrixParser(Ref bitMatrix); Ref readVersion(Ref bitMatrix); - ArrayRef readCodewords(); + ArrayRef readCodewords(); bool readModule(int row, int column, int numRows, int numColumns); private: diff --git a/src/zxing/zxing/datamatrix/decoder/DataBlock.h b/src/zxing/zxing/datamatrix/decoder/DataBlock.h index 9ff8dc3..c735355 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataBlock.h +++ b/src/zxing/zxing/datamatrix/decoder/DataBlock.h @@ -32,15 +32,15 @@ namespace datamatrix { class DataBlock : public Counted { private: int numDataCodewords_; - ArrayRef codewords_; + ArrayRef codewords_; - DataBlock(int numDataCodewords, ArrayRef codewords); + DataBlock(int numDataCodewords, ArrayRef codewords); public: - static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version); + static std::vector > getDataBlocks(ArrayRef rawCodewords, Version *version); int getNumDataCodewords(); - ArrayRef getCodewords(); + ArrayRef getCodewords(); }; } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp index 37b242e..87dc4b1 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp @@ -57,8 +57,8 @@ Ref BitMatrixParser::readVersion(Ref bitMatrix) { throw ReaderException("Couldn't decode version"); } -ArrayRef BitMatrixParser::readCodewords() { - ArrayRef result(parsedVersion_->getTotalCodewords()); +ArrayRef BitMatrixParser::readCodewords() { + ArrayRef result(parsedVersion_->getTotalCodewords()); int resultOffset = 0; int row = 4; int column = 0; @@ -75,22 +75,22 @@ ArrayRef BitMatrixParser::readCodewords() { do { // Check the four corner cases if ((row == numRows) && (column == 0) && !corner1Read) { - result[resultOffset++] = (byte) readCorner1(numRows, numColumns); + result[resultOffset++] = (zxing::byte) readCorner1(numRows, numColumns); row -= 2; column +=2; corner1Read = true; } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) { - result[resultOffset++] = (byte) readCorner2(numRows, numColumns); + result[resultOffset++] = (zxing::byte) readCorner2(numRows, numColumns); row -= 2; column +=2; corner2Read = true; } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) { - result[resultOffset++] = (byte) readCorner3(numRows, numColumns); + result[resultOffset++] = (zxing::byte) readCorner3(numRows, numColumns); row -= 2; column +=2; corner3Read = true; } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) { - result[resultOffset++] = (byte) readCorner4(numRows, numColumns); + result[resultOffset++] = (zxing::byte) readCorner4(numRows, numColumns); row -= 2; column +=2; corner4Read = true; @@ -98,7 +98,7 @@ ArrayRef BitMatrixParser::readCodewords() { // Sweep upward diagonally to the right do { if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) { - result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); + result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns); } row -= 2; column +=2; @@ -109,7 +109,7 @@ ArrayRef BitMatrixParser::readCodewords() { // Sweep downward diagonally to the left do { if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) { - result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns); + result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns); } row += 2; column -=2; diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp index 474fd48..7787272 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp @@ -26,7 +26,7 @@ namespace datamatrix { using namespace std; -DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : +DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : numDataCodewords_(numDataCodewords), codewords_(codewords) { } @@ -34,11 +34,11 @@ int DataBlock::getNumDataCodewords() { return numDataCodewords_; } -ArrayRef DataBlock::getCodewords() { +ArrayRef DataBlock::getCodewords() { return codewords_; } -std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version) { +std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version) { // Figure out the number and size of data blocks used by this version and // error correction level ECBlocks* ecBlocks = version->getECBlocks(); @@ -58,7 +58,7 @@ std::vector > DataBlock::getDataBlocks(ArrayRef rawCodeword for (int i = 0; i < ecBlock->getCount(); i++) { int numDataCodewords = ecBlock->getDataCodewords(); int numBlockCodewords = ecBlocks->getECCodewords() + numDataCodewords; - ArrayRef buffer(numBlockCodewords); + ArrayRef buffer(numBlockCodewords); Ref blockRef(new DataBlock(numDataCodewords, buffer)); result[numResultBlocks++] = blockRef; } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp index e38a188..839a079 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecodedBitStreamParser.cpp @@ -48,14 +48,14 @@ const char DecodedBitStreamParser::TEXT_BASIC_SET_CHARS[] = { const char DecodedBitStreamParser::TEXT_SHIFT3_SET_CHARS[] = { '\'', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (byte) 127 + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', (zxing::byte) 127 }; -Ref DecodedBitStreamParser::decode(ArrayRef bytes) { +Ref DecodedBitStreamParser::decode(ArrayRef bytes) { Ref bits(new BitSource(bytes)); ostringstream result; ostringstream resultTrailer; - vector byteSegments; + vector byteSegments; int mode = ASCII_ENCODE; do { if (mode == ASCII_ENCODE) { @@ -87,7 +87,7 @@ Ref DecodedBitStreamParser::decode(ArrayRef bytes) { if (resultTrailer.str().size() > 0) { result << resultTrailer.str(); } - ArrayRef rawBytes(bytes); + ArrayRef rawBytes(bytes); Ref text(new String(result.str())); return Ref(new DecoderResult(rawBytes, text)); } @@ -102,7 +102,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref bits, ostringstrea } else if (oneByte <= 128) { // ASCII data (ASCII value + 1) oneByte = upperShift ? (oneByte + 128) : oneByte; // upperShift = false; - result << (byte) (oneByte - 1); + result << (zxing::byte) (oneByte - 1); return ASCII_ENCODE; } else if (oneByte == 129) { // Pad return PAD_ENCODE; @@ -117,7 +117,7 @@ int DecodedBitStreamParser::decodeAsciiSegment(Ref bits, ostringstrea } else if (oneByte == 231) { // Latch to Base 256 encodation return BASE256_ENCODE; } else if (oneByte == 232) { // FNC1 - result << ((byte) 29); // translate as ASCII 29 + result << ((zxing::byte) 29); // translate as ASCII 29 } else if (oneByte == 233 || oneByte == 234) { // Structured Append, Reader Programming // Ignore these symbols for now @@ -178,7 +178,7 @@ void DecodedBitStreamParser::decodeC40Segment(Ref bits, ostringstream shift = cValue + 1; } else { if (upperShift) { - result << (byte) (C40_BASIC_SET_CHARS[cValue] + 128); + result << (zxing::byte) (C40_BASIC_SET_CHARS[cValue] + 128); upperShift = false; } else { result << C40_BASIC_SET_CHARS[cValue]; @@ -187,23 +187,23 @@ void DecodedBitStreamParser::decodeC40Segment(Ref bits, ostringstream break; case 1: if (upperShift) { - result << (byte) (cValue + 128); + result << (zxing::byte) (cValue + 128); upperShift = false; } else { - result << (byte) cValue; + result << (zxing::byte) cValue; } shift = 0; break; case 2: if (cValue < 27) { if (upperShift) { - result << (byte) (C40_SHIFT2_SET_CHARS[cValue] + 128); + result << (zxing::byte) (C40_SHIFT2_SET_CHARS[cValue] + 128); upperShift = false; } else { result << C40_SHIFT2_SET_CHARS[cValue]; } } else if (cValue == 27) { // FNC1 - result << ((byte) 29); // translate as ASCII 29 + result << ((zxing::byte) 29); // translate as ASCII 29 } else if (cValue == 30) { // Upper Shift upperShift = true; } else { @@ -213,10 +213,10 @@ void DecodedBitStreamParser::decodeC40Segment(Ref bits, ostringstream break; case 3: if (upperShift) { - result << (byte) (cValue + 224); + result << (zxing::byte) (cValue + 224); upperShift = false; } else { - result << (byte) (cValue + 96); + result << (zxing::byte) (cValue + 96); } shift = 0; break; @@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea shift = cValue + 1; } else { if (upperShift) { - result << (byte) (TEXT_BASIC_SET_CHARS[cValue] + 128); + result << (zxing::byte) (TEXT_BASIC_SET_CHARS[cValue] + 128); upperShift = false; } else { result << (TEXT_BASIC_SET_CHARS[cValue]); @@ -264,10 +264,10 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea break; case 1: if (upperShift) { - result << (byte) (cValue + 128); + result << (zxing::byte) (cValue + 128); upperShift = false; } else { - result << (byte) (cValue); + result << (zxing::byte) (cValue); } shift = 0; break; @@ -275,13 +275,13 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea // Shift 2 for Text is the same encoding as C40 if (cValue < 27) { if (upperShift) { - result << (byte) (C40_SHIFT2_SET_CHARS[cValue] + 128); + result << (zxing::byte) (C40_SHIFT2_SET_CHARS[cValue] + 128); upperShift = false; } else { result << (C40_SHIFT2_SET_CHARS[cValue]); } } else if (cValue == 27) { // FNC1 - result << ((byte) 29); // translate as ASCII 29 + result << ((zxing::byte) 29); // translate as ASCII 29 } else if (cValue == 30) { // Upper Shift upperShift = true; } else { @@ -291,7 +291,7 @@ void DecodedBitStreamParser::decodeTextSegment(Ref bits, ostringstrea break; case 3: if (upperShift) { - result << (byte) (TEXT_SHIFT3_SET_CHARS[cValue] + 128); + result << (zxing::byte) (TEXT_SHIFT3_SET_CHARS[cValue] + 128); upperShift = false; } else { result << (TEXT_SHIFT3_SET_CHARS[cValue]); @@ -333,9 +333,9 @@ void DecodedBitStreamParser::decodeAnsiX12Segment(Ref bits, ostringst } else if (cValue == 3) { // space result << ' '; } else if (cValue < 14) { // 0 - 9 - result << (byte) (cValue + 44); + result << (zxing::byte) (cValue + 44); } else if (cValue < 40) { // A - Z - result << (byte) (cValue + 51); + result << (zxing::byte) (cValue + 51); } else { throw FormatException("decodeAnsiX12Segment: no case"); } @@ -376,12 +376,12 @@ void DecodedBitStreamParser::decodeEdifactSegment(Ref bits, ostringst if ((edifactValue & 0x20) == 0) { // no 1 in the leading (6th) bit edifactValue |= 0x40; // Add a leading 01 to the 6 bit binary value } - result << (byte)(edifactValue); + result << (zxing::byte)(edifactValue); } } while (bits->available() > 0); } -void DecodedBitStreamParser::decodeBase256Segment(Ref bits, ostringstream& result, vector byteSegments) { +void DecodedBitStreamParser::decodeBase256Segment(Ref bits, ostringstream& result, vector byteSegments) { // Figure out how long the Base 256 Segment is. int codewordPosition = 1 + bits->getByteOffset(); // position is 1-indexed int d1 = unrandomize255State(bits->readBits(8), codewordPosition++); @@ -408,7 +408,7 @@ void DecodedBitStreamParser::decodeBase256Segment(Ref bits, ostringst } bytes[i] = unrandomize255State(bits->readBits(8), codewordPosition++); byteSegments.push_back(bytes[i]); - result << (byte)bytes[i]; + result << (zxing::byte)bytes[i]; } delete [] bytes; } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp index 31efb0f..b3eff54 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp @@ -42,7 +42,7 @@ namespace datamatrix { Decoder::Decoder() : rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) {} -void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { +void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { int numCodewords = codewordBytes->size(); ArrayRef codewordInts(numCodewords); for (int i = 0; i < numCodewords; i++) { @@ -58,7 +58,7 @@ void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) // Copy back into array of bytes -- only need to worry about the bytes that were data // We don't care about errors in the error-correction codewords for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (byte)codewordInts[i]; + codewordBytes[i] = (zxing::byte)codewordInts[i]; } } @@ -68,7 +68,7 @@ Ref Decoder::decode(Ref bits) { Version *version = parser.readVersion(bits); // Read codewords - ArrayRef codewords(parser.readCodewords()); + ArrayRef codewords(parser.readCodewords()); // Separate into data blocks std::vector > dataBlocks = DataBlock::getDataBlocks(codewords, version); @@ -79,12 +79,12 @@ Ref Decoder::decode(Ref bits) { for (int i = 0; i < dataBlocksCount; i++) { totalBytes += dataBlocks[i]->getNumDataCodewords(); } - ArrayRef resultBytes(totalBytes); + ArrayRef resultBytes(totalBytes); // Error-correct and copy data blocks together into a stream of bytes for (int j = 0; j < dataBlocksCount; j++) { Ref dataBlock(dataBlocks[j]); - ArrayRef codewordBytes = dataBlock->getCodewords(); + ArrayRef codewordBytes = dataBlock->getCodewords(); int numDataCodewords = dataBlock->getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { diff --git a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h index 7ee2a6e..8353ef0 100644 --- a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h @@ -79,7 +79,7 @@ private: /** * See ISO 16022:2006, 5.2.9 and Annex B, B.2 */ - void decodeBase256Segment(Ref bits, std::ostringstream &result, std::vector byteSegments); + void decodeBase256Segment(Ref bits, std::ostringstream &result, std::vector byteSegments); void parseTwoBytes(int firstByte, int secondByte, int* result); /** @@ -89,13 +89,13 @@ private: int base256CodewordPosition) { int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; - return (byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); + return (zxing::byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); }; void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src); public: DecodedBitStreamParser() { }; - Ref decode(ArrayRef bytes); + Ref decode(ArrayRef bytes); }; } diff --git a/src/zxing/zxing/datamatrix/decoder/Decoder.h b/src/zxing/zxing/datamatrix/decoder/Decoder.h index 31c0743..9f617e8 100644 --- a/src/zxing/zxing/datamatrix/decoder/Decoder.h +++ b/src/zxing/zxing/datamatrix/decoder/Decoder.h @@ -35,7 +35,7 @@ class Decoder { private: ReedSolomonDecoder rsDecoder_; - void correctErrors(ArrayRef bytes, int numDataCodewords); + void correctErrors(ArrayRef bytes, int numDataCodewords); public: Decoder(); diff --git a/src/zxing/zxing/oned/CodaBarReader.cpp b/src/zxing/zxing/oned/CodaBarReader.cpp index 3db0a47..f9de381 100644 --- a/src/zxing/zxing/oned/CodaBarReader.cpp +++ b/src/zxing/zxing/oned/CodaBarReader.cpp @@ -96,7 +96,7 @@ Ref CodaBarReader::decodeRow(int rowNumber, Ref row, zxing::De // Hack: We store the position in the alphabet table into a // StringBuilder, so that we can access the decoded patterns in // validatePattern. We'll translate to the actual characters later. - decodeRowResult.append(1, (byte)charOffset); + decodeRowResult.append(1, (zxing::byte)charOffset); nextStart += 8; // Stop as soon as we see the end character. if (decodeRowResult.length() > 1 && @@ -161,7 +161,7 @@ Ref CodaBarReader::decodeRow(int rowNumber, Ref row, zxing::De Ref(new OneDResultPoint(right, (float) rowNumber)); return Ref(new Result(Ref(new String(decodeRowResult)), - ArrayRef(), + ArrayRef(), resultPoints, BarcodeFormat::CODABAR)); } diff --git a/src/zxing/zxing/oned/Code128Reader.cpp b/src/zxing/zxing/oned/Code128Reader.cpp index 56ec39b..86691c4 100644 --- a/src/zxing/zxing/oned/Code128Reader.cpp +++ b/src/zxing/zxing/oned/Code128Reader.cpp @@ -273,7 +273,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De bool isNextShifted = false; string result; - vector rawCodes(20, 0); + vector rawCodes(20, 0); int lastStart = startPatternInfo[0]; int nextStart = startPatternInfo[1]; @@ -329,16 +329,16 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De case CODE_CODE_A: if (code < 64) { if (shiftUpperMode == upperMode) { - result.append(1,(byte) (' ' + code)); + result.append(1,(zxing::byte) (' ' + code)); } else { - result.append(1,(byte) (' ' + code + 128)); + result.append(1,(zxing::byte) (' ' + code + 128)); } shiftUpperMode = false; } else if (code < 96) { if (shiftUpperMode == upperMode) { - result.append(1, (byte) (code - 64)); + result.append(1, (zxing::byte) (code - 64)); } else { - result.append(1, (byte) (code + 64)); + result.append(1, (zxing::byte) (code + 64)); } shiftUpperMode = false; } else { @@ -356,7 +356,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De result.append("]C1"); } else { // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(1, (byte) 29); + result.append(1, (zxing::byte) 29); } } break; @@ -393,9 +393,9 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De case CODE_CODE_B: if (code < 96) { if (shiftUpperMode == upperMode) { - result.append(1, (byte) (' ' + code)); + result.append(1, (zxing::byte) (' ' + code)); } else { - result.append(1, (byte) (' ' + code + 128)); + result.append(1, (zxing::byte) (' ' + code + 128)); } shiftUpperMode = false; } else { @@ -411,7 +411,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De result.append("]C1"); } else { // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(1, (byte) 29); + result.append(1, (zxing::byte) 29); } } break; @@ -467,7 +467,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De result.append("]C1"); } else { // GS1 specification 5.4.7.5. Every subsequent FNC1 is returned as ASCII 29 (GS) - result.append(1, (byte) 29); + result.append(1, (zxing::byte) 29); } } break; @@ -532,7 +532,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De float right = lastStart + lastPatternSize / 2.0f; int rawCodesSize = rawCodes.size(); - ArrayRef rawBytes (rawCodesSize); + ArrayRef rawBytes (rawCodesSize); for (int i = 0; i < rawCodesSize; i++) { rawBytes[i] = rawCodes[i]; } diff --git a/src/zxing/zxing/oned/Code39Reader.cpp b/src/zxing/zxing/oned/Code39Reader.cpp index 04583de..1a0cd5b 100644 --- a/src/zxing/zxing/oned/Code39Reader.cpp +++ b/src/zxing/zxing/oned/Code39Reader.cpp @@ -171,7 +171,7 @@ Ref Code39Reader::decodeRow(int rowNumber, Ref row, zxing::Dec Ref(new OneDResultPoint(right, (float) rowNumber)); return Ref( - new Result(resultString, ArrayRef(), resultPoints, BarcodeFormat::CODE_39) + new Result(resultString, ArrayRef(), resultPoints, BarcodeFormat::CODE_39) ); } @@ -283,7 +283,7 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '+': // +A to +Z map to a to z if (next >= 'A' && next <= 'Z') { - decodedChar = (byte) (next + 32); + decodedChar = (zxing::byte) (next + 32); } else { throw ReaderException(""); } @@ -291,7 +291,7 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '$': // $A to $Z map to control codes SH to SB if (next >= 'A' && next <= 'Z') { - decodedChar = (byte) (next - 64); + decodedChar = (zxing::byte) (next - 64); } else { throw ReaderException(""); } @@ -299,9 +299,9 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '%': // %A to %E map to control codes ESC to US if (next >= 'A' && next <= 'E') { - decodedChar = (byte) (next - 38); + decodedChar = (zxing::byte) (next - 38); } else if (next >= 'F' && next <= 'W') { - decodedChar = (byte) (next - 11); + decodedChar = (zxing::byte) (next - 11); } else { throw ReaderException(""); } @@ -309,7 +309,7 @@ Ref Code39Reader::decodeExtended(std::string encoded){ case '/': // /A to /O map to ! to , and /Z maps to : if (next >= 'A' && next <= 'O') { - decodedChar = (byte) (next - 32); + decodedChar = (zxing::byte) (next - 32); } else if (next == 'Z') { decodedChar = ':'; } else { diff --git a/src/zxing/zxing/oned/Code93Reader.cpp b/src/zxing/zxing/oned/Code93Reader.cpp index f01dba2..5d010bf 100644 --- a/src/zxing/zxing/oned/Code93Reader.cpp +++ b/src/zxing/zxing/oned/Code93Reader.cpp @@ -130,7 +130,7 @@ Ref Code93Reader::decodeRow(int rowNumber, Ref row, zxing::Dec return Ref(new Result( resultString, - ArrayRef(), + ArrayRef(), resultPoints, BarcodeFormat::CODE_93)); } @@ -226,7 +226,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'd': // +A to +Z map to a to z if (next >= 'A' && next <= 'Z') { - decodedChar = (byte) (next + 32); + decodedChar = (zxing::byte) (next + 32); } else { throw FormatException::getFormatInstance(); } @@ -234,7 +234,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'a': // $A to $Z map to control codes SH to SB if (next >= 'A' && next <= 'Z') { - decodedChar = (byte) (next - 64); + decodedChar = (zxing::byte) (next - 64); } else { throw FormatException::getFormatInstance(); } @@ -242,9 +242,9 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'b': // %A to %E map to control codes ESC to US if (next >= 'A' && next <= 'E') { - decodedChar = (byte) (next - 38); + decodedChar = (zxing::byte) (next - 38); } else if (next >= 'F' && next <= 'W') { - decodedChar = (byte) (next - 11); + decodedChar = (zxing::byte) (next - 11); } else { throw FormatException::getFormatInstance(); } @@ -252,7 +252,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { case 'c': // /A to /O map to ! to , and /Z maps to : if (next >= 'A' && next <= 'O') { - decodedChar = (byte) (next - 32); + decodedChar = (zxing::byte) (next - 32); } else if (next == 'Z') { decodedChar = ':'; } else { diff --git a/src/zxing/zxing/oned/EAN13Reader.cpp b/src/zxing/zxing/oned/EAN13Reader.cpp index 86b823e..3658ac9 100644 --- a/src/zxing/zxing/oned/EAN13Reader.cpp +++ b/src/zxing/zxing/oned/EAN13Reader.cpp @@ -44,7 +44,7 @@ int EAN13Reader::decodeMiddle(Ref row, for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); - resultString.append(1, (byte) ('0' + bestMatch % 10)); + resultString.append(1, (zxing::byte) ('0' + bestMatch % 10)); for (int i = 0, end = counters.size(); i row, for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - resultString.append(1, (byte) ('0' + bestMatch)); + resultString.append(1, (zxing::byte) ('0' + bestMatch)); for (int i = 0, end = counters.size(); i < end; i++) { rowOffset += counters[i]; } @@ -73,7 +73,7 @@ void EAN13Reader::determineFirstDigit(std::string& resultString, int lgPatternFo // std::cerr << "K " << resultString << " " << lgPatternFound << " " < row, for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - result.append(1, (byte) ('0' + bestMatch)); + result.append(1, (zxing::byte) ('0' + bestMatch)); for (int i = 0, end = counters.size(); i < end; i++) { rowOffset += counters[i]; } @@ -52,7 +52,7 @@ int EAN8Reader::decodeMiddle(Ref row, rowOffset = middleRange[1]; for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); - result.append(1, (byte) ('0' + bestMatch)); + result.append(1, (zxing::byte) ('0' + bestMatch)); for (int i = 0, end = counters.size(); i < end; i++) { rowOffset += counters[i]; } diff --git a/src/zxing/zxing/oned/ITFReader.cpp b/src/zxing/zxing/oned/ITFReader.cpp index 4fc1331..4a4748b 100644 --- a/src/zxing/zxing/oned/ITFReader.cpp +++ b/src/zxing/zxing/oned/ITFReader.cpp @@ -117,7 +117,7 @@ Ref ITFReader::decodeRow(int rowNumber, Ref row, zxing::Decode Ref(new OneDResultPoint(float(startRange[1]), float(rowNumber))); resultPoints[1] = Ref(new OneDResultPoint(float(endRange[0]), float(rowNumber))); - return Ref(new Result(resultString, ArrayRef(), resultPoints, BarcodeFormat::ITF)); + return Ref(new Result(resultString, ArrayRef(), resultPoints, BarcodeFormat::ITF)); } /** @@ -151,9 +151,9 @@ void ITFReader::decodeMiddle(Ref row, } int bestMatch = decodeDigit(counterBlack); - resultString.append(1, (byte) ('0' + bestMatch)); + resultString.append(1, (zxing::byte) ('0' + bestMatch)); bestMatch = decodeDigit(counterWhite); - resultString.append(1, (byte) ('0' + bestMatch)); + resultString.append(1, (zxing::byte) ('0' + bestMatch)); for (int i = 0, e = counterDigitPair.size(); i < e; i++) { payloadStart += counterDigitPair[i]; diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index 4812ca1..0460105 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -156,7 +156,7 @@ Ref UPCEANReader::decodeRow(int rowNumber, ArrayRef< Ref > resultPoints(2); resultPoints[0] = Ref(new OneDResultPoint(left, (float) rowNumber)); resultPoints[1] = Ref(new OneDResultPoint(right, (float) rowNumber)); - Ref decodeResult (new Result(resultString, ArrayRef(), resultPoints, format)); + Ref decodeResult (new Result(resultString, ArrayRef(), resultPoints, format)); // Java extension and man stuff return decodeResult; } diff --git a/src/zxing/zxing/oned/UPCEReader.cpp b/src/zxing/zxing/oned/UPCEReader.cpp index faff7c2..900cb6d 100644 --- a/src/zxing/zxing/oned/UPCEReader.cpp +++ b/src/zxing/zxing/oned/UPCEReader.cpp @@ -64,7 +64,7 @@ int UPCEReader::decodeMiddle(Ref row, Range const& startRange, string& for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); - result.append(1, (byte) ('0' + bestMatch % 10)); + result.append(1, (zxing::byte) ('0' + bestMatch % 10)); for (int i = 0, e = counters.size(); i < e; i++) { rowOffset += counters[i]; } @@ -91,8 +91,8 @@ bool UPCEReader::determineNumSysAndCheckDigit(std::string& resultString, int lgP for (int numSys = 0; numSys <= 1; numSys++) { for (int d = 0; d < 10; d++) { if (lgPatternFound == NUMSYS_AND_CHECK_DIGIT_PATTERNS[numSys][d]) { - resultString.insert((size_t)0, (size_t)1, (byte) ('0' + numSys)); - resultString.append(1, (byte) ('0' + d)); + resultString.insert((size_t)0, (size_t)1, (zxing::byte) ('0' + numSys)); + resultString.append(1, (zxing::byte) ('0' + d)); return true; } } diff --git a/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp b/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp index fd19718..695883d 100644 --- a/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp +++ b/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp @@ -116,7 +116,7 @@ Ref DecodedBitStreamParser::decode(ArrayRef codewords) throw FormatException(); } } - return Ref(new DecoderResult(ArrayRef(), result)); + return Ref(new DecoderResult(ArrayRef(), result)); } /** @@ -217,7 +217,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa // Alpha (uppercase alphabetic) if (subModeCh < 26) { // Upper case Alpha Character - ch = (byte) ('A' + subModeCh); + ch = (zxing::byte) ('A' + subModeCh); } else { if (subModeCh == 26) { ch = ' '; @@ -230,7 +230,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa priorToShiftMode = subMode; subMode = PUNCT_SHIFT; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((byte) byteCompactionData[i]); + result->append((zxing::byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -240,7 +240,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa case LOWER: // Lower (lowercase alphabetic) if (subModeCh < 26) { - ch = (byte) ('a' + subModeCh); + ch = (zxing::byte) ('a' + subModeCh); } else { if (subModeCh == 26) { ch = ' '; @@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa priorToShiftMode = subMode; subMode = PUNCT_SHIFT; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((byte) byteCompactionData[i]); + result->append((zxing::byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -280,7 +280,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa priorToShiftMode = subMode; subMode = PUNCT_SHIFT; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((byte) byteCompactionData[i]); + result->append((zxing::byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -295,7 +295,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa if (subModeCh == PAL) { subMode = ALPHA; } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { - result->append((byte) byteCompactionData[i]); + result->append((zxing::byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -306,7 +306,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa // Restore sub-mode subMode = priorToShiftMode; if (subModeCh < 26) { - ch = (byte) ('A' + subModeCh); + ch = (zxing::byte) ('A' + subModeCh); } else { if (subModeCh == 26) { ch = ' '; @@ -332,7 +332,7 @@ void DecodedBitStreamParser::decodeTextCompaction(ArrayRef textCompactionDa } else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) { // PS before Shift-to-Byte is used as a padding character, // see 5.4.2.4 of the specification - result->append((byte) byteCompactionData[i]); + result->append((zxing::byte) byteCompactionData[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -366,7 +366,7 @@ int DecodedBitStreamParser::byteCompaction(int mode, // is not a multiple of 6 int count = 0; int64_t value = 0; - ArrayRef decodedData = new Array(6); + ArrayRef decodedData = new Array(6); ArrayRef byteCompactedCodewords = new Array(6); bool end = false; int nextCode = codewords[codeIndex++]; @@ -394,7 +394,7 @@ int DecodedBitStreamParser::byteCompaction(int mode, // Convert to Base 256 for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (byte) (value%256); + decodedData[5 - j] = (zxing::byte) (value%256); value >>= 8; } result->append(string((char*)&(decodedData->values()[0]), decodedData->values().size())); @@ -412,7 +412,7 @@ int DecodedBitStreamParser::byteCompaction(int mode, // as one byte per codeword, without compaction. for (int i = 0; i < count; i++) { - result->append((byte)byteCompactedCodewords[i]); + result->append((zxing::byte)byteCompactedCodewords[i]); } } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { @@ -442,9 +442,9 @@ int DecodedBitStreamParser::byteCompaction(int mode, if ((count % 5 == 0) && (count > 0)) { // Decode every 5 codewords // Convert to Base 256 - ArrayRef decodedData = new Array(6); + ArrayRef decodedData = new Array(6); for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (byte) (value & 0xFF); + decodedData[5 - j] = (zxing::byte) (value & 0xFF); value >>= 8; } result->append(string((char*)&decodedData[0],6)); diff --git a/src/zxing/zxing/qrcode/QRFormatInformation.cpp b/src/zxing/zxing/qrcode/QRFormatInformation.cpp index dfe4847..3059b59 100644 --- a/src/zxing/zxing/qrcode/QRFormatInformation.cpp +++ b/src/zxing/zxing/qrcode/QRFormatInformation.cpp @@ -40,7 +40,7 @@ int FormatInformation::N_FORMAT_INFO_DECODE_LOOKUPS = 32; int FormatInformation::BITS_SET_IN_HALF_BYTE[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; FormatInformation::FormatInformation(int formatInfo) : - errorCorrectionLevel_(ErrorCorrectionLevel::forBits((formatInfo >> 3) & 0x03)), dataMask_((byte)(formatInfo & 0x07)) { + errorCorrectionLevel_(ErrorCorrectionLevel::forBits((formatInfo >> 3) & 0x03)), dataMask_((zxing::byte)(formatInfo & 0x07)) { } ErrorCorrectionLevel& FormatInformation::getErrorCorrectionLevel() { diff --git a/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h b/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h index ed76f05..d240553 100644 --- a/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/qrcode/decoder/BitMatrixParser.h @@ -43,7 +43,7 @@ public: BitMatrixParser(Ref bitMatrix); Ref readFormatInformation(); Version *readVersion(); - ArrayRef readCodewords(); + ArrayRef readCodewords(); void remask(); void setMirror(boolean mirror); void mirror(); diff --git a/src/zxing/zxing/qrcode/decoder/DataBlock.h b/src/zxing/zxing/qrcode/decoder/DataBlock.h index 96c76d4..b4913c4 100644 --- a/src/zxing/zxing/qrcode/decoder/DataBlock.h +++ b/src/zxing/zxing/qrcode/decoder/DataBlock.h @@ -32,16 +32,16 @@ namespace qrcode { class DataBlock : public Counted { private: int numDataCodewords_; - ArrayRef codewords_; + ArrayRef codewords_; - DataBlock(int numDataCodewords, ArrayRef codewords); + DataBlock(int numDataCodewords, ArrayRef codewords); public: static std::vector > - getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); + getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel); int getNumDataCodewords(); - ArrayRef getCodewords(); + ArrayRef getCodewords(); }; } diff --git a/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h index 077bf00..189f320 100644 --- a/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/qrcode/decoder/DecodedBitStreamParser.h @@ -51,16 +51,16 @@ private: std::string& result, int count, common::CharacterSetECI const *currentCharacterSetECI, - ArrayRef > &byteSegments, + ArrayRef > &byteSegments, Hashtable const& hints); static void decodeAlphanumericSegment(Ref bits, std::string &result, int count, bool fc1InEffect); static void decodeNumericSegment(Ref bits, std::string &result, int count); - static void append(std::string &ost, const byte *bufIn, size_t nIn, const char *src); + static void append(std::string &ost, const zxing::byte *bufIn, size_t nIn, const char *src); static void append(std::string &ost, std::string const& in, const char *src); public: - static Ref decode(ArrayRef bytes, + static Ref decode(ArrayRef bytes, Version *version, ErrorCorrectionLevel const& ecLevel, Hashtable const& hints); diff --git a/src/zxing/zxing/qrcode/decoder/Decoder.h b/src/zxing/zxing/qrcode/decoder/Decoder.h index 401cfed..0970cc3 100644 --- a/src/zxing/zxing/qrcode/decoder/Decoder.h +++ b/src/zxing/zxing/qrcode/decoder/Decoder.h @@ -33,7 +33,7 @@ class Decoder { private: ReedSolomonDecoder rsDecoder_; - void correctErrors(ArrayRef bytes, int numDataCodewords); + void correctErrors(ArrayRef bytes, int numDataCodewords); public: Decoder(); diff --git a/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp b/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp index a348b94..3b47c9c 100644 --- a/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp @@ -116,7 +116,7 @@ Version *BitMatrixParser::readVersion() { throw ReaderException("Could not decode version"); } -ArrayRef BitMatrixParser::readCodewords() { +ArrayRef BitMatrixParser::readCodewords() { Ref formatInfo = readFormatInformation(); Version *version = readVersion(); @@ -138,7 +138,7 @@ ArrayRef BitMatrixParser::readCodewords() { // cout << *functionPattern << endl; bool readingUp = true; - ArrayRef result(version->getTotalCodewords()); + ArrayRef result(version->getTotalCodewords()); int resultOffset = 0; int currentByte = 0; int bitsRead = 0; @@ -163,7 +163,7 @@ ArrayRef BitMatrixParser::readCodewords() { } // If we've made a whole byte, save it off if (bitsRead == 8) { - result[resultOffset++] = (byte)currentByte; + result[resultOffset++] = (zxing::byte)currentByte; bitsRead = 0; currentByte = 0; } diff --git a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp index 56c5c09..7352bb5 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp @@ -26,7 +26,7 @@ namespace qrcode { using namespace std; -DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : +DataBlock::DataBlock(int numDataCodewords, ArrayRef codewords) : numDataCodewords_(numDataCodewords), codewords_(codewords) { } @@ -34,12 +34,12 @@ int DataBlock::getNumDataCodewords() { return numDataCodewords_; } -ArrayRef DataBlock::getCodewords() { +ArrayRef DataBlock::getCodewords() { return codewords_; } -std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version, +std::vector > DataBlock::getDataBlocks(ArrayRef rawCodewords, Version *version, ErrorCorrectionLevel &ecLevel) { @@ -63,7 +63,7 @@ std::vector > DataBlock::getDataBlocks(ArrayRef rawCodeword for (int i = 0; i < ecBlock->getCount(); i++) { int numDataCodewords = ecBlock->getDataCodewords(); int numBlockCodewords = ecBlocks.getECCodewordsPerBloc() + numDataCodewords; - ArrayRef buffer(numBlockCodewords); + ArrayRef buffer(numBlockCodewords); Ref blockRef(new DataBlock(numDataCodewords, buffer)); result[numResultBlocks++] = blockRef; } diff --git a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp index 327f8e9..29feb83 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp @@ -57,11 +57,11 @@ namespace {int GB2312_SUBSET = 1;} void DecodedBitStreamParser::append(std::string &result, string const& in, const char *src) { - append(result, (byte const*)in.c_str(), in.length(), src); + append(result, (zxing::byte const*)in.c_str(), in.length(), src); } void DecodedBitStreamParser::append(std::string &result, - const byte *bufIn, + const zxing::byte *bufIn, size_t nIn, const char *src) { #ifndef NO_ICONV @@ -132,8 +132,8 @@ void DecodedBitStreamParser::decodeHanziSegment(Ref bits_, // In the 0xB0A1 to 0xFAFE range assembledTwoBytes += 0x0A6A1; } - buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF); - buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF); + buffer[offset] = (zxing::byte) ((assembledTwoBytes >> 8) & 0xFF); + buffer[offset + 1] = (zxing::byte) (assembledTwoBytes & 0xFF); offset += 2; count--; } @@ -167,8 +167,8 @@ void DecodedBitStreamParser::decodeKanjiSegment(Ref bits, std::string // In the 0xE040 to 0xEBBF range assembledTwoBytes += 0x0C140; } - buffer[offset] = (byte)(assembledTwoBytes >> 8); - buffer[offset + 1] = (byte)assembledTwoBytes; + buffer[offset] = (zxing::byte)(assembledTwoBytes >> 8); + buffer[offset + 1] = (zxing::byte)assembledTwoBytes; offset += 2; count--; } @@ -186,7 +186,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(Ref bits_, string& result, int count, CharacterSetECI const * currentCharacterSetECI, - ArrayRef< ArrayRef >& byteSegments, + ArrayRef< ArrayRef >& byteSegments, Hashtable const& hints) { int nBytes = count; BitSource& bits (*bits_); @@ -195,10 +195,10 @@ std::string DecodedBitStreamParser::decodeByteSegment(Ref bits_, throw FormatException(); } - ArrayRef bytes_ (count); + ArrayRef bytes_ (count); byte* readBytes = &(*bytes_)[0]; for (int i = 0; i < count; i++) { - readBytes[i] = (byte) bits.readBits(8); + readBytes[i] = (zxing::byte) bits.readBits(8); } string encoding; if (currentCharacterSetECI == 0) { @@ -319,7 +319,7 @@ void DecodedBitStreamParser::decodeAlphanumericSegment(Ref bits_, r << s[i++]; } else { // In alpha mode, % should be converted to FNC1 separator 0x1D - r << (byte)0x1D; + r << (zxing::byte)0x1D; } } } @@ -350,7 +350,7 @@ int parseECIValue(BitSource& bits) { } Ref -DecodedBitStreamParser::decode(ArrayRef bytes, +DecodedBitStreamParser::decode(ArrayRef bytes, Version* version, ErrorCorrectionLevel const& ecLevel, Hashtable const& hints) { @@ -358,7 +358,7 @@ DecodedBitStreamParser::decode(ArrayRef bytes, BitSource& bits (*bits_); string result; result.reserve(50); - ArrayRef< ArrayRef > byteSegments (0); + ArrayRef< ArrayRef > byteSegments (0); const CharacterSetECI* currentCharacterSetECI = 0; string charSet = ""; try { diff --git a/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp b/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp index 82602f3..9272885 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp @@ -43,7 +43,7 @@ Decoder::Decoder() : rsDecoder_(GenericGF::QR_CODE_FIELD_256) { } -void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { +void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) { int numCodewords = codewordBytes->size(); ArrayRef codewordInts(numCodewords); for (int i = 0; i < numCodewords; i++) { @@ -59,7 +59,7 @@ void Decoder::correctErrors(ArrayRef codewordBytes, int numDataCodewords) } for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (byte)codewordInts[i]; + codewordBytes[i] = (zxing::byte)codewordInts[i]; } } @@ -74,7 +74,7 @@ Ref Decoder::decode(Ref bits) { // Read codewords - ArrayRef codewords(parser.readCodewords()); + ArrayRef codewords(parser.readCodewords()); // Separate into data blocks @@ -86,18 +86,18 @@ Ref Decoder::decode(Ref bits) { for (size_t i = 0; i < dataBlocks.size(); i++) { totalBytes += dataBlocks[i]->getNumDataCodewords(); } - ArrayRef resultBytes(totalBytes); + ArrayRef resultBytes(totalBytes); int resultOffset = 0; // Error-correct and copy data blocks together into a stream of bytes for (size_t j = 0; j < dataBlocks.size(); j++) { Ref dataBlock(dataBlocks[j]); - ArrayRef codewordBytes = dataBlock->getCodewords(); + ArrayRef codewordBytes = dataBlock->getCodewords(); int numDataCodewords = dataBlock->getNumDataCodewords(); correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { - resultBytes[resultOffset++] = (byte)codewordBytes[i]; + resultBytes[resultOffset++] = (zxing::byte)codewordBytes[i]; } } diff --git a/src/zxing/zxing/qrcode/encoder/BlockPair.h b/src/zxing/zxing/qrcode/encoder/BlockPair.h index d5ab54d..08e140c 100644 --- a/src/zxing/zxing/qrcode/encoder/BlockPair.h +++ b/src/zxing/zxing/qrcode/encoder/BlockPair.h @@ -12,18 +12,18 @@ namespace qrcode { class BlockPair { private: - ArrayRef data_; - ArrayRef errorCorrection_; + ArrayRef data_; + ArrayRef errorCorrection_; public: - BlockPair(ArrayRef data, ArrayRef errorCorrection) : + BlockPair(ArrayRef data, ArrayRef errorCorrection) : data_(data), errorCorrection_(errorCorrection) {} BlockPair(const BlockPair& other) : data_(other.data_), errorCorrection_(other.errorCorrection_) {} - ArrayRef getDataBytes() { return data_; } + ArrayRef getDataBytes() { return data_; } - ArrayRef getErrorCorrectionBytes() { return errorCorrection_; } + ArrayRef getErrorCorrectionBytes() { return errorCorrection_; } }; } diff --git a/src/zxing/zxing/qrcode/encoder/ByteMatrix.cpp b/src/zxing/zxing/qrcode/encoder/ByteMatrix.cpp index 156110d..15f2489 100644 --- a/src/zxing/zxing/qrcode/encoder/ByteMatrix.cpp +++ b/src/zxing/zxing/qrcode/encoder/ByteMatrix.cpp @@ -27,27 +27,27 @@ byte ByteMatrix::get(size_t x, size_t y) const return bytes_[y][x]; } -std::vector< std::vector > ByteMatrix::getArray() const +std::vector< std::vector > ByteMatrix::getArray() const { return bytes_; } -void ByteMatrix::set(size_t x, size_t y, const byte value) +void ByteMatrix::set(size_t x, size_t y, const zxing::byte value) { bytes_[y][x] = value; } void ByteMatrix::set(size_t x, size_t y, size_t value) { - bytes_[y][x] = (byte) value; + bytes_[y][x] = (zxing::byte) value; } void ByteMatrix::set(size_t x, size_t y, bool value) { - bytes_[y][x] = (byte) (value ? 1 : 0); + bytes_[y][x] = (zxing::byte) (value ? 1 : 0); } -void ByteMatrix::clear(const byte value) +void ByteMatrix::clear(const zxing::byte value) { for (size_t y = 0; y < height_; y++) { for (size_t x = 0; x < width_; x++) { @@ -60,7 +60,7 @@ const std::string ByteMatrix::toString() const { std::stringstream result;// = new StringBuilder(2 * width * height + 2); for (size_t y = 0; y < height_; y++) { - const std::vector& bytesY = bytes_[y]; + const std::vector& bytesY = bytes_[y]; for (size_t x = 0; x < width_; x++) { switch (bytesY[x]) { case 0: diff --git a/src/zxing/zxing/qrcode/encoder/ByteMatrix.h b/src/zxing/zxing/qrcode/encoder/ByteMatrix.h index bce3870..9010a64 100644 --- a/src/zxing/zxing/qrcode/encoder/ByteMatrix.h +++ b/src/zxing/zxing/qrcode/encoder/ByteMatrix.h @@ -12,7 +12,7 @@ namespace qrcode { class ByteMatrix : public Counted { private: - std::vector< std::vector > bytes_; + std::vector< std::vector > bytes_; size_t width_; size_t height_; @@ -22,13 +22,13 @@ public: size_t getHeight() const; size_t getWidth() const; - byte get(size_t x, size_t y) const; + zxing::byte get(size_t x, size_t y) const; - std::vector > getArray() const; - void set(size_t x, size_t y, const byte value); + std::vector > getArray() const; + void set(size_t x, size_t y, const zxing::byte value); void set(size_t x, size_t y, size_t value); void set(size_t x, size_t y, bool value); - void clear(const byte value); + void clear(const zxing::byte value); const std::string toString() const; }; diff --git a/src/zxing/zxing/qrcode/encoder/Encoder.h b/src/zxing/zxing/qrcode/encoder/Encoder.h index ca6b74a..0c0eeef 100644 --- a/src/zxing/zxing/qrcode/encoder/Encoder.h +++ b/src/zxing/zxing/qrcode/encoder/Encoder.h @@ -77,7 +77,7 @@ protected: int numDataBytes, int numRSBlocks); - static ArrayRef generateECBytes(const std::vector &dataBytes, int numEcBytesInBlock); + static ArrayRef generateECBytes(const std::vector &dataBytes, int numEcBytesInBlock); static void appendNumericBytes(const std::string& content, BitArray& bits); diff --git a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp index 82a3240..e82f634 100644 --- a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp +++ b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp @@ -29,11 +29,11 @@ int MaskUtil::applyMaskPenaltyRule1(const ByteMatrix& matrix) int MaskUtil::applyMaskPenaltyRule2(const ByteMatrix& matrix) { int penalty = 0; - const std::vector >& array = matrix.getArray(); + const std::vector >& array = matrix.getArray(); int width = matrix.getWidth(); int height = matrix.getHeight(); for (int y = 0; y < height - 1; y++) { - const std::vector& arrayY = array[y]; + const std::vector& arrayY = array[y]; for (int x = 0; x < width - 1; x++) { int value = arrayY[x]; if (value == arrayY[x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) { @@ -52,12 +52,12 @@ int MaskUtil::applyMaskPenaltyRule2(const ByteMatrix& matrix) int MaskUtil::applyMaskPenaltyRule3(const ByteMatrix& matrix) { int numPenalties = 0; - const std::vector >& array = matrix.getArray(); + const std::vector >& array = matrix.getArray(); int width = matrix.getWidth(); int height = matrix.getHeight(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { - const std::vector& arrayY = array[y]; // We can at least optimize this access + const std::vector& arrayY = array[y]; // We can at least optimize this access if (x + 6 < width && arrayY[x] == 1 && arrayY[x + 1] == 0 && @@ -85,7 +85,7 @@ int MaskUtil::applyMaskPenaltyRule3(const ByteMatrix& matrix) return numPenalties * N3; } -bool MaskUtil::isWhiteHorizontal(const std::vector& rowArray, int from, int to) +bool MaskUtil::isWhiteHorizontal(const std::vector& rowArray, int from, int to) { from = std::max(from, 0); to = std::min(to, (int)rowArray.size()); @@ -97,7 +97,7 @@ bool MaskUtil::isWhiteHorizontal(const std::vector& rowArray, int from, in return true; } -bool MaskUtil::isWhiteVertical(const std::vector > &array, int col, int from, int to) +bool MaskUtil::isWhiteVertical(const std::vector > &array, int col, int from, int to) { from = std::max(from, 0); to = std::min(to, (int)array.size()); @@ -116,11 +116,11 @@ bool MaskUtil::isWhiteVertical(const std::vector > &array, int int MaskUtil::applyMaskPenaltyRule4(const ByteMatrix& matrix) { int numDarkCells = 0; - const std::vector >& array = matrix.getArray(); + const std::vector >& array = matrix.getArray(); int width = matrix.getWidth(); int height = matrix.getHeight(); for (int y = 0; y < height; y++) { - const std::vector& arrayY = array[y]; + const std::vector& arrayY = array[y]; for (size_t x = 0; x < width; x++) { if (arrayY[x] == 1) { numDarkCells++; @@ -183,7 +183,7 @@ int MaskUtil::applyMaskPenaltyRule1Internal(const ByteMatrix& matrix, bool isHor int penalty = 0; int iLimit = isHorizontal ? matrix.getHeight() : matrix.getWidth(); int jLimit = isHorizontal ? matrix.getWidth() : matrix.getHeight(); - const std::vector >& array = matrix.getArray(); + const std::vector >& array = matrix.getArray(); for (size_t i = 0; i < iLimit; i++) { int numSameBitCells = 0; int prevBit = -1; diff --git a/src/zxing/zxing/qrcode/encoder/MaskUtil.h b/src/zxing/zxing/qrcode/encoder/MaskUtil.h index 1da1ff4..8378f54 100644 --- a/src/zxing/zxing/qrcode/encoder/MaskUtil.h +++ b/src/zxing/zxing/qrcode/encoder/MaskUtil.h @@ -15,9 +15,9 @@ private: static const int N3; static const int N4; - static bool isWhiteHorizontal(const std::vector& rowArray, int from, int to); + static bool isWhiteHorizontal(const std::vector& rowArray, int from, int to); - static bool isWhiteVertical(const std::vector >& array, int col, int from, int to); + static bool isWhiteVertical(const std::vector >& array, int col, int from, int to); /** * Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both diff --git a/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp b/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp index 4095e30..57579f3 100644 --- a/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp +++ b/src/zxing/zxing/qrcode/encoder/MatrixUtil.cpp @@ -294,11 +294,11 @@ void MatrixUtil::embedTimingPatterns(ByteMatrix& matrix) int bit = (i + 1) % 2; // Horizontal line. if (isEmpty(matrix.get(i, 6))) { - matrix.set(i, 6, (byte)bit); + matrix.set(i, 6, (zxing::byte)bit); } // Vertical line. if (isEmpty(matrix.get(6, i))) { - matrix.set(6, i, (byte)bit); + matrix.set(6, i, (zxing::byte)bit); } } } @@ -308,7 +308,7 @@ void MatrixUtil::embedDarkDotAtLeftBottomCorner(ByteMatrix& matrix) if (matrix.get(8, matrix.getHeight() - 8) == 0) { throw WriterException(); } - matrix.set(8, matrix.getHeight() - 8, (byte)1); + matrix.set(8, matrix.getHeight() - 8, (zxing::byte)1); } void MatrixUtil::embedHorizontalSeparationPattern(int xStart, @@ -319,7 +319,7 @@ void MatrixUtil::embedHorizontalSeparationPattern(int xStart, if (!isEmpty(matrix.get(xStart + x, yStart))) { throw WriterException(); } - matrix.set(xStart + x, yStart, (byte)0); + matrix.set(xStart + x, yStart, (zxing::byte)0); } } @@ -331,7 +331,7 @@ void MatrixUtil::embedVerticalSeparationPattern(int xStart, if (!isEmpty(matrix.get(xStart, yStart + y))) { throw WriterException(); } - matrix.set(xStart, yStart + y, (byte)0); + matrix.set(xStart, yStart + y, (zxing::byte)0); } } @@ -339,7 +339,7 @@ void MatrixUtil::embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatr { for (int y = 0; y < 5; ++y) { for (int x = 0; x < 5; ++x) { - matrix.set(xStart + x, yStart + y, (byte)POSITION_ADJUSTMENT_PATTERN[y][x]); + matrix.set(xStart + x, yStart + y, (zxing::byte)POSITION_ADJUSTMENT_PATTERN[y][x]); } } } @@ -348,7 +348,7 @@ void MatrixUtil::embedPositionDetectionPattern(int xStart, int yStart, ByteMatri { for (int y = 0; y < 7; ++y) { for (int x = 0; x < 7; ++x) { - matrix.set(xStart + x, yStart + y, (byte)POSITION_DETECTION_PATTERN[y][x]); + matrix.set(xStart + x, yStart + y, (zxing::byte)POSITION_DETECTION_PATTERN[y][x]); } } } diff --git a/src/zxing/zxing/qrcode/encoder/MatrixUtil.h b/src/zxing/zxing/qrcode/encoder/MatrixUtil.h index 183b685..26d0b67 100644 --- a/src/zxing/zxing/qrcode/encoder/MatrixUtil.h +++ b/src/zxing/zxing/qrcode/encoder/MatrixUtil.h @@ -62,7 +62,7 @@ private: public: // Set all cells to -1. -1 means that the cell is empty (not set yet). static void clearMatrix(ByteMatrix& matrix) { - matrix.clear((byte) -1); + matrix.clear((zxing::byte) -1); } // Embed basic patterns. On success, modify the matrix and return true. diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index 7e092db..fb70731 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -186,7 +186,7 @@ Mode Encoder::chooseMode(const std::string& content, const std::string& encoding //bool Encoder::isOnlyDoubleByteKanji(const std::string& content) //{ -// std::vector bytes; +// std::vector bytes; // try { // bytes = content.getBytes("Shift_JIS"); // } catch (UnsupportedEncodingException ignored) { @@ -374,11 +374,11 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, numDataBytesInBlock, numEcBytesInBlock); int size = numDataBytesInBlock[0]; - std::vector dataBytes; + std::vector dataBytes; dataBytes.resize(size); bits.toBytes(8*dataBytesOffset, dataBytes, 0, size); - ArrayRef ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); - blocks.push_back(BlockPair(ArrayRef(dataBytes.data(), dataBytes.size()),ecBytes)); //?? please revisit + ArrayRef ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); + blocks.push_back(BlockPair(ArrayRef(dataBytes.data(), dataBytes.size()),ecBytes)); //?? please revisit maxNumDataBytes = max(maxNumDataBytes, size); maxNumEcBytes = max(maxNumEcBytes, (int)ecBytes->size()); @@ -393,7 +393,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, // First, place data blocks. for (int i = 0; i < maxNumDataBytes; i++) { for (std::vector< BlockPair >::iterator it=blocks.begin(); it != blocks.end(); it++) { - ArrayRef dataBytes = it->getDataBytes(); + ArrayRef dataBytes = it->getDataBytes(); if (i < dataBytes.array_->size()) { result->appendBits(dataBytes[i], 8); ///????? are we sure? } @@ -402,7 +402,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, // Then, place error correction blocks. for (int i = 0; i < maxNumEcBytes; i++) { for (std::vector< BlockPair >::iterator it=blocks.begin(); it != blocks.end(); it++) { - ArrayRef ecBytes = it->getErrorCorrectionBytes(); + ArrayRef ecBytes = it->getErrorCorrectionBytes(); if (i < ecBytes.array_->size()) { result->appendBits(ecBytes[i], 8); } @@ -420,15 +420,15 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, return result; } -ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) +ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) { int numDataBytes = dataBytes.size(); - std::vector dataBytesCopy(dataBytes); + std::vector dataBytesCopy(dataBytes); zxing::ReedSolomonEncoder encoder(GenericGF::QR_CODE_FIELD_256); encoder.encode(dataBytesCopy, numEcBytesInBlock); - ArrayRef ecBytes(numEcBytesInBlock); + ArrayRef ecBytes(numEcBytesInBlock); for (int i = 0; i < numEcBytesInBlock; i++) { ecBytes[i] = dataBytesCopy[numDataBytes + i]; } From 36ac7dd520ff4c5c338a3699e3a147ca51f27958 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 16:13:36 +0100 Subject: [PATCH 17/83] More signed / unsigned warning fixes --- src/zxing/win32/zxing/win_iconv.c | 6 +-- .../zxing/aztec/decoder/AztecDecoder.cpp | 2 +- src/zxing/zxing/common/Array.h | 2 +- src/zxing/zxing/common/GridSampler.cpp | 4 +- .../zxing/common/PerspectiveTransform.cpp | 2 +- src/zxing/zxing/common/Str.cpp | 4 +- .../zxing/datamatrix/DataMatrixVersion.cpp | 2 +- .../decoder/DataMatrixBitMatrixParser.cpp | 2 +- .../decoder/DataMatrixDataBlock.cpp | 2 +- .../datamatrix/decoder/DataMatrixDecoder.cpp | 2 +- .../detector/DataMatrixDetector.cpp | 2 +- .../detector/MultiFinderPatternFinder.cpp | 2 +- src/zxing/zxing/oned/CodaBarReader.cpp | 4 +- src/zxing/zxing/oned/Code128Reader.cpp | 8 ++-- src/zxing/zxing/oned/Code39Reader.cpp | 16 ++++---- src/zxing/zxing/oned/Code93Reader.cpp | 20 +++++----- src/zxing/zxing/oned/EAN13Reader.cpp | 4 +- src/zxing/zxing/oned/EAN8Reader.cpp | 4 +- src/zxing/zxing/oned/ITFReader.cpp | 4 +- .../zxing/oned/MultiFormatOneDReader.cpp | 2 +- .../zxing/oned/MultiFormatUPCEANReader.cpp | 2 +- src/zxing/zxing/oned/OneDReader.cpp | 4 +- src/zxing/zxing/oned/UPCEANReader.cpp | 6 +-- src/zxing/zxing/oned/UPCEReader.cpp | 2 +- .../zxing/pdf417/detector/LinesSampler.cpp | 4 +- src/zxing/zxing/qrcode/QRVersion.cpp | 6 +-- .../qrcode/decoder/QRBitMatrixParser.cpp | 2 +- .../zxing/qrcode/decoder/QRDataBlock.cpp | 2 +- src/zxing/zxing/qrcode/decoder/QRDataMask.cpp | 4 +- .../decoder/QRDecodedBitStreamParser.cpp | 4 +- .../detector/QRAlignmentPatternFinder.cpp | 2 +- .../qrcode/detector/QRFinderPatternFinder.cpp | 38 +++++++++---------- 32 files changed, 85 insertions(+), 85 deletions(-) diff --git a/src/zxing/win32/zxing/win_iconv.c b/src/zxing/win32/zxing/win_iconv.c index 17f6773..49b3675 100644 --- a/src/zxing/win32/zxing/win_iconv.c +++ b/src/zxing/win32/zxing/win_iconv.c @@ -783,7 +783,7 @@ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t if (outbuf != NULL && *outbuf != NULL && cd->to.flush != NULL) { tomode = cd->to.mode; - outsize = cd->to.flush(&cd->to, (uchar *)*outbuf, *outbytesleft); + outsize = cd->to.flush(&cd->to, (uchar *)*outbuf, (int)*outbytesleft); if (outsize == -1) { if ((cd->to.flags & FLAG_IGNORE) && errno != E2BIG) @@ -810,7 +810,7 @@ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t tomode = cd->to.mode; wsize = MB_CHAR_MAX; - insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf, *inbytesleft, wbuf, &wsize); + insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf, (int)*inbytesleft, wbuf, &wsize); if (insize == -1) { if (cd->to.flags & FLAG_IGNORE) @@ -861,7 +861,7 @@ win_iconv(iconv_t _cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t } } - outsize = cd->to.wctomb(&cd->to, wbuf, wsize, (uchar *)*outbuf, *outbytesleft); + outsize = cd->to.wctomb(&cd->to, wbuf, wsize, (uchar *)*outbuf, (int)*outbytesleft); if (outsize == -1) { if ((cd->to.flags & FLAG_IGNORE) && errno != E2BIG) diff --git a/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp b/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp index 441c35e..33388ee 100644 --- a/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp +++ b/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp @@ -441,7 +441,7 @@ Ref Decoder::extractBits(Ref matrix) { } - Ref returnValue(new BitArray(rawbits.size())); + Ref returnValue(new BitArray(int(rawbits.size()))); for (int i = 0; i < (int)rawbits.size(); i++) { if (rawbits[i]) returnValue->set(i); } diff --git a/src/zxing/zxing/common/Array.h b/src/zxing/zxing/common/Array.h index af3a521..83b4232 100644 --- a/src/zxing/zxing/common/Array.h +++ b/src/zxing/zxing/common/Array.h @@ -70,7 +70,7 @@ public: return values_[i]; } int size() const { - return values_.size(); + return int(values_.size()); } bool empty() const { return values_.size() == 0; diff --git a/src/zxing/zxing/common/GridSampler.cpp b/src/zxing/zxing/common/GridSampler.cpp index c1c86ad..4506595 100644 --- a/src/zxing/zxing/common/GridSampler.cpp +++ b/src/zxing/zxing/common/GridSampler.cpp @@ -36,7 +36,7 @@ Ref GridSampler::sampleGrid(Ref image, int dimension, Ref< Ref bits(new BitMatrix(dimension)); vector points(dimension << 1, (const float)0.0f); for (int y = 0; y < dimension; y++) { - int max = points.size(); + int max = int(points.size()); float yValue = (float)y + 0.5f; for (int x = 0; x < max; x += 2) { points[x] = (float)(x >> 1) + 0.5f; @@ -57,7 +57,7 @@ Ref GridSampler::sampleGrid(Ref image, int dimensionX, int Ref bits(new BitMatrix(dimensionX, dimensionY)); vector points(dimensionX << 1, (const float)0.0f); for (int y = 0; y < dimensionY; y++) { - int max = points.size(); + int max = int(points.size()); float yValue = (float)y + 0.5f; for (int x = 0; x < max; x += 2) { points[x] = (float)(x >> 1) + 0.5f; diff --git a/src/zxing/zxing/common/PerspectiveTransform.cpp b/src/zxing/zxing/common/PerspectiveTransform.cpp index 7344efb..8f33e43 100644 --- a/src/zxing/zxing/common/PerspectiveTransform.cpp +++ b/src/zxing/zxing/common/PerspectiveTransform.cpp @@ -87,7 +87,7 @@ Ref PerspectiveTransform::times(Ref } void PerspectiveTransform::transformPoints(vector &points) { - int max = points.size(); + int max = int(points.size()); for (int i = 0; i < max; i += 2) { float x = points[i]; float y = points[i + 1]; diff --git a/src/zxing/zxing/common/Str.cpp b/src/zxing/zxing/common/Str.cpp index 983651a..f48b6cd 100644 --- a/src/zxing/zxing/common/Str.cpp +++ b/src/zxing/zxing/common/Str.cpp @@ -39,9 +39,9 @@ const std::string& String::getText() const { char String::charAt(int i) const { return text_[i]; } -int String::size() const { return text_.size(); } +int String::size() const { return int(text_.size()); } -int String::length() const { return text_.size(); } +int String::length() const { return int(text_.size()); } Ref String::substring(int i) const { return Ref(new String(text_.substr(i))); diff --git a/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp b/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp index f94ca65..a6fd59a 100644 --- a/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp +++ b/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp @@ -193,7 +193,7 @@ int Version::buildVersions() { new ECBlocks(24, new ECB(1, 32))))); VERSIONS.push_back(Ref(new Version(30, 16, 48, 14, 22, new ECBlocks(28, new ECB(1, 49))))); - return VERSIONS.size(); + return int(VERSIONS.size()); } } } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp index 37b242e..ba48a17 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp @@ -27,7 +27,7 @@ namespace zxing { namespace datamatrix { int BitMatrixParser::copyBit(size_t x, size_t y, int versionBits) { - return bitMatrix_->get(x, y) ? (versionBits << 1) | 0x1 : versionBits << 1; + return bitMatrix_->get(int(x), int(y)) ? (versionBits << 1) | 0x1 : versionBits << 1; } BitMatrixParser::BitMatrixParser(Ref bitMatrix) : bitMatrix_(NULL), diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp index 474fd48..26c96de 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp @@ -67,7 +67,7 @@ std::vector > DataBlock::getDataBlocks(ArrayRef rawCodeword // All blocks have the same amount of data, except that the last n // (where n may be 0) have 1 more byte. Figure out where these start. int shorterBlocksTotalCodewords = result[0]->codewords_->size(); - int longerBlocksStartAt = result.size() - 1; + int longerBlocksStartAt = int(result.size()) - 1; while (longerBlocksStartAt >= 0) { int numCodewords = result[longerBlocksStartAt]->codewords_->size(); if (numCodewords == shorterBlocksTotalCodewords) { diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp index 31efb0f..3bd1411 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp @@ -72,7 +72,7 @@ Ref Decoder::decode(Ref bits) { // Separate into data blocks std::vector > dataBlocks = DataBlock::getDataBlocks(codewords, version); - int dataBlocksCount = dataBlocks.size(); + int dataBlocksCount = int(dataBlocks.size()); // Count total number of data bytes int totalBytes = 0; diff --git a/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp b/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp index 9fc02af..4ae2a30 100644 --- a/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp +++ b/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp @@ -425,7 +425,7 @@ Ref Detector::sampleGrid(Ref image, int dimensionX, int di } void Detector::insertionSort(std::vector > &vector) { - int max = vector.size(); + int max = int(vector.size()); bool swapped = true; Ref value; Ref valueB; diff --git a/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp b/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp index edc825f..38cd03d 100644 --- a/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +++ b/src/zxing/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp @@ -138,7 +138,7 @@ vector > MultiFinderPatternFinder::findMulti(DecodeHints vector > > MultiFinderPatternFinder::selectBestPatterns(){ vector > possibleCenters = possibleCenters_; - int size = possibleCenters.size(); + int size = int(possibleCenters.size()); if (size < 3) { // Couldn't find enough finder patterns diff --git a/src/zxing/zxing/oned/CodaBarReader.cpp b/src/zxing/zxing/oned/CodaBarReader.cpp index 3db0a47..f00ef81 100644 --- a/src/zxing/zxing/oned/CodaBarReader.cpp +++ b/src/zxing/zxing/oned/CodaBarReader.cpp @@ -79,7 +79,7 @@ CodaBarReader::CodaBarReader() Ref CodaBarReader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints /*hints*/) { { // Arrays.fill(counters, 0); - int size = counters.size(); + int size = int(counters.size()); counters.resize(0); counters.resize(size); } @@ -170,7 +170,7 @@ void CodaBarReader::validatePattern(int start) { // First, sum up the total size of our four categories of stripe sizes; vector sizes (4, 0); vector counts (4, 0); - int end = decodeRowResult.length() - 1; + int end = int(decodeRowResult.length()) - 1; // We break out of this loop in the middle, in order to handle // inter-character spaces properly. diff --git a/src/zxing/zxing/oned/Code128Reader.cpp b/src/zxing/zxing/oned/Code128Reader.cpp index 56ec39b..b5c952a 100644 --- a/src/zxing/zxing/oned/Code128Reader.cpp +++ b/src/zxing/zxing/oned/Code128Reader.cpp @@ -187,7 +187,7 @@ vector Code128Reader::findStartPattern(Ref row){ vector counters (6, 0); int patternStart = rowOffset; bool isWhite = false; - int patternLength = counters.size(); + int patternLength = int(counters.size()); for (int i = rowOffset; i < width; i++) { if (row->get(i) ^ isWhite) { @@ -312,7 +312,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De // Advance to where the next code will to start lastStart = nextStart; - for (int i = 0, e = counters.size(); i < e; i++) { + for (int i = 0, e = int(counters.size()); i < e; i++) { nextStart += counters[i]; } @@ -512,7 +512,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De } // Need to pull out the check digits from string - int resultLength = result.length(); + int resultLength = int(result.length()); if (resultLength == 0) { // false positive throw NotFoundException(); @@ -531,7 +531,7 @@ Ref Code128Reader::decodeRow(int rowNumber, Ref row, zxing::De float left = (float) (startPatternInfo[1] + startPatternInfo[0]) / 2.0f; float right = lastStart + lastPatternSize / 2.0f; - int rawCodesSize = rawCodes.size(); + int rawCodesSize = int(rawCodes.size()); ArrayRef rawBytes (rawCodesSize); for (int i = 0; i < rawCodesSize; i++) { rawBytes[i] = rawCodes[i]; diff --git a/src/zxing/zxing/oned/Code39Reader.cpp b/src/zxing/zxing/oned/Code39Reader.cpp index 04583de..91bb8c9 100644 --- a/src/zxing/zxing/oned/Code39Reader.cpp +++ b/src/zxing/zxing/oned/Code39Reader.cpp @@ -95,7 +95,7 @@ Code39Reader::Code39Reader(bool usingCheckDigit_, bool extendedMode_) { Ref Code39Reader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints /*hints*/) { std::vector& theCounters (counters); { // Arrays.fill(counters, 0); - int size = theCounters.size(); + int size = int(theCounters.size()); theCounters.resize(0); theCounters.resize(size); } std::string& result (decodeRowResult); @@ -117,7 +117,7 @@ Ref Code39Reader::decodeRow(int rowNumber, Ref row, zxing::Dec decodedChar = patternToChar(pattern); result.append(1, decodedChar); lastStart = nextStart; - for (int i = 0, end=theCounters.size(); i < end; i++) { + for (int i = 0, end=int(theCounters.size()); i < end; i++) { nextStart += theCounters[i]; } // Read off white space @@ -127,7 +127,7 @@ Ref Code39Reader::decodeRow(int rowNumber, Ref row, zxing::Dec // Look for whitespace after pattern: int lastPatternSize = 0; - for (int i = 0, e = theCounters.size(); i < e; i++) { + for (int i = 0, e = int(theCounters.size()); i < e; i++) { lastPatternSize += theCounters[i]; } int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; @@ -138,10 +138,10 @@ Ref Code39Reader::decodeRow(int rowNumber, Ref row, zxing::Dec } if (usingCheckDigit) { - int max = result.length() - 1; + int max = int(result.length()) - 1; int total = 0; for (int i = 0; i < max; i++) { - total += alphabet_string.find_first_of(decodeRowResult[i], 0); + total += int(alphabet_string.find_first_of(decodeRowResult[i], 0)); } if (result[max] != ALPHABET[total % 43]) { throw ChecksumException(); @@ -182,7 +182,7 @@ vector Code39Reader::findAsteriskPattern(Ref row, vector& co int counterPosition = 0; int patternStart = rowOffset; bool isWhite = false; - int patternLength = counters.size(); + int patternLength = int(counters.size()); for (int i = rowOffset; i < width; i++) { if (row->get(i) ^ isWhite) { @@ -218,7 +218,7 @@ vector Code39Reader::findAsteriskPattern(Ref row, vector& co // For efficiency, returns -1 on failure. Not throwing here saved as many as // 700 exceptions per image when using some of our blackbox images. int Code39Reader::toNarrowWidePattern(vector& counters){ - int numCounters = counters.size(); + int numCounters = int(counters.size()); int maxNarrowCounter = 0; int wideCounters; do { @@ -272,7 +272,7 @@ char Code39Reader::patternToChar(int pattern){ } Ref Code39Reader::decodeExtended(std::string encoded){ - int length = encoded.length(); + int length = int(encoded.length()); std::string tmpDecoded; for (int i = 0; i < length; i++) { char c = encoded[i]; diff --git a/src/zxing/zxing/oned/Code93Reader.cpp b/src/zxing/zxing/oned/Code93Reader.cpp index f01dba2..5cddd1b 100644 --- a/src/zxing/zxing/oned/Code93Reader.cpp +++ b/src/zxing/zxing/oned/Code93Reader.cpp @@ -72,7 +72,7 @@ Ref Code93Reader::decodeRow(int rowNumber, Ref row, zxing::Dec vector& theCounters (counters); { // Arrays.fill(counters, 0); - int size = theCounters.size(); + int size = int(theCounters.size()); theCounters.resize(0); theCounters.resize(size); } string& result (decodeRowResult); @@ -89,7 +89,7 @@ Ref Code93Reader::decodeRow(int rowNumber, Ref row, zxing::Dec decodedChar = patternToChar(pattern); result.append(1, decodedChar); lastStart = nextStart; - for(int i=0, e=theCounters.size(); i < e; ++i) { + for(int i=0, e=int(theCounters.size()); i < e; ++i) { nextStart += theCounters[i]; } // Read off white space @@ -99,7 +99,7 @@ Ref Code93Reader::decodeRow(int rowNumber, Ref row, zxing::Dec // Look for whitespace after pattern: int lastPatternSize = 0; - for (int i = 0, e = theCounters.size(); i < e; i++) { + for (int i = 0, e = int(theCounters.size()); i < e; i++) { lastPatternSize += theCounters[i]; } @@ -140,14 +140,14 @@ Code93Reader::Range Code93Reader::findAsteriskPattern(Ref row) { int rowOffset = row->getNextSet(0); { // Arrays.fill(counters, 0); - int size = counters.size(); + int size = int(counters.size()); counters.resize(0); counters.resize(size); } vector& theCounters (counters); int patternStart = rowOffset; bool isWhite = false; - int patternLength = theCounters.size(); + int patternLength = int(theCounters.size()); int counterPosition = 0; for (int i = rowOffset; i < width; i++) { @@ -176,9 +176,9 @@ Code93Reader::Range Code93Reader::findAsteriskPattern(Ref row) { } int Code93Reader::toPattern(vector& counters) { - int max = counters.size(); + int max = int(counters.size()); int sum = 0; - for(int i=0, e=counters.size(); i Code93Reader::decodeExtended(string const& encoded) { - int length = encoded.length(); + int length = int(encoded.length()); string decoded; for (int i = 0; i < length; i++) { char c = encoded[i]; @@ -271,7 +271,7 @@ Ref Code93Reader::decodeExtended(string const& encoded) { } void Code93Reader::checkChecksums(string const& result) { - int length = result.length(); + int length = int(result.length()); checkOneChecksum(result, length - 2, 20); checkOneChecksum(result, length - 1, 15); } @@ -282,7 +282,7 @@ void Code93Reader::checkOneChecksum(string const& result, int weight = 1; int total = 0; for (int i = checkPosition - 1; i >= 0; i--) { - total += weight * ALPHABET_STRING.find_first_of(result[i]); + total += weight * int(ALPHABET_STRING.find_first_of(result[i])); if (++weight > weightMax) { weight = 1; } diff --git a/src/zxing/zxing/oned/EAN13Reader.cpp b/src/zxing/zxing/oned/EAN13Reader.cpp index 86b823e..e044a1c 100644 --- a/src/zxing/zxing/oned/EAN13Reader.cpp +++ b/src/zxing/zxing/oned/EAN13Reader.cpp @@ -45,7 +45,7 @@ int EAN13Reader::decodeMiddle(Ref row, for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); resultString.append(1, (byte) ('0' + bestMatch % 10)); - for (int i = 0, end = counters.size(); i = 10) { @@ -62,7 +62,7 @@ int EAN13Reader::decodeMiddle(Ref row, int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); resultString.append(1, (byte) ('0' + bestMatch)); - for (int i = 0, end = counters.size(); i < end; i++) { + for (int i = 0, end = int(counters.size()); i < end; i++) { rowOffset += counters[i]; } } diff --git a/src/zxing/zxing/oned/EAN8Reader.cpp b/src/zxing/zxing/oned/EAN8Reader.cpp index a7da8c7..cf89942 100644 --- a/src/zxing/zxing/oned/EAN8Reader.cpp +++ b/src/zxing/zxing/oned/EAN8Reader.cpp @@ -42,7 +42,7 @@ int EAN8Reader::decodeMiddle(Ref row, for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append(1, (byte) ('0' + bestMatch)); - for (int i = 0, end = counters.size(); i < end; i++) { + for (int i = 0, end = int(counters.size()); i < end; i++) { rowOffset += counters[i]; } } @@ -53,7 +53,7 @@ int EAN8Reader::decodeMiddle(Ref row, for (int x = 0; x < 4 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS); result.append(1, (byte) ('0' + bestMatch)); - for (int i = 0, end = counters.size(); i < end; i++) { + for (int i = 0, end = int(counters.size()); i < end; i++) { rowOffset += counters[i]; } } diff --git a/src/zxing/zxing/oned/ITFReader.cpp b/src/zxing/zxing/oned/ITFReader.cpp index 4fc1331..7f5b01d 100644 --- a/src/zxing/zxing/oned/ITFReader.cpp +++ b/src/zxing/zxing/oned/ITFReader.cpp @@ -155,7 +155,7 @@ void ITFReader::decodeMiddle(Ref row, bestMatch = decodeDigit(counterWhite); resultString.append(1, (byte) ('0' + bestMatch)); - for (int i = 0, e = counterDigitPair.size(); i < e; i++) { + for (int i = 0, e = int(counterDigitPair.size()); i < e; i++) { payloadStart += counterDigitPair[i]; } } @@ -274,7 +274,7 @@ ITFReader::Range ITFReader::findGuardPattern(Ref row, vector const& pattern) { // TODO: This is very similar to implementation in UPCEANReader. Consider if they can be // merged to a single method. - int patternLength = pattern.size(); + int patternLength = int(pattern.size()); vector counters(patternLength); int width = row->getSize(); bool isWhite = false; diff --git a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp index 3bfe5d0..7b18345 100644 --- a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp @@ -81,7 +81,7 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { #include Ref MultiFormatOneDReader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints hints) { - int size = readers.size(); + int size = int(readers.size()); for (int i = 0; i < size; i++) { OneDReader* reader = readers[i]; try { diff --git a/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp b/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp index dbc67b2..0ee3398 100644 --- a/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp @@ -64,7 +64,7 @@ MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() Ref MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints /*hints*/) { // Compute this location once and reuse it on multiple implementations UPCEANReader::Range startGuardPattern = UPCEANReader::findStartGuardPattern(row); - for (int i = 0, e = readers.size(); i < e; i++) { + for (int i = 0, e = int(readers.size()); i < e; i++) { Ref reader = readers[i]; Ref result; try { diff --git a/src/zxing/zxing/oned/OneDReader.cpp b/src/zxing/zxing/oned/OneDReader.cpp index 4cf73b5..e48600c 100644 --- a/src/zxing/zxing/oned/OneDReader.cpp +++ b/src/zxing/zxing/oned/OneDReader.cpp @@ -155,7 +155,7 @@ int OneDReader::patternMatchVariance(vector& counters, int OneDReader::patternMatchVariance(vector& counters, int const pattern[], int maxIndividualVariance) { - int numCounters = counters.size(); + int numCounters = int(counters.size()); unsigned int total = 0; unsigned int patternLength = 0; for (int i = 0; i < numCounters; i++) { @@ -189,7 +189,7 @@ int OneDReader::patternMatchVariance(vector& counters, void OneDReader::recordPattern(Ref row, int start, vector& counters) { - int numCounters = counters.size(); + int numCounters = int(counters.size()); for (int i = 0; i < numCounters; i++) { counters[i] = 0; } diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index 4812ca1..28dd1ad 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -206,7 +206,7 @@ UPCEANReader::Range UPCEANReader::findGuardPattern(Ref row, } std::cerr << std::endl; } - int patternLength = pattern.size(); + int patternLength = int(pattern.size()); int width = row->getSize(); bool isWhite = whiteFirst; rowOffset = whiteFirst ? row->getNextUnset(rowOffset) : row->getNextSet(rowOffset); @@ -249,7 +249,7 @@ int UPCEANReader::decodeDigit(Ref row, recordPattern(row, rowOffset, counters); int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept int bestMatch = -1; - int max = patterns.size(); + int max = int(patterns.size()); for (int i = 0; i < max; i++) { int const* pattern (patterns[i]); int variance = patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE); @@ -281,7 +281,7 @@ bool UPCEANReader::checkChecksum(Ref const& s) { */ bool UPCEANReader::checkStandardUPCEANChecksum(Ref const& s_) { std::string const& s (s_->getText()); - int length = s.length(); + int length = int(s.length()); if (length == 0) { return false; } diff --git a/src/zxing/zxing/oned/UPCEReader.cpp b/src/zxing/zxing/oned/UPCEReader.cpp index faff7c2..f1d4a41 100644 --- a/src/zxing/zxing/oned/UPCEReader.cpp +++ b/src/zxing/zxing/oned/UPCEReader.cpp @@ -65,7 +65,7 @@ int UPCEReader::decodeMiddle(Ref row, Range const& startRange, string& for (int x = 0; x < 6 && rowOffset < end; x++) { int bestMatch = decodeDigit(row, counters, rowOffset, L_AND_G_PATTERNS); result.append(1, (byte) ('0' + bestMatch % 10)); - for (int i = 0, e = counters.size(); i < e; i++) { + for (int i = 0, e = int(counters.size()); i < e; i++) { rowOffset += counters[i]; } if (bestMatch >= 10) { diff --git a/src/zxing/zxing/pdf417/detector/LinesSampler.cpp b/src/zxing/zxing/pdf417/detector/LinesSampler.cpp index c3e5f38..1ada0f6 100644 --- a/src/zxing/zxing/pdf417/detector/LinesSampler.cpp +++ b/src/zxing/zxing/pdf417/detector/LinesSampler.cpp @@ -190,7 +190,7 @@ Ref LinesSampler::sample() { detectedCodeWords.resize(rowCount); // XXX - Ref grid(new BitMatrix(dimension_, detectedCodeWords.size())); + Ref grid(new BitMatrix(dimension_, int(detectedCodeWords.size()))); codewordsToBitMatrix(detectedCodeWords, grid); return grid; @@ -712,7 +712,7 @@ int LinesSampler::decodeRowCount(const int symbolsPerLine, vector > detectedCodeWords.insert(detectedCodeWords.begin() + insertLinesAt[i] + i, vector(symbolsPerLine, 0)); } - int rowCount = getValueWithMaxVotes(rowCountVotes,detectedCodeWords.size()).getVote(); + int rowCount = getValueWithMaxVotes(rowCountVotes, int(detectedCodeWords.size())).getVote(); // int ecLevel = getValueWithMaxVotes(ecLevelVotes); #if PDF417_DIAG && OUTPUT_EC_LEVEL diff --git a/src/zxing/zxing/qrcode/QRVersion.cpp b/src/zxing/zxing/qrcode/QRVersion.cpp index 9b59dc3..8fc48e6 100644 --- a/src/zxing/zxing/qrcode/QRVersion.cpp +++ b/src/zxing/zxing/qrcode/QRVersion.cpp @@ -59,7 +59,7 @@ int ECBlocks::getECCodewordsPerBloc() int ECBlocks::getTotalECCodewords() { - return ecCodewordsPerBloc_ * ecBlocks_.size(); + return ecCodewordsPerBloc_ * int(ecBlocks_.size()); } std::vector& ECBlocks::getECBlocks() { @@ -166,7 +166,7 @@ Ref Version::decodeVersionInformation(unsigned int versionBits) { // We can tolerate up to 3 bits of error since no two version info codewords will // differ in less than 4 bits. if (bestDifference <= 3) { - return getVersionForNumber(bestVersion); + return getVersionForNumber(int(bestVersion)); } // If we didn't find a close enough match, fail return Ref(NULL); @@ -559,7 +559,7 @@ int Version::buildVersions() { new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), new ECB(61, 16))))); - return VERSIONS.size(); + return int(VERSIONS.size()); } } diff --git a/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp b/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp index a348b94..f3d2888 100644 --- a/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRBitMatrixParser.cpp @@ -26,7 +26,7 @@ namespace zxing { namespace qrcode { int BitMatrixParser::copyBit(size_t x, size_t y, int versionBits) { - return bitMatrix_->get(x, y) ? (versionBits << 1) | 0x1 : versionBits << 1; + return bitMatrix_->get(int(x), int(y)) ? (versionBits << 1) | 0x1 : versionBits << 1; } BitMatrixParser::BitMatrixParser(Ref bitMatrix) : diff --git a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp index 56c5c09..e06e547 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp @@ -72,7 +72,7 @@ std::vector > DataBlock::getDataBlocks(ArrayRef rawCodeword // All blocks have the same amount of data, except that the last n // (where n may be 0) have 1 more byte. Figure out where these start. int shorterBlocksTotalCodewords = result[0]->codewords_->size(); - int longerBlocksStartAt = result.size() - 1; + int longerBlocksStartAt = int(result.size()) - 1; while (longerBlocksStartAt >= 0) { int numCodewords = result[longerBlocksStartAt]->codewords_->size(); if (numCodewords == shorterBlocksTotalCodewords) { diff --git a/src/zxing/zxing/qrcode/decoder/QRDataMask.cpp b/src/zxing/zxing/qrcode/decoder/QRDataMask.cpp index b231a17..e61d2ac 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDataMask.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDataMask.cpp @@ -48,7 +48,7 @@ void DataMask::unmaskBitMatrix(BitMatrix& bits, size_t dimension) { for (size_t x = 0; x < dimension; x++) { // TODO: check why the coordinates have to be swapped if (isMasked(y, x)) { - bits.flip(x, y); + bits.flip(int(x), int(y)); } } } @@ -152,7 +152,7 @@ int DataMask::buildDataMasks() { DATA_MASKS.push_back(Ref (new DataMask101())); DATA_MASKS.push_back(Ref (new DataMask110())); DATA_MASKS.push_back(Ref (new DataMask111())); - return DATA_MASKS.size(); + return int(DATA_MASKS.size()); } } diff --git a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp index 327f8e9..12cc611 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp @@ -75,7 +75,7 @@ void DecodedBitStreamParser::append(std::string &result, return; } - const int maxOut = 4 * nIn + 1; + const int maxOut = 4 * int(nIn) + 1; char* bufOut = new char[maxOut]; ICONV_CONST char *fromPtr = (ICONV_CONST char *)bufIn; @@ -97,7 +97,7 @@ void DecodedBitStreamParser::append(std::string &result, } iconv_close(cd); - int nResult = maxOut - nTo; + int nResult = maxOut - int(nTo); bufOut[nResult] = '\0'; result.append((const char *)bufOut); delete[] bufOut; diff --git a/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp b/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp index 5f46671..081a176 100644 --- a/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp +++ b/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp @@ -102,7 +102,7 @@ Ref AlignmentPatternFinder::handlePossibleCenter(vector & float centerI = crossCheckVertical(i, (int)centerJ, 2 * stateCount[1], stateCountTotal); if (!isnan_z(centerI)) { float estimatedModuleSize = (float)(stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f; - int max = possibleCenters_->size(); + int max = int(possibleCenters_->size()); for (int index = 0; index < max; index++) { Ref center((*possibleCenters_)[index]); // Look for about the same center and module size: diff --git a/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp b/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp index 3800fbf..b714dab 100644 --- a/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp +++ b/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp @@ -125,15 +125,15 @@ float FinderPatternFinder::crossCheckVertical(size_t startI, size_t centerJ, int int *stateCount = getCrossCheckStateCount(); // Start counting up from center - int i = startI; - while (i >= 0 && image_->get(centerJ, i)) { + int i = int(startI); + while (i >= 0 && image_->get(int(centerJ), i)) { stateCount[2]++; i--; } if (i < 0) { return nan(); } - while (i >= 0 && !image_->get(centerJ, i) && stateCount[1] <= maxCount) { + while (i >= 0 && !image_->get(int(centerJ), i) && stateCount[1] <= maxCount) { stateCount[1]++; i--; } @@ -141,7 +141,7 @@ float FinderPatternFinder::crossCheckVertical(size_t startI, size_t centerJ, int if (i < 0 || stateCount[1] > maxCount) { return nan(); } - while (i >= 0 && image_->get(centerJ, i) && stateCount[0] <= maxCount) { + while (i >= 0 && image_->get(int(centerJ), i) && stateCount[0] <= maxCount) { stateCount[0]++; i--; } @@ -150,22 +150,22 @@ float FinderPatternFinder::crossCheckVertical(size_t startI, size_t centerJ, int } // Now also count down from center - i = startI + 1; - while (i < maxI && image_->get(centerJ, i)) { + i = int(startI) + 1; + while (i < maxI && image_->get(int(centerJ), i)) { stateCount[2]++; i++; } if (i == maxI) { return nan(); } - while (i < maxI && !image_->get(centerJ, i) && stateCount[3] < maxCount) { + while (i < maxI && !image_->get(int(centerJ), i) && stateCount[3] < maxCount) { stateCount[3]++; i++; } if (i == maxI || stateCount[3] >= maxCount) { return nan(); } - while (i < maxI && image_->get(centerJ, i) && stateCount[4] < maxCount) { + while (i < maxI && image_->get(int(centerJ), i) && stateCount[4] < maxCount) { stateCount[4]++; i++; } @@ -189,22 +189,22 @@ float FinderPatternFinder::crossCheckHorizontal(size_t startJ, size_t centerI, i int maxJ = image_->getWidth(); int *stateCount = getCrossCheckStateCount(); - int j = startJ; - while (j >= 0 && image_->get(j, centerI)) { + int j = int(startJ); + while (j >= 0 && image_->get(j, int(centerI))) { stateCount[2]++; j--; } if (j < 0) { return nan(); } - while (j >= 0 && !image_->get(j, centerI) && stateCount[1] <= maxCount) { + while (j >= 0 && !image_->get(j, int(centerI)) && stateCount[1] <= maxCount) { stateCount[1]++; j--; } if (j < 0 || stateCount[1] > maxCount) { return nan(); } - while (j >= 0 && image_->get(j, centerI) && stateCount[0] <= maxCount) { + while (j >= 0 && image_->get(j, int(centerI)) && stateCount[0] <= maxCount) { stateCount[0]++; j--; } @@ -212,22 +212,22 @@ float FinderPatternFinder::crossCheckHorizontal(size_t startJ, size_t centerI, i return nan(); } - j = startJ + 1; - while (j < maxJ && image_->get(j, centerI)) { + j = int(startJ) + 1; + while (j < maxJ && image_->get(j, int(centerI))) { stateCount[2]++; j++; } if (j == maxJ) { return nan(); } - while (j < maxJ && !image_->get(j, centerI) && stateCount[3] < maxCount) { + while (j < maxJ && !image_->get(j, int(centerI)) && stateCount[3] < maxCount) { stateCount[3]++; j++; } if (j == maxJ || stateCount[3] >= maxCount) { return nan(); } - while (j < maxJ && image_->get(j, centerI) && stateCount[4] < maxCount) { + while (j < maxJ && image_->get(j, int(centerI)) && stateCount[4] < maxCount) { stateCount[4]++; j++; } @@ -247,7 +247,7 @@ float FinderPatternFinder::crossCheckHorizontal(size_t startJ, size_t centerI, i bool FinderPatternFinder::handlePossibleCenter(int* stateCount, size_t i, size_t j) { int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - float centerJ = centerFromEnd(stateCount, j); + float centerJ = centerFromEnd(stateCount, int(j)); float centerI = crossCheckVertical(i, (size_t)centerJ, stateCount[2], stateCountTotal); if (!isnan_z(centerI)) { // Re-cross check @@ -459,7 +459,7 @@ Ref FinderPatternFinder::find(DecodeHints const& hints) { // modules in size. This gives the smallest number of pixels the center // could be, so skip this often. When trying harder, look for all // QR versions regardless of how dense they are. - int iSkip = (3 * maxI) / (4 * MAX_MODULES); + int iSkip = (3 * int(maxI)) / (4 * MAX_MODULES); if (iSkip < MIN_SKIP || tryHarder) { iSkip = MIN_SKIP; } @@ -473,7 +473,7 @@ Ref FinderPatternFinder::find(DecodeHints const& hints) { memset(stateCount, 0, sizeof(stateCount)); int currentState = 0; for (size_t j = 0; j < maxJ; j++) { - if (matrix.get(j, i)) { + if (matrix.get(int(j), int(i))) { // Black pixel if ((currentState & 1) == 1) { // Counting white pixels currentState++; From 076dd575bd1c5702611a12a0710d34c78d5da4a8 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 16:41:52 +0100 Subject: [PATCH 18/83] Adopted to latest upstream changes --- src/CameraImageWrapper.cpp | 4 +-- src/zxing/zxing/common/BitArray.cpp | 4 +-- .../GreyscaleRotatedLuminanceSource.cpp | 2 +- src/zxing/zxing/common/StringUtils.cpp | 4 +-- src/zxing/zxing/qrcode/encoder/MaskUtil.cpp | 2 +- src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 2 +- .../reedsolomon/ReedSolomonEncoderTests.cpp | 28 +++++++++---------- .../zxing/qrcode/encoder/EncoderTests.cpp | 10 +++---- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/CameraImageWrapper.cpp b/src/CameraImageWrapper.cpp index 6c15248..3a33614 100644 --- a/src/CameraImageWrapper.cpp +++ b/src/CameraImageWrapper.cpp @@ -179,7 +179,7 @@ ArrayRef CameraImageWrapper::getMatrixP() const return imageBytes; } -byte CameraImageWrapper::gray(unsigned int r, unsigned int g, unsigned int b) +zxing::byte CameraImageWrapper::gray(unsigned int r, unsigned int g, unsigned int b) { //the values are not masked with (x & 0xFF) because functions qRed, qGreen, qBlue already do it return R_TO_GREYSCALE[r] + G_TO_GREYSCALE[g] + B_TO_GREYSCALE[b]; @@ -197,7 +197,7 @@ void CameraImageWrapper::updateImageAsGrayscale(const QImage &origin) imageBytes = ArrayRef(height*width); imageBytesPerRow = ArrayRef>(height); - byte* m = &imageBytes[0]; + zxing::byte* m = &imageBytes[0]; for(int j=0; j& array, int offset, int numBytes) const +void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int numBytes) const { if(int(array.size()) < (numBytes + offset)) array.resize(size_t(numBytes + offset)); @@ -276,7 +276,7 @@ void BitArray::toBytes(int bitOffset, std::vector& array, int offset, int } bitOffset++; } - array[size_t(offset + i)] = byte(theByte); + array[size_t(offset + i)] = zxing::byte(theByte); } } diff --git a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp index 2ef3e12..0870468 100644 --- a/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp +++ b/src/zxing/zxing/common/GreyscaleRotatedLuminanceSource.cpp @@ -71,7 +71,7 @@ GreyscaleRotatedLuminanceSource::getRow(int y, ArrayRef row) const ArrayRef GreyscaleRotatedLuminanceSource::getMatrix() const { ArrayRef result (getWidth() * getHeight()); for (int y = 0; y < getHeight(); y++) { - byte* row = &result[y * getWidth()]; + zxing::byte* row = &result[y * getWidth()]; int offset = (left_ * dataWidth_) + (dataWidth_ - 1 - (y + top_)); for (int x = 0; x < getWidth(); x++) { row[x] = greyData_[offset]; diff --git a/src/zxing/zxing/common/StringUtils.cpp b/src/zxing/zxing/common/StringUtils.cpp index e894765..797f8cd 100644 --- a/src/zxing/zxing/common/StringUtils.cpp +++ b/src/zxing/zxing/common/StringUtils.cpp @@ -36,7 +36,7 @@ char const* const StringUtils::ISO88591 = "ISO8859-1"; const bool StringUtils::ASSUME_SHIFT_JIS = false; string -StringUtils::guessEncoding(byte* bytes, int length, +StringUtils::guessEncoding(zxing::byte* bytes, int length, Hashtable const& hints) { Hashtable::const_iterator i = hints.find(DecodeHints::CHARACTER_SET); if (i != hints.end()) { @@ -65,7 +65,7 @@ StringUtils::guessEncoding(byte* bytes, int length, //int isoHighChars = 0; int isoHighOther = 0; - typedef byte byte; + typedef zxing::byte byte; boolean utf8bom = length > 3 && bytes[0] == (zxing::byte) 0xEF && bytes[1] == (zxing::byte) 0xBB && diff --git a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp index c8baa5f..cb97f1d 100644 --- a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp +++ b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp @@ -183,7 +183,7 @@ int MaskUtil::applyMaskPenaltyRule1Internal(const ByteMatrix& matrix, bool isHor int penalty = 0; int iLimit = int(isHorizontal ? matrix.getHeight() : matrix.getWidth()); int jLimit = int(isHorizontal ? matrix.getWidth() : matrix.getHeight()); - const std::vector >& array = matrix.getArray(); + const std::vector >& array = matrix.getArray(); for (int i = 0; i < iLimit; i++) { int numSameBitCells = 0; int prevBit = -1; diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index 4e33255..7eb09ca 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -420,7 +420,7 @@ BitArray* Encoder::interleaveWithECBytes(const BitArray& bits, return result; } -ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) +ArrayRef Encoder::generateECBytes(const std::vector& dataBytes, int numEcBytesInBlock) { size_t numDataBytes = dataBytes.size(); std::vector dataBytesCopy(dataBytes); diff --git a/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp b/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp index 83b89ab..cd5b437 100644 --- a/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp +++ b/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp @@ -43,7 +43,7 @@ void ReedSolomonTests::testQRCode() // testEncodeDecodeRandom(GenericGF::QR_CODE_FIELD_256, 220, 35); } -void ReedSolomonTests::corrupt(std::vector &received, int howMany, int max) +void ReedSolomonTests::corrupt(std::vector &received, int howMany, int max) { std::vector corrupted(received.size(), false); for (int j = 0; j < howMany; j++) { @@ -63,9 +63,9 @@ void ReedSolomonTests::testEncodeDecodeRandom(Ref field, int dataSize assertTrue(dataSize > 0 && dataSize <= field->getSize() - 3); /*"Invalid data size for " + field, */ assertTrue(ecSize > 0 && ecSize + dataSize <= field->getSize()); /*"Invalid ECC size for " + field, */ ReedSolomonEncoder encoder(field); - std::vector message;//(dataSize + ecSize); - std::vector dataWords(dataSize); - std::vector ecWords(ecSize); + std::vector message;//(dataSize + ecSize); + std::vector dataWords(dataSize); + std::vector ecWords(ecSize); initializeRandom(); int iterations = field->getSize() > 256 ? 1 : DECODER_RANDOM_TEST_ITERATIONS; for (int i = 0; i < iterations; i++) { @@ -83,20 +83,20 @@ void ReedSolomonTests::testEncodeDecodeRandom(Ref field, int dataSize } void ReedSolomonTests::testEncodeDecode(Ref field, - const std::vector &dataWords, - const std::vector &ecWords) + const std::vector &dataWords, + const std::vector &ecWords) { testEncoder(field, dataWords, ecWords); testDecoder(field, dataWords, ecWords); } void ReedSolomonTests::testEncoder(Ref field, - const std::vector &dataWords, - const std::vector &ecWords) + const std::vector &dataWords, + const std::vector &ecWords) { ReedSolomonEncoder encoder(field); - std::vector messageExpected; - std::vector message(dataWords); + std::vector messageExpected; + std::vector message(dataWords); messageExpected = dataWords; messageExpected.insert(std::end(messageExpected), std::begin(ecWords), std::end(ecWords)); @@ -107,11 +107,11 @@ void ReedSolomonTests::testEncoder(Ref field, } void ReedSolomonTests::testDecoder(Ref field, - const std::vector &dataWords, - const std::vector &ecWords) { + const std::vector &dataWords, + const std::vector &ecWords) { ReedSolomonDecoder decoder(field); - std::vector message; - std::vector referenceMessage; + std::vector message; + std::vector referenceMessage; int maxErrors = ecWords.size() / 2; initializeRandom(); diff --git a/tests/src/QZXingTests/zxing/qrcode/encoder/EncoderTests.cpp b/tests/src/QZXingTests/zxing/qrcode/encoder/EncoderTests.cpp index d6215ce..779ae99 100644 --- a/tests/src/QZXingTests/zxing/qrcode/encoder/EncoderTests.cpp +++ b/tests/src/QZXingTests/zxing/qrcode/encoder/EncoderTests.cpp @@ -263,7 +263,7 @@ void EncoderTests::testGetNumDataBytesAndNumECBytesForBlockID() void EncoderTests::testInterleaveWithECBytes() { const byte arr[] = {32, 65, 205, 69, 41, 220, 46, 128, 236}; - std::vector dataBytes (arr, arr + getArrayLength(arr)); + std::vector dataBytes (arr, arr + getArrayLength(arr)); BitArray in; for (byte dataByte: dataBytes) { @@ -280,7 +280,7 @@ void EncoderTests::testInterleaveWithECBytes() }; int expectedLength = getArrayLength(expected); assertEquals(expectedLength, out->getSizeInBytes()); - std::vector outArray; + std::vector outArray; out->toBytes(0, outArray, 0, expectedLength); // Can't use Arrays.equals(), because outArray may be longer than out.sizeInBytes() @@ -297,7 +297,7 @@ void EncoderTests::testInterleaveWithECBytes() 135, 151, 160, 236, 17, 236, 17, 236, 17, 236, 17 }; - dataBytes = std::vector(arr2, arr2 + getArrayLength(arr2)); + dataBytes = std::vector(arr2, arr2 + getArrayLength(arr2)); in = BitArray(); foreach (byte dataByte, dataBytes) { @@ -392,9 +392,9 @@ void EncoderTests::testAppend8BitBytes() void EncoderTests::testGenerateECBytes() { - std::vector dataBytes = {32, 65, 205, 69, 41, 220, 46, 128, 236}; + std::vector dataBytes = {32, 65, 205, 69, 41, 220, 46, 128, 236}; - ArrayRef ecBytes = Encoder::generateECBytes(dataBytes, 17); + ArrayRef ecBytes = Encoder::generateECBytes(dataBytes, 17); byte expected[] = { 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61 }; From 6c6999256c9778de2fa0508b0ba648eea20d69a9 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Mon, 5 Nov 2018 17:13:34 +0100 Subject: [PATCH 19/83] Fixed compiling tests & fixed warnings (except THROWS macro) --- src/zxing/zxing/common/StringUtils.cpp | 1 - tests/src/QZXingTests/DecodeValidator.cpp | 6 ++++-- tests/src/QZXingTests/TestCase.h | 21 ++++++++++--------- tests/src/QZXingTests/main.cpp | 2 +- .../reedsolomon/ReedSolomonEncoderTests.cpp | 6 +++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/zxing/zxing/common/StringUtils.cpp b/src/zxing/zxing/common/StringUtils.cpp index 797f8cd..09e8178 100644 --- a/src/zxing/zxing/common/StringUtils.cpp +++ b/src/zxing/zxing/common/StringUtils.cpp @@ -65,7 +65,6 @@ StringUtils::guessEncoding(zxing::byte* bytes, int length, //int isoHighChars = 0; int isoHighOther = 0; - typedef zxing::byte byte; boolean utf8bom = length > 3 && bytes[0] == (zxing::byte) 0xEF && bytes[1] == (zxing::byte) 0xBB && diff --git a/tests/src/QZXingTests/DecodeValidator.cpp b/tests/src/QZXingTests/DecodeValidator.cpp index 577d682..43c82a8 100644 --- a/tests/src/QZXingTests/DecodeValidator.cpp +++ b/tests/src/QZXingTests/DecodeValidator.cpp @@ -1,8 +1,10 @@ #include "DecodeValidator.h" +#include #include #include #include +#include #define LOG_OUTPUT_DIVIDER "##############################################" #define LOG_SECTOR_TITLE(a) '\n' << LOG_OUTPUT_DIVIDER\ @@ -123,13 +125,13 @@ void DecodeValidator::printResults() if(failedResultLogs.size()) qDebug() << " failed image files:"; - for(size_t i=0; i #include #include "backward.hpp" +#include #include namespace zxing{ @@ -45,7 +46,7 @@ private: return QString::number(item); } - static QString itemToString(byte item) { + static QString itemToString(zxing::byte item) { return QString::number(item); } @@ -109,13 +110,13 @@ protected: } void assertDataEquals(const std::string &message, - const std::vector &expected, - const std::vector & received) + const std::vector &expected, + const std::vector & received) { if(expected.size() != received.size()) assertTrue(false); - for (int i = 0; i < expected.size(); i++) { + for (size_t i = 0; i < expected.size(); i++) { if (expected[i] != received[i]) { qDebug() << QString::fromStdString(message) << ". Mismatch at " << QString::number(i) /*<< ". Expected " + arrayToString(expected) + ", got " + arrayToString(Arrays.copyOf(received, expected.length)))*/; @@ -125,13 +126,13 @@ protected: } void assertDataEquals(const std::string &message, - const std::vector &expected, - const ArrayRef &received) + const std::vector &expected, + const ArrayRef &received) { - if(expected.size() != received->size()) + if(int(expected.size()) != received->size()) assertTrue(false); - for (int i = 0; i < expected.size(); i++) { + for (size_t i = 0; i < expected.size(); i++) { if (expected[i] != received[i]) { qDebug() << QString::fromStdString(message) << ". Mismatch at " << QString::number(i) /*<< ". Expected " + arrayToString(expected) + ", got " + arrayToString(Arrays.copyOf(received, expected.length)))*/; @@ -141,10 +142,10 @@ protected: } void assertDataEquals(const std::string &message, - const std::vector &expected, + const std::vector &expected, const ArrayRef &received) { - ArrayRef received_copy(received->size()); + ArrayRef received_copy(received->size()); for(int i=0; isize(); i++) received_copy[i] = received[i]; diff --git a/tests/src/QZXingTests/main.cpp b/tests/src/QZXingTests/main.cpp index 2f6ed0b..e2caf2b 100644 --- a/tests/src/QZXingTests/main.cpp +++ b/tests/src/QZXingTests/main.cpp @@ -3,7 +3,7 @@ #include "DecodeValidator.h" -int main(int /*argc*/, char */*argv[]*/) +int main(int /*argc*/, char **/*argv[]*/) { DecodeValidator decodeValidator; decodeValidator.executeTests("../../resources/"); diff --git a/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp b/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp index cd5b437..5920932 100644 --- a/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp +++ b/tests/src/QZXingTests/zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp @@ -121,8 +121,8 @@ void ReedSolomonTests::testDecoder(Ref field, referenceMessage.insert(std::end(referenceMessage), std::begin(ecWords), std::end(ecWords)); for (int j = 0; j < iterations; j++) { - for (int i = 0; i < ecWords.size(); i++) { - if (i > 10 && i < ecWords.size() / 2 - 10) { + for (int i = 0; i < int(ecWords.size()); i++) { + if (i > 10 && i < int(ecWords.size()) / 2 - 10) { // performance improvement - skip intermediate cases in long-running tests i += ecWords.size() / 10; } @@ -131,7 +131,7 @@ void ReedSolomonTests::testDecoder(Ref field, corrupt(message, i, field->getSize()); ArrayRef messageArrayRef(message.size()); - for(int i=0; i Date: Wed, 14 Nov 2018 16:55:44 +0800 Subject: [PATCH 20/83] Appveyor: Add ci for windows use msvc and mingw --- appveyor.yml | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..bb5aec8 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,113 @@ +#Author: KangLin(kl222@126.com) + +version: '0.1.1.{build}' + +image: Visual Studio 2015 + +configuration: + - release + - debug + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + QT_ROOT: C:/Qt/5.11/msvc2017_64 + - QT_ROOT: C:/Qt/5.11/msvc2015 + - QT_ROOT: C:/Qt/5.11/mingw53_32 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + QT_ROOT: C:/Qt/5.10/msvc2017_64 + - QT_ROOT: C:/Qt/5.10/msvc2015_64 + - QT_ROOT: C:/Qt/5.10/msvc2015 + - QT_ROOT: C:/Qt/5.10/msvc2013_64 + - QT_ROOT: C:/Qt/5.10/mingw53_32 + + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + QT_ROOT: C:/Qt/5.9/msvc2017_64 + - QT_ROOT: C:/Qt/5.9/msvc2015_64 + - QT_ROOT: C:/Qt/5.9/msvc2015 + - QT_ROOT: C:/Qt/5.9/msvc2013_64 + - QT_ROOT: C:/Qt/5.9/mingw53_32 + + - QT_ROOT: C:/Qt/5.7.0/msvc2015 + - QT_ROOT: C:/Qt/5.7.0/mingw53_32 + + - QT_ROOT: C:/Qt/5.6/msvc2015_64 + - QT_ROOT: C:/Qt/5.6/msvc2015 + - QT_ROOT: C:/Qt/5.6/msvc2013_64 + - QT_ROOT: C:/Qt/5.6/msvc2013 + +init: + +install: + - for /f "delims=" %%i in ('git describe --tags') do (set BUILD_VERSION=%%i) + - if "%BUILD_VERSION%" == "" for /f "delims=" %%i in ('git rev-parse HEAD') do (set BUILD_VERSION=%%i) + - echo BUILD_VERSION=%BUILD_VERSION% + - if NOT "%QT_ROOT%" == "NO" for /f "delims=" %%i in ('%QT_ROOT%/bin/qmake -query QT_VERSION') do (set QT_VERSION=%%i) + - echo "QT_VERSION:%QT_VERSION" + - if NOT "%QT_ROOT%" == "NO" for /f "delims=" %%i in ('%QT_ROOT%/bin/qmake -query QMAKE_XSPEC') do (set QMAKE_XSPEC=%%i) + - echo "QMAKE_XSPEC=%QMAKE_XSPEC%" + - set TOOLCHAIN_VERSION="" + - ps: >- + if (($env:QMAKE_XSPEC).Contains("msvc")) + { + $env:MAKE="nmake" + if (($env:QT_ROOT).Contains("_64")) + { + $env:varch="amd64" + } + else + { + $env:varch="x86" + } + if (($env:QT_ROOT).Contains("2017")) + { + $env:TOOLCHAIN_VERSION="15" + } + else + { + if (($env:QT_ROOT).Contains("2015")) + { + $env:TOOLCHAIN_VERSION="14" + }elseif (($env:QT_ROOT).Contains("2013")) + { + $env:TOOLCHAIN_VERSION="12" + } + } + } + else + { + $env:MAKE="mingw32-make" + $env:PATH="C:\Qt\Tools\mingw530_32;$env:PATH" + } + + - if NOT "%TOOLCHAIN_VERSION%"=="" if %TOOLCHAIN_VERSION% LSS 15 (call "C:/Program Files (x86)/Microsoft Visual Studio %TOOLCHAIN_VERSION%.0/VC/vcvarsall.bat" %varch%) else (call "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat" %varch%) + - echo "cl " + - cl + +build_script: + - mkdir "%APPVEYOR_BUILD_FOLDER%/build" + - cd "%APPVEYOR_BUILD_FOLDER%/build" + - call "%QT_ROOT%/bin/qmake.exe" CONFIG+=%Configuration% PREFIX="%APPVEYOR_BUILD_FOLDER%/install" "%APPVEYOR_BUILD_FOLDER%/src/QZXing.pro" + - call %MAKE% + - call %MAKE% install + +test_script: + +artifacts: + - path: install + name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_$(BUILD_VERSION) + type: zip + +# whitelist branches to avoid testing feature branches twice (as branch and as pull request) +branches: + only: + - master + +deploy: + provider: GitHub + #token: https://github.com/settings/tokens encode token: https://ci.appveyor.com/tools/encrypt + auth_token: + secure: #TODO: set your token + on: + appveyor_repo_tag: true # deploy on tag push only From 6e5d4087321d6464eea78484a8f88c1c09a74df8 Mon Sep 17 00:00:00 2001 From: KangLin Date: Wed, 14 Nov 2018 16:56:14 +0800 Subject: [PATCH 21/83] Travis: add ci for linux and android --- .travis.yml | 49 ++++++++++++++ ci/build-install-tools.sh | 78 ++++++++++++++++++++++ ci/build_env.sh | 24 +++++++ ci/qt-installer.sh | 133 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 284 insertions(+) create mode 100644 .travis.yml create mode 100644 ci/build-install-tools.sh create mode 100644 ci/build_env.sh create mode 100644 ci/qt-installer.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f86b3d8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,49 @@ +#Author: KangLin(kl222@126.com) + +sudo: required +dist: trusty + +language: cpp + +cache: + - apt: true + - directories: + - Tools + +compiler: + - g++ + +jdk: oraclejdk7 + +os: + - unix + +addons: + ssh_known_hosts: + - github.com + +env: + matrix: + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.11 QT_VERSION=5.11.2 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.11 QT_VERSION=5.11.2 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.10 QT_VERSION=5.10.1 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.10 QT_VERSION=5.10.1 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.7 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.7 + +before_install: + - echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}" + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + +install: + - bash ${TRAVIS_BUILD_DIR}/ci/build-install-tools.sh #> /dev/null + +before_script: + - source ${TRAVIS_BUILD_DIR}/ci/build_env.sh + +script: + - mkdir ${TRAVIS_BUILD_DIR}/build + - cd ${TRAVIS_BUILD_DIR}/build + - ${QT_ROOT}/bin/qmake -o Makefile CONFIG+=Release ${TRAVIS_BUILD_DIR}/src/QZXing.pro + - make -f Makefile diff --git a/ci/build-install-tools.sh b/ci/build-install-tools.sh new file mode 100644 index 0000000..4f5f792 --- /dev/null +++ b/ci/build-install-tools.sh @@ -0,0 +1,78 @@ +#!/bin/bash +#Author: KangLin(kl222@126.com) + +set -e + +SOURCE_DIR="`pwd`" +echo $SOURCE_DIR +TOOLS_DIR=${SOURCE_DIR}/Tools +echo ${TOOLS_DIR} + +if [ ! -f "${TOOLS_DIR}" ]; then + mkdir -p ${TOOLS_DIR} +fi + +function function_common() +{ + cd ${TOOLS_DIR} + + # Qt download and install:https://github.com/benlau/qtci + if [ -n "${QT_VERSION}" ]; then + QT_DIR=`pwd`/Qt/${QT_VERSION} + if [ ! -d "${QT_DIR}" ]; then + wget -c --no-check-certificate -nv http://download.qt.io/official_releases/qt/${QT_VERSION_DIR}/${QT_VERSION}/qt-opensource-linux-x64-${QT_VERSION}.run + bash ${SOURCE_DIR}/ci/qt-installer.sh qt-opensource-linux-x64-${QT_VERSION}.run ${QT_DIR} + rm qt-opensource-linux-x64-${QT_VERSION}.run + fi + fi +} + +function function_android() +{ + cd ${TOOLS_DIR} + + #Download android ndk + if [ ! -d "`pwd`/android-ndk" ]; then + wget -c -nv http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin + chmod u+x android-ndk-r10e-linux-x86_64.bin + ./android-ndk-r10e-linux-x86_64.bin > /dev/null + mv android-ndk-r10e android-ndk + rm android-ndk-r10e-linux-x86_64.bin + fi + + cd ${TOOLS_DIR} + + #Download android sdk + if [ ! -d "`pwd`/android-sdk" ]; then + wget -c -nv https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz + tar xf android-sdk_r24.4.1-linux.tgz + mv android-sdk-linux android-sdk + rm android-sdk_r24.4.1-linux.tgz + (sleep 5 ; while true ; do sleep 1 ; printf 'y\r\n' ; done ) \ + | android-sdk/tools/android update sdk -u -t tool,android-18,android-24,extra,platform,platform-tools,build-tools-25 + fi + + function_common + cd ${SOURCE_DIR} +} + +function function_linux() +{ + function_common + + cd ${SOURCE_DIR} +} + +case ${BUILD_TARGERT} in + android*) + function_android + ;; + linux) + function_linux + ;; + *) + echo "There aren't ${BUILD_TARGERT}" + ;; +esac + +cd ${SOURCE_DIR} diff --git a/ci/build_env.sh b/ci/build_env.sh new file mode 100644 index 0000000..8434b38 --- /dev/null +++ b/ci/build_env.sh @@ -0,0 +1,24 @@ +#Author: KangLin(kl222@126.com) + +SOURCE_DIR="`pwd`" +echo $SOURCE_DIR +TOOLS_DIR=${SOURCE_DIR}/Tools + +cd ${TOOLS_DIR} + +case "${BUILD_TARGERT}" in + linux) + QT_DIR=`pwd`/Qt/${QT_VERSION} + export QT_ROOT=${QT_DIR}/${QT_VERSION}/gcc_64 + ;; + android*) + export ANDROID_NDK_ROOT=`pwd`/android-ndk + export ANDROID_NDK=$ANDROID_NDK_ROOT + + export ANDROID_SDK_ROOT=`pwd`/android-sdk + export ANDROID_SDK=$ANDROID_SDK_ROOT + + QT_DIR=`pwd`/Qt/${QT_VERSION} + export QT_ROOT=${QT_DIR}/${QT_VERSION}/android_armv7 + ;; +esac diff --git a/ci/qt-installer.sh b/ci/qt-installer.sh new file mode 100644 index 0000000..6eb39ca --- /dev/null +++ b/ci/qt-installer.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +#http://stackoverflow.com/questions/25105269/silent-install-qt-run-installer-on-ubuntu-server +#http://doc.qt.io/qtinstallerframework/noninteractive.html +#参考:https://github.com/benlau/qtci +# https://github.com/mjscosta/qt-silent-installer + +set -e #quit on error + +if [ $# -lt 2 ]; +then + echo qt-installer.sh qt-installer-file output_path + exit -1 +fi + +export PATH=$PATH:$PWD +export WORKDIR=$PWD +INSTALLER=$1 +OUTPUT=$2 +SCRIPT="$(mktemp /tmp/tmp.XXXXXXXXX)" +case $BUILD_TARGERT in + android_arm*) + SELECTEDPACKAGES=android_armv7 + ;; + android_x86) + SELECTEDPACKAGES=android_x86 + ;; + linux) + SELECTEDPACKAGES=gcc_64 + ;; + *) + echo "Aach[$RABBIT_ARCH] don't suppoert" +esac + +cat < $SCRIPT +function Controller() { + installer.autoRejectMessageBoxes(); + installer.installationFinished.connect(function() { + gui.clickButton(buttons.NextButton); + }); +} + +function log() { + var msg = ["QTCI: "].concat([].slice.call(arguments)); + + console.log(msg.join(" ")); +} + +Controller.prototype.WelcomePageCallback = function() { + gui.clickButton(buttons.NextButton, 5000); +} + +Controller.prototype.CredentialsPageCallback = function() { + gui.clickButton(buttons.CommitButton); +} + +Controller.prototype.ComponentSelectionPageCallback = function() { + var components = installer.components(); + log("Available components: " + components.length); + for (var i = 0 ; i < components.length ;i++) { + log(components[i].name); + } + log("Select components"); + function trim(str) { + return str.replace(/^ +/,"").replace(/ *$/,""); + } + var widget = gui.currentPageWidget(); + widget.deselectAll(); + var packages = trim("$SELECTEDPACKAGES").split(","); + if (packages.length > 0 && packages[0] !== "") { + + for (var i in packages) { + var pkg = trim(packages[i]); + for (var i = 0 ; i < components.length ;i++) { + if(components[i].name.indexOf(pkg) != -1) + { + log("Select " + components[i].name); + widget.selectComponent(trim(components[i].name)); + } + } + } + } else { + log("Use default component list"); + } + + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.IntroductionPageCallback = function() { + gui.clickButton(buttons.NextButton); +} + + +Controller.prototype.TargetDirectoryPageCallback = function() { + var widget = gui.currentPageWidget(); + + if (widget != null) { + widget.TargetDirectoryLineEdit.setText("$OUTPUT"); + } + + gui.clickButton(buttons.NextButton); + +} + +Controller.prototype.LicenseAgreementPageCallback = function() { + var widget = gui.currentPageWidget(); + + if (widget != null) { + widget.AcceptLicenseRadioButton.setChecked(true); + } + + gui.clickButton(buttons.NextButton); +} + +Controller.prototype.StartMenuDirectoryPageCallback = function() { + gui.clickButton(buttons.CommitButton); +} + +Controller.prototype.ReadyForInstallationPageCallback = function() { + gui.clickButton(buttons.CommitButton); +} + +Controller.prototype.FinishedPageCallback = function() { + var widget = gui.currentPageWidget(); + widget.LaunchQtCreatorCheckBoxForm.launchQtCreatorCheckBox.setChecked(false); + gui.clickButton(buttons.FinishButton); +} +EOF + +chmod u+x $1 + +$1 -v --script $SCRIPT + From 3e3c653b21e5fc828cc880ab0dc65acdc23fe43e Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Wed, 14 Nov 2018 19:35:26 +0200 Subject: [PATCH 22/83] Update README.md added build status badge from travis-ci --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3aec30..dcf5b9b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# qzxing +# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) Qt/QML wrapper library for the [ZXing](https://github.com/zxing/zxing) barcode image processing library. Supports barcode decoding for the following types: From f5125e442096c7d1345d5ea3fb7f7d8a543c6372 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Thu, 15 Nov 2018 14:17:10 +0100 Subject: [PATCH 23/83] Fixed QZXingImageProvider ignoring requestedSize when being called without custom settings --- src/QZXingImageProvider.cpp | 50 ++++++++++++++----------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/src/QZXingImageProvider.cpp b/src/QZXingImageProvider.cpp index 6b9d062..30aab6d 100644 --- a/src/QZXingImageProvider.cpp +++ b/src/QZXingImageProvider.cpp @@ -10,7 +10,8 @@ QZXingImageProvider::QZXingImageProvider() : QQuickImageProvider(QQuickImageProv QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { int slashIndex = id.indexOf('/'); - if (slashIndex == -1) { + if (slashIndex == -1) + { qWarning() << "Can't parse url" << id << ". Usage is encode?/"; return QImage(); } @@ -23,15 +24,11 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q return QImage(); } - int customSettingsIndex = id.lastIndexOf('?'); - QString data; - QImage result; - QString corretionLevel; - QString format; - QZXing::EncodeErrorCorrectionLevel correctionLevelEnum = - QZXing::EncodeErrorCorrectionLevel_L; + QZXing::EncoderFormat format = QZXing::EncoderFormat_QR_CODE; + QZXing::EncodeErrorCorrectionLevel correctionLevel = QZXing::EncodeErrorCorrectionLevel_L; + int customSettingsIndex = id.lastIndexOf('?'); if(customSettingsIndex >= 0) { int startOfDataIndex = slashIndex + 1; @@ -41,37 +38,28 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q // it could not recognize the first key-value pair provided QUrlQuery optionQuery("options?dummy=&" + id.mid(customSettingsIndex + 1)); - corretionLevel = optionQuery.queryItemValue("corretionLevel"); - format = optionQuery.queryItemValue("format"); - - if(corretionLevel == "H") - correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_H; - else if(corretionLevel == "Q") - correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_Q; - else if(corretionLevel == "M") - correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_M; - else if(corretionLevel == "L") - correctionLevelEnum = QZXing::EncodeErrorCorrectionLevel_L; - } - - if(!corretionLevel.isEmpty() || !format.isEmpty()) - { - if(format != "qrcode") + QString correctionLevelString = optionQuery.queryItemValue("corretionLevel"); + QString formatString = optionQuery.queryItemValue("format"); + if(formatString != "qrcode") { - qWarning() << "Format not supported: " << format; + qWarning() << "Format not supported: " << formatString; return QImage(); } - result = QZXing::encodeData(data, QZXing::EncoderFormat_QR_CODE, - requestedSize, - correctionLevelEnum); - } - else + if(correctionLevelString == "H") + correctionLevel = QZXing::EncodeErrorCorrectionLevel_H; + else if(correctionLevelString == "Q") + correctionLevel = QZXing::EncodeErrorCorrectionLevel_Q; + else if(correctionLevelString == "M") + correctionLevel = QZXing::EncodeErrorCorrectionLevel_M; + else if(correctionLevelString == "L") + correctionLevel = QZXing::EncodeErrorCorrectionLevel_L; + } else { data = id.mid(slashIndex + 1); - result = QZXing::encodeData(data); } + QImage result = QZXing::encodeData(data, format, requestedSize, correctionLevel); *size = result.size(); return result; } From 3f3a89b2ba6d0bc8032d5b91e597348cf5768768 Mon Sep 17 00:00:00 2001 From: Alexander Stillich Date: Fri, 16 Nov 2018 13:05:58 +0100 Subject: [PATCH 24/83] Introduced ZXING_NULLPTR and ZXING_NOEXCEPT to abstract differences between C+11 and non-C++11 compilers Fixed warnings in QZXingFilter.cpp Removed C++11 requirement from all .pro files Set compiler warning flags via CONFIG += warn_on instead of using GCC specific switches --- examples/BarcodeEncoder/BarcodeEncoder.pro | 4 +- .../QMLBarcodeScanner/QMLBarcodeReader.pro | 2 - .../QZXingDragNDropTest.pro | 4 +- examples/QZXingLive/QZXingLive.pro | 4 +- src/QZXing.cpp | 4 +- src/QZXing.h | 6 ++- src/QZXing.pri | 2 +- src/QZXing.pro | 1 - src/QZXingFilter.cpp | 43 ++++++++++--------- src/zxing/zxing/ChecksumException.cpp | 6 +-- src/zxing/zxing/ChecksumException.h | 6 +-- src/zxing/zxing/Exception.cpp | 14 +++--- src/zxing/zxing/Exception.h | 12 +++--- src/zxing/zxing/FormatException.cpp | 2 +- src/zxing/zxing/FormatException.h | 2 +- src/zxing/zxing/IllegalStateException.cpp | 6 +-- src/zxing/zxing/IllegalStateException.h | 6 +-- src/zxing/zxing/NotFoundException.cpp | 6 +-- src/zxing/zxing/NotFoundException.h | 6 +-- src/zxing/zxing/ReaderException.cpp | 6 +-- src/zxing/zxing/ReaderException.h | 6 +-- .../zxing/UnsupportedEncodingException.cpp | 6 +-- .../zxing/UnsupportedEncodingException.h | 6 +-- src/zxing/zxing/WriterException.cpp | 6 +-- src/zxing/zxing/WriterException.h | 6 +-- src/zxing/zxing/ZXing.h | 14 ++++++ .../zxing/common/IllegalArgumentException.cpp | 2 +- .../zxing/common/IllegalArgumentException.h | 2 +- .../reedsolomon/ReedSolomonException.cpp | 4 +- .../common/reedsolomon/ReedSolomonException.h | 4 +- .../datamatrix/detector/DetectorException.h | 2 +- src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 8 ++-- tests/src/QZXingTests/QZXingTests.pro | 3 -- 33 files changed, 110 insertions(+), 101 deletions(-) diff --git a/examples/BarcodeEncoder/BarcodeEncoder.pro b/examples/BarcodeEncoder/BarcodeEncoder.pro index 7bc3c1e..cd6ef25 100644 --- a/examples/BarcodeEncoder/BarcodeEncoder.pro +++ b/examples/BarcodeEncoder/BarcodeEncoder.pro @@ -1,8 +1,6 @@ QT += qml quick -CONFIG += c++11 qzxing_qml - -gcc:QMAKE_CXXFLAGS += -Wall -Wextra +CONFIG += qzxing_qml SOURCES += main.cpp diff --git a/examples/QMLBarcodeScanner/QMLBarcodeReader.pro b/examples/QMLBarcodeScanner/QMLBarcodeReader.pro index 9a394d7..e14e7e1 100644 --- a/examples/QMLBarcodeScanner/QMLBarcodeReader.pro +++ b/examples/QMLBarcodeScanner/QMLBarcodeReader.pro @@ -4,8 +4,6 @@ VERSION = 1.1.0 QT += declarative network -gcc:QMAKE_CXXFLAGS += -Wall -Wextra - !maemo5 { contains(QT_CONFIG, opengl) { # QT += opengl diff --git a/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro b/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro index ab47305..fa6829e 100644 --- a/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro +++ b/examples/QZXingDragNDropTest/QZXingDragNDropTest.pro @@ -1,14 +1,12 @@ # Add more folders to ship with the application, here +DEPLOYMENTFOLDERS = folder_01 folder_01.source = qml/QZXingDragNDropTest folder_01.target = qml -DEPLOYMENTFOLDERS = folder_01 QT += widgets CONFIG += qzxing_qml -gcc:QMAKE_CXXFLAGS += -Wall -Wextra - # Additional import path used to resolve QML modules in Creator's code model QML_IMPORT_PATH = diff --git a/examples/QZXingLive/QZXingLive.pro b/examples/QZXingLive/QZXingLive.pro index 26c0054..2f2d741 100644 --- a/examples/QZXingLive/QZXingLive.pro +++ b/examples/QZXingLive/QZXingLive.pro @@ -1,8 +1,6 @@ TEMPLATE = app -CONFIG += c++11 qzxing_multimedia - -gcc:QMAKE_CXXFLAGS += -Wall -Wextra +CONFIG += qzxing_multimedia CONFIG(debug, debug|release) { CONFIG+=qml_debug diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 2070fa6..20f248c 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -332,7 +332,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo return ""; } - CameraImageWrapper *ciw = nullptr; + CameraImageWrapper *ciw = ZXING_NULLPTR; if ((maxWidth > 0) || (maxHeight > 0)) ciw = CameraImageWrapper::Factory(image, maxWidth, maxHeight, smoothTransformation); @@ -440,7 +440,7 @@ QString QZXing::decodeSubImageQML(QObject *item, const int offsetX, const int offsetY, const int width, const int height) { - if(item == nullptr) + if(item == ZXING_NULLPTR) { processingTime = 0; emit decodingFinished(false); diff --git a/src/QZXing.h b/src/QZXing.h index 4b6f603..e1bcee1 100644 --- a/src/QZXing.h +++ b/src/QZXing.h @@ -18,6 +18,8 @@ #define QZXING_H #include "QZXing_global.h" +#include "zxing/ZXing.h" + #include #include @@ -91,10 +93,10 @@ public: EncodeErrorCorrectionLevel_H }; - QZXing(QObject *parent = NULL); + QZXing(QObject *parent = ZXING_NULLPTR); ~QZXing(); - QZXing(DecoderFormat decodeHints, QObject *parent = NULL); + QZXing(DecoderFormat decodeHints, QObject *parent = ZXING_NULLPTR); #ifdef QZXING_QML diff --git a/src/QZXing.pri b/src/QZXing.pri index 8a8c975..f0976c9 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -14,7 +14,7 @@ # limitations under the License. # -CONFIG += qt +CONFIG += qt warn_on DEFINES += QZXING_LIBRARY \ ZXING_ICONV_CONST \ diff --git a/src/QZXing.pro b/src/QZXing.pro index 8cf5593..7545d2d 100644 --- a/src/QZXing.pro +++ b/src/QZXing.pro @@ -22,7 +22,6 @@ TARGET = QZXing TEMPLATE = lib # CONFIG += staticlib -gcc:QMAKE_CXXFLAGS += -Wall -Wextra DEFINES -= DISABLE_LIBRARY_FEATURES symbian { diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index 8a630a5..f60883d 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -1,3 +1,4 @@ +#include "zxing/ZXing.h" #include "QZXingFilter.h" #include @@ -14,13 +15,13 @@ namespace { } uchar yuvToGray(uchar Y, uchar U, uchar V) { - const int C = (int) Y - 16; - const int D = (int) U - 128; - const int E = (int) V - 128; + const int C = int(Y) - 16; + const int D = int(U) - 128; + const int E = int(V) - 128; return gray( - qBound(0, (298 * C + 409 * E + 128) >> 8, 255), - qBound(0, (298 * C - 100 * D - 208 * E + 128) >> 8, 255), - qBound(0, (298 * C + 516 * D + 128) >> 8, 255) + qBound(0, uchar((298 * C + 409 * E + 128) >> 8), 255), + qBound(0, uchar((298 * C - 100 * D - 208 * E + 128) >> 8), 255), + qBound(0, uchar((298 * C + 516 * D + 128) >> 8), 255) ); } } @@ -68,14 +69,14 @@ QVideoFilterRunnable * QZXingFilter::createFilterRunnable() /// QZXingFilterRunnable::QZXingFilterRunnable(QZXingFilter * filter) - : QObject(nullptr) + : QObject(ZXING_NULLPTR) , filter(filter) { } QZXingFilterRunnable::~QZXingFilterRunnable() { - filter = nullptr; + filter = ZXING_NULLPTR; } QVideoFrame QZXingFilterRunnable::run(QVideoFrame * input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags) @@ -133,6 +134,8 @@ struct CaptureRect {} bool isValid; + char pad[3]; // avoid warning about padding + int sourceWidth; int sourceHeight; @@ -172,9 +175,9 @@ static QImage* rgbDataToGrayscale(const uchar* data, const CaptureRect& captureR uchar b = data[blue]; if (isPremultiplied) { uchar a = data[alpha]; - r = (uint(r) * 255) / a; - g = (uint(g) * 255) / a; - b = (uint(b) * 255) / a; + r = uchar((uint(r) * 255) / a); + g = uchar((uint(g) * 255) / a); + b = uchar((uint(b) * 255) / a); } *pixel = gray(r, g, b); ++pixel; @@ -194,17 +197,17 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame const int width = videoFrame.size.width(); const int height = videoFrame.size.height(); const CaptureRect captureRect(_captureRect, width, height); - const uchar* data = (uchar*) videoFrame.data.constData(); + const uchar* data = reinterpret_cast(videoFrame.data.constData()); uchar* pixel; int wh; int w_2; int wh_54; - uint32_t *yuvPtr = (uint32_t *)data; + const uint32_t *yuvPtr = reinterpret_cast(data); /// Create QImage from QVideoFrame. - QImage *image_ptr = nullptr; + QImage *image_ptr = ZXING_NULLPTR; switch (videoFrame.pixelFormat) { case QVideoFrame::Format_RGB32: @@ -287,12 +290,12 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame pixel = image_ptr->bits(); for (int y = captureRect.startY; y < captureRect.endY; y++){ - uint32_t *row = &yuvPtr[y*(width/2)-(width/4)]; + const uint32_t *row = &yuvPtr[y*(width/2)-(width/4)]; for (int x = captureRect.startX; x < captureRect.endX; x++){ - uint32_t pxl = row[x]; - const int y0 = (unsigned char)((uint8_t *)&pxl)[0]; - const int u = (unsigned char)((uint8_t *)&pxl)[1]; - const int v = (unsigned char)((uint8_t *)&pxl)[3]; + const uint8_t *pxl = reinterpret_cast(&row[x]); + const uint8_t y0 = pxl[0]; + const uint8_t u = pxl[1]; + const uint8_t v = pxl[3]; *pixel = yuvToGray(y0, u, v); ++pixel; } @@ -333,6 +336,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame QString QZXingFilterRunnable::decode(const QImage &image) { - return (filter != nullptr) ? + return (filter != ZXING_NULLPTR) ? filter->decoder.decodeImage(image, image.width(), image.height()) : QString(); } diff --git a/src/zxing/zxing/ChecksumException.cpp b/src/zxing/zxing/ChecksumException.cpp index b9c3c6c..f7c05cf 100644 --- a/src/zxing/zxing/ChecksumException.cpp +++ b/src/zxing/zxing/ChecksumException.cpp @@ -23,6 +23,6 @@ using zxing::ChecksumException; -ChecksumException::ChecksumException() noexcept {} -ChecksumException::ChecksumException(const char *msg) noexcept : ReaderException(msg) {} -ChecksumException::~ChecksumException() noexcept {} +ChecksumException::ChecksumException() ZXING_NOEXCEPT {} +ChecksumException::ChecksumException(const char *msg) ZXING_NOEXCEPT : ReaderException(msg) {} +ChecksumException::~ChecksumException() ZXING_NOEXCEPT {} diff --git a/src/zxing/zxing/ChecksumException.h b/src/zxing/zxing/ChecksumException.h index 5171248..07498b4 100644 --- a/src/zxing/zxing/ChecksumException.h +++ b/src/zxing/zxing/ChecksumException.h @@ -24,9 +24,9 @@ namespace zxing { class ChecksumException : public ReaderException { public: - ChecksumException() noexcept; - ChecksumException(const char *msg) noexcept; - ~ChecksumException() noexcept; + ChecksumException() ZXING_NOEXCEPT; + ChecksumException(const char *msg) ZXING_NOEXCEPT; + ~ChecksumException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/Exception.cpp b/src/zxing/zxing/Exception.cpp index 2a71cd7..9c388f5 100644 --- a/src/zxing/zxing/Exception.cpp +++ b/src/zxing/zxing/Exception.cpp @@ -26,26 +26,26 @@ using zxing::Exception; -Exception::Exception() noexcept - : message(nullptr) { +Exception::Exception() ZXING_NOEXCEPT + : message(ZXING_NULLPTR) { } -Exception::Exception(const char *msg) noexcept +Exception::Exception(const char *msg) ZXING_NOEXCEPT : message(copy(msg)) { } -Exception::Exception(const zxing::Exception &that) noexcept +Exception::Exception(const zxing::Exception &that) ZXING_NOEXCEPT : std::exception(that), message(copy(that.message)) { } -Exception::~Exception() noexcept { +Exception::~Exception() ZXING_NOEXCEPT { if(message) { deleteMessage(); } } -const char *Exception::what() const noexcept { +const char *Exception::what() const ZXING_NOEXCEPT { return message ? message : ""; } @@ -54,7 +54,7 @@ void Exception::deleteMessage() { } char const* Exception::copy(char const* msg) { - char* message = nullptr; + char* message = ZXING_NULLPTR; if (msg) { auto l = strlen(msg)+1; if (l) { diff --git a/src/zxing/zxing/Exception.h b/src/zxing/zxing/Exception.h index 52becaf..724d7cc 100644 --- a/src/zxing/zxing/Exception.h +++ b/src/zxing/zxing/Exception.h @@ -21,6 +21,8 @@ * limitations under the License. */ +#include + #include #include @@ -31,11 +33,11 @@ private: char const* const message; public: - Exception() noexcept; - Exception(const char* msg) noexcept; - Exception(Exception const& that) noexcept; - ~Exception() noexcept; - char const* what() const noexcept; + Exception() ZXING_NOEXCEPT; + Exception(const char* msg) ZXING_NOEXCEPT; + Exception(Exception const& that) ZXING_NOEXCEPT; + ~Exception() ZXING_NOEXCEPT; + char const* what() const ZXING_NOEXCEPT; private: static char const* copy(char const*); diff --git a/src/zxing/zxing/FormatException.cpp b/src/zxing/zxing/FormatException.cpp index 7115abb..5907936 100644 --- a/src/zxing/zxing/FormatException.cpp +++ b/src/zxing/zxing/FormatException.cpp @@ -29,7 +29,7 @@ FormatException::FormatException(const char *msg) : ReaderException(msg) { } -FormatException::~FormatException() noexcept { +FormatException::~FormatException() ZXING_NOEXCEPT { } FormatException const& diff --git a/src/zxing/zxing/FormatException.h b/src/zxing/zxing/FormatException.h index 61b846e..54272fb 100644 --- a/src/zxing/zxing/FormatException.h +++ b/src/zxing/zxing/FormatException.h @@ -28,7 +28,7 @@ class FormatException : public ReaderException { public: FormatException(); FormatException(const char *msg); - ~FormatException() noexcept; + ~FormatException() ZXING_NOEXCEPT; static FormatException const& getFormatInstance(); }; diff --git a/src/zxing/zxing/IllegalStateException.cpp b/src/zxing/zxing/IllegalStateException.cpp index 83c23a5..f5d64b4 100644 --- a/src/zxing/zxing/IllegalStateException.cpp +++ b/src/zxing/zxing/IllegalStateException.cpp @@ -19,12 +19,12 @@ */ #include -zxing::IllegalStateException::IllegalStateException() noexcept { +zxing::IllegalStateException::IllegalStateException() ZXING_NOEXCEPT { } -zxing::IllegalStateException::IllegalStateException(const char *msg) noexcept +zxing::IllegalStateException::IllegalStateException(const char *msg) ZXING_NOEXCEPT : ReaderException(msg) { } -zxing::IllegalStateException::~IllegalStateException() noexcept { +zxing::IllegalStateException::~IllegalStateException() ZXING_NOEXCEPT { } diff --git a/src/zxing/zxing/IllegalStateException.h b/src/zxing/zxing/IllegalStateException.h index bbe43e2..76e4068 100644 --- a/src/zxing/zxing/IllegalStateException.h +++ b/src/zxing/zxing/IllegalStateException.h @@ -25,9 +25,9 @@ namespace zxing { class IllegalStateException : public ReaderException { public: - IllegalStateException() noexcept; - IllegalStateException(const char *msg) noexcept; - ~IllegalStateException() noexcept; + IllegalStateException() ZXING_NOEXCEPT; + IllegalStateException(const char *msg) ZXING_NOEXCEPT; + ~IllegalStateException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/NotFoundException.cpp b/src/zxing/zxing/NotFoundException.cpp index f8dcc77..72182bb 100644 --- a/src/zxing/zxing/NotFoundException.cpp +++ b/src/zxing/zxing/NotFoundException.cpp @@ -19,12 +19,12 @@ */ #include -zxing::NotFoundException::NotFoundException() noexcept { +zxing::NotFoundException::NotFoundException() ZXING_NOEXCEPT { } -zxing::NotFoundException::NotFoundException(const char *msg) noexcept +zxing::NotFoundException::NotFoundException(const char *msg) ZXING_NOEXCEPT : ReaderException(msg) { } -zxing::NotFoundException::~NotFoundException() noexcept { +zxing::NotFoundException::~NotFoundException() ZXING_NOEXCEPT { } diff --git a/src/zxing/zxing/NotFoundException.h b/src/zxing/zxing/NotFoundException.h index bb4e923..df19076 100644 --- a/src/zxing/zxing/NotFoundException.h +++ b/src/zxing/zxing/NotFoundException.h @@ -25,9 +25,9 @@ namespace zxing { class NotFoundException : public ReaderException { public: - NotFoundException() noexcept; - NotFoundException(const char *msg) noexcept; - ~NotFoundException() noexcept; + NotFoundException() ZXING_NOEXCEPT; + NotFoundException(const char *msg) ZXING_NOEXCEPT; + ~NotFoundException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/ReaderException.cpp b/src/zxing/zxing/ReaderException.cpp index 76a1cd1..e500246 100644 --- a/src/zxing/zxing/ReaderException.cpp +++ b/src/zxing/zxing/ReaderException.cpp @@ -19,12 +19,12 @@ */ #include -zxing::ReaderException::ReaderException() noexcept { +zxing::ReaderException::ReaderException() ZXING_NOEXCEPT { } -zxing::ReaderException::ReaderException(const char *msg) noexcept +zxing::ReaderException::ReaderException(const char *msg) ZXING_NOEXCEPT : Exception(msg) { } -zxing::ReaderException::~ReaderException() noexcept { +zxing::ReaderException::~ReaderException() ZXING_NOEXCEPT { } diff --git a/src/zxing/zxing/ReaderException.h b/src/zxing/zxing/ReaderException.h index 64fbfa9..fb2d819 100644 --- a/src/zxing/zxing/ReaderException.h +++ b/src/zxing/zxing/ReaderException.h @@ -27,9 +27,9 @@ namespace zxing { class ReaderException : public Exception { public: - ReaderException() noexcept; - ReaderException(char const* msg) noexcept; - ~ReaderException() noexcept; + ReaderException() ZXING_NOEXCEPT; + ReaderException(char const* msg) ZXING_NOEXCEPT; + ~ReaderException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/UnsupportedEncodingException.cpp b/src/zxing/zxing/UnsupportedEncodingException.cpp index b60e1fc..ca880a2 100644 --- a/src/zxing/zxing/UnsupportedEncodingException.cpp +++ b/src/zxing/zxing/UnsupportedEncodingException.cpp @@ -19,12 +19,12 @@ */ #include -zxing::UnsupportedEncodingException::UnsupportedEncodingException() noexcept { +zxing::UnsupportedEncodingException::UnsupportedEncodingException() ZXING_NOEXCEPT { } -zxing::UnsupportedEncodingException::UnsupportedEncodingException(const char *msg) noexcept +zxing::UnsupportedEncodingException::UnsupportedEncodingException(const char *msg) ZXING_NOEXCEPT : Exception(msg) { } -zxing::UnsupportedEncodingException::~UnsupportedEncodingException() noexcept { +zxing::UnsupportedEncodingException::~UnsupportedEncodingException() ZXING_NOEXCEPT { } diff --git a/src/zxing/zxing/UnsupportedEncodingException.h b/src/zxing/zxing/UnsupportedEncodingException.h index c3a3d14..ed47292 100644 --- a/src/zxing/zxing/UnsupportedEncodingException.h +++ b/src/zxing/zxing/UnsupportedEncodingException.h @@ -7,9 +7,9 @@ namespace zxing { class UnsupportedEncodingException : public Exception { public: - UnsupportedEncodingException() noexcept; - UnsupportedEncodingException(char const* msg) noexcept; - ~UnsupportedEncodingException() noexcept; + UnsupportedEncodingException() ZXING_NOEXCEPT; + UnsupportedEncodingException(char const* msg) ZXING_NOEXCEPT; + ~UnsupportedEncodingException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/WriterException.cpp b/src/zxing/zxing/WriterException.cpp index 1d6560f..5719ad6 100644 --- a/src/zxing/zxing/WriterException.cpp +++ b/src/zxing/zxing/WriterException.cpp @@ -19,12 +19,12 @@ */ #include -zxing::WriterException::WriterException() noexcept { +zxing::WriterException::WriterException() ZXING_NOEXCEPT { } -zxing::WriterException::WriterException(const char *msg) noexcept +zxing::WriterException::WriterException(const char *msg) ZXING_NOEXCEPT : Exception(msg) { } -zxing::WriterException::~WriterException() noexcept { +zxing::WriterException::~WriterException() ZXING_NOEXCEPT { } diff --git a/src/zxing/zxing/WriterException.h b/src/zxing/zxing/WriterException.h index cfd5308..cec61b2 100644 --- a/src/zxing/zxing/WriterException.h +++ b/src/zxing/zxing/WriterException.h @@ -7,9 +7,9 @@ namespace zxing { class WriterException : public Exception { public: - WriterException() noexcept; - WriterException(char const* msg) noexcept; - ~WriterException() noexcept; + WriterException() ZXING_NOEXCEPT; + WriterException(char const* msg) ZXING_NOEXCEPT; + ~WriterException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/ZXing.h b/src/zxing/zxing/ZXing.h index cbca440..f826c54 100644 --- a/src/zxing/zxing/ZXing.h +++ b/src/zxing/zxing/ZXing.h @@ -151,4 +151,18 @@ private: #define ZXING_TIME_MARK(string) (void)0 #endif +#ifndef ZXING_NULLPTR +#if __cplusplus >= 201103L + #define ZXING_NULLPTR nullptr +#else + #define ZXING_NULLPTR NULL +#endif +#endif // ZXING_NULLPTR + +#if __cplusplus >= 201103L + #define ZXING_NOEXCEPT noexcept +#else + #define ZXING_NOEXCEPT throw() +#endif + #endif diff --git a/src/zxing/zxing/common/IllegalArgumentException.cpp b/src/zxing/zxing/common/IllegalArgumentException.cpp index 3e372c9..742b174 100644 --- a/src/zxing/zxing/common/IllegalArgumentException.cpp +++ b/src/zxing/zxing/common/IllegalArgumentException.cpp @@ -24,4 +24,4 @@ using zxing::IllegalArgumentException; IllegalArgumentException::IllegalArgumentException() : Exception() {} IllegalArgumentException::IllegalArgumentException(const char *msg) : Exception(msg) {} -IllegalArgumentException::~IllegalArgumentException() noexcept {} +IllegalArgumentException::~IllegalArgumentException() ZXING_NOEXCEPT {} diff --git a/src/zxing/zxing/common/IllegalArgumentException.h b/src/zxing/zxing/common/IllegalArgumentException.h index e6c95df..c47f630 100644 --- a/src/zxing/zxing/common/IllegalArgumentException.h +++ b/src/zxing/zxing/common/IllegalArgumentException.h @@ -28,7 +28,7 @@ class IllegalArgumentException : public Exception { public: IllegalArgumentException(); IllegalArgumentException(const char *msg); - ~IllegalArgumentException() noexcept; + ~IllegalArgumentException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp index 87367c3..cac95d9 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.cpp @@ -21,10 +21,10 @@ #include namespace zxing { -ReedSolomonException::ReedSolomonException(const char *msg) noexcept : +ReedSolomonException::ReedSolomonException(const char *msg) ZXING_NOEXCEPT : Exception(msg) { } -ReedSolomonException::~ReedSolomonException() noexcept { +ReedSolomonException::~ReedSolomonException() ZXING_NOEXCEPT { } } diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h index b98adbd..bd94518 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonException.h @@ -25,8 +25,8 @@ namespace zxing { class ReedSolomonException : public Exception { public: - ReedSolomonException(const char *msg) noexcept; - ~ReedSolomonException() noexcept; + ReedSolomonException(const char *msg) ZXING_NOEXCEPT; + ~ReedSolomonException() ZXING_NOEXCEPT; }; } diff --git a/src/zxing/zxing/datamatrix/detector/DetectorException.h b/src/zxing/zxing/datamatrix/detector/DetectorException.h index ddc5eba..1c5f118 100644 --- a/src/zxing/zxing/datamatrix/detector/DetectorException.h +++ b/src/zxing/zxing/datamatrix/detector/DetectorException.h @@ -16,7 +16,7 @@ namespace datamatrix { class DetectorException : public Exception { public: DetectorException(const char *msg); - virtual ~DetectorException() noexcept; + virtual ~DetectorException() ZXING_NOEXCEPT; }; } /* namespace nexxera */ } /* namespace zxing */ diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index 7eb09ca..d0bda7e 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -39,13 +39,13 @@ int Encoder::calculateMaskPenalty(const ByteMatrix& matrix) Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ecLevel) { - return encode(content, ecLevel, nullptr); + return encode(content, ecLevel, ZXING_NULLPTR); } Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ecLevel, const EncodeHint* hints) { // Determine what character encoding has been specified by the caller, if any - std::string encoding = hints == nullptr ? "" : hints->getCharacterSet(); + std::string encoding = hints == ZXING_NULLPTR ? "" : hints->getCharacterSet(); if (encoding == "") encoding = DEFAULT_BYTE_MODE_ENCODING; @@ -61,7 +61,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec if (mode == Mode::BYTE && DEFAULT_BYTE_MODE_ENCODING != encoding) { zxing::common::CharacterSetECI const * eci = zxing::common::CharacterSetECI::getCharacterSetECIByName(encoding); - if (eci != nullptr) { + if (eci != ZXING_NULLPTR) { appendECI(*eci, headerBits); } } @@ -75,7 +75,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec appendBytes(content, mode, dataBits, encoding); Ref version; - if (hints != nullptr/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) { + if (hints != ZXING_NULLPTR/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) { version = Version::getVersionForNumber(1); int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); if (!willFit(bitsNeeded, version, ecLevel)) { diff --git a/tests/src/QZXingTests/QZXingTests.pro b/tests/src/QZXingTests/QZXingTests.pro index acf5080..765d259 100644 --- a/tests/src/QZXingTests/QZXingTests.pro +++ b/tests/src/QZXingTests/QZXingTests.pro @@ -1,6 +1,3 @@ -CONFIG += gnu++11 -QMAKE_CXXFLAGS += -std=gnu++11 - TARGET = QZXingTests CONFIG += console CONFIG -= app_bundle From 1ef4fb175f11f2392142847570f375e538854d76 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Tue, 25 Dec 2018 17:42:15 +0200 Subject: [PATCH 25/83] minor fixes --- src/zxing/zxing/Exception.cpp | 2 +- src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zxing/zxing/Exception.cpp b/src/zxing/zxing/Exception.cpp index 9c388f5..2b96043 100644 --- a/src/zxing/zxing/Exception.cpp +++ b/src/zxing/zxing/Exception.cpp @@ -56,7 +56,7 @@ void Exception::deleteMessage() { char const* Exception::copy(char const* msg) { char* message = ZXING_NULLPTR; if (msg) { - auto l = strlen(msg)+1; + size_t l = strlen(msg)+1; if (l) { message = new char[l]; strcpy(message, msg); diff --git a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp index 8fac684..630392b 100644 --- a/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp +++ b/src/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp @@ -64,7 +64,7 @@ void ReedSolomonEncoder::encode(std::vector &toEncode, int ecBytes) } for (int i = 0; i < coefficients->size(); i++) - toEncode[size_t(dataBytes + numZeroCoefficients + i)] = byte(coefficients[int(i)]); + toEncode[size_t(dataBytes + numZeroCoefficients + i)] = zxing::byte(coefficients[int(i)]); } } From 38bbed6fcbc1d1850072e800f3cba3fc16e31cb1 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Fri, 18 Jan 2019 01:34:20 +0200 Subject: [PATCH 26/83] add support to QZXing::getLastDecodeOperationSucceded function, returns the success status of the last decode operation execution --- src/QZXing.cpp | 23 ++++++++++++++--------- src/QZXing.h | 3 +++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 20f248c..4f81ea9 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -37,7 +37,7 @@ using namespace zxing; -QZXing::QZXing(QObject *parent) : QObject(parent), tryHarder_(false) +QZXing::QZXing(QObject *parent) : QObject(parent), tryHarder_(false), lastDecodeOperationSucceded_(false) { decoder = new MultiFormatReader(); setDecoder(DecoderFormat_QR_CODE | @@ -69,7 +69,7 @@ QZXing::~QZXing() delete decoder; } -QZXing::QZXing(QZXing::DecoderFormat decodeHints, QObject *parent) : QObject(parent) +QZXing::QZXing(QZXing::DecoderFormat decodeHints, QObject *parent) : QObject(parent), lastDecodeOperationSucceded_(false) { decoder = new MultiFormatReader(); imageHandler = new ImageHandler(); @@ -180,6 +180,11 @@ QString QZXing::charSet() const return charSet_; } +bool QZXing::getLastDecodeOperationSucceded() +{ + return lastDecodeOperationSucceded_; +} + void QZXing::setDecoder(const uint &hint) { unsigned int newHints = 0; @@ -347,40 +352,40 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo DecodeHints hints(static_cast(enabledDecoders)); - bool hasSucceded = false; + lastDecodeOperationSucceded_ = false; try { res = decoder->decode(bb, hints); processingTime = t.elapsed(); - hasSucceded = true; + lastDecodeOperationSucceded_ = true; } catch(zxing::Exception &/*e*/){} - if(!hasSucceded) + if(!lastDecodeOperationSucceded_) { hints.setTryHarder(true); try { res = decoder->decode(bb, hints); processingTime = t.elapsed(); - hasSucceded = true; + lastDecodeOperationSucceded_ = true; } catch(zxing::Exception &/*e*/) {} if (tryHarder_ && bb->isRotateSupported()) { Ref bbTmp = bb; - for (int i=0; (i<3 && !hasSucceded); i++) { + for (int i=0; (i<3 && !lastDecodeOperationSucceded_); i++) { Ref rotatedImage(bbTmp->rotateCounterClockwise()); bbTmp = rotatedImage; try { res = decoder->decode(rotatedImage, hints); processingTime = t.elapsed(); - hasSucceded = true; + lastDecodeOperationSucceded_ = true; } catch(zxing::Exception &/*e*/) {} } } } - if (hasSucceded) { + if (lastDecodeOperationSucceded_) { QString string = QString(res->getText()->getText().c_str()); if (!string.isEmpty() && (string.length() > 0)) { int fmt = res->getBarcodeFormat().value; diff --git a/src/QZXing.h b/src/QZXing.h index e1bcee1..fd36b63 100644 --- a/src/QZXing.h +++ b/src/QZXing.h @@ -116,6 +116,8 @@ public: Q_INVOKABLE QString foundedFormat() const; Q_INVOKABLE QString charSet() const; + bool getLastDecodeOperationSucceded(); + public slots: /** * The decoding function. Will try to decode the given image based on the enabled decoders. @@ -208,6 +210,7 @@ private: QString foundedFmt; QString charSet_; bool tryHarder_; + bool lastDecodeOperationSucceded_; /** * If true, the decoding operation will take place at a different thread. From 15ddcaf18145ac3ff4bfbd5b48c31b7cd040e9dd Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Fri, 18 Jan 2019 01:38:10 +0200 Subject: [PATCH 27/83] Added support to the execution of stress test for encode / decode operation for all possible combinations of Qr code length and error correction levels. Created as a first step to detect the bug of #83. --- tests/src/QZXingTests/EncodeValidator.h | 2 +- tests/src/QZXingTests/EncoderStressTest.cpp | 120 ++++++++++++++++++++ tests/src/QZXingTests/EncoderStressTest.h | 44 +++++++ tests/src/QZXingTests/QZXingTests.pro | 6 +- tests/src/QZXingTests/TestCase.h | 1 + tests/src/QZXingTests/main.cpp | 37 +++++- 6 files changed, 202 insertions(+), 8 deletions(-) create mode 100644 tests/src/QZXingTests/EncoderStressTest.cpp create mode 100644 tests/src/QZXingTests/EncoderStressTest.h diff --git a/tests/src/QZXingTests/EncodeValidator.h b/tests/src/QZXingTests/EncodeValidator.h index c665b0d..af81335 100644 --- a/tests/src/QZXingTests/EncodeValidator.h +++ b/tests/src/QZXingTests/EncodeValidator.h @@ -17,7 +17,7 @@ class EncodeValidator : public TestCase { public: EncodeValidator(); - void execute(); + void execute() override; }; } diff --git a/tests/src/QZXingTests/EncoderStressTest.cpp b/tests/src/QZXingTests/EncoderStressTest.cpp new file mode 100644 index 0000000..7dbe8ea --- /dev/null +++ b/tests/src/QZXingTests/EncoderStressTest.cpp @@ -0,0 +1,120 @@ +#include "EncoderStressTest.h" +#include + +namespace zxing { +namespace tests{ + +EncoderStressTest::EncoderStressTest(): TestCase(), decoder(QZXing::DecoderFormat_QR_CODE), + sumOfSuccessfullTests(0), totalExecutedTests(0) +{ + /** + N A B + L 7089 4296 2953 + M 5596 3391 2331 + Q 3993 2420 1663 + H 3057 1852 1273 + */ + + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::L.name()][qrcode::Mode::NUMERIC.getName()] = 7089; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::M.name()][qrcode::Mode::NUMERIC.getName()] = 5596; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::Q.name()][qrcode::Mode::NUMERIC.getName()] = 3993; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::H.name()][qrcode::Mode::NUMERIC.getName()] = 3057; + + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::L.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 4296; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::M.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 3391; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::Q.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 2420; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::H.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 1852; + + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::L.name()][qrcode::Mode::BYTE.getName()] = 2953; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::M.name()][qrcode::Mode::BYTE.getName()] = 2331; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::Q.name()][qrcode::Mode::BYTE.getName()] = 1663; + maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::H.name()][qrcode::Mode::BYTE.getName()] = 1273; +} + +void zxing::tests::EncoderStressTest::execute() +{ + runTests(zxing::qrcode::Mode::NUMERIC); + runTests(zxing::qrcode::Mode::ALPHANUMERIC); + runTests(zxing::qrcode::Mode::BYTE); + + std::cout << "total: successful: " << sumOfSuccessfullTests << ", total: " << totalExecutedTests << std::endl; +} + +int EncoderStressTest::getMaxCharacterNumber(qrcode::ErrorCorrectionLevel &errorCorrectionLevel, qrcode::Mode &mode) +{ + if(maxCharacterNumberMap_.contains(errorCorrectionLevel.name()) && + maxCharacterNumberMap_[errorCorrectionLevel.name()].contains(mode.getName())) + return maxCharacterNumberMap_[errorCorrectionLevel.name()][mode.getName()]; + else + return 0; +} + +char EncoderStressTest::getCharacterForQrMode(qrcode::Mode &mode) +{ +/* + N + 0-9 + + A + 0 - 9 + A - Z + (space) + $ % * + - . / : + + B + A + a-z +*/ + if(mode == qrcode::Mode::NUMERIC) + return '0'; + else if (mode == qrcode::Mode::ALPHANUMERIC) + return 'A'; + else if (mode == qrcode::Mode::BYTE) + return 'a'; + else + return (rand() % 256); +} + +void EncoderStressTest::runTests(qrcode::Mode &mode) +{ + runTests(zxing::qrcode::ErrorCorrectionLevel::L, mode); + runTests(zxing::qrcode::ErrorCorrectionLevel::M, mode); + runTests(zxing::qrcode::ErrorCorrectionLevel::Q, mode); + runTests(zxing::qrcode::ErrorCorrectionLevel::H, mode); +} + +void EncoderStressTest::runTests(zxing::qrcode::ErrorCorrectionLevel &errorCorrectionLevel, zxing::qrcode::Mode &mode) +{ + currentSetupExecutedTests = 0; + currentSetupSuccessfullTests = 0; + + QString currentCharacters; + int maxCharLength = getMaxCharacterNumber(errorCorrectionLevel, mode); + + for(int i=1; i<=maxCharLength; ++i) + { + currentCharacters += getCharacterForQrMode(mode); + QImage generatedImage = QZXing::encodeData(currentCharacters); + + QString decodedData = decoder.decodeImage(generatedImage); + + std::cout << "M[" << mode.getName() << "], E[" << errorCorrectionLevel.name() << "], L[" << i << "]: " << + "decoded=" << decoder.getLastDecodeOperationSucceded() << + ", match=" << (currentCharacters == decodedData) << std::endl; + + if(decoder.getLastDecodeOperationSucceded() && (currentCharacters == decodedData)) + { + ++sumOfSuccessfullTests; + ++currentSetupSuccessfullTests; + } + ++totalExecutedTests; + ++currentSetupExecutedTests; + } + + std::cout << "subtotal: M[" << mode.getName() << "], E[" << errorCorrectionLevel.name() << "]: " << + "successfull: " << currentSetupSuccessfullTests << ", total: " << currentSetupExecutedTests << std::endl; +} + + +} +} + diff --git a/tests/src/QZXingTests/EncoderStressTest.h b/tests/src/QZXingTests/EncoderStressTest.h new file mode 100644 index 0000000..a28e073 --- /dev/null +++ b/tests/src/QZXingTests/EncoderStressTest.h @@ -0,0 +1,44 @@ +#ifndef ENCODERSTRESSTEST_H +#define ENCODERSTRESSTEST_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace zxing { +namespace tests{ + +class EncoderStressTest : public TestCase +{ +public: + EncoderStressTest(); + void execute() override; + +protected: + int getMaxCharacterNumber(zxing::qrcode::ErrorCorrectionLevel &errorCorrectionLevel, zxing::qrcode::Mode &mode); + char getCharacterForQrMode(zxing::qrcode::Mode &mode); + + void runTests(zxing::qrcode::Mode &mode); + void runTests(zxing::qrcode::ErrorCorrectionLevel &errorCorrectionLevel, zxing::qrcode::Mode &mode); + +private: + QZXing decoder; + QMap> maxCharacterNumberMap_; + + int sumOfSuccessfullTests; + int totalExecutedTests; + + int currentSetupSuccessfullTests; + int currentSetupExecutedTests; +}; + +} +} + +#endif // ENCODERSTRESSTEST_H diff --git a/tests/src/QZXingTests/QZXingTests.pro b/tests/src/QZXingTests/QZXingTests.pro index 765d259..11ebaa8 100644 --- a/tests/src/QZXingTests/QZXingTests.pro +++ b/tests/src/QZXingTests/QZXingTests.pro @@ -15,7 +15,8 @@ HEADERS += \ zxing/qrcode/encoder/EncoderTests.h \ zxing/common/reedsolomon/ReedSolomonEncoderTests.h \ zxing/common/BitArrayTests.h \ - zxing/qrcode/encoder/BitVectorTests.h + zxing/qrcode/encoder/BitVectorTests.h \ + EncoderStressTest.h #\backward.hpp SOURCES += main.cpp \ @@ -29,6 +30,7 @@ SOURCES += main.cpp \ zxing/qrcode/encoder/EncoderTests.cpp \ zxing/common/reedsolomon/ReedSolomonEncoderTests.cpp \ zxing/common/BitArrayTests.cpp \ - zxing/qrcode/encoder/BitVectorTests.cpp + zxing/qrcode/encoder/BitVectorTests.cpp \ + EncoderStressTest.cpp include(../../../src/QZXing.pri) diff --git a/tests/src/QZXingTests/TestCase.h b/tests/src/QZXingTests/TestCase.h index 8fa7a7e..8bb50af 100644 --- a/tests/src/QZXingTests/TestCase.h +++ b/tests/src/QZXingTests/TestCase.h @@ -156,6 +156,7 @@ protected: static int generateRandomNumber(int range); public: + virtual ~TestCase() {} virtual void execute()=0; }; diff --git a/tests/src/QZXingTests/main.cpp b/tests/src/QZXingTests/main.cpp index e2caf2b..26231df 100644 --- a/tests/src/QZXingTests/main.cpp +++ b/tests/src/QZXingTests/main.cpp @@ -1,14 +1,41 @@ #include +#include #include #include "DecodeValidator.h" +#include "EncoderStressTest.h" -int main(int /*argc*/, char **/*argv[]*/) +int main(int argc, char **argv) { - DecodeValidator decodeValidator; - decodeValidator.executeTests("../../resources/"); + QCoreApplication application(argc, argv); + QCoreApplication::setApplicationName("QZXingTests"); - zxing::tests::EncodeValidator encodeValidator; - encodeValidator.execute(); + QCommandLineParser parser; + parser.setApplicationDescription("Executes unit tests for QZXing library"); + parser.addHelpOption(); + parser.addVersionOption(); + + QCommandLineOption encoderStressTestOption(QStringList() << "encoder-stress", + QCoreApplication::translate("main", "Execute stress test for Qr Code encoding and decoding")); + + parser.addOption(encoderStressTestOption); + + parser.process(application); + + bool isEncoderStressTestEnabled = parser.isSet(encoderStressTestOption); + + if(isEncoderStressTestEnabled) + { + zxing::tests::EncoderStressTest encoderStressTest; + encoderStressTest.execute(); + } + else + { + DecodeValidator decodeValidator; + decodeValidator.executeTests("../../resources/"); + + zxing::tests::EncodeValidator encodeValidator; + encodeValidator.execute(); + } } From 83243790f85fdfcd26ec501c524ac0cc310f2ba1 Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Mon, 25 Mar 2019 12:30:23 +0200 Subject: [PATCH 28/83] simplified CharacterSetECI initialization --- src/zxing/zxing/common/CharacterSetECI.cpp | 86 +++++++++++----------- src/zxing/zxing/common/CharacterSetECI.h | 8 +- 2 files changed, 48 insertions(+), 46 deletions(-) diff --git a/src/zxing/zxing/common/CharacterSetECI.cpp b/src/zxing/zxing/common/CharacterSetECI.cpp index 4066e75..610690f 100644 --- a/src/zxing/zxing/common/CharacterSetECI.cpp +++ b/src/zxing/zxing/common/CharacterSetECI.cpp @@ -32,68 +32,70 @@ std::vector CharacterSetECI::ECItables; bool CharacterSetECI::inited = CharacterSetECI::init_tables(); -#define ADD_CHARACTER_SET(VALUES, STRINGS) \ - { static int values[] = {VALUES, -1}; \ - static char const* strings[] = {STRINGS, 0}; \ - addCharacterSet(values, strings); } +#define COMMA , -#define XC , +#define ADD_CHARACTER_SET(VALUES, STRINGS) \ + { int values[] = {VALUES}; \ + const char *strings[] = {STRINGS}; \ + addCharacterSet(std::vector(values, values + sizeof(values) / sizeof(values[0])), \ + std::vector(strings, strings + sizeof(strings) / sizeof(strings[0]))); } bool CharacterSetECI::init_tables() { - ADD_CHARACTER_SET(0 XC 2, "Cp437"); - ADD_CHARACTER_SET(1 XC 3, "ISO8859_1" XC "ISO-8859-1"); - ADD_CHARACTER_SET(4, "ISO8859_2" XC "ISO-8859-2"); - ADD_CHARACTER_SET(5, "ISO8859_3" XC "ISO-8859-3"); - ADD_CHARACTER_SET(6, "ISO8859_4" XC "ISO-8859-4"); - ADD_CHARACTER_SET(7, "ISO8859_5" XC "ISO-8859-5"); - ADD_CHARACTER_SET(8, "ISO8859_6" XC "ISO-8859-6"); - ADD_CHARACTER_SET(9, "ISO8859_7" XC "ISO-8859-7"); - ADD_CHARACTER_SET(10, "ISO8859_8" XC "ISO-8859-8"); - ADD_CHARACTER_SET(11, "ISO8859_9" XC "ISO-8859-9"); - ADD_CHARACTER_SET(12, "ISO8859_10" XC "ISO-8859-10"); - ADD_CHARACTER_SET(13, "ISO8859_11" XC "ISO-8859-11"); - ADD_CHARACTER_SET(15, "ISO8859_13" XC "ISO-8859-13"); - ADD_CHARACTER_SET(16, "ISO8859_14" XC "ISO-8859-14"); - ADD_CHARACTER_SET(17, "ISO8859_15" XC "ISO-8859-15"); - ADD_CHARACTER_SET(18, "ISO8859_16" XC "ISO-8859-16"); - ADD_CHARACTER_SET(20, "SJIS" XC "Shift_JIS"); - ADD_CHARACTER_SET(21, "Cp1250" XC "windows-1250"); - ADD_CHARACTER_SET(22, "Cp1251" XC "windows-1251"); - ADD_CHARACTER_SET(23, "Cp1252" XC "windows-1252"); - ADD_CHARACTER_SET(24, "Cp1256" XC "windows-1256"); - ADD_CHARACTER_SET(25, "UnicodeBigUnmarked" XC "UTF-16BE" XC "UnicodeBig"); - ADD_CHARACTER_SET(26, "UTF8" XC "UTF-8"); - ADD_CHARACTER_SET(27 XC 170, "ASCII" XC "US-ASCII"); + ADD_CHARACTER_SET(1 COMMA 3, "ISO8859_1" COMMA "ISO-8859-1") + ADD_CHARACTER_SET(0 COMMA 2, "Cp437"); + ADD_CHARACTER_SET(4, "ISO8859_2" COMMA "ISO-8859-2"); + ADD_CHARACTER_SET(5, "ISO8859_3" COMMA "ISO-8859-3"); + ADD_CHARACTER_SET(6, "ISO8859_4" COMMA "ISO-8859-4"); + ADD_CHARACTER_SET(7, "ISO8859_5" COMMA "ISO-8859-5"); + ADD_CHARACTER_SET(8, "ISO8859_6" COMMA "ISO-8859-6"); + ADD_CHARACTER_SET(9, "ISO8859_7" COMMA "ISO-8859-7"); + ADD_CHARACTER_SET(10, "ISO8859_8" COMMA "ISO-8859-8"); + ADD_CHARACTER_SET(11, "ISO8859_9" COMMA "ISO-8859-9"); + ADD_CHARACTER_SET(12, "ISO8859_10" COMMA "ISO-8859-10"); + ADD_CHARACTER_SET(13, "ISO8859_11" COMMA "ISO-8859-11"); + ADD_CHARACTER_SET(15, "ISO8859_13" COMMA "ISO-8859-13"); + ADD_CHARACTER_SET(16, "ISO8859_14" COMMA "ISO-8859-14"); + ADD_CHARACTER_SET(17, "ISO8859_15" COMMA "ISO-8859-15"); + ADD_CHARACTER_SET(18, "ISO8859_16" COMMA "ISO-8859-16"); + ADD_CHARACTER_SET(20, "SJIS" COMMA "Shift_JIS"); + ADD_CHARACTER_SET(21, "Cp1250" COMMA "windows-1250"); + ADD_CHARACTER_SET(22, "Cp1251" COMMA "windows-1251"); + ADD_CHARACTER_SET(23, "Cp1252" COMMA "windows-1252"); + ADD_CHARACTER_SET(24, "Cp1256" COMMA "windows-1256"); + ADD_CHARACTER_SET(25, "UnicodeBigUnmarked" COMMA "UTF-16BE" COMMA "UnicodeBig"); + ADD_CHARACTER_SET(26, "UTF8" COMMA "UTF-8"); + ADD_CHARACTER_SET(27 COMMA 170, "ASCII" COMMA "US-ASCII"); ADD_CHARACTER_SET(28, "Big5"); - ADD_CHARACTER_SET(29, "GB18030" XC "GB2312" XC "EUC_CN" XC "GBK"); - ADD_CHARACTER_SET(30, "EUC_KR" XC "EUC-KR"); + ADD_CHARACTER_SET(29, "GB18030" COMMA "GB2312" COMMA "EUC_CN" COMMA "GBK"); + ADD_CHARACTER_SET(30, "EUC_KR" COMMA "EUC-KR"); std::atexit(removeAllCharacterSets); return true; } -#undef XC - -CharacterSetECI::CharacterSetECI(int const* values, - char const* const* names) - : Counted(), values_(values), names_(names) {} +CharacterSetECI::CharacterSetECI(const std::vector values, const std::vector names) + : Counted(), values_(values) +{ + for(size_t i=0; i values, const std::vector names) { CharacterSetECI* charSet = new CharacterSetECI(values, names); - for(int const* values_tmp = values; *values_tmp != -1; values_tmp++) { - VALUE_TO_ECI[*values_tmp] = charSet; + for(size_t i=0; i values_; + std::vector names_; - CharacterSetECI(int const* values, char const* const* names); + CharacterSetECI(const std::vector values, const std::vector names); - static void addCharacterSet(int const* value, char const* const* encodingNames); + static void addCharacterSet(const std::vector value, const std::vector encodingNames); public: char const* name() const; From 9dfa221563f7abbb2374e314e59ac65e7642fa4a Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Mon, 25 Mar 2019 12:32:10 +0200 Subject: [PATCH 29/83] Added blocking map-reduce concurrency when executing EncoderStressTest. (still has issues.) --- tests/src/QZXingTests/EncoderStressTest.cpp | 102 +++++++++++--------- tests/src/QZXingTests/EncoderStressTest.h | 36 +++++-- tests/src/QZXingTests/QZXingTests.pro | 2 + 3 files changed, 88 insertions(+), 52 deletions(-) diff --git a/tests/src/QZXingTests/EncoderStressTest.cpp b/tests/src/QZXingTests/EncoderStressTest.cpp index 7dbe8ea..ab4f341 100644 --- a/tests/src/QZXingTests/EncoderStressTest.cpp +++ b/tests/src/QZXingTests/EncoderStressTest.cpp @@ -1,11 +1,15 @@ #include "EncoderStressTest.h" #include +#include namespace zxing { namespace tests{ -EncoderStressTest::EncoderStressTest(): TestCase(), decoder(QZXing::DecoderFormat_QR_CODE), - sumOfSuccessfullTests(0), totalExecutedTests(0) +QMutex EncoderStressTest::mutex; +QMutex EncoderStressTest::printLockMutex; + +EncoderStressTest::EncoderStressTest(): TestCase(), + sumOfSuccessfullTests_(0), totalExecutedTests_(0) { /** N A B @@ -15,20 +19,23 @@ EncoderStressTest::EncoderStressTest(): TestCase(), decoder(QZXing::DecoderForma H 3057 1852 1273 */ - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::L.name()][qrcode::Mode::NUMERIC.getName()] = 7089; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::M.name()][qrcode::Mode::NUMERIC.getName()] = 5596; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::Q.name()][qrcode::Mode::NUMERIC.getName()] = 3993; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::H.name()][qrcode::Mode::NUMERIC.getName()] = 3057; + // 4 different error correction levels + maxCharacterNumberMap_.resize(4); - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::L.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 4296; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::M.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 3391; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::Q.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 2420; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::H.name()][qrcode::Mode::ALPHANUMERIC.getName()] = 1852; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_L][qrcode::Mode::NUMERIC.getName()] = 7089; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_M][qrcode::Mode::NUMERIC.getName()] = 5596; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_Q][qrcode::Mode::NUMERIC.getName()] = 3993; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_H][qrcode::Mode::NUMERIC.getName()] = 3057; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::L.name()][qrcode::Mode::BYTE.getName()] = 2953; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::M.name()][qrcode::Mode::BYTE.getName()] = 2331; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::Q.name()][qrcode::Mode::BYTE.getName()] = 1663; - maxCharacterNumberMap_[qrcode::ErrorCorrectionLevel::H.name()][qrcode::Mode::BYTE.getName()] = 1273; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_L][qrcode::Mode::ALPHANUMERIC.getName()] = 4296; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_M][qrcode::Mode::ALPHANUMERIC.getName()] = 3391; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_Q][qrcode::Mode::ALPHANUMERIC.getName()] = 2420; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_H][qrcode::Mode::ALPHANUMERIC.getName()] = 1852; + + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_L][qrcode::Mode::BYTE.getName()] = 2953; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_M][qrcode::Mode::BYTE.getName()] = 2331; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_Q][qrcode::Mode::BYTE.getName()] = 1663; + maxCharacterNumberMap_[QZXing::EncodeErrorCorrectionLevel_H][qrcode::Mode::BYTE.getName()] = 1273; } void zxing::tests::EncoderStressTest::execute() @@ -37,14 +44,14 @@ void zxing::tests::EncoderStressTest::execute() runTests(zxing::qrcode::Mode::ALPHANUMERIC); runTests(zxing::qrcode::Mode::BYTE); - std::cout << "total: successful: " << sumOfSuccessfullTests << ", total: " << totalExecutedTests << std::endl; + std::cout << "total: successful: " << sumOfSuccessfullTests_ << ", total: " << totalExecutedTests_ << std::endl; } -int EncoderStressTest::getMaxCharacterNumber(qrcode::ErrorCorrectionLevel &errorCorrectionLevel, qrcode::Mode &mode) +int EncoderStressTest::getMaxCharacterNumber(QZXing::EncodeErrorCorrectionLevel errorCorrectionLevel, qrcode::Mode &mode) { - if(maxCharacterNumberMap_.contains(errorCorrectionLevel.name()) && - maxCharacterNumberMap_[errorCorrectionLevel.name()].contains(mode.getName())) - return maxCharacterNumberMap_[errorCorrectionLevel.name()][mode.getName()]; + if(maxCharacterNumberMap_.size() > errorCorrectionLevel && + maxCharacterNumberMap_[errorCorrectionLevel].contains(mode.getName())) + return maxCharacterNumberMap_[errorCorrectionLevel][mode.getName()]; else return 0; } @@ -76,44 +83,53 @@ char EncoderStressTest::getCharacterForQrMode(qrcode::Mode &mode) void EncoderStressTest::runTests(qrcode::Mode &mode) { - runTests(zxing::qrcode::ErrorCorrectionLevel::L, mode); - runTests(zxing::qrcode::ErrorCorrectionLevel::M, mode); - runTests(zxing::qrcode::ErrorCorrectionLevel::Q, mode); - runTests(zxing::qrcode::ErrorCorrectionLevel::H, mode); + runTests(QZXing::EncodeErrorCorrectionLevel_L, mode); + runTests(QZXing::EncodeErrorCorrectionLevel_M, mode); + runTests(QZXing::EncodeErrorCorrectionLevel_Q, mode); + runTests(QZXing::EncodeErrorCorrectionLevel_H, mode); } -void EncoderStressTest::runTests(zxing::qrcode::ErrorCorrectionLevel &errorCorrectionLevel, zxing::qrcode::Mode &mode) +void EncoderStressTest::runTests(QZXing::EncodeErrorCorrectionLevel errorCorrectionLevel, zxing::qrcode::Mode &mode) { - currentSetupExecutedTests = 0; - currentSetupSuccessfullTests = 0; - QString currentCharacters; int maxCharLength = getMaxCharacterNumber(errorCorrectionLevel, mode); + QList testRunDataSet; for(int i=1; i<=maxCharLength; ++i) { currentCharacters += getCharacterForQrMode(mode); - QImage generatedImage = QZXing::encodeData(currentCharacters); - QString decodedData = decoder.decodeImage(generatedImage); - - std::cout << "M[" << mode.getName() << "], E[" << errorCorrectionLevel.name() << "], L[" << i << "]: " << - "decoded=" << decoder.getLastDecodeOperationSucceded() << - ", match=" << (currentCharacters == decodedData) << std::endl; - - if(decoder.getLastDecodeOperationSucceded() && (currentCharacters == decodedData)) - { - ++sumOfSuccessfullTests; - ++currentSetupSuccessfullTests; - } - ++totalExecutedTests; - ++currentSetupExecutedTests; + TestRunData testData; + testData.data = currentCharacters; + testData.errorCorrectionLevel = errorCorrectionLevel; + testData.mode = mode; + testRunDataSet.append(testData); } - std::cout << "subtotal: M[" << mode.getName() << "], E[" << errorCorrectionLevel.name() << "]: " << - "successfull: " << currentSetupSuccessfullTests << ", total: " << currentSetupExecutedTests << std::endl; + QtConcurrent::blockingMap(testRunDataSet, EncoderStressTest::runTest); } +void EncoderStressTest::runTest(TestRunData &testData) +{ + QImage generatedImage = QZXing::encodeData(testData.data, + QZXing::EncoderFormat_QR_CODE, + QSize(500, 500), + testData.errorCorrectionLevel); + + // mutex.lock(); + QZXing decoder(QZXing::DecoderFormat_QR_CODE); + QString decodedData = decoder.decodeImage(generatedImage); + bool wasDecoded = decoder.getLastDecodeOperationSucceded(); + // mutex.unlock(); + + testData.successful = (testData.data == decodedData); + + printLockMutex.lock(); + std::cout << "M[" << testData.mode.getName() << "], E[" << testData.errorCorrectionLevel << "], L[" << testData.data.size() << "]: " << + "decoded=" << wasDecoded << + ", match=" << testData.successful << std::endl; + printLockMutex.unlock(); +} } } diff --git a/tests/src/QZXingTests/EncoderStressTest.h b/tests/src/QZXingTests/EncoderStressTest.h index a28e073..08d09ff 100644 --- a/tests/src/QZXingTests/EncoderStressTest.h +++ b/tests/src/QZXingTests/EncoderStressTest.h @@ -10,10 +10,28 @@ #include #include #include +#include +#include +#include +#include +#include +#include namespace zxing { namespace tests{ +struct TestRunData { + QString data; + QZXing::EncodeErrorCorrectionLevel errorCorrectionLevel; + qrcode::Mode mode; + + bool successful; + +public: + TestRunData(): data(""), errorCorrectionLevel(QZXing::EncodeErrorCorrectionLevel_L), + mode(qrcode::Mode::BYTE), successful(false) {} +}; + class EncoderStressTest : public TestCase { public: @@ -21,21 +39,21 @@ public: void execute() override; protected: - int getMaxCharacterNumber(zxing::qrcode::ErrorCorrectionLevel &errorCorrectionLevel, zxing::qrcode::Mode &mode); + int getMaxCharacterNumber(QZXing::EncodeErrorCorrectionLevel errorCorrectionLevel, zxing::qrcode::Mode &mode); char getCharacterForQrMode(zxing::qrcode::Mode &mode); void runTests(zxing::qrcode::Mode &mode); - void runTests(zxing::qrcode::ErrorCorrectionLevel &errorCorrectionLevel, zxing::qrcode::Mode &mode); + void runTests(QZXing::EncodeErrorCorrectionLevel errorCorrectionLevel, zxing::qrcode::Mode &mode); + + static void runTest(TestRunData &testData); private: - QZXing decoder; - QMap> maxCharacterNumberMap_; + QVector> maxCharacterNumberMap_; + size_t sumOfSuccessfullTests_; + size_t totalExecutedTests_; - int sumOfSuccessfullTests; - int totalExecutedTests; - - int currentSetupSuccessfullTests; - int currentSetupExecutedTests; + static QMutex mutex; + static QMutex printLockMutex; }; } diff --git a/tests/src/QZXingTests/QZXingTests.pro b/tests/src/QZXingTests/QZXingTests.pro index 11ebaa8..b4f6498 100644 --- a/tests/src/QZXingTests/QZXingTests.pro +++ b/tests/src/QZXingTests/QZXingTests.pro @@ -2,6 +2,8 @@ TARGET = QZXingTests CONFIG += console CONFIG -= app_bundle +QT += concurrent + TEMPLATE = app HEADERS += \ From 9e40185e8d103cb0925d83b7ae242a08b0eaaf36 Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Mon, 25 Mar 2019 14:37:19 +0200 Subject: [PATCH 30/83] replace all Ref to Version* --- .../zxing/common/reedsolomon/GenericGF.cpp | 11 +- .../zxing/common/reedsolomon/GenericGF.h | 7 +- .../zxing/datamatrix/DataMatrixVersion.cpp | 140 +++++++-------- src/zxing/zxing/datamatrix/Version.h | 18 +- .../datamatrix/decoder/BitMatrixParser.h | 4 +- .../decoder/DataMatrixBitMatrixParser.cpp | 4 +- src/zxing/zxing/qrcode/QRVersion.cpp | 170 +++++++++--------- src/zxing/zxing/qrcode/Version.h | 10 +- src/zxing/zxing/qrcode/decoder/Mode.h | 2 +- src/zxing/zxing/qrcode/decoder/QRMode.cpp | 2 +- src/zxing/zxing/qrcode/encoder/Encoder.h | 10 +- src/zxing/zxing/qrcode/encoder/QRCode.cpp | 6 +- src/zxing/zxing/qrcode/encoder/QRCode.h | 6 +- src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 16 +- 14 files changed, 206 insertions(+), 200 deletions(-) diff --git a/src/zxing/zxing/common/reedsolomon/GenericGF.cpp b/src/zxing/zxing/common/reedsolomon/GenericGF.cpp index e2763cd..27ad073 100644 --- a/src/zxing/zxing/common/reedsolomon/GenericGF.cpp +++ b/src/zxing/zxing/common/reedsolomon/GenericGF.cpp @@ -38,16 +38,21 @@ Ref GenericGF::AZTEC_DATA_8 = DATA_MATRIX_FIELD_256; Ref GenericGF::MAXICODE_FIELD_64 = AZTEC_DATA_6; namespace { - int INITIALIZATION_THRESHOLD = 0; + size_t INITIALIZATION_THRESHOLD = 0; } -GenericGF::GenericGF(int primitive_, int size_, int b) +GenericGF::GenericGF(int primitive_, size_t size_, int b) : size(size_), primitive(primitive_), generatorBase(b), initialized(false) { if (size <= INITIALIZATION_THRESHOLD) { initialize(); } } - + +GenericGF::~GenericGF() +{ + return; +} + void GenericGF::initialize() { expTable = std::vector(size); logTable = std::vector(size); diff --git a/src/zxing/zxing/common/reedsolomon/GenericGF.h b/src/zxing/zxing/common/reedsolomon/GenericGF.h index 3a068f8..bcc0c31 100644 --- a/src/zxing/zxing/common/reedsolomon/GenericGF.h +++ b/src/zxing/zxing/common/reedsolomon/GenericGF.h @@ -35,10 +35,13 @@ namespace zxing { std::vector logTable; Ref zero; Ref one; - int size; + size_t size; int primitive; int generatorBase; bool initialized; + + GenericGF(int primitive, size_t size, int b); + ~GenericGF(); void initialize(); void checkInit(); @@ -53,8 +56,6 @@ namespace zxing { static Ref DATA_MATRIX_FIELD_256; static Ref MAXICODE_FIELD_64; - GenericGF(int primitive, int size, int b); - Ref getZero(); Ref getOne(); int getSize(); diff --git a/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp b/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp index a6fd59a..a1eb5ae 100644 --- a/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp +++ b/src/zxing/zxing/datamatrix/DataMatrixVersion.cpp @@ -61,7 +61,7 @@ ECBlocks::~ECBlocks() { } } -vector > Version::VERSIONS; +vector Version::VERSIONS; static int N_VERSIONS = Version::buildVersions(); Version::Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, int dataRegionSizeRows, @@ -84,35 +84,35 @@ Version::~Version() { delete ecBlocks_; } -int Version::getVersionNumber() { +int Version::getVersionNumber() const { return versionNumber_; } -int Version::getSymbolSizeRows() { +int Version::getSymbolSizeRows() const { return symbolSizeRows_; } -int Version::getSymbolSizeColumns() { +int Version::getSymbolSizeColumns() const { return symbolSizeColumns_; } -int Version::getDataRegionSizeRows() { +int Version::getDataRegionSizeRows() const { return dataRegionSizeRows_; } -int Version::getDataRegionSizeColumns() { +int Version::getDataRegionSizeColumns() const { return dataRegionSizeColumns_; } -int Version::getTotalCodewords() { +int Version::getTotalCodewords() const { return totalCodewords_; } -ECBlocks* Version::getECBlocks() { +ECBlocks* Version::getECBlocks() const { return ecBlocks_; } -Ref Version::getVersionForDimensions(int numRows, int numColumns) { +Version* Version::getVersionForDimensions(int numRows, int numColumns) { if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) { throw ReaderException("Number of rows and columns must be even"); } @@ -121,7 +121,7 @@ Ref Version::getVersionForDimensions(int numRows, int numColumns) { // If we interleave the rectangular versions with the square versions we could // do a binary search. for (int i = 0; i < N_VERSIONS; ++i){ - Ref version(VERSIONS[i]); + Version* version = VERSIONS[i]; if (version->getSymbolSizeRows() == numRows && version->getSymbolSizeColumns() == numColumns) { return version; } @@ -133,66 +133,66 @@ Ref Version::getVersionForDimensions(int numRows, int numColumns) { * See ISO 16022:2006 5.5.1 Table 7 */ int Version::buildVersions() { - VERSIONS.push_back(Ref(new Version(1, 10, 10, 8, 8, - new ECBlocks(5, new ECB(1, 3))))); - VERSIONS.push_back(Ref(new Version(2, 12, 12, 10, 10, - new ECBlocks(7, new ECB(1, 5))))); - VERSIONS.push_back(Ref(new Version(3, 14, 14, 12, 12, - new ECBlocks(10, new ECB(1, 8))))); - VERSIONS.push_back(Ref(new Version(4, 16, 16, 14, 14, - new ECBlocks(12, new ECB(1, 12))))); - VERSIONS.push_back(Ref(new Version(5, 18, 18, 16, 16, - new ECBlocks(14, new ECB(1, 18))))); - VERSIONS.push_back(Ref(new Version(6, 20, 20, 18, 18, - new ECBlocks(18, new ECB(1, 22))))); - VERSIONS.push_back(Ref(new Version(7, 22, 22, 20, 20, - new ECBlocks(20, new ECB(1, 30))))); - VERSIONS.push_back(Ref(new Version(8, 24, 24, 22, 22, - new ECBlocks(24, new ECB(1, 36))))); - VERSIONS.push_back(Ref(new Version(9, 26, 26, 24, 24, - new ECBlocks(28, new ECB(1, 44))))); - VERSIONS.push_back(Ref(new Version(10, 32, 32, 14, 14, - new ECBlocks(36, new ECB(1, 62))))); - VERSIONS.push_back(Ref(new Version(11, 36, 36, 16, 16, - new ECBlocks(42, new ECB(1, 86))))); - VERSIONS.push_back(Ref(new Version(12, 40, 40, 18, 18, - new ECBlocks(48, new ECB(1, 114))))); - VERSIONS.push_back(Ref(new Version(13, 44, 44, 20, 20, - new ECBlocks(56, new ECB(1, 144))))); - VERSIONS.push_back(Ref(new Version(14, 48, 48, 22, 22, - new ECBlocks(68, new ECB(1, 174))))); - VERSIONS.push_back(Ref(new Version(15, 52, 52, 24, 24, - new ECBlocks(42, new ECB(2, 102))))); - VERSIONS.push_back(Ref(new Version(16, 64, 64, 14, 14, - new ECBlocks(56, new ECB(2, 140))))); - VERSIONS.push_back(Ref(new Version(17, 72, 72, 16, 16, - new ECBlocks(36, new ECB(4, 92))))); - VERSIONS.push_back(Ref(new Version(18, 80, 80, 18, 18, - new ECBlocks(48, new ECB(4, 114))))); - VERSIONS.push_back(Ref(new Version(19, 88, 88, 20, 20, - new ECBlocks(56, new ECB(4, 144))))); - VERSIONS.push_back(Ref(new Version(20, 96, 96, 22, 22, - new ECBlocks(68, new ECB(4, 174))))); - VERSIONS.push_back(Ref(new Version(21, 104, 104, 24, 24, - new ECBlocks(56, new ECB(6, 136))))); - VERSIONS.push_back(Ref(new Version(22, 120, 120, 18, 18, - new ECBlocks(68, new ECB(6, 175))))); - VERSIONS.push_back(Ref(new Version(23, 132, 132, 20, 20, - new ECBlocks(62, new ECB(8, 163))))); - VERSIONS.push_back(Ref(new Version(24, 144, 144, 22, 22, - new ECBlocks(62, new ECB(8, 156), new ECB(2, 155))))); - VERSIONS.push_back(Ref(new Version(25, 8, 18, 6, 16, - new ECBlocks(7, new ECB(1, 5))))); - VERSIONS.push_back(Ref(new Version(26, 8, 32, 6, 14, - new ECBlocks(11, new ECB(1, 10))))); - VERSIONS.push_back(Ref(new Version(27, 12, 26, 10, 24, - new ECBlocks(14, new ECB(1, 16))))); - VERSIONS.push_back(Ref(new Version(28, 12, 36, 10, 16, - new ECBlocks(18, new ECB(1, 22))))); - VERSIONS.push_back(Ref(new Version(29, 16, 36, 14, 16, - new ECBlocks(24, new ECB(1, 32))))); - VERSIONS.push_back(Ref(new Version(30, 16, 48, 14, 22, - new ECBlocks(28, new ECB(1, 49))))); + VERSIONS.push_back(new Version(1, 10, 10, 8, 8, + new ECBlocks(5, new ECB(1, 3)))); + VERSIONS.push_back(new Version(2, 12, 12, 10, 10, + new ECBlocks(7, new ECB(1, 5)))); + VERSIONS.push_back(new Version(3, 14, 14, 12, 12, + new ECBlocks(10, new ECB(1, 8)))); + VERSIONS.push_back(new Version(4, 16, 16, 14, 14, + new ECBlocks(12, new ECB(1, 12)))); + VERSIONS.push_back(new Version(5, 18, 18, 16, 16, + new ECBlocks(14, new ECB(1, 18)))); + VERSIONS.push_back(new Version(6, 20, 20, 18, 18, + new ECBlocks(18, new ECB(1, 22)))); + VERSIONS.push_back(new Version(7, 22, 22, 20, 20, + new ECBlocks(20, new ECB(1, 30)))); + VERSIONS.push_back(new Version(8, 24, 24, 22, 22, + new ECBlocks(24, new ECB(1, 36)))); + VERSIONS.push_back(new Version(9, 26, 26, 24, 24, + new ECBlocks(28, new ECB(1, 44)))); + VERSIONS.push_back(new Version(10, 32, 32, 14, 14, + new ECBlocks(36, new ECB(1, 62)))); + VERSIONS.push_back(new Version(11, 36, 36, 16, 16, + new ECBlocks(42, new ECB(1, 86)))); + VERSIONS.push_back(new Version(12, 40, 40, 18, 18, + new ECBlocks(48, new ECB(1, 114)))); + VERSIONS.push_back(new Version(13, 44, 44, 20, 20, + new ECBlocks(56, new ECB(1, 144)))); + VERSIONS.push_back(new Version(14, 48, 48, 22, 22, + new ECBlocks(68, new ECB(1, 174)))); + VERSIONS.push_back(new Version(15, 52, 52, 24, 24, + new ECBlocks(42, new ECB(2, 102)))); + VERSIONS.push_back(new Version(16, 64, 64, 14, 14, + new ECBlocks(56, new ECB(2, 140)))); + VERSIONS.push_back(new Version(17, 72, 72, 16, 16, + new ECBlocks(36, new ECB(4, 92)))); + VERSIONS.push_back(new Version(18, 80, 80, 18, 18, + new ECBlocks(48, new ECB(4, 114)))); + VERSIONS.push_back(new Version(19, 88, 88, 20, 20, + new ECBlocks(56, new ECB(4, 144)))); + VERSIONS.push_back(new Version(20, 96, 96, 22, 22, + new ECBlocks(68, new ECB(4, 174)))); + VERSIONS.push_back(new Version(21, 104, 104, 24, 24, + new ECBlocks(56, new ECB(6, 136)))); + VERSIONS.push_back(new Version(22, 120, 120, 18, 18, + new ECBlocks(68, new ECB(6, 175)))); + VERSIONS.push_back(new Version(23, 132, 132, 20, 20, + new ECBlocks(62, new ECB(8, 163)))); + VERSIONS.push_back(new Version(24, 144, 144, 22, 22, + new ECBlocks(62, new ECB(8, 156), new ECB(2, 155)))); + VERSIONS.push_back(new Version(25, 8, 18, 6, 16, + new ECBlocks(7, new ECB(1, 5)))); + VERSIONS.push_back(new Version(26, 8, 32, 6, 14, + new ECBlocks(11, new ECB(1, 10)))); + VERSIONS.push_back(new Version(27, 12, 26, 10, 24, + new ECBlocks(14, new ECB(1, 16)))); + VERSIONS.push_back(new Version(28, 12, 36, 10, 16, + new ECBlocks(18, new ECB(1, 22)))); + VERSIONS.push_back(new Version(29, 16, 36, 14, 16, + new ECBlocks(24, new ECB(1, 32)))); + VERSIONS.push_back(new Version(30, 16, 48, 14, 22, + new ECBlocks(28, new ECB(1, 49)))); return int(VERSIONS.size()); } } diff --git a/src/zxing/zxing/datamatrix/Version.h b/src/zxing/zxing/datamatrix/Version.h index 8412c75..9961437 100644 --- a/src/zxing/zxing/datamatrix/Version.h +++ b/src/zxing/zxing/datamatrix/Version.h @@ -64,18 +64,18 @@ private: int dataRegionSizeColumns, ECBlocks *ecBlocks); public: - static std::vector > VERSIONS; + static std::vector VERSIONS; ~Version(); - int getVersionNumber(); - int getSymbolSizeRows(); - int getSymbolSizeColumns(); - int getDataRegionSizeRows(); - int getDataRegionSizeColumns(); - int getTotalCodewords(); - ECBlocks* getECBlocks(); + int getVersionNumber() const; + int getSymbolSizeRows() const; + int getSymbolSizeColumns() const; + int getDataRegionSizeRows() const; + int getDataRegionSizeColumns() const; + int getTotalCodewords() const; + ECBlocks* getECBlocks() const; static int buildVersions(); - Ref getVersionForDimensions(int numRows, int numColumns); + Version *getVersionForDimensions(int numRows, int numColumns); private: Version(const Version&); diff --git a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h index d20c241..367b5e0 100644 --- a/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h +++ b/src/zxing/zxing/datamatrix/decoder/BitMatrixParser.h @@ -33,14 +33,14 @@ namespace datamatrix { class BitMatrixParser : public Counted { private: Ref bitMatrix_; - Ref parsedVersion_; + Version* parsedVersion_; Ref readBitMatrix_; int copyBit(size_t x, size_t y, int versionBits); public: BitMatrixParser(Ref bitMatrix); - Ref readVersion(Ref bitMatrix); + Version* readVersion(Ref bitMatrix); ArrayRef readCodewords(); bool readModule(int row, int column, int numRows, int numColumns); diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp index c9a1cb3..3acc434 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp @@ -42,7 +42,7 @@ BitMatrixParser::BitMatrixParser(Ref bitMatrix) : bitMatrix_(NULL), readBitMatrix_ = new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight()); } -Ref BitMatrixParser::readVersion(Ref bitMatrix) { +Version* BitMatrixParser::readVersion(Ref bitMatrix) { if (parsedVersion_ != 0) { return parsedVersion_; } @@ -50,7 +50,7 @@ Ref BitMatrixParser::readVersion(Ref bitMatrix) { int numRows = bitMatrix->getHeight(); int numColumns = bitMatrix->getWidth(); - Ref version = parsedVersion_->getVersionForDimensions(numRows, numColumns); + Version* version = parsedVersion_->getVersionForDimensions(numRows, numColumns); if (version != 0) { return version; } diff --git a/src/zxing/zxing/qrcode/QRVersion.cpp b/src/zxing/zxing/qrcode/QRVersion.cpp index 8fc48e6..932b012 100644 --- a/src/zxing/zxing/qrcode/QRVersion.cpp +++ b/src/zxing/zxing/qrcode/QRVersion.cpp @@ -78,7 +78,7 @@ unsigned int Version::VERSION_DECODE_INFO[] = { 0x07C94, 0x085BC, 0x09A99, 0x0A4 0x27541, 0x28C69 }; int Version::N_VERSION_DECODE_INFOS = 34; -vector > Version::VERSIONS; +vector Version::VERSIONS; static int N_VERSIONS = Version::buildVersions(); int Version::getVersionNumber() const { @@ -101,7 +101,7 @@ ECBlocks& Version::getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) cons return *ecBlocks_[ecLevel.ordinal()]; } -Ref Version::getProvisionalVersionForDimension(int dimension) { +Version* Version::getProvisionalVersionForDimension(int dimension) { if (dimension % 4 != 1) { throw FormatException(); } @@ -113,7 +113,7 @@ Ref Version::getProvisionalVersionForDimension(int dimension) { } } -Ref Version::getVersionForNumber(int versionNumber) { +Version* Version::getVersionForNumber(int versionNumber) { if (versionNumber < 1 || versionNumber > N_VERSIONS) { throw ReaderException("versionNumber must be between 1 and 40"); } @@ -146,7 +146,7 @@ Version::~Version() { } } -Ref Version::decodeVersionInformation(unsigned int versionBits) { +Version* Version::decodeVersionInformation(unsigned int versionBits) { int bestDifference = numeric_limits::max(); size_t bestVersion = 0; for (int i = 0; i < N_VERSION_DECODE_INFOS; i++) { @@ -169,7 +169,7 @@ Ref Version::decodeVersionInformation(unsigned int versionBits) { return getVersionForNumber(int(bestVersion)); } // If we didn't find a close enough match, fail - return Ref(NULL); + return NULL; } Ref Version::buildFunctionPattern() { @@ -225,62 +225,62 @@ static vector *intArray(size_t n...) { } int Version::buildVersions() { - VERSIONS.push_back(Ref(new Version(1, intArray(0), + VERSIONS.push_back(new Version(1, intArray(0), new ECBlocks(7, new ECB(1, 19)), new ECBlocks(10, new ECB(1, 16)), new ECBlocks(13, new ECB(1, 13)), - new ECBlocks(17, new ECB(1, 9))))); - VERSIONS.push_back(Ref(new Version(2, intArray(2, 6, 18), + new ECBlocks(17, new ECB(1, 9)))); + VERSIONS.push_back(new Version(2, intArray(2, 6, 18), new ECBlocks(10, new ECB(1, 34)), new ECBlocks(16, new ECB(1, 28)), new ECBlocks(22, new ECB(1, 22)), - new ECBlocks(28, new ECB(1, 16))))); - VERSIONS.push_back(Ref(new Version(3, intArray(2, 6, 22), + new ECBlocks(28, new ECB(1, 16)))); + VERSIONS.push_back(new Version(3, intArray(2, 6, 22), new ECBlocks(15, new ECB(1, 55)), new ECBlocks(26, new ECB(1, 44)), new ECBlocks(18, new ECB(2, 17)), - new ECBlocks(22, new ECB(2, 13))))); - VERSIONS.push_back(Ref(new Version(4, intArray(2, 6, 26), + new ECBlocks(22, new ECB(2, 13)))); + VERSIONS.push_back(new Version(4, intArray(2, 6, 26), new ECBlocks(20, new ECB(1, 80)), new ECBlocks(18, new ECB(2, 32)), new ECBlocks(26, new ECB(2, 24)), - new ECBlocks(16, new ECB(4, 9))))); - VERSIONS.push_back(Ref(new Version(5, intArray(2, 6, 30), + new ECBlocks(16, new ECB(4, 9)))); + VERSIONS.push_back(new Version(5, intArray(2, 6, 30), new ECBlocks(26, new ECB(1, 108)), new ECBlocks(24, new ECB(2, 43)), new ECBlocks(18, new ECB(2, 15), new ECB(2, 16)), new ECBlocks(22, new ECB(2, 11), - new ECB(2, 12))))); - VERSIONS.push_back(Ref(new Version(6, intArray(2, 6, 34), + new ECB(2, 12)))); + VERSIONS.push_back(new Version(6, intArray(2, 6, 34), new ECBlocks(18, new ECB(2, 68)), new ECBlocks(16, new ECB(4, 27)), new ECBlocks(24, new ECB(4, 19)), - new ECBlocks(28, new ECB(4, 15))))); - VERSIONS.push_back(Ref(new Version(7, intArray(3, 6, 22, 38), + new ECBlocks(28, new ECB(4, 15)))); + VERSIONS.push_back(new Version(7, intArray(3, 6, 22, 38), new ECBlocks(20, new ECB(2, 78)), new ECBlocks(18, new ECB(4, 31)), new ECBlocks(18, new ECB(2, 14), new ECB(4, 15)), new ECBlocks(26, new ECB(4, 13), - new ECB(1, 14))))); - VERSIONS.push_back(Ref(new Version(8, intArray(3, 6, 24, 42), + new ECB(1, 14)))); + VERSIONS.push_back(new Version(8, intArray(3, 6, 24, 42), new ECBlocks(24, new ECB(2, 97)), new ECBlocks(22, new ECB(2, 38), new ECB(2, 39)), new ECBlocks(22, new ECB(4, 18), new ECB(2, 19)), new ECBlocks(26, new ECB(4, 14), - new ECB(2, 15))))); - VERSIONS.push_back(Ref(new Version(9, intArray(3, 6, 26, 46), + new ECB(2, 15)))); + VERSIONS.push_back(new Version(9, intArray(3, 6, 26, 46), new ECBlocks(30, new ECB(2, 116)), new ECBlocks(22, new ECB(3, 36), new ECB(2, 37)), new ECBlocks(20, new ECB(4, 16), new ECB(4, 17)), new ECBlocks(24, new ECB(4, 12), - new ECB(4, 13))))); - VERSIONS.push_back(Ref(new Version(10, intArray(3, 6, 28, 50), + new ECB(4, 13)))); + VERSIONS.push_back(new Version(10, intArray(3, 6, 28, 50), new ECBlocks(18, new ECB(2, 68), new ECB(2, 69)), new ECBlocks(26, new ECB(4, 43), @@ -288,16 +288,16 @@ int Version::buildVersions() { new ECBlocks(24, new ECB(6, 19), new ECB(2, 20)), new ECBlocks(28, new ECB(6, 15), - new ECB(2, 16))))); - VERSIONS.push_back(Ref(new Version(11, intArray(3, 6, 30, 54), + new ECB(2, 16)))); + VERSIONS.push_back(new Version(11, intArray(3, 6, 30, 54), new ECBlocks(20, new ECB(4, 81)), new ECBlocks(30, new ECB(1, 50), new ECB(4, 51)), new ECBlocks(28, new ECB(4, 22), new ECB(4, 23)), new ECBlocks(24, new ECB(3, 12), - new ECB(8, 13))))); - VERSIONS.push_back(Ref(new Version(12, intArray(3, 6, 32, 58), + new ECB(8, 13)))); + VERSIONS.push_back(new Version(12, intArray(3, 6, 32, 58), new ECBlocks(24, new ECB(2, 92), new ECB(2, 93)), new ECBlocks(22, new ECB(6, 36), @@ -305,16 +305,16 @@ int Version::buildVersions() { new ECBlocks(26, new ECB(4, 20), new ECB(6, 21)), new ECBlocks(28, new ECB(7, 14), - new ECB(4, 15))))); - VERSIONS.push_back(Ref(new Version(13, intArray(3, 6, 34, 62), + new ECB(4, 15)))); + VERSIONS.push_back(new Version(13, intArray(3, 6, 34, 62), new ECBlocks(26, new ECB(4, 107)), new ECBlocks(22, new ECB(8, 37), new ECB(1, 38)), new ECBlocks(24, new ECB(8, 20), new ECB(4, 21)), new ECBlocks(22, new ECB(12, 11), - new ECB(4, 12))))); - VERSIONS.push_back(Ref(new Version(14, intArray(4, 6, 26, 46, 66), + new ECB(4, 12)))); + VERSIONS.push_back(new Version(14, intArray(4, 6, 26, 46, 66), new ECBlocks(30, new ECB(3, 115), new ECB(1, 116)), new ECBlocks(24, new ECB(4, 40), @@ -322,8 +322,8 @@ int Version::buildVersions() { new ECBlocks(20, new ECB(11, 16), new ECB(5, 17)), new ECBlocks(24, new ECB(11, 12), - new ECB(5, 13))))); - VERSIONS.push_back(Ref(new Version(15, intArray(4, 6, 26, 48, 70), + new ECB(5, 13)))); + VERSIONS.push_back(new Version(15, intArray(4, 6, 26, 48, 70), new ECBlocks(22, new ECB(5, 87), new ECB(1, 88)), new ECBlocks(24, new ECB(5, 41), @@ -331,8 +331,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(5, 24), new ECB(7, 25)), new ECBlocks(24, new ECB(11, 12), - new ECB(7, 13))))); - VERSIONS.push_back(Ref(new Version(16, intArray(4, 6, 26, 50, 74), + new ECB(7, 13)))); + VERSIONS.push_back(new Version(16, intArray(4, 6, 26, 50, 74), new ECBlocks(24, new ECB(5, 98), new ECB(1, 99)), new ECBlocks(28, new ECB(7, 45), @@ -340,8 +340,8 @@ int Version::buildVersions() { new ECBlocks(24, new ECB(15, 19), new ECB(2, 20)), new ECBlocks(30, new ECB(3, 15), - new ECB(13, 16))))); - VERSIONS.push_back(Ref(new Version(17, intArray(4, 6, 30, 54, 78), + new ECB(13, 16)))); + VERSIONS.push_back(new Version(17, intArray(4, 6, 30, 54, 78), new ECBlocks(28, new ECB(1, 107), new ECB(5, 108)), new ECBlocks(28, new ECB(10, 46), @@ -349,8 +349,8 @@ int Version::buildVersions() { new ECBlocks(28, new ECB(1, 22), new ECB(15, 23)), new ECBlocks(28, new ECB(2, 14), - new ECB(17, 15))))); - VERSIONS.push_back(Ref(new Version(18, intArray(4, 6, 30, 56, 82), + new ECB(17, 15)))); + VERSIONS.push_back(new Version(18, intArray(4, 6, 30, 56, 82), new ECBlocks(30, new ECB(5, 120), new ECB(1, 121)), new ECBlocks(26, new ECB(9, 43), @@ -358,8 +358,8 @@ int Version::buildVersions() { new ECBlocks(28, new ECB(17, 22), new ECB(1, 23)), new ECBlocks(28, new ECB(2, 14), - new ECB(19, 15))))); - VERSIONS.push_back(Ref(new Version(19, intArray(4, 6, 30, 58, 86), + new ECB(19, 15)))); + VERSIONS.push_back(new Version(19, intArray(4, 6, 30, 58, 86), new ECBlocks(28, new ECB(3, 113), new ECB(4, 114)), new ECBlocks(26, new ECB(3, 44), @@ -367,8 +367,8 @@ int Version::buildVersions() { new ECBlocks(26, new ECB(17, 21), new ECB(4, 22)), new ECBlocks(26, new ECB(9, 13), - new ECB(16, 14))))); - VERSIONS.push_back(Ref(new Version(20, intArray(4, 6, 34, 62, 90), + new ECB(16, 14)))); + VERSIONS.push_back(new Version(20, intArray(4, 6, 34, 62, 90), new ECBlocks(28, new ECB(3, 107), new ECB(5, 108)), new ECBlocks(26, new ECB(3, 41), @@ -376,23 +376,23 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(15, 24), new ECB(5, 25)), new ECBlocks(28, new ECB(15, 15), - new ECB(10, 16))))); - VERSIONS.push_back(Ref(new Version(21, intArray(5, 6, 28, 50, 72, 94), + new ECB(10, 16)))); + VERSIONS.push_back(new Version(21, intArray(5, 6, 28, 50, 72, 94), new ECBlocks(28, new ECB(4, 116), new ECB(4, 117)), new ECBlocks(26, new ECB(17, 42)), new ECBlocks(28, new ECB(17, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(19, 16), - new ECB(6, 17))))); - VERSIONS.push_back(Ref(new Version(22, intArray(5, 6, 26, 50, 74, 98), + new ECB(6, 17)))); + VERSIONS.push_back(new Version(22, intArray(5, 6, 26, 50, 74, 98), new ECBlocks(28, new ECB(2, 111), new ECB(7, 112)), new ECBlocks(28, new ECB(17, 46)), new ECBlocks(30, new ECB(7, 24), new ECB(16, 25)), - new ECBlocks(24, new ECB(34, 13))))); - VERSIONS.push_back(Ref(new Version(23, intArray(5, 6, 30, 54, 78, 102), + new ECBlocks(24, new ECB(34, 13)))); + VERSIONS.push_back(new Version(23, intArray(5, 6, 30, 54, 78, 102), new ECBlocks(30, new ECB(4, 121), new ECB(5, 122)), new ECBlocks(28, new ECB(4, 47), @@ -400,8 +400,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(11, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(16, 15), - new ECB(14, 16))))); - VERSIONS.push_back(Ref(new Version(24, intArray(5, 6, 28, 54, 80, 106), + new ECB(14, 16)))); + VERSIONS.push_back(new Version(24, intArray(5, 6, 28, 54, 80, 106), new ECBlocks(30, new ECB(6, 117), new ECB(4, 118)), new ECBlocks(28, new ECB(6, 45), @@ -409,8 +409,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(11, 24), new ECB(16, 25)), new ECBlocks(30, new ECB(30, 16), - new ECB(2, 17))))); - VERSIONS.push_back(Ref(new Version(25, intArray(5, 6, 32, 58, 84, 110), + new ECB(2, 17)))); + VERSIONS.push_back(new Version(25, intArray(5, 6, 32, 58, 84, 110), new ECBlocks(26, new ECB(8, 106), new ECB(4, 107)), new ECBlocks(28, new ECB(8, 47), @@ -418,8 +418,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(7, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(22, 15), - new ECB(13, 16))))); - VERSIONS.push_back(Ref(new Version(26, intArray(5, 6, 30, 58, 86, 114), + new ECB(13, 16)))); + VERSIONS.push_back(new Version(26, intArray(5, 6, 30, 58, 86, 114), new ECBlocks(28, new ECB(10, 114), new ECB(2, 115)), new ECBlocks(28, new ECB(19, 46), @@ -427,8 +427,8 @@ int Version::buildVersions() { new ECBlocks(28, new ECB(28, 22), new ECB(6, 23)), new ECBlocks(30, new ECB(33, 16), - new ECB(4, 17))))); - VERSIONS.push_back(Ref(new Version(27, intArray(5, 6, 34, 62, 90, 118), + new ECB(4, 17)))); + VERSIONS.push_back(new Version(27, intArray(5, 6, 34, 62, 90, 118), new ECBlocks(30, new ECB(8, 122), new ECB(4, 123)), new ECBlocks(28, new ECB(22, 45), @@ -436,8 +436,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(8, 23), new ECB(26, 24)), new ECBlocks(30, new ECB(12, 15), - new ECB(28, 16))))); - VERSIONS.push_back(Ref(new Version(28, intArray(6, 6, 26, 50, 74, 98, 122), + new ECB(28, 16)))); + VERSIONS.push_back(new Version(28, intArray(6, 6, 26, 50, 74, 98, 122), new ECBlocks(30, new ECB(3, 117), new ECB(10, 118)), new ECBlocks(28, new ECB(3, 45), @@ -445,8 +445,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(4, 24), new ECB(31, 25)), new ECBlocks(30, new ECB(11, 15), - new ECB(31, 16))))); - VERSIONS.push_back(Ref(new Version(29, intArray(6, 6, 30, 54, 78, 102, 126), + new ECB(31, 16)))); + VERSIONS.push_back(new Version(29, intArray(6, 6, 30, 54, 78, 102, 126), new ECBlocks(30, new ECB(7, 116), new ECB(7, 117)), new ECBlocks(28, new ECB(21, 45), @@ -454,8 +454,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(1, 23), new ECB(37, 24)), new ECBlocks(30, new ECB(19, 15), - new ECB(26, 16))))); - VERSIONS.push_back(Ref(new Version(30, intArray(6, 6, 26, 52, 78, 104, 130), + new ECB(26, 16)))); + VERSIONS.push_back(new Version(30, intArray(6, 6, 26, 52, 78, 104, 130), new ECBlocks(30, new ECB(5, 115), new ECB(10, 116)), new ECBlocks(28, new ECB(19, 47), @@ -463,8 +463,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(15, 24), new ECB(25, 25)), new ECBlocks(30, new ECB(23, 15), - new ECB(25, 16))))); - VERSIONS.push_back(Ref(new Version(31, intArray(6, 6, 30, 56, 82, 108, 134), + new ECB(25, 16)))); + VERSIONS.push_back(new Version(31, intArray(6, 6, 30, 56, 82, 108, 134), new ECBlocks(30, new ECB(13, 115), new ECB(3, 116)), new ECBlocks(28, new ECB(2, 46), @@ -472,16 +472,16 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(42, 24), new ECB(1, 25)), new ECBlocks(30, new ECB(23, 15), - new ECB(28, 16))))); - VERSIONS.push_back(Ref(new Version(32, intArray(6, 6, 34, 60, 86, 112, 138), + new ECB(28, 16)))); + VERSIONS.push_back(new Version(32, intArray(6, 6, 34, 60, 86, 112, 138), new ECBlocks(30, new ECB(17, 115)), new ECBlocks(28, new ECB(10, 46), new ECB(23, 47)), new ECBlocks(30, new ECB(10, 24), new ECB(35, 25)), new ECBlocks(30, new ECB(19, 15), - new ECB(35, 16))))); - VERSIONS.push_back(Ref(new Version(33, intArray(6, 6, 30, 58, 86, 114, 142), + new ECB(35, 16)))); + VERSIONS.push_back(new Version(33, intArray(6, 6, 30, 58, 86, 114, 142), new ECBlocks(30, new ECB(17, 115), new ECB(1, 116)), new ECBlocks(28, new ECB(14, 46), @@ -489,8 +489,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(29, 24), new ECB(19, 25)), new ECBlocks(30, new ECB(11, 15), - new ECB(46, 16))))); - VERSIONS.push_back(Ref(new Version(34, intArray(6, 6, 34, 62, 90, 118, 146), + new ECB(46, 16)))); + VERSIONS.push_back(new Version(34, intArray(6, 6, 34, 62, 90, 118, 146), new ECBlocks(30, new ECB(13, 115), new ECB(6, 116)), new ECBlocks(28, new ECB(14, 46), @@ -498,8 +498,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(44, 24), new ECB(7, 25)), new ECBlocks(30, new ECB(59, 16), - new ECB(1, 17))))); - VERSIONS.push_back(Ref(new Version(35, intArray(7, 6, 30, 54, 78, + new ECB(1, 17)))); + VERSIONS.push_back(new Version(35, intArray(7, 6, 30, 54, 78, 102, 126, 150), new ECBlocks(30, new ECB(12, 121), new ECB(7, 122)), @@ -508,8 +508,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(39, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(22, 15), - new ECB(41, 16))))); - VERSIONS.push_back(Ref(new Version(36, intArray(7, 6, 24, 50, 76, + new ECB(41, 16)))); + VERSIONS.push_back(new Version(36, intArray(7, 6, 24, 50, 76, 102, 128, 154), new ECBlocks(30, new ECB(6, 121), new ECB(14, 122)), @@ -518,8 +518,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(46, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(2, 15), - new ECB(64, 16))))); - VERSIONS.push_back(Ref(new Version(37, intArray(7, 6, 28, 54, 80, + new ECB(64, 16)))); + VERSIONS.push_back(new Version(37, intArray(7, 6, 28, 54, 80, 106, 132, 158), new ECBlocks(30, new ECB(17, 122), new ECB(4, 123)), @@ -528,8 +528,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(49, 24), new ECB(10, 25)), new ECBlocks(30, new ECB(24, 15), - new ECB(46, 16))))); - VERSIONS.push_back(Ref(new Version(38, intArray(7, 6, 32, 58, 84, + new ECB(46, 16)))); + VERSIONS.push_back(new Version(38, intArray(7, 6, 32, 58, 84, 110, 136, 162), new ECBlocks(30, new ECB(4, 122), new ECB(18, 123)), @@ -538,8 +538,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(48, 24), new ECB(14, 25)), new ECBlocks(30, new ECB(42, 15), - new ECB(32, 16))))); - VERSIONS.push_back(Ref(new Version(39, intArray(7, 6, 26, 54, 82, + new ECB(32, 16)))); + VERSIONS.push_back(new Version(39, intArray(7, 6, 26, 54, 82, 110, 138, 166), new ECBlocks(30, new ECB(20, 117), new ECB(4, 118)), @@ -548,8 +548,8 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(43, 24), new ECB(22, 25)), new ECBlocks(30, new ECB(10, 15), - new ECB(67, 16))))); - VERSIONS.push_back(Ref(new Version(40, intArray(7, 6, 30, 58, 86, + new ECB(67, 16)))); + VERSIONS.push_back(new Version(40, intArray(7, 6, 30, 58, 86, 114, 142, 170), new ECBlocks(30, new ECB(19, 118), new ECB(6, 119)), @@ -558,7 +558,7 @@ int Version::buildVersions() { new ECBlocks(30, new ECB(34, 24), new ECB(34, 25)), new ECBlocks(30, new ECB(20, 15), - new ECB(61, 16))))); + new ECB(61, 16)))); return int(VERSIONS.size()); } diff --git a/src/zxing/zxing/qrcode/Version.h b/src/zxing/zxing/qrcode/Version.h index 987a446..d96c8fd 100644 --- a/src/zxing/zxing/qrcode/Version.h +++ b/src/zxing/zxing/qrcode/Version.h @@ -53,7 +53,7 @@ public: ~ECBlocks(); }; -class Version : public Counted { +class Version { private: int versionNumber_; @@ -66,7 +66,7 @@ private: public: static unsigned int VERSION_DECODE_INFO[]; static int N_VERSION_DECODE_INFOS; - static std::vector > VERSIONS; + static std::vector VERSIONS; ~Version(); int getVersionNumber() const; @@ -74,9 +74,9 @@ public: int getTotalCodewords(); int getDimensionForVersion(); ECBlocks &getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) const; - static Ref getProvisionalVersionForDimension(int dimension); - static Ref getVersionForNumber(int versionNumber); - static Ref decodeVersionInformation(unsigned int versionBits); + static Version* getProvisionalVersionForDimension(int dimension); + static Version* getVersionForNumber(int versionNumber); + static Version* decodeVersionInformation(unsigned int versionBits); Ref buildFunctionPattern(); static int buildVersions(); }; diff --git a/src/zxing/zxing/qrcode/decoder/Mode.h b/src/zxing/zxing/qrcode/decoder/Mode.h index dab5f9e..98971a5 100644 --- a/src/zxing/zxing/qrcode/decoder/Mode.h +++ b/src/zxing/zxing/qrcode/decoder/Mode.h @@ -37,7 +37,7 @@ private: int bits_; std::string name_; - Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, char const* name); + Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, const std::string &name); public: Mode(const Mode& mode); diff --git a/src/zxing/zxing/qrcode/decoder/QRMode.cpp b/src/zxing/zxing/qrcode/decoder/QRMode.cpp index 29bd5a1..d0ac6b5 100644 --- a/src/zxing/zxing/qrcode/decoder/QRMode.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRMode.cpp @@ -51,7 +51,7 @@ Mode::Mode() : name_("") {} -Mode::Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, char const* name) : +Mode::Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, const std::string &name) : characterCountBitsForVersions0To9_(cbv0_9), characterCountBitsForVersions10To26_(cbv10_26), characterCountBitsForVersions27AndHigher_(cbv27), bits_(bits), name_(name) { diff --git a/src/zxing/zxing/qrcode/encoder/Encoder.h b/src/zxing/zxing/qrcode/encoder/Encoder.h index 0c0eeef..09af16e 100644 --- a/src/zxing/zxing/qrcode/encoder/Encoder.h +++ b/src/zxing/zxing/qrcode/encoder/Encoder.h @@ -92,10 +92,10 @@ protected: private: static int chooseMaskPattern(Ref bits, ErrorCorrectionLevel& ecLevel, - Ref version, + Version* version, Ref matrix); - static Ref chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) ; + static Version* chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) ; static void appendECI(const zxing::common::CharacterSetECI& eci, BitArray& bits); @@ -106,9 +106,9 @@ private: static int calculateMaskPenalty(const ByteMatrix& matrix); static int calculateBitsNeeded(const Mode &mode, const BitArray &headerBits, const BitArray &dataBits, const - Ref version); - static bool willFit(int numInputBits, Ref version, const ErrorCorrectionLevel &ecLevel); - static Ref recommendVersion(ErrorCorrectionLevel &ecLevel, + Version* version); + static bool willFit(int numInputBits, Version* version, const ErrorCorrectionLevel &ecLevel); + static Version* recommendVersion(ErrorCorrectionLevel &ecLevel, Mode &mode, BitArray &headerBits, BitArray &dataBits); diff --git a/src/zxing/zxing/qrcode/encoder/QRCode.cpp b/src/zxing/zxing/qrcode/encoder/QRCode.cpp index a13866e..cd53551 100644 --- a/src/zxing/zxing/qrcode/encoder/QRCode.cpp +++ b/src/zxing/zxing/qrcode/encoder/QRCode.cpp @@ -26,7 +26,7 @@ Ref QRCode::getECLevel() const return ecLevel_ptr_; } -Ref QRCode::getVersion() const +Version* QRCode::getVersion() const { return version_ptr_; } @@ -56,7 +56,7 @@ const std::string QRCode::toString() result << "null"; result << "\n version: "; - if(!version_ptr_.empty()) + if(version_ptr_) { std::string version_str; std::ostringstream convert; @@ -89,7 +89,7 @@ void QRCode::setECLevel(Ref value) ecLevel_ptr_ = value; } -void QRCode::setVersion(Ref version) +void QRCode::setVersion(Version* version) { version_ptr_ = version; } diff --git a/src/zxing/zxing/qrcode/encoder/QRCode.h b/src/zxing/zxing/qrcode/encoder/QRCode.h index cd4f434..a2f1e26 100644 --- a/src/zxing/zxing/qrcode/encoder/QRCode.h +++ b/src/zxing/zxing/qrcode/encoder/QRCode.h @@ -17,7 +17,7 @@ private: Mode mode_; Ref ecLevel_ptr_; - Ref version_ptr_; + Version* version_ptr_; int maskPattern_; Ref matrix_ptr_; @@ -28,13 +28,13 @@ public: ~QRCode(); Mode getMode() const; Ref getECLevel() const; - Ref getVersion() const; + Version* getVersion() const; int getMaskPattern() const; Ref getMatrix() const; const std::string toString(); void setMode(const Mode &value); void setECLevel(Ref value); - void setVersion(Ref version); + void setVersion(Version* version); void setMaskPattern(int value); void setMatrix(Ref value); diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index d0bda7e..ba45df4 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -74,7 +74,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec BitArray dataBits; appendBytes(content, mode, dataBits, encoding); - Ref version; + Version* version; if (hints != ZXING_NULLPTR/* && hints->containsKey(EncodeHintType.QR_VERSION)*/) { version = Version::getVersionForNumber(1); int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); @@ -126,7 +126,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec //return NULL; } -bool Encoder::willFit(int numInputBits, Ref version, const ErrorCorrectionLevel &ecLevel) { +bool Encoder::willFit(int numInputBits, Version* version, const ErrorCorrectionLevel &ecLevel) { // In the following comments, we use numbers of Version 7-H. // numBytes = 196 int numBytes = version->getTotalCodewords(); @@ -207,7 +207,7 @@ Mode Encoder::chooseMode(const std::string& content, const std::string& encoding int Encoder::chooseMaskPattern(Ref bits, ErrorCorrectionLevel& ecLevel, - Ref version, + Version* version, Ref matrix) { @@ -225,11 +225,11 @@ int Encoder::chooseMaskPattern(Ref bits, return bestMaskPattern; } -Ref Encoder::chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) +Version* Encoder::chooseVersion(int numInputBits, const ErrorCorrectionLevel &ecLevel) { // In the following comments, we use numbers of Version 7-H. for (int versionNum = 1; versionNum <= 40; versionNum++) { - Ref version = Version::getVersionForNumber(versionNum); + Version* version = Version::getVersionForNumber(versionNum); if (willFit(numInputBits, version, ecLevel)) { return version; } @@ -583,12 +583,12 @@ void Encoder::appendECI(const zxing::common::CharacterSetECI& eci, BitArray& bit } int Encoder::calculateBitsNeeded(const Mode &mode, const BitArray &headerBits, const BitArray &dataBits, const - Ref version) + Version* version) { return headerBits.getSize() + mode.getCharacterCountBits(&(*version)) + dataBits.getSize(); } -Ref Encoder::recommendVersion(ErrorCorrectionLevel &ecLevel, +Version* Encoder::recommendVersion(ErrorCorrectionLevel &ecLevel, Mode &mode, BitArray &headerBits, BitArray &dataBits) @@ -597,7 +597,7 @@ Ref Encoder::recommendVersion(ErrorCorrectionLevel &ecLevel, // bits it takes to know version. First we take a guess at version by assuming version will be // the minimum, 1: int provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version::getVersionForNumber(1)); - Ref provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel); + Version* provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel); // Use that guess to calculate the right version. I am still not sure this works in 100% of cases. int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion); From 9f53b1ac033255a5d6e0abf73c40252f0bdaeef6 Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Tue, 26 Mar 2019 22:26:31 +0200 Subject: [PATCH 31/83] code cleanup --- tests/src/QZXingTests/EncoderStressTest.cpp | 3 --- tests/src/QZXingTests/EncoderStressTest.h | 1 - 2 files changed, 4 deletions(-) diff --git a/tests/src/QZXingTests/EncoderStressTest.cpp b/tests/src/QZXingTests/EncoderStressTest.cpp index ab4f341..5d8c0e2 100644 --- a/tests/src/QZXingTests/EncoderStressTest.cpp +++ b/tests/src/QZXingTests/EncoderStressTest.cpp @@ -5,7 +5,6 @@ namespace zxing { namespace tests{ -QMutex EncoderStressTest::mutex; QMutex EncoderStressTest::printLockMutex; EncoderStressTest::EncoderStressTest(): TestCase(), @@ -116,11 +115,9 @@ void EncoderStressTest::runTest(TestRunData &testData) QSize(500, 500), testData.errorCorrectionLevel); - // mutex.lock(); QZXing decoder(QZXing::DecoderFormat_QR_CODE); QString decodedData = decoder.decodeImage(generatedImage); bool wasDecoded = decoder.getLastDecodeOperationSucceded(); - // mutex.unlock(); testData.successful = (testData.data == decodedData); diff --git a/tests/src/QZXingTests/EncoderStressTest.h b/tests/src/QZXingTests/EncoderStressTest.h index 08d09ff..f16a244 100644 --- a/tests/src/QZXingTests/EncoderStressTest.h +++ b/tests/src/QZXingTests/EncoderStressTest.h @@ -52,7 +52,6 @@ private: size_t sumOfSuccessfullTests_; size_t totalExecutedTests_; - static QMutex mutex; static QMutex printLockMutex; }; From a747ab7af704de313a836b7ce2336aa3220b83b6 Mon Sep 17 00:00:00 2001 From: Alfred Neumayer Date: Mon, 1 Apr 2019 19:00:40 +0200 Subject: [PATCH 32/83] avoid processing empty video frame buffers --- src/QZXingFilter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index f60883d..8ec2998 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -191,6 +191,12 @@ static QImage* rgbDataToGrayscale(const uchar* data, const CaptureRect& captureR void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame, const QRect& _captureRect) { + if (videoFrame.data.length() < 1) { + qDebug() << "QZXingFilterRunnable: Buffer is empty"; + filter->decoding = false; + return; + } + static unsigned int i = 0; i++; // qDebug() << "Future: Going to process frame: " << i; From b2dc6340981502ec845294fc070db71bd6fbb931 Mon Sep 17 00:00:00 2001 From: Alfred Neumayer Date: Wed, 10 Apr 2019 16:40:00 +0200 Subject: [PATCH 33/83] src: use ::abs() instead of abs() Fix undefined reference errors while building with clang. --- .../zxing/datamatrix/detector/DataMatrixDetector.cpp | 6 +++--- .../zxing/qrcode/detector/QRAlignmentPatternFinder.cpp | 2 +- src/zxing/zxing/qrcode/detector/QRDetector.cpp | 6 +++--- .../zxing/qrcode/detector/QRFinderPatternFinder.cpp | 10 +++++----- src/zxing/zxing/qrcode/encoder/MaskUtil.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp b/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp index 4ae2a30..e33c340 100644 --- a/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp +++ b/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp @@ -357,7 +357,7 @@ Ref Detector::transitionsBetween(Ref fr int fromY = (int) from->getY(); int toX = (int) to->getX(); int toY = (int) to->getY(); - bool steep = abs(toY - fromY) > abs(toX - fromX); + bool steep = ::abs(toY - fromY) > abs(toX - fromX); if (steep) { int temp = fromX; fromX = fromY; @@ -367,8 +367,8 @@ Ref Detector::transitionsBetween(Ref fr toY = temp; } - int dx = abs(toX - fromX); - int dy = abs(toY - fromY); + int dx = ::abs(toX - fromX); + int dy = ::abs(toY - fromY); int error = -dx >> 1; int ystep = fromY < toY ? 1 : -1; int xstep = fromX < toX ? 1 : -1; diff --git a/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp b/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp index 081a176..c1053db 100644 --- a/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp +++ b/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp @@ -89,7 +89,7 @@ float AlignmentPatternFinder::crossCheckVertical(int startI, int centerJ, int ma } int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - if (5 * abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { + if (5 * ::abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) { return nan(); } diff --git a/src/zxing/zxing/qrcode/detector/QRDetector.cpp b/src/zxing/zxing/qrcode/detector/QRDetector.cpp index e88de3e..1476719 100644 --- a/src/zxing/zxing/qrcode/detector/QRDetector.cpp +++ b/src/zxing/zxing/qrcode/detector/QRDetector.cpp @@ -242,7 +242,7 @@ float Detector::sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) { // Mild variant of Bresenham's algorithm; // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm - bool steep = abs(toY - fromY) > abs(toX - fromX); + bool steep = ::abs(toY - fromY) > ::abs(toX - fromX); if (steep) { int temp = fromX; fromX = fromY; @@ -252,8 +252,8 @@ float Detector::sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) toY = temp; } - int dx = abs(toX - fromX); - int dy = abs(toY - fromY); + int dx = ::abs(toX - fromX); + int dy = ::abs(toY - fromY); int error = -dx >> 1; int xstep = fromX < toX ? 1 : -1; int ystep = fromY < toY ? 1 : -1; diff --git a/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp b/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp index b714dab..215051e 100644 --- a/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp +++ b/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp @@ -112,11 +112,11 @@ bool FinderPatternFinder::foundPatternCross(int* stateCount) { int moduleSize = (totalModuleSize << 8) / 7; int maxVariance = moduleSize / 2; // Allow less than 50% variance from 1-1-3-1-1 proportions - return abs(moduleSize - (stateCount[0] << 8)) < maxVariance && - abs(moduleSize - (stateCount[1] << 8)) < maxVariance && - abs(3.0f * moduleSize - (stateCount[2] << 8)) < 3 * maxVariance && - abs(moduleSize - (stateCount[3] << 8)) < maxVariance && - abs(moduleSize - (stateCount[4] << 8)) < maxVariance; + return ::abs(moduleSize - (stateCount[0] << 8)) < maxVariance && + ::abs(moduleSize - (stateCount[1] << 8)) < maxVariance && + ::abs(3.0f * moduleSize - (stateCount[2] << 8)) < 3 * maxVariance && + ::abs(moduleSize - (stateCount[3] << 8)) < maxVariance && + ::abs(moduleSize - (stateCount[4] << 8)) < maxVariance; } float FinderPatternFinder::crossCheckVertical(size_t startI, size_t centerJ, int maxCount, int originalStateCountTotal) { diff --git a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp index cb97f1d..a85c260 100644 --- a/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp +++ b/src/zxing/zxing/qrcode/encoder/MaskUtil.cpp @@ -128,7 +128,7 @@ int MaskUtil::applyMaskPenaltyRule4(const ByteMatrix& matrix) } } int numTotalCells = int(matrix.getHeight() * matrix.getWidth()); - int fivePercentVariances = abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells; + int fivePercentVariances = ::abs(numDarkCells * 2 - numTotalCells) * 10 / numTotalCells; return fivePercentVariances * N4; } From 006e091f91b752e463f8736b01eaf0d6de0584b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= Date: Fri, 12 Apr 2019 10:27:44 +0200 Subject: [PATCH 34/83] update gradle version of example --- .../android/gradle/wrapper/gradle-wrapper.jar | Bin 49896 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/QZXingLive/android/gradle/wrapper/gradle-wrapper.jar b/examples/QZXingLive/android/gradle/wrapper/gradle-wrapper.jar index 8c0fb64a8698b08ecc4158d828ca593c4928e9dd..f6b961fd5a86aa5fbfe90f707c3138408be7c718 100644 GIT binary patch delta 48231 zcmZ6y18`+gw=JBGZQHhO+qP}%bkfO*la6iMCr&!t`;)vy2ezW3jI->zD_YVBHc zRqd)-W6e3nSSR5S9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G`qhAf8X&o6 Date: Fri, 12 Apr 2019 10:28:18 +0200 Subject: [PATCH 35/83] update gradle build file to latest android support and gradle tools --- examples/QZXingLive/android/build.gradle | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/QZXingLive/android/build.gradle b/examples/QZXingLive/android/build.gradle index 1596d33..87811e8 100644 --- a/examples/QZXingLive/android/build.gradle +++ b/examples/QZXingLive/android/build.gradle @@ -1,15 +1,17 @@ buildscript { repositories { + google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:3.2.0' } } allprojects { repositories { + google() jcenter() } } @@ -18,8 +20,8 @@ apply plugin: 'com.android.application' dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:25.0.1' - compile 'com.android.support:design:25.0.1' + compile 'com.android.support:appcompat-v7:28.0.0' + compile 'com.android.support:design:28.0.0' } android { From 38409776aaf7f27ae3c2c2d0e49eeec4b00b5f84 Mon Sep 17 00:00:00 2001 From: "Alfred E. Neumayer" Date: Mon, 15 Apr 2019 12:34:01 +0200 Subject: [PATCH 36/83] Replace missing abs() with ::abs() --- src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp b/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp index e33c340..ec2a805 100644 --- a/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp +++ b/src/zxing/zxing/datamatrix/detector/DataMatrixDetector.cpp @@ -357,7 +357,7 @@ Ref Detector::transitionsBetween(Ref fr int fromY = (int) from->getY(); int toX = (int) to->getX(); int toY = (int) to->getY(); - bool steep = ::abs(toY - fromY) > abs(toX - fromX); + bool steep = ::abs(toY - fromY) > ::abs(toX - fromX); if (steep) { int temp = fromX; fromX = fromY; From b952523aeb9bfe917315211dbeed47542cb9333e Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 17 Apr 2019 10:26:04 +0300 Subject: [PATCH 37/83] Fixed the support to YUYV image format. Pending bug: the extracted aread of the image is not correct (it is missaligned). #86 --- src/QZXingFilter.cpp | 50 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index 8ec2998..d0f9d71 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -24,10 +24,24 @@ namespace { qBound(0, uchar((298 * C + 516 * D + 128) >> 8), 255) ); } + + uchar yuvToGray2(uchar y, uchar u, uchar v) + { + double rD = y + 1.4075 * (v - 128); + double gD = y - 0.3455 * (u - 128) - (0.7169 * (v - 128)); + double bD = y + 1.7790 * (u - 128); + + return gray( + qBound(0, (uchar)::floor(rD), 255), + qBound(0, (uchar)::floor(gD), 255), + qBound(0, (uchar)::floor(bD), 255) + ); + } } QZXingFilter::QZXingFilter(QObject *parent) : QAbstractVideoFilter(parent) + , decoder(QZXing::DecoderFormat_QR_CODE) , decoding(false) { /// Connecting signals to handlers that will send signals to QML @@ -246,28 +260,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame image_ptr = new QImage(data, width, height, QImage::Format_RGB16); break; case QVideoFrame::Format_YUV420P: - //fix for issues #4 and #9 - image_ptr = new QImage(captureRect.targetWidth, captureRect.targetHeight, QImage::Format_Grayscale8); - pixel = image_ptr->bits(); - wh = width * height; - w_2 = width / 2; - wh_54 = wh * 5 / 4; - - for (int y = captureRect.startY; y < captureRect.endY; y++) { - const int Y_offset = y * width; - const int y_2 = y / 2; - const int U_offset = y_2 * w_2 + wh; - const int V_offset = y_2 * w_2 + wh_54; - for (int x = captureRect.startX; x < captureRect.endX; x++) { - const int x_2 = x / 2; - const uchar Y = data[Y_offset + x]; - const uchar U = data[U_offset + x_2]; - const uchar V = data[V_offset + x_2]; - *pixel = yuvToGray(Y, U, V); - ++pixel; - } - } - break; case QVideoFrame::Format_NV12: /// nv12 format, encountered on macOS image_ptr = new QImage(captureRect.targetWidth, captureRect.targetHeight, QImage::Format_Grayscale8); @@ -290,6 +282,7 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame ++pixel; } } + break; case QVideoFrame::Format_YUYV: image_ptr = new QImage(captureRect.targetWidth, captureRect.targetHeight, QImage::Format_Grayscale8); @@ -297,15 +290,21 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame for (int y = captureRect.startY; y < captureRect.endY; y++){ const uint32_t *row = &yuvPtr[y*(width/2)-(width/4)]; - for (int x = captureRect.startX; x < captureRect.endX; x++){ + int end = captureRect.startX + (captureRect.endX - captureRect.startX)/2; + for (int x = captureRect.startX; x < end; x++){ const uint8_t *pxl = reinterpret_cast(&row[x]); const uint8_t y0 = pxl[0]; const uint8_t u = pxl[1]; const uint8_t v = pxl[3]; - *pixel = yuvToGray(y0, u, v); + const uint8_t y1 = pxl[2]; + + *pixel = yuvToGray2(y0, u, v); + ++pixel; + *pixel = yuvToGray2(y1, u, v); ++pixel; } } + break; /// TODO: Handle (create QImages from) YUV formats. default: @@ -324,6 +323,7 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame return; } +// image_ptr->save("/home/ftylitak/tempimage-no-crop.png"); if (captureRect.isValid && image_ptr->size() != _captureRect.size()) image_ptr = new QImage(image_ptr->copy(_captureRect)); @@ -335,6 +335,8 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame //QZXingImageProvider::getInstance()->storeImage(image); + image_ptr->save("/home/ftylitak/tempimage.png"); + decode(*image_ptr); delete image_ptr; From 4f37a03731019879399b4256c5df990b9f91dcc5 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 17 Apr 2019 10:38:55 +0300 Subject: [PATCH 38/83] Fixed capturing rectangle to be respected when decoding YUYV images in QZXingFilter. Now it seems that Decoding is working for Linux. #86 --- src/QZXingFilter.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index d0f9d71..f32aa77 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -289,9 +289,9 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame pixel = image_ptr->bits(); for (int y = captureRect.startY; y < captureRect.endY; y++){ - const uint32_t *row = &yuvPtr[y*(width/2)-(width/4)]; - int end = captureRect.startX + (captureRect.endX - captureRect.startX)/2; - for (int x = captureRect.startX; x < end; x++){ + const uint32_t *row = &yuvPtr[y*(width/2)]; + int end = captureRect.startX/2 + (captureRect.endX - captureRect.startX)/2; + for (int x = captureRect.startX/2; x < end; x++){ const uint8_t *pxl = reinterpret_cast(&row[x]); const uint8_t y0 = pxl[0]; const uint8_t u = pxl[1]; @@ -323,7 +323,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame return; } -// image_ptr->save("/home/ftylitak/tempimage-no-crop.png"); if (captureRect.isValid && image_ptr->size() != _captureRect.size()) image_ptr = new QImage(image_ptr->copy(_captureRect)); @@ -335,8 +334,6 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame //QZXingImageProvider::getInstance()->storeImage(image); - image_ptr->save("/home/ftylitak/tempimage.png"); - decode(*image_ptr); delete image_ptr; From c121d18605303efdda3373cef75ab19ad7f39fbc Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Fri, 10 May 2019 20:42:53 +0200 Subject: [PATCH 39/83] add upc_ean extension --- src/QZXing.cpp | 16 +- src/QZXing.h | 5 + src/QZXing.pri | 9 + src/zxing/zxing/Result.cpp | 10 +- src/zxing/zxing/Result.h | 6 +- src/zxing/zxing/ResultMetadata.cpp | 110 ++++++++++++ src/zxing/zxing/ResultMetadata.h | 137 +++++++++++++++ src/zxing/zxing/common/ByteArray.h | 42 +++++ .../zxing/oned/UPCEANExtension2Support.cpp | 97 ++++++++++ .../zxing/oned/UPCEANExtension2Support.h | 38 ++++ .../zxing/oned/UPCEANExtension5Support.cpp | 166 ++++++++++++++++++ .../zxing/oned/UPCEANExtension5Support.h | 38 ++++ .../zxing/oned/UPCEANExtensionSupport.cpp | 48 +++++ src/zxing/zxing/oned/UPCEANExtensionSupport.h | 38 ++++ src/zxing/zxing/oned/UPCEANReader.cpp | 20 ++- src/zxing/zxing/oned/UPCEANReader.h | 5 +- 16 files changed, 776 insertions(+), 9 deletions(-) create mode 100644 src/zxing/zxing/ResultMetadata.cpp create mode 100644 src/zxing/zxing/ResultMetadata.h create mode 100644 src/zxing/zxing/common/ByteArray.h create mode 100644 src/zxing/zxing/oned/UPCEANExtension2Support.cpp create mode 100644 src/zxing/zxing/oned/UPCEANExtension2Support.h create mode 100644 src/zxing/zxing/oned/UPCEANExtension5Support.cpp create mode 100644 src/zxing/zxing/oned/UPCEANExtension5Support.h create mode 100644 src/zxing/zxing/oned/UPCEANExtensionSupport.cpp create mode 100644 src/zxing/zxing/oned/UPCEANExtensionSupport.h diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 4f81ea9..51b0781 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "CameraImageWrapper.h" #include "ImageHandler.h" #include @@ -185,6 +186,17 @@ bool QZXing::getLastDecodeOperationSucceded() return lastDecodeOperationSucceded_; } +QVariantMap QZXing::metadataToMap(const ResultMetadata &metadata) +{ + QVariantMap obj; + for (const ResultMetadata::Key &key: metadata.keys()) { + QString keyName = QString::fromStdString(metadata.keyToString(key)); + obj[keyName] = QVariant(metadata.getString(key).c_str()); + } + + return obj; +} + void QZXing::setDecoder(const uint &hint) { unsigned int newHints = 0; @@ -398,7 +410,9 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo } emit tagFound(string); - emit tagFoundAdvanced(string, foundedFmt, charSet_); + + QVariantMap metadataMap = metadataToMap(res->getMetadata()); + emit tagFoundAdvanced(string, foundedFmt, charSet_, metadataMap); try { const QRectF rect = getTagRect(res->getResultPoints(), binz->getBlackMatrix()); diff --git a/src/QZXing.h b/src/QZXing.h index fd36b63..00ea21a 100644 --- a/src/QZXing.h +++ b/src/QZXing.h @@ -30,6 +30,7 @@ // forward declaration namespace zxing { class MultiFormatReader; +class ResultMetadata; } class ImageHandler; @@ -118,6 +119,9 @@ public: bool getLastDecodeOperationSucceded(); +private: + QVariantMap metadataToMap(const zxing::ResultMetadata& metadata); + public slots: /** * The decoding function. Will try to decode the given image based on the enabled decoders. @@ -200,6 +204,7 @@ signals: void tagFound(QString tag); void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet) const; void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet, const QRectF &rect) const; + void tagFoundAdvanced(const QString &tag, const QString &format, const QString &charSet, const QVariantMap &metadata) const; void error(QString msg); private: diff --git a/src/QZXing.pri b/src/QZXing.pri index f0976c9..04ca8ae 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -34,6 +34,7 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/ResultPointCallback.h \ $$PWD/zxing/zxing/ResultPoint.h \ $$PWD/zxing/zxing/Result.h \ + $$PWD/zxing/zxing/ResultMetadata.h \ $$PWD/zxing/zxing/ReaderException.h \ $$PWD/zxing/zxing/Reader.h \ $$PWD/zxing/zxing/NotFoundException.h \ @@ -75,6 +76,7 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonDecoder.h \ $$PWD/zxing/zxing/common/reedsolomon/GenericGFPoly.h \ $$PWD/zxing/zxing/common/reedsolomon/GenericGF.h \ + $$PWD/zxing/zxing/common/ByteArray.h \ $$PWD/zxing/zxing/datamatrix/Version.h \ $$PWD/zxing/zxing/datamatrix/DataMatrixReader.h \ $$PWD/zxing/zxing/datamatrix/decoder/Decoder.h \ @@ -86,6 +88,9 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/datamatrix/detector/CornerPoint.h \ $$PWD/zxing/zxing/oned/UPCEReader.h \ $$PWD/zxing/zxing/oned/UPCEANReader.h \ + $$PWD/zxing/zxing/oned/UPCEANExtensionSupport.h \ + $$PWD/zxing/zxing/oned/UPCEANExtension2Support.h \ + $$PWD/zxing/zxing/oned/UPCEANExtension5Support.h \ $$PWD/zxing/zxing/oned/UPCAReader.h \ $$PWD/zxing/zxing/oned/OneDResultPoint.h \ $$PWD/zxing/zxing/oned/OneDReader.h \ @@ -157,6 +162,7 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/ResultPointCallback.cpp \ $$PWD/zxing/zxing/ResultPoint.cpp \ $$PWD/zxing/zxing/Result.cpp \ + $$PWD/zxing/zxing/ResultMetadata.cpp \ $$PWD/zxing/zxing/Reader.cpp \ $$PWD/zxing/zxing/MultiFormatReader.cpp \ $$PWD/zxing/zxing/LuminanceSource.cpp \ @@ -198,6 +204,9 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/datamatrix/DataMatrixReader.cpp \ $$PWD/zxing/zxing/oned/UPCEReader.cpp \ $$PWD/zxing/zxing/oned/UPCEANReader.cpp \ + $$PWD/zxing/zxing/oned/UPCEANExtensionSupport.cpp \ + $$PWD/zxing/zxing/oned/UPCEANExtension2Support.cpp \ + $$PWD/zxing/zxing/oned/UPCEANExtension5Support.cpp \ $$PWD/zxing/zxing/oned/UPCAReader.cpp \ $$PWD/zxing/zxing/oned/OneDResultPoint.cpp \ $$PWD/zxing/zxing/oned/OneDReader.cpp \ diff --git a/src/zxing/zxing/Result.cpp b/src/zxing/zxing/Result.cpp index 8f66edb..fdfec54 100644 --- a/src/zxing/zxing/Result.cpp +++ b/src/zxing/zxing/Result.cpp @@ -35,8 +35,9 @@ namespace zxing { Result::Result(Ref text, ArrayRef rawBytes, ArrayRef< Ref > resultPoints, - BarcodeFormat format, std::string charSet) : - text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet) { + BarcodeFormat format, std::string charSet, + ResultMetadata metadata) : + text_(text), rawBytes_(rawBytes), resultPoints_(resultPoints), format_(format), charSet_(charSet), metadata_(metadata) { } Result::~Result() { @@ -67,4 +68,9 @@ std::string Result::getCharSet() const return charSet_; } +ResultMetadata &Result::getMetadata() +{ + return metadata_; +} + } diff --git a/src/zxing/zxing/Result.h b/src/zxing/zxing/Result.h index 3e6f731..9a4e6b8 100644 --- a/src/zxing/zxing/Result.h +++ b/src/zxing/zxing/Result.h @@ -26,6 +26,7 @@ #include #include #include +#include #include namespace zxing { @@ -37,12 +38,14 @@ private: ArrayRef< Ref > resultPoints_; BarcodeFormat format_; std::string charSet_; + ResultMetadata metadata_; public: Result(Ref text, ArrayRef rawBytes, ArrayRef< Ref > resultPoints, - BarcodeFormat format, std::string charSet = ""); + BarcodeFormat format, std::string charSet = "", + ResultMetadata metadata = ResultMetadata()); ~Result(); Ref getText(); ArrayRef getRawBytes(); @@ -50,6 +53,7 @@ public: ArrayRef< Ref >& getResultPoints(); BarcodeFormat getBarcodeFormat() const; std::string getCharSet() const; + ResultMetadata& getMetadata(); friend std::ostream& operator<<(std::ostream &out, Result& result); }; diff --git a/src/zxing/zxing/ResultMetadata.cpp b/src/zxing/zxing/ResultMetadata.cpp new file mode 100644 index 0000000..3a194c1 --- /dev/null +++ b/src/zxing/zxing/ResultMetadata.cpp @@ -0,0 +1,110 @@ +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include +#include + +namespace zxing { + +struct ResultMetadata::Value +{ + virtual ~Value() {} + virtual int toInteger(int fallback) const { + return fallback; + } + virtual std::string toString() const { + return std::string(); + } +}; + +struct ResultMetadata::IntegerValue : public Value +{ + int value; + explicit IntegerValue(int v) : value(v) {} + int toInteger(int) const override { + return value; + } +}; + +struct ResultMetadata::StringValue : public Value +{ + std::string value; + explicit StringValue(std::string v) : value(std::move(v)) {} + std::string toString() const override { + return value; + } +}; + +int ResultMetadata::getInt(Key key, int fallbackValue) const +{ + auto it = _contents.find(key); + return it != _contents.end() ? it->second->toInteger(fallbackValue) : fallbackValue; +} + +std::string ResultMetadata::getString(Key key) const { + auto it = _contents.find(key); + return it != _contents.end() ? it->second->toString() : std::string(); +} + +void ResultMetadata::put(Key key, int value) { + _contents[key] = std::make_shared(value); +} + +void ResultMetadata::put(Key key, const std::string &value) { + _contents[key] = std::make_shared(value); +} + +void ResultMetadata::putAll(const ResultMetadata& other) { + _contents.insert(other._contents.begin(), other._contents.end()); +} + +std::list ResultMetadata::keys() const +{ + std::list keys; + for(auto it = _contents.begin(); it != _contents.end(); ++it) { + keys.push_back(it->first); + } + + return keys; +} + +bool ResultMetadata::empty() const +{ + return _contents.empty(); +} + +std::string ResultMetadata::keyToString(Key key) const +{ + switch (key) + { + case OTHER: return "OTHER"; + case ORIENTATION: return "ORIENTATION"; + case BYTE_SEGMENTS: return "BYTE_SEGMENTS"; + case ERROR_CORRECTION_LEVEL: return "ERROR_CORRECTION_LEVEL"; + case ISSUE_NUMBER: return "ISSUE_NUMBER"; + case SUGGESTED_PRICE: return "SUGGESTED_PRICE"; + case POSSIBLE_COUNTRY: return "POSSIBLE_COUNTRY"; + case UPC_EAN_EXTENSION: return "UPC_EAN_EXTENSION"; + case PDF417_EXTRA_METADATA: return "PDF417_EXTRA_METADATA"; + case STRUCTURED_APPEND_SEQUENCE: return "STRUCTURED_APPEND_SEQUENCE"; + case STRUCTURED_APPEND_CODE_COUNT: return "STRUCTURED_APPEND_CODE_COUNT"; + case STRUCTURED_APPEND_PARITY: return "STRUCTURED_APPEND_PARITY"; + } +} + +} // zxing diff --git a/src/zxing/zxing/ResultMetadata.h b/src/zxing/zxing/ResultMetadata.h new file mode 100644 index 0000000..b982e92 --- /dev/null +++ b/src/zxing/zxing/ResultMetadata.h @@ -0,0 +1,137 @@ +#ifndef ZXING_RESULT_METADATA_H +#define ZXING_RESULT_METADATA_H +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include +#include +#include +#include + +namespace zxing { + +class ByteArray; + +/** + * Represents some type of metadata about the result of the decoding that the decoder + * wishes to communicate back to the caller. + */ +class ResultMetadata +{ +public: + + enum Key { + + /** + * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}. + */ + OTHER, + + /** + * Denotes the likely approximate orientation of the barcode in the image. This value + * is given as degrees rotated clockwise from the normal, upright orientation. + * For example a 1D barcode which was found by reading top-to-bottom would be + * said to have orientation "90". This key maps to an {@link Integer} whose + * value is in the range [0,360). + */ + ORIENTATION, + + /** + *

2D barcode formats typically encode text, but allow for a sort of 'byte mode' + * which is sometimes used to encode binary data. While {@link Result} makes available + * the complete raw bytes in the barcode for these formats, it does not offer the bytes + * from the byte segments alone.

+ */ + BYTE_SEGMENTS, + + /** + * Error correction level used, if applicable. The value type depends on the + * format, but is typically a String. + */ + ERROR_CORRECTION_LEVEL, + + /** + * For some periodicals, indicates the issue number as an {@link Integer}. + */ + ISSUE_NUMBER, + + /** + * For some products, indicates the suggested retail price in the barcode as a + * formatted {@link String}. + */ + SUGGESTED_PRICE, + + /** + * For some products, the possible country of manufacture as a {@link String} denoting the + * ISO country code. Some map to multiple possible countries, like "US/CA". + */ + POSSIBLE_COUNTRY, + + /** + * For some products, the extension text + */ + UPC_EAN_EXTENSION, + + /** + * PDF417-specific metadata + */ + PDF417_EXTRA_METADATA, + + /** + * If the code format supports structured append and the current scanned code is part of one then the + * sequence number is given with it. + */ + STRUCTURED_APPEND_SEQUENCE, + + /** + * If the code format supports structured append and the current scanned code is part of one then the + * total code count is given with it. + */ + STRUCTURED_APPEND_CODE_COUNT, + + /** + * If the code format supports structured append and the current scanned code is part of one then the + * parity is given with it. + */ + STRUCTURED_APPEND_PARITY + }; + + int getInt(Key key, int fallbackValue = 0) const; + std::string getString(Key key) const; + + void put(Key key, int value); + void put(Key key, const std::string& value); + + void putAll(const ResultMetadata& other); + + std::list keys() const; + std::string keyToString(Key key) const; + + bool empty() const; + +private: + struct Value; + struct IntegerValue; + struct StringValue; + + std::map> _contents; +}; + +} + +#endif diff --git a/src/zxing/zxing/common/ByteArray.h b/src/zxing/zxing/common/ByteArray.h new file mode 100644 index 0000000..7a2afb9 --- /dev/null +++ b/src/zxing/zxing/common/ByteArray.h @@ -0,0 +1,42 @@ +#ifndef ZXING_BYTE_ARRAY_H +#define ZXING_BYTE_ARRAY_H +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include +#include + +namespace zxing { + +/** + * ByteArray is an extension of std::vector. + */ +class ByteArray : public std::vector +{ +public: + ByteArray() {} + ByteArray(std::initializer_list list) : std::vector(list) {} + explicit ByteArray(int len) : std::vector(len, 0) {} + int length() const { return static_cast(size()); } + const char* charPtr() const { return reinterpret_cast(data()); } + char* charPtr() { return reinterpret_cast(data()); } +}; + +} + +#endif diff --git a/src/zxing/zxing/oned/UPCEANExtension2Support.cpp b/src/zxing/zxing/oned/UPCEANExtension2Support.cpp new file mode 100644 index 0000000..2027367 --- /dev/null +++ b/src/zxing/zxing/oned/UPCEANExtension2Support.cpp @@ -0,0 +1,97 @@ +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace zxing { +namespace oned { + +static int decodeMiddle(Ref row, int rowOffset_, std::string& resultString) +{ + std::vector counters(4); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + + int end = row->getSize(); + int rowOffset = rowOffset_; + + int lgPatternFound = 0; + + for (int x = 0; x < 2 && rowOffset < end; x++) { + int bestMatch = UPCEANReader::decodeDigit(row, counters, rowOffset, + UPCEANReader::L_AND_G_PATTERNS); + resultString += static_cast('0' + bestMatch % 10); + for (int counter : counters) { + rowOffset += counter; + } + if (bestMatch >= 10) { + lgPatternFound |= 1 << (1 - x); + } + if (x != 1) { + // Read off separator if not last + rowOffset = row->getNextSet(rowOffset); + rowOffset = row->getNextUnset(rowOffset); + } + } + + if (resultString.length() != 2) { + throw NotFoundException(); + } + + if (std::atoi(resultString.c_str()) % 4 !=lgPatternFound) { + throw NotFoundException(); + } + + return rowOffset; +} + +Ref UPCEANExtension2Support::decodeRow(int rowNumber, Ref row, int extStartRangeBegin, int extStartRangeEnd) +{ + std::string resultString; + int range = decodeMiddle(row, extStartRangeEnd, resultString); + + ResultMetadata metadata; + metadata.put(ResultMetadata::ISSUE_NUMBER, std::atoi(resultString.c_str())); + + ArrayRef< Ref > resultPoints(2); + resultPoints[0] = Ref(new OneDResultPoint((extStartRangeBegin + extStartRangeEnd) / 2.0f, + static_cast (rowNumber))); + resultPoints[1] = Ref(new OneDResultPoint(static_cast (range), + static_cast (rowNumber))); + return Ref(new Result(Ref(new String(resultString)), + ArrayRef(), + resultPoints, + BarcodeFormat::UPC_EAN_EXTENSION, + "", + metadata)); +} + +} +} diff --git a/src/zxing/zxing/oned/UPCEANExtension2Support.h b/src/zxing/zxing/oned/UPCEANExtension2Support.h new file mode 100644 index 0000000..f36b145 --- /dev/null +++ b/src/zxing/zxing/oned/UPCEANExtension2Support.h @@ -0,0 +1,38 @@ +#ifndef ZXING_UPCEAN_EXTENSION_2_SUPPORT_H +#define ZXING_UPCEAN_EXTENSION_2_SUPPORT_H +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ +#include + +namespace zxing { + +class Result; +class BitArray; + +namespace oned { + +class UPCEANExtension2Support +{ +public: + static Ref decodeRow(int rowNumber, Ref row, int extStartRangeBegin, int extStartRangeEnd); +}; + +} +} + +#endif diff --git a/src/zxing/zxing/oned/UPCEANExtension5Support.cpp b/src/zxing/zxing/oned/UPCEANExtension5Support.cpp new file mode 100644 index 0000000..577b296 --- /dev/null +++ b/src/zxing/zxing/oned/UPCEANExtension5Support.cpp @@ -0,0 +1,166 @@ +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace zxing { +namespace oned { + +static int extensionChecksum(const std::string& s) +{ + int length = static_cast(s.length()); + int sum = 0; + for (int i = length - 2; i >= 0; i -= 2) { + sum += (int)s[i] - (int) '0'; + } + sum *= 3; + for (int i = length - 1; i >= 0; i -= 2) { + sum += (int)s[i] - (int) '0'; + } + sum *= 3; + return sum % 10; +} + +static int determineCheckDigit(int lgPatternFound) +{ + static const int CHECK_DIGIT_ENCODINGS[] = { + 0x18, 0x14, 0x12, 0x11, 0x0C, 0x06, 0x03, 0x0A, 0x09, 0x05 + }; + for (int d = 0; d < 10; d++) { + if (lgPatternFound == CHECK_DIGIT_ENCODINGS[d]) { + return d; + } + } + return -1; +} + +static int decodeMiddle(Ref row, int rowOffset_, std::string& resultString) +{ + std::vector counters(4); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + + int end = row->getSize(); + int rowOffset = rowOffset_; + + int lgPatternFound = 0; + + for (int x = 0; x < 5 && rowOffset < end; x++) { + int bestMatch = UPCEANReader::decodeDigit(row, counters, rowOffset, + UPCEANReader::L_AND_G_PATTERNS); + resultString += static_cast('0' + bestMatch % 10); + for (int counter : counters) { + rowOffset += counter; + } + if (bestMatch >= 10) { + lgPatternFound |= 1 << (4 - x); + } + if (x != 4) { + // Read off separator if not last + rowOffset = row->getNextSet(rowOffset); + rowOffset = row->getNextUnset(rowOffset); + } + } + + if (resultString.length() != 5) { + throw NotFoundException(); + } + + int checkDigit = determineCheckDigit(lgPatternFound); + if (extensionChecksum(resultString) != checkDigit) { + throw NotFoundException(); + } + + return rowOffset; +} + +static std::string parseExtension5String(const std::string& raw) +{ + std::string currency; + switch (raw.front()) { + case '0': + currency = "\xa3"; + break; + case '5': + currency = "$"; + break; + case '9': + // Reference: http://www.jollytech.com + if (raw == "90000") { + // No suggested retail price + return std::string(); + } + if (raw == "99991") { + // Complementary + return "0.00"; + } + if (raw == "99990") { + return "Used"; + } + // Otherwise... unknown currency? + currency = ""; + break; + default: + currency = ""; + break; + } + int rawAmount = std::atoi(raw.substr(1).c_str()); + std::stringstream buf; + buf << currency << std::fixed << std::setprecision(2) << (float(rawAmount) / 100); + return buf.str(); +} + +Ref UPCEANExtension5Support::decodeRow(int rowNumber, Ref row, int extStartRangeBegin, int extStartRangeEnd) +{ + std::string resultString; + int range = decodeMiddle(row, extStartRangeEnd, resultString); + + ResultMetadata metadata; + std::string value = parseExtension5String(resultString); + if (!value.empty()) { + metadata.put(ResultMetadata::SUGGESTED_PRICE, value); + } + + ArrayRef< Ref > resultPoints(2); + resultPoints[0] = Ref(new OneDResultPoint((extStartRangeBegin + extStartRangeEnd) / 2.0f, + static_cast (rowNumber))); + resultPoints[1] = Ref(new OneDResultPoint(static_cast (range), + static_cast (rowNumber))); + + return Ref(new Result(Ref(new String(resultString)), + ArrayRef(), + resultPoints, + BarcodeFormat::UPC_EAN_EXTENSION, + "", + metadata)); +} + +} +} diff --git a/src/zxing/zxing/oned/UPCEANExtension5Support.h b/src/zxing/zxing/oned/UPCEANExtension5Support.h new file mode 100644 index 0000000..090b151 --- /dev/null +++ b/src/zxing/zxing/oned/UPCEANExtension5Support.h @@ -0,0 +1,38 @@ +#ifndef ZXING_UPCEAN_EXTENSION_5_SUPPORT_H +#define ZXING_UPCEAN_EXTENSION_5_SUPPORT_H +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ +#include + +namespace zxing { + +class Result; +class BitArray; + +namespace oned { + +class UPCEANExtension5Support +{ +public: + static Ref decodeRow(int rowNumber, Ref row, int extStartRangeBegin, int extStartRangeEnd); +}; + +} +} + +#endif diff --git a/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp b/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp new file mode 100644 index 0000000..0511f03 --- /dev/null +++ b/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp @@ -0,0 +1,48 @@ +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace zxing { +namespace oned { + +static const std::vector EXTENSION_START_PATTERN = { 1, 1, 2 }; + +Ref UPCEANExtensionSupport::decodeRow(int rowNumber, Ref row, int rowOffset) +{ + auto extStartRange = UPCEANReader::findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN); + + try { + return UPCEANExtension5Support::decodeRow(rowNumber, row, extStartRange[0], extStartRange[1]); + } catch (NotFoundException const& /*nfe*/) { + return UPCEANExtension2Support::decodeRow(rowNumber, row, extStartRange[0], extStartRange[1]); + } +} + +} // oned +} // zxing diff --git a/src/zxing/zxing/oned/UPCEANExtensionSupport.h b/src/zxing/zxing/oned/UPCEANExtensionSupport.h new file mode 100644 index 0000000..ecdc171 --- /dev/null +++ b/src/zxing/zxing/oned/UPCEANExtensionSupport.h @@ -0,0 +1,38 @@ +#ifndef ZXING_UPCEAN_EXTENSION_SUPPORT_H +#define ZXING_UPCEAN_EXTENSION_SUPPORT_H +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ +#include + +namespace zxing { + +class Result; +class BitArray; + +namespace oned { + +class UPCEANExtensionSupport +{ +public: + static Ref decodeRow(int rowNumber, Ref row, int rowOffset); +}; + +} +} + +#endif diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index 8daab87..d8652f5 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -153,11 +153,25 @@ Ref UPCEANReader::decodeRow(int rowNumber, float left = (float) (startGuardRange[1] + startGuardRange[0]) / 2.0f; float right = (float) (endRange[1] + endRange[0]) / 2.0f; BarcodeFormat format = getBarcodeFormat(); + ArrayRef< Ref > resultPoints(2); - resultPoints[0] = Ref(new OneDResultPoint(left, (float) rowNumber)); - resultPoints[1] = Ref(new OneDResultPoint(right, (float) rowNumber)); + resultPoints[0] = Ref(new OneDResultPoint(left, static_cast (rowNumber))); + resultPoints[1] = Ref(new OneDResultPoint(right, static_cast (rowNumber))); + Ref decodeResult (new Result(resultString, ArrayRef(), resultPoints, format)); - // Java extension and man stuff + + try { + Ref extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]); + if (extensionResult) { + decodeResult->getMetadata().put(ResultMetadata::UPC_EAN_EXTENSION, extensionResult->getText()->getText()); + decodeResult->getMetadata().putAll(extensionResult->getMetadata()); + decodeResult->getResultPoints() << extensionResult->getResultPoints(); + } + } catch (NotFoundException const& /*nfe*/) { + // continue + } + + // Java man stuff return decodeResult; } diff --git a/src/zxing/zxing/oned/UPCEANReader.h b/src/zxing/zxing/oned/UPCEANReader.h index 452db88..0e54147 100644 --- a/src/zxing/zxing/oned/UPCEANReader.h +++ b/src/zxing/zxing/oned/UPCEANReader.h @@ -19,6 +19,7 @@ */ #include +#include #include #include @@ -28,7 +29,7 @@ namespace oned { class UPCEANReader : public OneDReader { private: std::string decodeRowStringBuffer; - // UPCEANExtensionSupport extensionReader; + UPCEANExtensionSupport extensionReader; // EANManufacturerOrgSupport eanManSupport; static const int MAX_AVG_VARIANCE; @@ -47,7 +48,7 @@ class UPCEANReader : public OneDReader { std::vector& counters); -protected: +public: static const std::vector START_END_PATTERN; static const std::vector MIDDLE_PATTERN; From b63e7ff6e13a7dedc1b689e2ff87b055c5e630a3 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Mon, 13 May 2019 14:51:09 +0200 Subject: [PATCH 40/83] correct convert to qvariant --- src/QZXing.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 51b0781..d85728c 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -191,7 +191,27 @@ QVariantMap QZXing::metadataToMap(const ResultMetadata &metadata) QVariantMap obj; for (const ResultMetadata::Key &key: metadata.keys()) { QString keyName = QString::fromStdString(metadata.keyToString(key)); - obj[keyName] = QVariant(metadata.getString(key).c_str()); + + switch (key) { + case ResultMetadata::ORIENTATION: + case ResultMetadata::ISSUE_NUMBER: + case ResultMetadata::STRUCTURED_APPEND_SEQUENCE: + case ResultMetadata::STRUCTURED_APPEND_CODE_COUNT: + case ResultMetadata::STRUCTURED_APPEND_PARITY: + obj[keyName] = QVariant(metadata.getInt(key)); + break; + case ResultMetadata::ERROR_CORRECTION_LEVEL: + case ResultMetadata::SUGGESTED_PRICE: + case ResultMetadata::POSSIBLE_COUNTRY: + case ResultMetadata::UPC_EAN_EXTENSION: + obj[keyName] = QVariant(metadata.getString(key).c_str()); + break; + + case ResultMetadata::OTHER: + case ResultMetadata::PDF417_EXTRA_METADATA: + case ResultMetadata::BYTE_SEGMENTS: + break; + } } return obj; From 04e06fa229590339d94d11899949b3128e8571f7 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Mon, 13 May 2019 15:25:10 +0200 Subject: [PATCH 41/83] save resultpoints --- src/zxing/zxing/oned/UPCEANReader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index d8652f5..9fe2718 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -165,7 +165,10 @@ Ref UPCEANReader::decodeRow(int rowNumber, if (extensionResult) { decodeResult->getMetadata().put(ResultMetadata::UPC_EAN_EXTENSION, extensionResult->getText()->getText()); decodeResult->getMetadata().putAll(extensionResult->getMetadata()); - decodeResult->getResultPoints() << extensionResult->getResultPoints(); + + for (const Ref& resultPoint: extensionResult->getResultPoints()->values()) { + decodeResult->getResultPoints()->push_back(resultPoint); + } } } catch (NotFoundException const& /*nfe*/) { // continue From a657058c4756af47b6faaa63867af9c56071d462 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Mon, 13 May 2019 16:26:15 +0200 Subject: [PATCH 42/83] fix spaces --- src/zxing/zxing/oned/UPCEANReader.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index 9fe2718..8bf4d84 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -161,15 +161,15 @@ Ref UPCEANReader::decodeRow(int rowNumber, Ref decodeResult (new Result(resultString, ArrayRef(), resultPoints, format)); try { - Ref extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]); - if (extensionResult) { - decodeResult->getMetadata().put(ResultMetadata::UPC_EAN_EXTENSION, extensionResult->getText()->getText()); - decodeResult->getMetadata().putAll(extensionResult->getMetadata()); + Ref extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]); + if (extensionResult) { + decodeResult->getMetadata().put(ResultMetadata::UPC_EAN_EXTENSION, extensionResult->getText()->getText()); + decodeResult->getMetadata().putAll(extensionResult->getMetadata()); - for (const Ref& resultPoint: extensionResult->getResultPoints()->values()) { - decodeResult->getResultPoints()->push_back(resultPoint); - } + for (const Ref& resultPoint: extensionResult->getResultPoints()->values()) { + decodeResult->getResultPoints()->push_back(resultPoint); } + } } catch (NotFoundException const& /*nfe*/) { // continue } From 4ce99aed3a9e22a92ebe5aa628953801d15e4133 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Mon, 13 May 2019 16:34:20 +0200 Subject: [PATCH 43/83] add ean manufacture org supported --- src/QZXing.pri | 2 + .../zxing/oned/EANManufacturerOrgSupport.cpp | 166 ++++++++++++++++++ .../zxing/oned/EANManufacturerOrgSupport.h | 41 +++++ src/zxing/zxing/oned/UPCEANReader.cpp | 8 +- src/zxing/zxing/oned/UPCEANReader.h | 3 +- 5 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp create mode 100644 src/zxing/zxing/oned/EANManufacturerOrgSupport.h diff --git a/src/QZXing.pri b/src/QZXing.pri index 04ca8ae..97339bf 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -99,6 +99,7 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/oned/ITFReader.h \ $$PWD/zxing/zxing/oned/EAN13Reader.h \ $$PWD/zxing/zxing/oned/EAN8Reader.h \ + $$PWD/zxing/zxing/oned/EANManufacturerOrgSupport.h \ $$PWD/zxing/zxing/oned/Code128Reader.h \ $$PWD/zxing/zxing/oned/Code39Reader.h \ $$PWD/zxing/zxing/oned/CodaBarReader.h \ @@ -215,6 +216,7 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/oned/ITFReader.cpp \ $$PWD/zxing/zxing/oned/EAN13Reader.cpp \ $$PWD/zxing/zxing/oned/EAN8Reader.cpp \ + $$PWD/zxing/zxing/oned/EANManufacturerOrgSupport.cpp \ $$PWD/zxing/zxing/oned/Code128Reader.cpp \ $$PWD/zxing/zxing/oned/Code39Reader.cpp \ $$PWD/zxing/zxing/oned/CodaBarReader.cpp \ diff --git a/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp b/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp new file mode 100644 index 0000000..2b9ab8b --- /dev/null +++ b/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp @@ -0,0 +1,166 @@ +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* + * Records EAN prefix to GS1 Member Organization, where the member organization + * correlates strongly with a country. This is an imperfect means of identifying + * a country of origin by EAN-13 barcode value. See + * + * http://en.wikipedia.org/wiki/List_of_GS1_country_codes. + * + * @author Sean Owen + */ + +#include +#include + +namespace zxing { +namespace oned { + +struct Country { + std::vector range; + std::string id; +}; + +static Country Countries[] { + { {0,19}, "US/CA" }, + { {30,39}, "US" }, + { {60,139}, "US/CA" }, + { {300,379}, "FR" }, + { {380}, "BG" }, + { {383}, "SI" }, + { {385}, "HR" }, + { {387}, "BA" }, + { {400,440}, "DE" }, + { {450,459}, "JP" }, + { {460,469}, "RU" }, + { {471}, "TW" }, + { {474}, "EE" }, + { {475}, "LV" }, + { {476}, "AZ" }, + { {477}, "LT" }, + { {478}, "UZ" }, + { {479}, "LK" }, + { {480}, "PH" }, + { {481}, "BY" }, + { {482}, "UA" }, + { {484}, "MD" }, + { {485}, "AM" }, + { {486}, "GE" }, + { {487}, "KZ" }, + { {489}, "HK" }, + { {490,499}, "JP" }, + { {500,509}, "GB" }, + { {520}, "GR" }, + { {528}, "LB" }, + { {529}, "CY" }, + { {531}, "MK" }, + { {535}, "MT" }, + { {539}, "IE" }, + { {540,549}, "BE/LU" }, + { {560}, "PT" }, + { {569}, "IS" }, + { {570,579}, "DK" }, + { {590}, "PL" }, + { {594}, "RO" }, + { {599}, "HU" }, + { {600,601}, "ZA" }, + { {603}, "GH" }, + { {608}, "BH" }, + { {609}, "MU" }, + { {611}, "MA" }, + { {613}, "DZ" }, + { {616}, "KE" }, + { {618}, "CI" }, + { {619}, "TN" }, + { {621}, "SY" }, + { {622}, "EG" }, + { {624}, "LY" }, + { {625}, "JO" }, + { {626}, "IR" }, + { {627}, "KW" }, + { {628}, "SA" }, + { {629}, "AE" }, + { {640,649}, "FI" }, + { {690,695}, "CN" }, + { {700,709}, "NO" }, + { {729}, "IL" }, + { {730,739}, "SE" }, + { {740}, "GT" }, + { {741}, "SV" }, + { {742}, "HN" }, + { {743}, "NI" }, + { {744}, "CR" }, + { {745}, "PA" }, + { {746}, "DO" }, + { {750}, "MX" }, + { {754,755}, "CA" }, + { {759}, "VE" }, + { {760,769}, "CH" }, + { {770}, "CO" }, + { {773}, "UY" }, + { {775}, "PE" }, + { {777}, "BO" }, + { {779}, "AR" }, + { {780}, "CL" }, + { {784}, "PY" }, + { {785}, "PE" }, + { {786}, "EC" }, + { {789,790}, "BR" }, + { {800,839}, "IT" }, + { {840,849}, "ES" }, + { {850}, "CU" }, + { {858}, "SK" }, + { {859}, "CZ" }, + { {860}, "YU" }, + { {865}, "MN" }, + { {867}, "KP" }, + { {868,869}, "TR" }, + { {870,879}, "NL" }, + { {880}, "KR" }, + { {885}, "TH" }, + { {888}, "SG" }, + { {890}, "IN" }, + { {893}, "VN" }, + { {896}, "PK" }, + { {899}, "ID" }, + { {900,919}, "AT" }, + { {930,939}, "AU" }, + { {940,949}, "AZ" }, + { {955}, "MY" }, + { {958}, "MO" } +}; + +Ref EANManufacturerOrgSupport::lookupCountryIdentifier(Ref& productCode) +{ + int prefix = std::stoi(productCode->getText().substr(0, 3)); + int size = (sizeof(Countries) / sizeof(Countries[0])); + for (int i = 0; i < size; i++) { + std::vector range = Countries[i].range; + int start = range[0]; + if (prefix < start) { + return Ref(); + } + int end = range.size() == 1 ? start : range[1]; + if (prefix <= end) { + return Ref(new String(Countries[i].id)); + } + } + return Ref(); +} + +} +} diff --git a/src/zxing/zxing/oned/EANManufacturerOrgSupport.h b/src/zxing/zxing/oned/EANManufacturerOrgSupport.h new file mode 100644 index 0000000..e317ff7 --- /dev/null +++ b/src/zxing/zxing/oned/EANManufacturerOrgSupport.h @@ -0,0 +1,41 @@ +#ifndef ZXING_EAN_MANUFACTURER_ORG_SUPPORT_H +#define ZXING_EAN_MANUFACTURER_ORG_SUPPORT_H +/* +* Copyright 2008 ZXing authors +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* 2019-05-08 translation from Java into C++ +*/ + +#include + +#include +#include + +namespace zxing { + +class String; + +namespace oned { + +class EANManufacturerOrgSupport +{ +public: + static Ref lookupCountryIdentifier(Ref &productCode); +}; + +} +} + +#endif diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index 8bf4d84..fd4dcaa 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -174,7 +174,13 @@ Ref UPCEANReader::decodeRow(int rowNumber, // continue } - // Java man stuff + if (format == BarcodeFormat::EAN_13 || format == BarcodeFormat::UPC_A) { + Ref countryID = eanManSupport.lookupCountryIdentifier(resultString); + if (countryID) { + decodeResult->getMetadata().put(ResultMetadata::POSSIBLE_COUNTRY, countryID->getText()); + } + } + return decodeResult; } diff --git a/src/zxing/zxing/oned/UPCEANReader.h b/src/zxing/zxing/oned/UPCEANReader.h index 0e54147..19b6837 100644 --- a/src/zxing/zxing/oned/UPCEANReader.h +++ b/src/zxing/zxing/oned/UPCEANReader.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -30,7 +31,7 @@ class UPCEANReader : public OneDReader { private: std::string decodeRowStringBuffer; UPCEANExtensionSupport extensionReader; - // EANManufacturerOrgSupport eanManSupport; + EANManufacturerOrgSupport eanManSupport; static const int MAX_AVG_VARIANCE; static const int MAX_INDIVIDUAL_VARIANCE; From 5048d2ecf05dfbe1a923552109558fd20f407e5c Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Mon, 13 May 2019 18:00:25 +0200 Subject: [PATCH 44/83] removing unnecessary inclusions --- src/zxing/zxing/oned/UPCEANExtension2Support.cpp | 1 - src/zxing/zxing/oned/UPCEANExtension5Support.cpp | 1 - src/zxing/zxing/oned/UPCEANExtensionSupport.cpp | 4 ---- 3 files changed, 6 deletions(-) diff --git a/src/zxing/zxing/oned/UPCEANExtension2Support.cpp b/src/zxing/zxing/oned/UPCEANExtension2Support.cpp index 2027367..657d4d7 100644 --- a/src/zxing/zxing/oned/UPCEANExtension2Support.cpp +++ b/src/zxing/zxing/oned/UPCEANExtension2Support.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/src/zxing/zxing/oned/UPCEANExtension5Support.cpp b/src/zxing/zxing/oned/UPCEANExtension5Support.cpp index 577b296..c474ff6 100644 --- a/src/zxing/zxing/oned/UPCEANExtension5Support.cpp +++ b/src/zxing/zxing/oned/UPCEANExtension5Support.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp b/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp index 0511f03..8866f21 100644 --- a/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp +++ b/src/zxing/zxing/oned/UPCEANExtensionSupport.cpp @@ -24,10 +24,6 @@ #include #include -#include -#include -#include - namespace zxing { namespace oned { From 1f9e9d3988138a4000bbffd508799d0c0d54daad Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Mon, 13 May 2019 22:51:40 +0200 Subject: [PATCH 45/83] stoi->atoi --- src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp b/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp index 2b9ab8b..334b9ff 100644 --- a/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp +++ b/src/zxing/zxing/oned/EANManufacturerOrgSupport.cpp @@ -27,6 +27,8 @@ #include #include +#include + namespace zxing { namespace oned { @@ -146,7 +148,7 @@ static Country Countries[] { Ref EANManufacturerOrgSupport::lookupCountryIdentifier(Ref& productCode) { - int prefix = std::stoi(productCode->getText().substr(0, 3)); + int prefix = std::atoi(productCode->getText().substr(0, 3).c_str()); int size = (sizeof(Countries) / sizeof(Countries[0])); for (int i = 0; i < size; i++) { std::vector range = Countries[i].range; From 49b0e85227878a43a9b6ca9d6cf66afb6dd3b4ac Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Thu, 16 May 2019 10:16:00 +0200 Subject: [PATCH 46/83] add allowed extensions --- src/QZXing.cpp | 21 +++++++++++++++++ src/QZXing.h | 5 ++++ src/zxing/zxing/DecodeHints.cpp | 13 +++++++++++ src/zxing/zxing/DecodeHints.h | 6 +++++ .../zxing/oned/MultiFormatUPCEANReader.cpp | 4 ++-- src/zxing/zxing/oned/UPCEANReader.cpp | 23 ++++++++++++++++--- src/zxing/zxing/oned/UPCEANReader.h | 2 +- 7 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index d85728c..ebbf84c 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -110,6 +110,25 @@ bool QZXing::getTryHarder() { return tryHarder_; } +void QZXing::setAllowedExtensions(const QVariantList& extensions) +{ + std::vector allowedExtensions; + for (const QVariant& extension: extensions) { + allowedExtensions.push_back(extension.toInt()); + } + + allowedExtensions_ = allowedExtensions; +} + +QVariantList QZXing::getAllowedExtensions() +{ + QVariantList allowedExtensions; + for (const int& extension: allowedExtensions_) { + allowedExtensions << extension; + } + + return allowedExtensions; +} QString QZXing::decoderFormatToString(int fmt) { @@ -384,6 +403,8 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo DecodeHints hints(static_cast(enabledDecoders)); + hints.setAllowedEanExtensions(allowedExtensions_); + lastDecodeOperationSucceded_ = false; try { res = decoder->decode(bb, hints); diff --git a/src/QZXing.h b/src/QZXing.h index 00ea21a..6350529 100644 --- a/src/QZXing.h +++ b/src/QZXing.h @@ -22,6 +22,7 @@ #include #include +#include #if QT_VERSION >= 0x050000 class QQmlEngine; @@ -54,6 +55,7 @@ class Q_PROPERTY(int processingTime READ getProcessTimeOfLastDecoding) Q_PROPERTY(uint enabledDecoders READ getEnabledFormats WRITE setDecoder NOTIFY enabledFormatsChanged) Q_PROPERTY(bool tryHarder READ getTryHarder WRITE setTryHarder) + Q_PROPERTY(QVariantList allowedExtensions READ getAllowedExtensions WRITE setAllowedExtensions) public: /* @@ -113,6 +115,8 @@ public: void setTryHarder(bool tryHarder); bool getTryHarder(); + void setAllowedExtensions(const QVariantList& extensions); + QVariantList getAllowedExtensions(); static QString decoderFormatToString(int fmt); Q_INVOKABLE QString foundedFormat() const; Q_INVOKABLE QString charSet() const; @@ -216,6 +220,7 @@ private: QString charSet_; bool tryHarder_; bool lastDecodeOperationSucceded_; + std::vector allowedExtensions_; /** * If true, the decoding operation will take place at a different thread. diff --git a/src/zxing/zxing/DecodeHints.cpp b/src/zxing/zxing/DecodeHints.cpp index 3961683..777a0b4 100644 --- a/src/zxing/zxing/DecodeHints.cpp +++ b/src/zxing/zxing/DecodeHints.cpp @@ -86,6 +86,7 @@ DecodeHints::DecodeHints(const zxing::DecodeHintType &init) { DecodeHints::DecodeHints(const DecodeHints &other) { hints = other.hints; callback = other.callback; + allowedEanExtensions = other.allowedEanExtensions; } void DecodeHints::addFormat(BarcodeFormat toadd) { @@ -150,6 +151,14 @@ bool DecodeHints::getTryHarder() const { return (hints & TRYHARDER_HINT) != 0; } +void DecodeHints::setAllowedEanExtensions(std::vector toset) { + allowedEanExtensions = toset; +} + +std::vector DecodeHints::getAllowedEanExtensions() const { + return allowedEanExtensions; +} + void DecodeHints::setResultPointCallback(Ref const& _callback) { callback = _callback; } @@ -162,6 +171,7 @@ zxing::DecodeHints &zxing::DecodeHints::operator =(const zxing::DecodeHints &oth { hints = other.hints; callback = other.callback; + allowedEanExtensions = other.allowedEanExtensions; return *this; } @@ -171,5 +181,8 @@ zxing::DecodeHints zxing::operator | (DecodeHints const& l, DecodeHints const& r if (!result.callback) { result.callback = r.callback; } + if (result.allowedEanExtensions.empty()) { + result.allowedEanExtensions = r.allowedEanExtensions; + } return result; } diff --git a/src/zxing/zxing/DecodeHints.h b/src/zxing/zxing/DecodeHints.h index b39c5b5..4a98695 100644 --- a/src/zxing/zxing/DecodeHints.h +++ b/src/zxing/zxing/DecodeHints.h @@ -23,6 +23,8 @@ #include #include +#include + namespace zxing { typedef unsigned int DecodeHintType; @@ -33,6 +35,7 @@ class DecodeHints { private: DecodeHintType hints; Ref callback; + std::vector allowedEanExtensions; public: static const DecodeHintType AZTEC_HINT; @@ -75,6 +78,9 @@ class DecodeHints { void setTryHarder(bool toset); bool getTryHarder() const; + void setAllowedEanExtensions(std::vector toset); + std::vector getAllowedEanExtensions() const; + void setResultPointCallback(Ref const&); Ref getResultPointCallback() const; diff --git a/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp b/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp index 0ee3398..fbff86b 100644 --- a/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp @@ -61,14 +61,14 @@ MultiFormatUPCEANReader::MultiFormatUPCEANReader(DecodeHints hints) : readers() #include -Ref MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints /*hints*/) { +Ref MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref row, DecodeHints hints) { // Compute this location once and reuse it on multiple implementations UPCEANReader::Range startGuardPattern = UPCEANReader::findStartGuardPattern(row); for (int i = 0, e = int(readers.size()); i < e; i++) { Ref reader = readers[i]; Ref result; try { - result = reader->decodeRow(rowNumber, row, startGuardPattern); + result = reader->decodeRow(rowNumber, row, startGuardPattern, hints); } catch (ReaderException const& ignored) { (void)ignored; continue; diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index fd4dcaa..c25c9a8 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -118,13 +118,14 @@ UPCEANReader::L_AND_G_PATTERNS (VECTOR_INIT(L_AND_G_PATTERNS_)); UPCEANReader::UPCEANReader() {} -Ref UPCEANReader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints /*hints*/) { - return decodeRow(rowNumber, row, findStartGuardPattern(row)); +Ref UPCEANReader::decodeRow(int rowNumber, Ref row, DecodeHints hints) { + return decodeRow(rowNumber, row, findStartGuardPattern(row), hints); } Ref UPCEANReader::decodeRow(int rowNumber, Ref row, - Range const& startGuardRange) { + Range const& startGuardRange, + DecodeHints hints) { string& result = decodeRowStringBuffer; result.clear(); int endStart = decodeMiddle(row, startGuardRange, result); @@ -159,12 +160,14 @@ Ref UPCEANReader::decodeRow(int rowNumber, resultPoints[1] = Ref(new OneDResultPoint(right, static_cast (rowNumber))); Ref decodeResult (new Result(resultString, ArrayRef(), resultPoints, format)); + int extensionLength = 0; try { Ref extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]); if (extensionResult) { decodeResult->getMetadata().put(ResultMetadata::UPC_EAN_EXTENSION, extensionResult->getText()->getText()); decodeResult->getMetadata().putAll(extensionResult->getMetadata()); + extensionLength = extensionResult->getText()->length(); for (const Ref& resultPoint: extensionResult->getResultPoints()->values()) { decodeResult->getResultPoints()->push_back(resultPoint); @@ -174,6 +177,20 @@ Ref UPCEANReader::decodeRow(int rowNumber, // continue } + std::vector allowedExtensions = hints.getAllowedEanExtensions(); + if (allowedExtensions.size() > 0) { + bool valid = false; + for (int length: allowedExtensions) { + if (extensionLength == length) { + valid = true; + break; + } + } + if (!valid) { + throw NotFoundException(); + } + } + if (format == BarcodeFormat::EAN_13 || format == BarcodeFormat::UPC_A) { Ref countryID = eanManSupport.lookupCountryIdentifier(resultString); if (countryID) { diff --git a/src/zxing/zxing/oned/UPCEANReader.h b/src/zxing/zxing/oned/UPCEANReader.h index 19b6837..98bb020 100644 --- a/src/zxing/zxing/oned/UPCEANReader.h +++ b/src/zxing/zxing/oned/UPCEANReader.h @@ -69,7 +69,7 @@ public: std::string& resultString) = 0; virtual Ref decodeRow(int rowNumber, Ref row, DecodeHints hints); - virtual Ref decodeRow(int rowNumber, Ref row, Range const& range); + virtual Ref decodeRow(int rowNumber, Ref row, Range const& range, DecodeHints hints = DecodeHints()); static int decodeDigit(Ref row, std::vector& counters, From 82d4407c78036aadfbd75824e50c7438e667aafd Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Fri, 17 May 2019 00:36:58 +0200 Subject: [PATCH 47/83] vector -> set --- src/QZXing.cpp | 4 ++-- src/QZXing.h | 4 +++- src/zxing/zxing/DecodeHints.cpp | 13 ++++++++----- src/zxing/zxing/DecodeHints.h | 8 ++++---- src/zxing/zxing/oned/UPCEANReader.cpp | 2 +- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index ebbf84c..522b170 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -112,9 +112,9 @@ bool QZXing::getTryHarder() } void QZXing::setAllowedExtensions(const QVariantList& extensions) { - std::vector allowedExtensions; + std::set allowedExtensions; for (const QVariant& extension: extensions) { - allowedExtensions.push_back(extension.toInt()); + allowedExtensions.insert(extension.toInt()); } allowedExtensions_ = allowedExtensions; diff --git a/src/QZXing.h b/src/QZXing.h index 6350529..b35bc8d 100644 --- a/src/QZXing.h +++ b/src/QZXing.h @@ -24,6 +24,8 @@ #include #include +#include + #if QT_VERSION >= 0x050000 class QQmlEngine; #endif @@ -220,7 +222,7 @@ private: QString charSet_; bool tryHarder_; bool lastDecodeOperationSucceded_; - std::vector allowedExtensions_; + std::set allowedExtensions_; /** * If true, the decoding operation will take place at a different thread. diff --git a/src/zxing/zxing/DecodeHints.cpp b/src/zxing/zxing/DecodeHints.cpp index 777a0b4..63b9c62 100644 --- a/src/zxing/zxing/DecodeHints.cpp +++ b/src/zxing/zxing/DecodeHints.cpp @@ -77,6 +77,7 @@ const zxing::DecodeHints DecodeHints::DEFAULT_HINT( DecodeHints::DecodeHints() { hints = 0; + allowedEanExtensions = {}; } DecodeHints::DecodeHints(const zxing::DecodeHintType &init) { @@ -151,11 +152,11 @@ bool DecodeHints::getTryHarder() const { return (hints & TRYHARDER_HINT) != 0; } -void DecodeHints::setAllowedEanExtensions(std::vector toset) { +void DecodeHints::setAllowedEanExtensions(std::set toset) { allowedEanExtensions = toset; } -std::vector DecodeHints::getAllowedEanExtensions() const { +std::set DecodeHints::getAllowedEanExtensions() const { return allowedEanExtensions; } @@ -181,8 +182,10 @@ zxing::DecodeHints zxing::operator | (DecodeHints const& l, DecodeHints const& r if (!result.callback) { result.callback = r.callback; } - if (result.allowedEanExtensions.empty()) { - result.allowedEanExtensions = r.allowedEanExtensions; - } + + result.allowedEanExtensions = l.allowedEanExtensions; + result.allowedEanExtensions.insert(r.allowedEanExtensions.begin(), + r.allowedEanExtensions.end()); + return result; } diff --git a/src/zxing/zxing/DecodeHints.h b/src/zxing/zxing/DecodeHints.h index 4a98695..f5261b4 100644 --- a/src/zxing/zxing/DecodeHints.h +++ b/src/zxing/zxing/DecodeHints.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace zxing { @@ -35,7 +35,7 @@ class DecodeHints { private: DecodeHintType hints; Ref callback; - std::vector allowedEanExtensions; + std::set allowedEanExtensions; public: static const DecodeHintType AZTEC_HINT; @@ -78,8 +78,8 @@ class DecodeHints { void setTryHarder(bool toset); bool getTryHarder() const; - void setAllowedEanExtensions(std::vector toset); - std::vector getAllowedEanExtensions() const; + void setAllowedEanExtensions(std::set toset); + std::set getAllowedEanExtensions() const; void setResultPointCallback(Ref const&); Ref getResultPointCallback() const; diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index c25c9a8..0853871 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -177,7 +177,7 @@ Ref UPCEANReader::decodeRow(int rowNumber, // continue } - std::vector allowedExtensions = hints.getAllowedEanExtensions(); + std::set allowedExtensions = hints.getAllowedEanExtensions(); if (allowedExtensions.size() > 0) { bool valid = false; for (int length: allowedExtensions) { From c35ca6492e0c8050f316faa0aa7ceb8bdf13a9f6 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Fri, 17 May 2019 00:43:11 +0200 Subject: [PATCH 48/83] simultaneous recognition UPC/EAN and UPC_EAN_EXTENCION --- src/QZXing.cpp | 12 ++++++++++++ src/zxing/zxing/DecodeHints.cpp | 17 +++++++++++++++++ src/zxing/zxing/DecodeHints.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 522b170..8cd15c6 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -422,6 +422,18 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo lastDecodeOperationSucceded_ = true; } catch(zxing::Exception &/*e*/) {} + if (!lastDecodeOperationSucceded_ && + hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION) && + !(hints & DecodeHints::PRODUCT_HINT).isEmpty() ) { + hints.setAllowedEanExtensions(std::set()); + + try { + res = decoder->decode(bb, hints); + processingTime = t.elapsed(); + lastDecodeOperationSucceded_ = true; + } catch(zxing::Exception &/*e*/) {} + } + if (tryHarder_ && bb->isRotateSupported()) { Ref bbTmp = bb; diff --git a/src/zxing/zxing/DecodeHints.cpp b/src/zxing/zxing/DecodeHints.cpp index 63b9c62..3c358ce 100644 --- a/src/zxing/zxing/DecodeHints.cpp +++ b/src/zxing/zxing/DecodeHints.cpp @@ -189,3 +189,20 @@ zxing::DecodeHints zxing::operator | (DecodeHints const& l, DecodeHints const& r return result; } + +zxing::DecodeHints zxing::operator & (DecodeHints const& l, DecodeHints const& r) { + DecodeHints result (l); + result.hints &= r.hints; + if (!result.callback) { + result.callback = r.callback; + } + + std::set intersect; + std::set_intersection(l.allowedEanExtensions.begin(), l.allowedEanExtensions.end(), + r.allowedEanExtensions.begin(), r.allowedEanExtensions.end(), + std::inserter(intersect, intersect.begin())); + + result.allowedEanExtensions = intersect; + + return result; +} diff --git a/src/zxing/zxing/DecodeHints.h b/src/zxing/zxing/DecodeHints.h index f5261b4..b24e349 100644 --- a/src/zxing/zxing/DecodeHints.h +++ b/src/zxing/zxing/DecodeHints.h @@ -30,6 +30,7 @@ namespace zxing { typedef unsigned int DecodeHintType; class DecodeHints; DecodeHints operator | (DecodeHints const&, DecodeHints const&); +DecodeHints operator & (DecodeHints const&, DecodeHints const&); class DecodeHints { private: @@ -87,6 +88,7 @@ class DecodeHints { DecodeHints& operator =(DecodeHints const &other); friend DecodeHints operator| (DecodeHints const&, DecodeHints const&); + friend DecodeHints operator& (DecodeHints const&, DecodeHints const&); }; } From 5514f3f9b31f062bb0caa64d1880399005068116 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Fri, 17 May 2019 01:14:01 +0200 Subject: [PATCH 49/83] backward compatibility --- src/QZXing.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 8cd15c6..394f260 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -463,6 +463,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo } emit tagFound(string); + emit tagFoundAdvanced(string, foundedFmt, charSet_); QVariantMap metadataMap = metadataToMap(res->getMetadata()); emit tagFoundAdvanced(string, foundedFmt, charSet_, metadataMap); From 16d5c266982d1841d3b5d73c5bd1d5106a8e59d0 Mon Sep 17 00:00:00 2001 From: Elnur Ismailzada Date: Sat, 18 May 2019 12:09:29 +0200 Subject: [PATCH 50/83] correct decode UPC_EAN_EXTENSION --- src/QZXing.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/QZXing.cpp b/src/QZXing.cpp index 394f260..9f118a2 100644 --- a/src/QZXing.cpp +++ b/src/QZXing.cpp @@ -403,7 +403,9 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo DecodeHints hints(static_cast(enabledDecoders)); - hints.setAllowedEanExtensions(allowedExtensions_); + if (hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION)) { + hints.setAllowedEanExtensions(allowedExtensions_); + } lastDecodeOperationSucceded_ = false; try { @@ -424,6 +426,7 @@ QString QZXing::decodeImage(const QImage &image, int maxWidth, int maxHeight, bo if (!lastDecodeOperationSucceded_ && hints.containsFormat(BarcodeFormat::UPC_EAN_EXTENSION) && + !allowedExtensions_.empty() && !(hints & DecodeHints::PRODUCT_HINT).isEmpty() ) { hints.setAllowedEanExtensions(std::set()); From 30fd430ada73e1cd59aa2a9346f2194190e6552a Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 19 Jun 2019 13:55:05 +0300 Subject: [PATCH 51/83] updated CI configuration to remove builds for Qt 5.10 and Qt 5.11 and add Qt 5.12 and Qt 5.13. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f86b3d8..c8210c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,12 +24,12 @@ addons: env: matrix: - - BUILD_TARGERT="linux" QT_VERSION_DIR=5.11 QT_VERSION=5.11.2 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.11 QT_VERSION=5.11.2 - - BUILD_TARGERT="linux" QT_VERSION_DIR=5.10 QT_VERSION=5.10.1 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.10 QT_VERSION=5.10.1 - - BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.7 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.7 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.11 QT_VERSION=5.13.o + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.11 QT_VERSION=5.13.0 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.10 QT_VERSION=5.12.4 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.10 QT_VERSION=5.12.4 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 before_install: - echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}" From 16521b68357a914c4b90eef19b3125562bfad23a Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 19 Jun 2019 14:03:41 +0300 Subject: [PATCH 52/83] fixed typos in new travis configuration. --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8210c9..96af1b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,10 +24,10 @@ addons: env: matrix: - - BUILD_TARGERT="linux" QT_VERSION_DIR=5.11 QT_VERSION=5.13.o - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.11 QT_VERSION=5.13.0 - - BUILD_TARGERT="linux" QT_VERSION_DIR=5.10 QT_VERSION=5.12.4 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.10 QT_VERSION=5.12.4 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0 + - BUILD_TARGERT="linux" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4 + - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4 - BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 From 9eac8518ac2c1296564f03ffa2f4707c12881b99 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Fri, 21 Jun 2019 15:02:24 +0300 Subject: [PATCH 53/83] In ByteArray,use zxing::byte instead of char. --- src/zxing/zxing/common/ByteArray.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/zxing/zxing/common/ByteArray.h b/src/zxing/zxing/common/ByteArray.h index 7a2afb9..acd4f59 100644 --- a/src/zxing/zxing/common/ByteArray.h +++ b/src/zxing/zxing/common/ByteArray.h @@ -20,6 +20,7 @@ #include #include +#include "Types.h" namespace zxing { @@ -33,8 +34,8 @@ public: ByteArray(std::initializer_list list) : std::vector(list) {} explicit ByteArray(int len) : std::vector(len, 0) {} int length() const { return static_cast(size()); } - const char* charPtr() const { return reinterpret_cast(data()); } - char* charPtr() { return reinterpret_cast(data()); } + const zxing::byte* bytePtr() const { return reinterpret_cast(data()); } + zxing::byte* bytePtr() { return reinterpret_cast(data()); } }; } From c5bb5f273028f3c3e6f643a37a6a70ed77853240 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Fri, 21 Jun 2019 15:58:25 +0300 Subject: [PATCH 54/83] If the decoded text is of type EAN_13 or UPC_A, remove the first character as it exists twice. Fixes #110 --- src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp b/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp index fbff86b..330c218 100644 --- a/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatUPCEANReader.cpp @@ -92,7 +92,8 @@ Ref MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref row, // here, and convert an EAN-13 result to a UPC-A result if // appropriate. bool ean13MayBeUPCA = - result->getBarcodeFormat() == BarcodeFormat::EAN_13 && + (result->getBarcodeFormat() == BarcodeFormat::UPC_A || + result->getBarcodeFormat() == BarcodeFormat::EAN_13) && result->getText()->charAt(0) == '0'; // Note: doesn't match Java which uses hints From f846faa2d732d5c87e79fd17dde1994af8b3bbc1 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 26 Jun 2019 11:11:46 +0300 Subject: [PATCH 55/83] Fix compilation of project when targeting MSVC. #113 --- src/zxing/zxing/DecodeHints.cpp | 1 + src/zxing/zxing/oned/UPCEANReader.cpp | 4 ++-- src/zxing/zxing/oned/UPCEANReader.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/zxing/zxing/DecodeHints.cpp b/src/zxing/zxing/DecodeHints.cpp index 3c358ce..b1c2844 100644 --- a/src/zxing/zxing/DecodeHints.cpp +++ b/src/zxing/zxing/DecodeHints.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using zxing::Ref; using zxing::ResultPointCallback; diff --git a/src/zxing/zxing/oned/UPCEANReader.cpp b/src/zxing/zxing/oned/UPCEANReader.cpp index 0853871..e3219f3 100644 --- a/src/zxing/zxing/oned/UPCEANReader.cpp +++ b/src/zxing/zxing/oned/UPCEANReader.cpp @@ -118,14 +118,14 @@ UPCEANReader::L_AND_G_PATTERNS (VECTOR_INIT(L_AND_G_PATTERNS_)); UPCEANReader::UPCEANReader() {} -Ref UPCEANReader::decodeRow(int rowNumber, Ref row, DecodeHints hints) { +Ref UPCEANReader::decodeRow(int rowNumber, Ref row, zxing::DecodeHints hints) { return decodeRow(rowNumber, row, findStartGuardPattern(row), hints); } Ref UPCEANReader::decodeRow(int rowNumber, Ref row, Range const& startGuardRange, - DecodeHints hints) { + zxing::DecodeHints hints) { string& result = decodeRowStringBuffer; result.clear(); int endStart = decodeMiddle(row, startGuardRange, result); diff --git a/src/zxing/zxing/oned/UPCEANReader.h b/src/zxing/zxing/oned/UPCEANReader.h index 98bb020..d6a8c11 100644 --- a/src/zxing/zxing/oned/UPCEANReader.h +++ b/src/zxing/zxing/oned/UPCEANReader.h @@ -68,8 +68,8 @@ public: Range const& startRange, std::string& resultString) = 0; - virtual Ref decodeRow(int rowNumber, Ref row, DecodeHints hints); - virtual Ref decodeRow(int rowNumber, Ref row, Range const& range, DecodeHints hints = DecodeHints()); + virtual Ref decodeRow(int rowNumber, Ref row, zxing::DecodeHints hints); + virtual Ref decodeRow(int rowNumber, Ref row, Range const& range, zxing::DecodeHints hints = DecodeHints()); static int decodeDigit(Ref row, std::vector& counters, From ab625225df593cd1c5affcb40cf11fae0d64a5ac Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Wed, 26 Jun 2019 11:24:18 +0300 Subject: [PATCH 56/83] Updated README.md Added AppVeyor badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dcf5b9b..b3eba48 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) +# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) [![Build Status](https://ci.appveyor.com/api/projects/status/0033p4dyo49iy5jq?svg=true)](https://ci.appveyor.com/project/ftylitak/qzxing) Qt/QML wrapper library for the [ZXing](https://github.com/zxing/zxing) barcode image processing library. Supports barcode decoding for the following types: From a9d61b4a0f04e670588c849f978fbefd377736cc Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 26 Jun 2019 11:39:45 +0300 Subject: [PATCH 57/83] Sanitation of AppVeyor to build less configurations. Qt LTS versions are covered. --- appveyor.yml | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bb5aec8..381f274 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,41 +1,34 @@ -#Author: KangLin(kl222@126.com) +#original author: KangLin(kl222@126.com) -version: '0.1.1.{build}' +version: '3.0.a.5.{build}' -image: Visual Studio 2015 +image: +- Visual Studio 2015 +- Visual Studio 2017 configuration: - release - - debug +# - debug environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - QT_ROOT: C:/Qt/5.11/msvc2017_64 - - QT_ROOT: C:/Qt/5.11/msvc2015 - - QT_ROOT: C:/Qt/5.11/mingw53_32 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - QT_ROOT: C:/Qt/5.10/msvc2017_64 - - QT_ROOT: C:/Qt/5.10/msvc2015_64 - - QT_ROOT: C:/Qt/5.10/msvc2015 - - QT_ROOT: C:/Qt/5.10/msvc2013_64 - - QT_ROOT: C:/Qt/5.10/mingw53_32 + QT_ROOT: C:/Qt/5.12/msvc2017_64 +# - QT_ROOT: C:/Qt/5.12/msvc2015 +# - QT_ROOT: C:/Qt/5.12/mingw53_32 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 QT_ROOT: C:/Qt/5.9/msvc2017_64 - - QT_ROOT: C:/Qt/5.9/msvc2015_64 - - QT_ROOT: C:/Qt/5.9/msvc2015 - - QT_ROOT: C:/Qt/5.9/msvc2013_64 - - QT_ROOT: C:/Qt/5.9/mingw53_32 +# - QT_ROOT: C:/Qt/5.9/msvc2015_64 +# - QT_ROOT: C:/Qt/5.9/msvc2015 +# - QT_ROOT: C:/Qt/5.9/msvc2013_64 +# - QT_ROOT: C:/Qt/5.9/mingw53_32 - - QT_ROOT: C:/Qt/5.7.0/msvc2015 - - QT_ROOT: C:/Qt/5.7.0/mingw53_32 - - - QT_ROOT: C:/Qt/5.6/msvc2015_64 - - QT_ROOT: C:/Qt/5.6/msvc2015 - - QT_ROOT: C:/Qt/5.6/msvc2013_64 - - QT_ROOT: C:/Qt/5.6/msvc2013 + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + QT_ROOT: C:/Qt/5.6/msvc2015_64 +# - QT_ROOT: C:/Qt/5.6/msvc2015 +# - QT_ROOT: C:/Qt/5.6/msvc2013_64 +# - QT_ROOT: C:/Qt/5.6/msvc2013 init: From 39c9b04697501dfc1c86ca9aefb778106c3d451f Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 26 Jun 2019 11:59:57 +0300 Subject: [PATCH 58/83] enhancing the configuration of AppVeyor. removed unreasonable build configurations --- appveyor.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 381f274..cc4cfa8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,13 +2,9 @@ version: '3.0.a.5.{build}' -image: -- Visual Studio 2015 -- Visual Studio 2017 - configuration: - release -# - debug + - debug environment: matrix: From 25c1c6b903279b4d07280a2362f89b89e93bcf4a Mon Sep 17 00:00:00 2001 From: Stefan Dunca Date: Mon, 1 Jul 2019 14:27:48 +0200 Subject: [PATCH 59/83] Fix usage of boolean due to definition conflicting with Windows SDK's --- src/zxing/zxing/InvertedLuminanceSource.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/zxing/zxing/InvertedLuminanceSource.cpp b/src/zxing/zxing/InvertedLuminanceSource.cpp index 859327d..e1b5e08 100644 --- a/src/zxing/zxing/InvertedLuminanceSource.cpp +++ b/src/zxing/zxing/InvertedLuminanceSource.cpp @@ -18,7 +18,6 @@ #include #include -using zxing::boolean; using zxing::Ref; using zxing::ArrayRef; using zxing::LuminanceSource; @@ -55,7 +54,7 @@ Ref InvertedLuminanceSource::crop(int left, int top, int width, return Ref(new InvertedLuminanceSource(delegate->crop(left, top, width, height))); } -boolean InvertedLuminanceSource::isRotateSupported() const { +zxing::boolean InvertedLuminanceSource::isRotateSupported() const { return delegate->isRotateSupported(); } From d45bc20897f918d5383ff4824272398e8ba6d42e Mon Sep 17 00:00:00 2001 From: Bas van Schaik <5082246+sjvs@users.noreply.github.com> Date: Tue, 2 Jul 2019 12:48:45 +0100 Subject: [PATCH 60/83] Create .lgtm.yml to configure LGTM.com C/C++ analysis This file gives LGTM.com how to configure the C/C++ code. It'll figure out the rest of the build command and required dependencies itself. --- .lgtm.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .lgtm.yml diff --git a/.lgtm.yml b/.lgtm.yml new file mode 100644 index 0000000..97a3a63 --- /dev/null +++ b/.lgtm.yml @@ -0,0 +1,4 @@ +extraction: + cpp: + configure: + command: "qmake -o Makefile CONFIG+=Release src/QZXing.pro" From bbf898fa0ab4dcfc84cf76cab9e745991b1ff2fe Mon Sep 17 00:00:00 2001 From: Bas van Schaik <5082246+sjvs@users.noreply.github.com> Date: Tue, 2 Jul 2019 13:01:16 +0100 Subject: [PATCH 61/83] Update .lgtm.yml From 0c624d1e9cf5cea8bde1a89be64a4ac56a05dca7 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 3 Jul 2019 14:11:30 +0300 Subject: [PATCH 62/83] Apply fixes suggested by LGTM checks. a) Create assignment operator overloads where copy constructors are already implemented. b) fix possible loss of data in DecodeBitStreamParser due to signedness missmatch. c) during an exception throw, throw an object's instance, not its pointer. --- src/zxing/zxing/ResultMetadata.cpp | 1 + .../zxing/datamatrix/decoder/DecodedBitStreamParser.h | 4 ++-- src/zxing/zxing/pdf417/detector/LinesSampler.cpp | 2 ++ src/zxing/zxing/qrcode/ErrorCorrectionLevel.h | 2 ++ src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp | 7 +++++++ src/zxing/zxing/qrcode/decoder/Mode.h | 1 + src/zxing/zxing/qrcode/decoder/QRMode.cpp | 11 +++++++++++ src/zxing/zxing/qrcode/encoder/BlockPair.h | 11 +++++++++++ src/zxing/zxing/qrcode/encoder/QREncoder.cpp | 2 +- 9 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/zxing/zxing/ResultMetadata.cpp b/src/zxing/zxing/ResultMetadata.cpp index 3a194c1..e0cff23 100644 --- a/src/zxing/zxing/ResultMetadata.cpp +++ b/src/zxing/zxing/ResultMetadata.cpp @@ -105,6 +105,7 @@ std::string ResultMetadata::keyToString(Key key) const case STRUCTURED_APPEND_CODE_COUNT: return "STRUCTURED_APPEND_CODE_COUNT"; case STRUCTURED_APPEND_PARITY: return "STRUCTURED_APPEND_PARITY"; } + return "UNKNOWN"; } } // zxing diff --git a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h index c6e6614..0980c47 100644 --- a/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/datamatrix/decoder/DecodedBitStreamParser.h @@ -85,11 +85,11 @@ private: /** * See ISO 16022:2006, Annex B, B.2 */ - char unrandomize255State(int randomizedBase256Codeword, + zxing::byte unrandomize255State(int randomizedBase256Codeword, int base256CodewordPosition) { int pseudoRandomNumber = ((149 * base256CodewordPosition) % 255) + 1; int tempVariable = randomizedBase256Codeword - pseudoRandomNumber; - return (zxing::byte) (tempVariable >= 0 ? tempVariable : (tempVariable + 256)); + return static_cast(tempVariable >= 0 ? tempVariable : (tempVariable + 256)); } void append(std::ostream &ost, const char *bufIn, size_t nIn, const char *src); diff --git a/src/zxing/zxing/pdf417/detector/LinesSampler.cpp b/src/zxing/zxing/pdf417/detector/LinesSampler.cpp index 1ada0f6..03fb4fb 100644 --- a/src/zxing/zxing/pdf417/detector/LinesSampler.cpp +++ b/src/zxing/zxing/pdf417/detector/LinesSampler.cpp @@ -206,6 +206,7 @@ void LinesSampler::codewordsToBitMatrix(vector > &codewords, Ref 0) { matrix->set(moduleOffset + k, i); } @@ -226,6 +227,7 @@ int LinesSampler::calculateClusterNumber(int codeword) { int barNumber = 0; bool blackBar = true; int clusterNumber = 0; + //TODO: Potential unsafe sign check of a bitwise operation. for (int i = 0; i < MODULES_IN_SYMBOL; i++) { if ((codeword & (1 << i)) > 0) { if (!blackBar) { diff --git a/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h b/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h index 77a6ccd..d703734 100644 --- a/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h +++ b/src/zxing/zxing/qrcode/ErrorCorrectionLevel.h @@ -31,6 +31,7 @@ private: int ordinal_; int bits_; std::string name_; + ErrorCorrectionLevel(int inOrdinal, int bits, char const* name); static ErrorCorrectionLevel *FOR_BITS[]; static int N_LEVELS; @@ -41,6 +42,7 @@ public: static ErrorCorrectionLevel H; ErrorCorrectionLevel(const ErrorCorrectionLevel& other); + ErrorCorrectionLevel& operator=(const ErrorCorrectionLevel &other); int ordinal() const; int bits() const; diff --git a/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp b/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp index 277a8b5..d7cc000 100644 --- a/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp +++ b/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp @@ -52,6 +52,13 @@ ErrorCorrectionLevel::operator string const& () const { return name_; } +ErrorCorrectionLevel& ErrorCorrectionLevel::operator=(const ErrorCorrectionLevel &other) +{ + ordinal_ = other.ordinal(); + bits_ = other.bits(); + name_ = other.name(); +} + ErrorCorrectionLevel& ErrorCorrectionLevel::forBits(int bits) { if (bits < 0 || bits >= N_LEVELS) { throw ReaderException("Ellegal error correction level bits"); diff --git a/src/zxing/zxing/qrcode/decoder/Mode.h b/src/zxing/zxing/qrcode/decoder/Mode.h index 98971a5..1215199 100644 --- a/src/zxing/zxing/qrcode/decoder/Mode.h +++ b/src/zxing/zxing/qrcode/decoder/Mode.h @@ -58,6 +58,7 @@ public: int getCharacterCountBits(const Version *version) const; int getBits() const { return bits_; } + Mode& operator=(const Mode& other); bool operator==(const Mode& other); bool operator!=(const Mode& other); diff --git a/src/zxing/zxing/qrcode/decoder/QRMode.cpp b/src/zxing/zxing/qrcode/decoder/QRMode.cpp index d0ac6b5..cdf1c3b 100644 --- a/src/zxing/zxing/qrcode/decoder/QRMode.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRMode.cpp @@ -108,6 +108,17 @@ int Mode::getCharacterCountBits(const Version *version) const } } +Mode& Mode::operator=(const Mode& other) +{ + characterCountBitsForVersions0To9_ = other.characterCountBitsForVersions0To9_; + characterCountBitsForVersions10To26_ = other.characterCountBitsForVersions10To26_; + characterCountBitsForVersions27AndHigher_ = other.characterCountBitsForVersions27AndHigher_; + bits_ = other.bits_; + name_ = other.name_; + + return *this; +} + bool Mode::operator==(const Mode& other) { return ( characterCountBitsForVersions0To9_ == other.characterCountBitsForVersions0To9_ diff --git a/src/zxing/zxing/qrcode/encoder/BlockPair.h b/src/zxing/zxing/qrcode/encoder/BlockPair.h index 08e140c..a1b498e 100644 --- a/src/zxing/zxing/qrcode/encoder/BlockPair.h +++ b/src/zxing/zxing/qrcode/encoder/BlockPair.h @@ -3,6 +3,7 @@ #include #include +#include using namespace std; @@ -24,6 +25,16 @@ public: ArrayRef getDataBytes() { return data_; } ArrayRef getErrorCorrectionBytes() { return errorCorrection_; } + + BlockPair& operator=(const BlockPair &other) { + data_->release(); + errorCorrection_->release(); + + data_ = other.data_; + errorCorrection_ = other.errorCorrection_; + + return *this; + } }; } diff --git a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp index ba45df4..7f28266 100644 --- a/src/zxing/zxing/qrcode/encoder/QREncoder.cpp +++ b/src/zxing/zxing/qrcode/encoder/QREncoder.cpp @@ -79,7 +79,7 @@ Ref Encoder::encode(const std::string& content, ErrorCorrectionLevel &ec version = Version::getVersionForNumber(1); int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); if (!willFit(bitsNeeded, version, ecLevel)) { - throw new WriterException("Data too big for requested version"); + throw WriterException("Data too big for requested version"); } } else { version = recommendVersion(ecLevel, mode, headerBits, dataBits); From a9744f9b892debe6f5e2517f0c29376eceec20d1 Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 3 Jul 2019 14:17:37 +0300 Subject: [PATCH 63/83] fix compilation error due to a missing return statement --- src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp b/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp index d7cc000..aeb0c56 100644 --- a/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp +++ b/src/zxing/zxing/qrcode/QRErrorCorrectionLevel.cpp @@ -57,6 +57,8 @@ ErrorCorrectionLevel& ErrorCorrectionLevel::operator=(const ErrorCorrectionLevel ordinal_ = other.ordinal(); bits_ = other.bits(); name_ = other.name(); + + return *this; } ErrorCorrectionLevel& ErrorCorrectionLevel::forBits(int bits) { From d91f80528d57c50c55d90327b337c7a353224042 Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Wed, 3 Jul 2019 15:18:45 +0300 Subject: [PATCH 64/83] Added LGTM badges Added LGTM badges. Their actual value is calculated once a day, so upon making changes roughly a day must pass to see results. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3eba48..06f6f28 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) [![Build Status](https://ci.appveyor.com/api/projects/status/0033p4dyo49iy5jq?svg=true)](https://ci.appveyor.com/project/ftylitak/qzxing) +# qzxing [![Build Status](https://travis-ci.com/ftylitak/qzxing.svg?branch=master)](https://travis-ci.com/ftylitak/qzxing) [![Build Status](https://ci.appveyor.com/api/projects/status/0033p4dyo49iy5jq?svg=true)](https://ci.appveyor.com/project/ftylitak/qzxing) [![Total alerts](https://img.shields.io/lgtm/alerts/g/ftylitak/qzxing.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ftylitak/qzxing/alerts/) [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/ftylitak/qzxing.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/ftylitak/qzxing/context:cpp) Qt/QML wrapper library for the [ZXing](https://github.com/zxing/zxing) barcode image processing library. Supports barcode decoding for the following types: From 191f636d3daa390f7f677071d36b47d47a16c70f Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Wed, 3 Jul 2019 15:21:13 +0300 Subject: [PATCH 65/83] Deactivate Android build checks from Travis After some changes from the Qt installers (? maybe), all Travis Android builds are not able to be configured in order to run. Deactivating thier build till it get fixed. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96af1b6..3535dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,11 +25,11 @@ addons: env: matrix: - BUILD_TARGERT="linux" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0 + # - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0 - BUILD_TARGERT="linux" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4 + # - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4 - BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 - - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 + # - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8 before_install: - echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}" From a177fe97d19fe6c1096b4005d063ecc532644ddc Mon Sep 17 00:00:00 2001 From: Eism Date: Sun, 7 Jul 2019 12:04:37 +0200 Subject: [PATCH 66/83] rss verssion 0.1 --- examples/QZXingLive/main.qml | 2 +- src/QZXing.pri | 62 +- src/zxing/zxing/DecodeHints.h | 2 +- src/zxing/zxing/common/Str.cpp | 4 +- src/zxing/zxing/common/Str.h | 2 +- src/zxing/zxing/common/detector/MathUtils.h | 9 + .../zxing/oned/MultiFormatOneDReader.cpp | 17 +- .../zxing/oned/rss/AbstractRSSReader.cpp | 101 +++ src/zxing/zxing/oned/rss/AbstractRSSReader.h | 101 +++ src/zxing/zxing/oned/rss/DataCharacter.cpp | 44 ++ src/zxing/zxing/oned/rss/DataCharacter.h | 59 ++ src/zxing/zxing/oned/rss/FinderPattern.cpp | 45 ++ src/zxing/zxing/oned/rss/FinderPattern.h | 63 ++ src/zxing/zxing/oned/rss/Pair.cpp | 32 + src/zxing/zxing/oned/rss/Pair.h | 51 ++ src/zxing/zxing/oned/rss/RSS14Reader.cpp | 455 +++++++++++ src/zxing/zxing/oned/rss/RSS14Reader.h | 71 ++ src/zxing/zxing/oned/rss/RSSUtils.cpp | 74 ++ src/zxing/zxing/oned/rss/RSSUtils.h | 42 + .../oned/rss/expanded/BitArrayBuilder.cpp | 53 ++ .../zxing/oned/rss/expanded/BitArrayBuilder.h | 56 ++ .../zxing/oned/rss/expanded/ExpandedPair.cpp | 49 ++ .../zxing/oned/rss/expanded/ExpandedPair.h | 85 +++ .../zxing/oned/rss/expanded/ExpandedRow.cpp | 48 ++ .../zxing/oned/rss/expanded/ExpandedRow.h | 80 ++ .../oned/rss/expanded/RSSExpandedReader.cpp | 720 ++++++++++++++++++ .../oned/rss/expanded/RSSExpandedReader.h | 128 ++++ .../rss/expanded/decoders/AI013103decoder.cpp | 21 + .../rss/expanded/decoders/AI013103decoder.h | 58 ++ .../rss/expanded/decoders/AI01320xDecoder.cpp | 28 + .../rss/expanded/decoders/AI01320xDecoder.h | 58 ++ .../rss/expanded/decoders/AI01392xDecoder.cpp | 34 + .../rss/expanded/decoders/AI01392xDecoder.h | 62 ++ .../rss/expanded/decoders/AI01393xDecoder.cpp | 50 ++ .../rss/expanded/decoders/AI01393xDecoder.h | 59 ++ .../expanded/decoders/AI013x0x1xDecoder.cpp | 70 ++ .../rss/expanded/decoders/AI013x0x1xDecoder.h | 72 ++ .../rss/expanded/decoders/AI013x0xDecoder.cpp | 25 + .../rss/expanded/decoders/AI013x0xDecoder.h | 60 ++ .../rss/expanded/decoders/AI01AndOtherAIs.cpp | 25 + .../rss/expanded/decoders/AI01AndOtherAIs.h | 60 ++ .../rss/expanded/decoders/AI01decoder.cpp | 51 ++ .../oned/rss/expanded/decoders/AI01decoder.h | 63 ++ .../expanded/decoders/AI01weightDecoder.cpp | 28 + .../rss/expanded/decoders/AI01weightDecoder.h | 60 ++ .../decoders/AbstractExpandedDecoder.cpp | 69 ++ .../decoders/AbstractExpandedDecoder.h | 70 ++ .../rss/expanded/decoders/AnyAIDecoder.cpp | 17 + .../oned/rss/expanded/decoders/AnyAIDecoder.h | 60 ++ .../expanded/decoders/BlockParsedResult.cpp | 31 + .../rss/expanded/decoders/BlockParsedResult.h | 65 ++ .../expanded/decoders/CurrentParsingState.cpp | 51 ++ .../expanded/decoders/CurrentParsingState.h | 78 ++ .../rss/expanded/decoders/DecodedChar.cpp | 21 + .../oned/rss/expanded/decoders/DecodedChar.h | 61 ++ .../expanded/decoders/DecodedInformation.cpp | 47 ++ .../expanded/decoders/DecodedInformation.h | 69 ++ .../rss/expanded/decoders/DecodedNumeric.cpp | 41 + .../rss/expanded/decoders/DecodedNumeric.h | 71 ++ .../rss/expanded/decoders/DecodedObject.cpp | 16 + .../rss/expanded/decoders/DecodedObject.h | 52 ++ .../rss/expanded/decoders/FieldParser.cpp | 276 +++++++ .../oned/rss/expanded/decoders/FieldParser.h | 66 ++ .../expanded/decoders/GeneralAppIdDecoder.cpp | 447 +++++++++++ .../expanded/decoders/GeneralAppIdDecoder.h | 101 +++ 65 files changed, 5034 insertions(+), 14 deletions(-) create mode 100644 src/zxing/zxing/oned/rss/AbstractRSSReader.cpp create mode 100644 src/zxing/zxing/oned/rss/AbstractRSSReader.h create mode 100644 src/zxing/zxing/oned/rss/DataCharacter.cpp create mode 100644 src/zxing/zxing/oned/rss/DataCharacter.h create mode 100644 src/zxing/zxing/oned/rss/FinderPattern.cpp create mode 100644 src/zxing/zxing/oned/rss/FinderPattern.h create mode 100644 src/zxing/zxing/oned/rss/Pair.cpp create mode 100644 src/zxing/zxing/oned/rss/Pair.h create mode 100644 src/zxing/zxing/oned/rss/RSS14Reader.cpp create mode 100644 src/zxing/zxing/oned/rss/RSS14Reader.h create mode 100644 src/zxing/zxing/oned/rss/RSSUtils.cpp create mode 100644 src/zxing/zxing/oned/rss/RSSUtils.h create mode 100644 src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedPair.h create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedRow.h create mode 100644 src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h diff --git a/examples/QZXingLive/main.qml b/examples/QZXingLive/main.qml index 7268934..6b1eb00 100644 --- a/examples/QZXingLive/main.qml +++ b/examples/QZXingLive/main.qml @@ -95,7 +95,7 @@ ApplicationWindow } decoder { - enabledDecoders: QZXing.DecoderFormat_EAN_13 | QZXing.DecoderFormat_CODE_39 | QZXing.DecoderFormat_QR_CODE + enabledDecoders: QZXing.DecoderFormat_RSS_14 | QZXing.DecoderFormat_UPC_A //| QZXing.DecoderFormat_CODE_39 | QZXing.DecoderFormat_QR_CODE onTagFound: { console.log(tag + " | " + decoder.foundedFormat() + " | " + decoder.charSet()); diff --git a/src/QZXing.pri b/src/QZXing.pri index 97339bf..2b72bd4 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -152,7 +152,36 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/EncodeHint.h \ $$PWD/zxing/zxing/UnsupportedEncodingException.h \ $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h \ - $$PWD/zxing/zxing/common/Types.h + $$PWD/zxing/zxing/common/Types.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.h \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.h \ + $$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h \ + $$PWD/zxing/zxing/oned/rss/AbstractRSSReader.h \ + $$PWD/zxing/zxing/oned/rss/DataCharacter.h \ + $$PWD/zxing/zxing/oned/rss/FinderPattern.h \ + $$PWD/zxing/zxing/oned/rss/Pair.h \ + $$PWD/zxing/zxing/oned/rss/RSS14Reader.h \ + $$PWD/zxing/zxing/oned/rss/RSSUtils.h SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/QZXing.cpp \ @@ -273,7 +302,36 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/qrcode/encoder/MatrixUtil.cpp \ $$PWD/zxing/zxing/qrcode/encoder/QRCode.cpp \ $$PWD/zxing/zxing/EncodeHint.cpp \ - $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp + $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp \ + $$PWD/zxing/zxing/oned/rss/AbstractRSSReader.cpp \ + $$PWD/zxing/zxing/oned/rss/DataCharacter.cpp \ + $$PWD/zxing/zxing/oned/rss/FinderPattern.cpp \ + $$PWD/zxing/zxing/oned/rss/Pair.cpp \ + $$PWD/zxing/zxing/oned/rss/RSS14Reader.cpp \ + $$PWD/zxing/zxing/oned/rss/RSSUtils.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp qzxing_multimedia { QT += multimedia diff --git a/src/zxing/zxing/DecodeHints.h b/src/zxing/zxing/DecodeHints.h index b24e349..7a6cb00 100644 --- a/src/zxing/zxing/DecodeHints.h +++ b/src/zxing/zxing/DecodeHints.h @@ -62,7 +62,7 @@ class DecodeHints { static const DecodeHintType CHARACTER_SET; // static const DecodeHintType ALLOWED_LENGTHS = 1 << 29; // static const DecodeHintType ASSUME_CODE_39_CHECK_DIGIT = 1 << 28; - // static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26; + static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26; static const DecodeHints PRODUCT_HINT; static const DecodeHints ONED_HINT; diff --git a/src/zxing/zxing/common/Str.cpp b/src/zxing/zxing/common/Str.cpp index f48b6cd..232c25f 100644 --- a/src/zxing/zxing/common/Str.cpp +++ b/src/zxing/zxing/common/Str.cpp @@ -43,8 +43,8 @@ int String::size() const { return int(text_.size()); } int String::length() const { return int(text_.size()); } -Ref String::substring(int i) const { - return Ref(new String(text_.substr(i))); +Ref String::substring(int i, int j) const { + return Ref(new String(text_.substr(i, j))); } void String::append(const std::string &tail) { diff --git a/src/zxing/zxing/common/Str.h b/src/zxing/zxing/common/Str.h index 8e8c8b3..c37db22 100644 --- a/src/zxing/zxing/common/Str.h +++ b/src/zxing/zxing/common/Str.h @@ -37,7 +37,7 @@ public: explicit String(const std::string &text); explicit String(int); char charAt(int) const; - Ref substring(int) const; + Ref substring(int, int = -1) const; const std::string& getText() const; int size() const; void append(std::string const& tail); diff --git a/src/zxing/zxing/common/detector/MathUtils.h b/src/zxing/zxing/common/detector/MathUtils.h index 900e33c..30811b9 100644 --- a/src/zxing/zxing/common/detector/MathUtils.h +++ b/src/zxing/zxing/common/detector/MathUtils.h @@ -18,6 +18,7 @@ */ #include +#include namespace zxing { namespace common { @@ -48,6 +49,14 @@ class MathUtils { int yDiff = aY - bY; return sqrt(float(xDiff * xDiff + yDiff * yDiff)); } + + static inline int sum(std::vector array) { + int count = 0; + for (int a : array) { + count += a; + } + return count; + } }; } diff --git a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp index 7b18345..2873a51 100644 --- a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp @@ -23,12 +23,16 @@ #include #include #include +#include +#include #include #include using zxing::Ref; using zxing::Result; using zxing::oned::MultiFormatOneDReader; +using zxing::oned::rss::RSS14Reader; +using zxing::oned::rss::RSSExpandedReader; // VC++ using zxing::DecodeHints; @@ -56,16 +60,15 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { if (hints.containsFormat(BarcodeFormat::CODABAR)) { readers.push_back(Ref(new CodaBarReader())); } -/* + if (hints.containsFormat(BarcodeFormat::RSS_14)) { readers.push_back(Ref(new RSS14Reader())); } -*/ -/* + if (hints.containsFormat(BarcodeFormat::RSS_EXPANDED)) { - readers.push_back(Ref(new RSS14ExpandedReader())); + readers.push_back(Ref(new RSSExpandedReader())); } -*/ + if (readers.size() == 0) { readers.push_back(Ref(new MultiFormatUPCEANReader(hints))); readers.push_back(Ref(new Code39Reader())); @@ -73,8 +76,8 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { readers.push_back(Ref(new Code93Reader())); readers.push_back(Ref(new Code128Reader())); readers.push_back(Ref(new ITFReader())); - // readers.push_back(Ref(new RSS14Reader())); - // readers.push_back(Ref(new RSS14ExpandedReader())); + readers.push_back(Ref(new RSS14Reader())); + readers.push_back(Ref(new RSSExpandedReader())); } } diff --git a/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp b/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp new file mode 100644 index 0000000..9e21540 --- /dev/null +++ b/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp @@ -0,0 +1,101 @@ +#include "AbstractRSSReader.h" + +namespace zxing { +namespace oned { +namespace rss { + +AbstractRSSReader::AbstractRSSReader() +{ + m_decodeFinderCounters = std::vector(4); + m_dataCharacterCounters = std::vector(8); + m_oddRoundingErrors = std::vector(4); + m_evenRoundingErrors = std::vector(4); + m_oddCounts = std::vector(m_dataCharacterCounters.size() / 2); + m_evenCounts = std::vector(m_dataCharacterCounters.size() / 2); +} + +std::vector AbstractRSSReader::getDecodeFinderCounters() +{ + return m_decodeFinderCounters; +} + +std::vector AbstractRSSReader::getDataCharacterCounters() +{ + return m_dataCharacterCounters; +} + +std::vector AbstractRSSReader::getOddRoundingErrors() +{ + return m_oddRoundingErrors; +} + +std::vector AbstractRSSReader::getEvenRoundingErrors() +{ + return m_evenRoundingErrors; +} + +std::vector AbstractRSSReader::getOddCounts() +{ + return m_oddCounts; +} + +int AbstractRSSReader::parseFinderValue(std::vector counters, std::vector > finderPatterns) +{ + for (int value = 0; value < finderPatterns.size(); value++) { + if (patternMatchVariance(counters, finderPatterns[value], MAX_INDIVIDUAL_VARIANCE) < + MAX_AVG_VARIANCE) { + return value; + } + } + throw NotFoundException(); +} + +void AbstractRSSReader::increment(std::vector array, std::vector errors) { + int index = 0; + float biggestError = errors[0]; + for (int i = 1; i < array.size(); i++) { + if (errors[i] > biggestError) { + biggestError = errors[i]; + index = i; + } + } + array[index]++; +} + +void AbstractRSSReader::decrement(std::vector array, std::vector errors) { + int index = 0; + float biggestError = errors[0]; + for (int i = 1; i < array.size(); i++) { + if (errors[i] < biggestError) { + biggestError = errors[i]; + index = i; + } + } + array[index]--; +} + +bool AbstractRSSReader::isFinderPattern(std::vector counters) { + int firstTwoSum = counters[0] + counters[1]; + int sum = firstTwoSum + counters[2] + counters[3]; + float ratio = firstTwoSum / (float) sum; + if (ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO) { + // passes ratio test in spec, but see if the counts are unreasonable + int minCounter = INT_MAX; + int maxCounter = INT_MIN; + for (int counter : counters) { + if (counter > maxCounter) { + maxCounter = counter; + } + if (counter < minCounter) { + minCounter = counter; + } + } + return maxCounter < 10 * minCounter; + } + return false; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/AbstractRSSReader.h b/src/zxing/zxing/oned/rss/AbstractRSSReader.h new file mode 100644 index 0000000..3257cda --- /dev/null +++ b/src/zxing/zxing/oned/rss/AbstractRSSReader.h @@ -0,0 +1,101 @@ +#ifndef ABSTRACT_RSS_READER_H +#define ABSTRACT_RSS_READER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//package com.google.zxing.oned.rss; + +//import com.google.zxing.NotFoundException; +//import com.google.zxing.common.detector.MathUtils; +//import com.google.zxing.oned.OneDReader; + +#include +#include +#include + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Superclass of {@link OneDReader} implementations that read barcodes in the RSS family + * of formats. + */ +class AbstractRSSReader : public OneDReader +{ + + static constexpr float MAX_AVG_VARIANCE = 0.2f; + static constexpr float MAX_INDIVIDUAL_VARIANCE = 0.45f; + + static constexpr float MIN_FINDER_PATTERN_RATIO = 9.5f / 12.0f; + static constexpr float MAX_FINDER_PATTERN_RATIO = 12.5f / 14.0f; + +protected: + AbstractRSSReader(); + + std::vector getDecodeFinderCounters(); + + std::vector getDataCharacterCounters(); + + std::vector getOddRoundingErrors(); + + std::vector getEvenRoundingErrors(); + + std::vector getOddCounts(); + + std::vector getEvenCounts() { + return m_evenCounts; + } + + static int parseFinderValue( std::vector counters, + std::vector< std::vector > finderPatterns); + + /** + * @param array values to sum + * @return sum of values + * @deprecated call {@link MathUtils#sum(int[])} + */ + // @Deprecated + // protected static int count( std::vector array) { + // return MathUtils.sum(array); + // } + + static void increment( std::vector array, std::vector errors); + + static void decrement(std::vector array, std::vector errors); + + static bool isFinderPattern(std::vector counters); + +private: + std::vector m_decodeFinderCounters; + std::vector m_dataCharacterCounters; + std::vector m_oddRoundingErrors; + std::vector m_evenRoundingErrors; + std::vector m_oddCounts; + std::vector m_evenCounts; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/DataCharacter.cpp b/src/zxing/zxing/oned/rss/DataCharacter.cpp new file mode 100644 index 0000000..3948a0d --- /dev/null +++ b/src/zxing/zxing/oned/rss/DataCharacter.cpp @@ -0,0 +1,44 @@ +#include "DataCharacter.h" + +namespace zxing { +namespace oned { +namespace rss { + +DataCharacter::DataCharacter(int value, int checksumPortion) + : m_value(value), m_checksumPortion(checksumPortion) +{ + +} + +DataCharacter::DataCharacter() + : m_value(0), m_checksumPortion(0) +{ } + +int DataCharacter::getValue() const +{ + return m_value; +} + +int DataCharacter::getChecksumPortion() const +{ + return m_checksumPortion; +} + +String DataCharacter::toString() const +{ + return String(m_value + "(" + m_checksumPortion + ')'); +} + +bool DataCharacter::equals(const DataCharacter &other) const +{ + return m_value == other.m_value && m_checksumPortion == other.m_checksumPortion; +} + +int DataCharacter::hashCode() const +{ + return m_value & m_checksumPortion; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/DataCharacter.h b/src/zxing/zxing/oned/rss/DataCharacter.h new file mode 100644 index 0000000..e940df5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/DataCharacter.h @@ -0,0 +1,59 @@ +#ifndef DATA_CHARACTER_H +#define DATA_CHARACTER_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Encapsulates a since character value in an RSS barcode, including its checksum information. + */ +class DataCharacter +{ + +public: + DataCharacter(int value, int checksumPortion); + + DataCharacter(); + + int getValue() const; + + int getChecksumPortion() const; + + String toString() const; + + bool equals(const DataCharacter& other) const; + + int hashCode() const; + +private: + int m_value; + int m_checksumPortion; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/FinderPattern.cpp b/src/zxing/zxing/oned/rss/FinderPattern.cpp new file mode 100644 index 0000000..e4b3d63 --- /dev/null +++ b/src/zxing/zxing/oned/rss/FinderPattern.cpp @@ -0,0 +1,45 @@ +#include "FinderPattern.h" + +namespace zxing { +namespace oned { +namespace rss { + +FinderPattern::FinderPattern(int value, std::vector startEnd, int start, int end, int rowNumber) + : m_value(value), + m_startEnd(startEnd) +{ + ArrayRef< Ref > resultPoints(2); + resultPoints[0] = Ref(new OneDResultPoint(start, rowNumber)); + resultPoints[0] = Ref(new OneDResultPoint(end, rowNumber)); + m_resultPoints = resultPoints; +} + +FinderPattern::FinderPattern(const FinderPattern *other) { + m_value = other != nullptr ? other->m_value : 0; + m_startEnd = other != nullptr ? other->m_startEnd : std::vector (); + m_resultPoints = other != nullptr ? other->m_resultPoints : nullptr; +} + +int FinderPattern::getValue() { + return m_value; +} + +std::vector FinderPattern::getStartEnd() { + return m_startEnd; +} + +ArrayRef > FinderPattern::getResultPoints() { + return m_resultPoints; +} + +bool FinderPattern::equals(const FinderPattern &other) { + return m_value == other.m_value; +} + +int FinderPattern::hashCode() { + return m_value; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/FinderPattern.h b/src/zxing/zxing/oned/rss/FinderPattern.h new file mode 100644 index 0000000..338a590 --- /dev/null +++ b/src/zxing/zxing/oned/rss/FinderPattern.h @@ -0,0 +1,63 @@ +#ifndef FINDER_PATTERN_H +#define FINDER_PATTERN_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Encapsulates an RSS barcode finder pattern, including its start/end position and row. + */ +class FinderPattern +{ + +public: + FinderPattern(int value, std::vector startEnd, int start, int end, int rowNumber); + + FinderPattern(const FinderPattern* other = nullptr); + + int getValue(); + + std::vector getStartEnd(); + + ArrayRef< Ref > getResultPoints(); + + bool equals(const FinderPattern& other); + + int hashCode(); + +private: + int m_value; + std::vector m_startEnd; + ArrayRef< Ref > m_resultPoints; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/Pair.cpp b/src/zxing/zxing/oned/rss/Pair.cpp new file mode 100644 index 0000000..535aca2 --- /dev/null +++ b/src/zxing/zxing/oned/rss/Pair.cpp @@ -0,0 +1,32 @@ +#include "Pair.h" + +namespace zxing { +namespace oned { +namespace rss { + +Pair::Pair(int value, int checksumPortion, FinderPattern finderPattern) + : DataCharacter (value, checksumPortion), m_finderPattern(finderPattern) +{ +} + +Pair::Pair() + : DataCharacter (0, 0), m_finderPattern(FinderPattern()) +{ +} + +FinderPattern Pair::getFinderPattern() { + return m_finderPattern; +} + +int Pair::getCount() { + return m_count; +} + +void Pair::incrementCount() { + m_count++; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/Pair.h b/src/zxing/zxing/oned/rss/Pair.h new file mode 100644 index 0000000..73bfcfa --- /dev/null +++ b/src/zxing/zxing/oned/rss/Pair.h @@ -0,0 +1,51 @@ +#ifndef RSS_PAIR_H +#define RSS_PAIR_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "DataCharacter.h" +#include "FinderPattern.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +class Pair : public DataCharacter +{ + +public: + Pair(int value, int checksumPortion, FinderPattern finderPattern); + Pair(); + + FinderPattern getFinderPattern(); + + int getCount(); + + void incrementCount(); + +private: + FinderPattern m_finderPattern; + int m_count; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.cpp b/src/zxing/zxing/oned/rss/RSS14Reader.cpp new file mode 100644 index 0000000..a593215 --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSS14Reader.cpp @@ -0,0 +1,455 @@ +#include "RSS14Reader.h" + +namespace zxing { +namespace oned { +namespace rss { + +using ::zxing::common::detector::MathUtils; + +static const std::vector OUTSIDE_EVEN_TOTAL_SUBSET = {1,10,34,70,126}; +static const std::vector INSIDE_ODD_TOTAL_SUBSET = {4,20,48,81}; +static const std::vector OUTSIDE_GSUM = {0,161,961,2015,2715}; +static const std::vector INSIDE_GSUM = {0,336,1036,1516}; +static const std::vector OUTSIDE_ODD_WIDEST = {8,6,4,3,1}; +static const std::vector INSIDE_ODD_WIDEST = {2,4,6,8}; + +static const std::vector> FINDER_PATTERNS = { + {3,8,2,1}, + {3,5,5,1}, + {3,3,7,1}, + {3,1,9,1}, + {2,7,4,1}, + {2,5,6,1}, + {2,3,8,1}, + {1,5,7,1}, + {1,3,9,1}, +}; + +RSS14Reader::RSS14Reader() + : m_possibleLeftPairs({}), + m_possibleRightPairs({}) +{ + +} + +Ref RSS14Reader::decodeRow(int rowNumber, Ref row, DecodeHints hints) +{ + Pair leftPair = decodePair(row, false, rowNumber, hints); + addOrTally(m_possibleLeftPairs, leftPair); + row->reverse(); + Pair rightPair = decodePair(row, true, rowNumber, hints); + addOrTally(m_possibleRightPairs, rightPair); + row->reverse(); + for (Pair left : m_possibleLeftPairs) { + if (left.getCount() > 1) { + for (Pair right : m_possibleRightPairs) { + if (right.getCount() > 1 && checkChecksum(left, right)) { + return constructResult(left, right); + } + } + } + } + throw NotFoundException(); +} + +void RSS14Reader::addOrTally(std::vector possiblePairs, Pair pair) { + if (pair.getCount() == 0) { + return; + } + boolean found = false; + for (Pair other : possiblePairs) { + if (other.getValue() == pair.getValue()) { + other.incrementCount(); + found = true; + break; + } + } + if (!found) { + possiblePairs.push_back(pair); + } +} + +void RSS14Reader::reset() +{ + m_possibleLeftPairs.clear(); + m_possibleRightPairs.clear(); +} + +Ref RSS14Reader::constructResult(Pair leftPair, Pair rightPair) +{ + long symbolValue = 4537077L * leftPair.getValue() + rightPair.getValue(); + String text(std::to_string(symbolValue)); + + String buffer(14); + for (int i = 13 - text.length(); i > 0; i--) { + buffer.append('0'); + } + buffer.append(text.getText()); + + int checkDigit = 0; + for (int i = 0; i < 13; i++) { + int digit = buffer.charAt(i) - '0'; + checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; + } + checkDigit = 10 - (checkDigit % 10); + if (checkDigit == 10) { + checkDigit = 0; + } + buffer.append(checkDigit); + + ArrayRef< Ref > leftPoints = leftPair.getFinderPattern().getResultPoints(); + ArrayRef< Ref > rightPoints = rightPair.getFinderPattern().getResultPoints(); + ArrayRef< Ref > resultPoints(5); + resultPoints[0] = leftPoints[0]; + resultPoints[1] = leftPoints[1]; + resultPoints[2] = rightPoints[0]; + resultPoints[3] = rightPoints[1]; + + return Ref(new Result( + Ref(new String(buffer)), + nullptr, + resultPoints, + BarcodeFormat::RSS_14)); +} + +Pair RSS14Reader::decodePair(Ref row, boolean right, int rowNumber, DecodeHints hints) +{ + try { + std::vector startEnd = findFinderPattern(row, right); + FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd); + + Ref resultPointCallback = hints.getResultPointCallback(); /////////////////////// + + if (resultPointCallback != nullptr) { + startEnd = pattern.getStartEnd(); + float center = (startEnd[0] + startEnd[1] - 1) / 2.0f; + if (right) { + // row is actually reversed + center = row->getSize() - 1 - center; + } + resultPointCallback->foundPossibleResultPoint(ResultPoint(center, static_cast(rowNumber))); + } + + DataCharacter outside = decodeDataCharacter(row, pattern, true); + DataCharacter inside = decodeDataCharacter(row, pattern, false); + return Pair(1597 * outside.getValue() + inside.getValue(), + outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), + pattern); + } catch (NotFoundException ignored) { + return Pair(); + } +} + +DataCharacter RSS14Reader::decodeDataCharacter(Ref row, FinderPattern pattern, boolean outsideChar) +{ + + std::vector counters = getDataCharacterCounters(); + for (int x = 0; x < counters.size(); x++) { + counters[x] = 0; + } + + if (outsideChar) { + recordPattern(row, pattern.getStartEnd()[0], counters); //////////////////////////////// + } else { + recordPattern(row, pattern.getStartEnd()[1], counters); + // reverse it + for (int i = 0, j = counters.size() - 1; i < j; i++, j--) { + int temp = counters[i]; + counters[i] = counters[j]; + counters[j] = temp; + } + } + + int numModules = outsideChar ? 16 : 15; + float elementWidth = MathUtils::sum(counters) / (float) numModules; + + std::vector oddCounts = getOddCounts(); + std::vector evenCounts = getEvenCounts(); + std::vector oddRoundingErrors = getOddRoundingErrors(); + std::vector evenRoundingErrors = getEvenRoundingErrors(); + + for (int i = 0; i < counters.size(); i++) { + float value = counters[i] / elementWidth; + int count = (int) (value + 0.5f); // Round + if (count < 1) { + count = 1; + } else if (count > 8) { + count = 8; + } + int offset = i / 2; + if ((i & 0x01) == 0) { + oddCounts[offset] = count; + oddRoundingErrors[offset] = value - count; + } else { + evenCounts[offset] = count; + evenRoundingErrors[offset] = value - count; + } + } + + adjustOddEvenCounts(outsideChar, numModules); + + int oddSum = 0; + int oddChecksumPortion = 0; + for (int i = oddCounts.size() - 1; i >= 0; i--) { + oddChecksumPortion *= 9; + oddChecksumPortion += oddCounts[i]; + oddSum += oddCounts[i]; + } + int evenChecksumPortion = 0; + int evenSum = 0; + for (int i = evenCounts.size() - 1; i >= 0; i--) { + evenChecksumPortion *= 9; + evenChecksumPortion += evenCounts[i]; + evenSum += evenCounts[i]; + } + int checksumPortion = oddChecksumPortion + 3 * evenChecksumPortion; + + if (outsideChar) { + if ((oddSum & 0x01) != 0 || oddSum > 12 || oddSum < 4) { + throw NotFoundException(); + } + int group = (12 - oddSum) / 2; + int oddWidest = OUTSIDE_ODD_WIDEST[group]; + int evenWidest = 9 - oddWidest; + int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, false); + int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, true); + int tEven = OUTSIDE_EVEN_TOTAL_SUBSET[group]; + int gSum = OUTSIDE_GSUM[group]; + return DataCharacter(vOdd * tEven + vEven + gSum, checksumPortion); + } else { + if ((evenSum & 0x01) != 0 || evenSum > 10 || evenSum < 4) { + throw NotFoundException(); + } + int group = (10 - evenSum) / 2; + int oddWidest = INSIDE_ODD_WIDEST[group]; + int evenWidest = 9 - oddWidest; + int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, true); + int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, false); + int tOdd = INSIDE_ODD_TOTAL_SUBSET[group]; + int gSum = INSIDE_GSUM[group]; + return DataCharacter(vEven * tOdd + vOdd + gSum, checksumPortion); + } + +} + +std::vector RSS14Reader::findFinderPattern(Ref row, bool rightFinderPattern) +{ + std::vector counters = getDecodeFinderCounters(); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + + int width = row->getSize(); + boolean isWhite = false; + int rowOffset = 0; + while (rowOffset < width) { + isWhite = !row->get(rowOffset); + if (rightFinderPattern == isWhite) { + // Will encounter white first when searching for right finder pattern + break; + } + rowOffset++; + } + + int counterPosition = 0; + int patternStart = rowOffset; + for (int x = rowOffset; x < width; x++) { + if (row->get(x) != isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == 3) { + if (isFinderPattern(counters)) { + return std::vector{patternStart, x}; + } + patternStart += counters[0] + counters[1]; + counters[0] = counters[2]; + counters[1] = counters[3]; + counters[2] = 0; + counters[3] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw NotFoundException(); + +} + +FinderPattern RSS14Reader::parseFoundFinderPattern(Ref row, int rowNumber, bool right, std::vector startEnd) +{ + // Actually we found elements 2-5 + bool firstIsBlack = row->get(startEnd[0]); + int firstElementStart = startEnd[0] - 1; + // Locate element 1 + while (firstElementStart >= 0 && firstIsBlack != row->get(firstElementStart)) { + firstElementStart--; + } + firstElementStart++; + int firstCounter = startEnd[0] - firstElementStart; + // Make 'counters' hold 1-4 + std::vector counters = getDecodeFinderCounters(); + std::vector _counters = counters; + for (int i = 1; i < counters.size(); i++) { + counters[i] = _counters[i - 1]; + } + + //System.arraycopy(counters, 0, counters, 1, counters.length - 1); //////////////////////////////////////// + counters[0] = firstCounter; + int value = parseFinderValue(counters, FINDER_PATTERNS); + int start = firstElementStart; + int end = startEnd[1]; + if (right) { + // row is actually reversed + start = row->getSize() - 1 - start; + end = row->getSize() - 1 - end; + } + return new FinderPattern(value, {firstElementStart, startEnd[1]}, start, end, rowNumber); +} + +void RSS14Reader::adjustOddEvenCounts(boolean outsideChar, int numModules) +{ + int oddSum = MathUtils::sum(getOddCounts()); + int evenSum = MathUtils::sum(getEvenCounts()); + + boolean incrementOdd = false; + boolean decrementOdd = false; + boolean incrementEven = false; + boolean decrementEven = false; + + if (outsideChar) { + if (oddSum > 12) { + decrementOdd = true; + } else if (oddSum < 4) { + incrementOdd = true; + } + if (evenSum > 12) { + decrementEven = true; + } else if (evenSum < 4) { + incrementEven = true; + } + } else { + if (oddSum > 11) { + decrementOdd = true; + } else if (oddSum < 5) { + incrementOdd = true; + } + if (evenSum > 10) { + decrementEven = true; + } else if (evenSum < 4) { + incrementEven = true; + } + } + + int mismatch = oddSum + evenSum - numModules; + boolean oddParityBad = (oddSum & 0x01) == (outsideChar ? 1 : 0); + boolean evenParityBad = (evenSum & 0x01) == 1; + /*if (mismatch == 2) { + if (!(oddParityBad && evenParityBad)) { + throw ReaderException.getInstance(); + } + decrementOdd = true; + decrementEven = true; + } else if (mismatch == -2) { + if (!(oddParityBad && evenParityBad)) { + throw ReaderException.getInstance(); + } + incrementOdd = true; + incrementEven = true; + } else */ + switch (mismatch) { + case 1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + decrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + decrementEven = true; + } + break; + case -1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + incrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + incrementEven = true; + } + break; + case 0: + if (oddParityBad) { + if (!evenParityBad) { + throw NotFoundException(); + } + // Both bad + if (oddSum < evenSum) { + incrementOdd = true; + decrementEven = true; + } else { + decrementOdd = true; + incrementEven = true; + } + } else { + if (evenParityBad) { + throw NotFoundException(); + } + // Nothing to do! + } + break; + default: + throw NotFoundException(); + } + + if (incrementOdd) { + if (decrementOdd) { + throw NotFoundException(); + } + increment(getOddCounts(), getOddRoundingErrors()); + } + if (decrementOdd) { + decrement(getOddCounts(), getOddRoundingErrors()); + } + if (incrementEven) { + if (decrementEven) { + throw NotFoundException(); + } + increment(getEvenCounts(), getOddRoundingErrors()); + } + if (decrementEven) { + decrement(getEvenCounts(), getEvenRoundingErrors()); + } +} + +bool RSS14Reader::checkChecksum(Pair leftPair, Pair rightPair) +{ + //int leftFPValue = leftPair.getFinderPattern().getValue(); + //int rightFPValue = rightPair.getFinderPattern().getValue(); + //if ((leftFPValue == 0 && rightFPValue == 8) || + // (leftFPValue == 8 && rightFPValue == 0)) { + //} + int checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79; + int targetCheckValue = + 9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue(); + if (targetCheckValue > 72) { + targetCheckValue--; + } + if (targetCheckValue > 8) { + targetCheckValue--; + } + return checkValue == targetCheckValue; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.h b/src/zxing/zxing/oned/rss/RSS14Reader.h new file mode 100644 index 0000000..660167c --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSS14Reader.h @@ -0,0 +1,71 @@ +#ifndef RSS14_READER_H +#define RSS14_READER_H +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AbstractRSSReader.h" +#include "Pair.h" +#include +#include "RSSUtils.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Decodes RSS-14, including truncated and stacked variants. See ISO/IEC 24724:2006. + */ +class RSS14Reader : public AbstractRSSReader +{ + +private: + std::vector m_possibleLeftPairs; + std::vector m_possibleRightPairs; + +public: + RSS14Reader(); + + Ref decodeRow(int rowNumber, Ref row, DecodeHints hints); + + static void addOrTally(std::vector possiblePairs, Pair pair); + + void reset(); + + Ref constructResult(Pair leftPair, Pair rightPair); + + static boolean checkChecksum(Pair leftPair, Pair rightPair); + + Pair decodePair(Ref row, boolean right, int rowNumber, DecodeHints hints); + + DataCharacter decodeDataCharacter(Ref row, FinderPattern pattern, boolean outsideChar); + + std::vector findFinderPattern(Ref row, bool rightFinderPattern); + + FinderPattern parseFoundFinderPattern(Ref row, int rowNumber, bool right, std::vector startEnd); + + void adjustOddEvenCounts(boolean outsideChar, int numModules); + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/RSSUtils.cpp b/src/zxing/zxing/oned/rss/RSSUtils.cpp new file mode 100644 index 0000000..63e99f5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSSUtils.cpp @@ -0,0 +1,74 @@ +#include "RSSUtils.h" + +namespace zxing { +namespace oned { +namespace rss { + +int RSSUtils::getRSSvalue(std::vector widths, int maxWidth, bool noNarrow) +{ + int n = 0; + for (int width : widths) { + n += width; + } + int val = 0; + int narrowMask = 0; + int elements = widths.size(); + for (int bar = 0; bar < elements - 1; bar++) { + int elmWidth; + for (elmWidth = 1, narrowMask |= 1 << bar; + elmWidth < widths[bar]; + elmWidth++, narrowMask &= ~(1 << bar)) { + int subVal = combins(n - elmWidth - 1, elements - bar - 2); + if (noNarrow && (narrowMask == 0) && + (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { + subVal -= combins(n - elmWidth - (elements - bar), + elements - bar - 2); + } + if (elements - bar - 1 > 1) { + int lessVal = 0; + for (int mxwElement = n - elmWidth - (elements - bar - 2); + mxwElement > maxWidth; mxwElement--) { + lessVal += combins(n - elmWidth - mxwElement - 1, + elements - bar - 3); + } + subVal -= lessVal * (elements - 1 - bar); + } else if (n - elmWidth > maxWidth) { + subVal--; + } + val += subVal; + } + n -= elmWidth; + } + return val; +} + +int RSSUtils::combins(int n, int r) +{ + int maxDenom; + int minDenom; + if (n - r > r) { + minDenom = r; + maxDenom = n - r; + } else { + minDenom = n - r; + maxDenom = r; + } + int val = 1; + int j = 1; + for (int i = n; i > maxDenom; i--) { + val *= i; + if (j <= minDenom) { + val /= j; + j++; + } + } + while (j <= minDenom) { + val /= j; + j++; + } + return val; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/RSSUtils.h b/src/zxing/zxing/oned/rss/RSSUtils.h new file mode 100644 index 0000000..26dc29c --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSSUtils.h @@ -0,0 +1,42 @@ +#ifndef RSS_UTILS_H +#define RSS_UTILS_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** Adapted from listings in ISO/IEC 24724 Appendix B and Appendix G. */ +class RSSUtils +{ + +public: + static int getRSSvalue(std::vector widths, int maxWidth, bool noNarrow); + + static int combins(int n, int r); +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp new file mode 100644 index 0000000..1c0633f --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp @@ -0,0 +1,53 @@ +#include "BitArrayBuilder.h" + +namespace zxing { +namespace oned { +namespace rss { + +Ref BitArrayBuilder::buildBitArray(std::vector pairs) { + int charNumber = (pairs.size() * 2) - 1; + if (pairs[pairs.size() - 1].getRightChar().getValue() == 0) { + charNumber -= 1; + } + + int size = 12 * charNumber; + + Ref binary(new BitArray(int(size))); + int accPos = 0; + + ExpandedPair firstPair = pairs[0]; + int firstValue = firstPair.getRightChar().getValue(); + for (int i = 11; i >= 0; --i) { + if ((firstValue & (1 << i)) != 0) { + binary->set(accPos); + } + accPos++; + } + + for (int i = 1; i < pairs.size(); ++i) { + ExpandedPair currentPair = pairs[i]; + + int leftValue = currentPair.getLeftChar().getValue(); + for (int j = 11; j >= 0; --j) { + if ((leftValue & (1 << j)) != 0) { + binary->set(accPos); + } + accPos++; + } + + if (currentPair.getRightChar().getValue() != 0) { + int rightValue = currentPair.getRightChar().getValue(); + for (int j = 11; j >= 0; --j) { + if ((rightValue & (1 << j)) != 0) { + binary->set(accPos); + } + accPos++; + } + } + } + return binary; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h new file mode 100644 index 0000000..861015a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h @@ -0,0 +1,56 @@ +#ifndef BIT_ARRAY_BUILDER_H +#define BIT_ARRAY_BUILDER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include "ExpandedPair.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class BitArrayBuilder +{ + +public: + static Ref buildBitArray(std::vector pairs); +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp new file mode 100644 index 0000000..c17ed4a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp @@ -0,0 +1,49 @@ +#include "ExpandedPair.h" + +namespace zxing { +namespace oned { +namespace rss { + +ExpandedPair::ExpandedPair(DataCharacter leftChar, DataCharacter rightChar, FinderPattern finderPattern) + : m_leftChar(leftChar), + m_rightChar(rightChar), + m_finderPattern(finderPattern) +{ } + +DataCharacter ExpandedPair::getLeftChar() { + return m_leftChar; +} + +DataCharacter ExpandedPair::getRightChar() { + return m_rightChar; +} + +FinderPattern ExpandedPair::getFinderPattern() { + return m_finderPattern; +} + +bool ExpandedPair::mustBeLast() { + return m_rightChar.toString().length() == 0; +} + +String ExpandedPair::toString() { + return + String(String("[ ").getText() + m_leftChar.toString().getText() + String(" , ").getText() + m_rightChar.toString().getText() + " : " + + (m_finderPattern.getValue() != 0 ? "null" : std::to_string(m_finderPattern.getValue())) + " ]"); +} + +bool ExpandedPair::equals(const ExpandedPair &other) { + return m_leftChar.equals(other.m_leftChar) && + m_rightChar.equals(other.m_rightChar) && + m_finderPattern.equals(other.m_finderPattern); +} + +int ExpandedPair::hashCode() { + return m_leftChar.hashCode() & m_rightChar.hashCode() & m_finderPattern.hashCode(); +} + + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h new file mode 100644 index 0000000..3cb9ea8 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h @@ -0,0 +1,85 @@ +#ifndef EXPANDED_PAIR_H +#define EXPANDED_PAIR_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +//package com.google.zxing.oned.rss.expanded; + +//import com.google.zxing.oned.rss.DataCharacter; +//import com.google.zxing.oned.rss.FinderPattern; + +//import java.util.Objects; + +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class ExpandedPair +{ + +public: + ExpandedPair(DataCharacter leftChar, + DataCharacter rightChar, + FinderPattern finderPattern); + + DataCharacter getLeftChar(); + + DataCharacter getRightChar(); + + FinderPattern getFinderPattern(); + + bool mustBeLast(); + + String toString(); + + bool equals(const ExpandedPair& other); + + int hashCode(); + + bool operator == (const ExpandedPair &x) {return equals(x);} //////////////////// + +private: + DataCharacter m_leftChar; + DataCharacter m_rightChar; + FinderPattern m_finderPattern; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp new file mode 100644 index 0000000..e0fdba9 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp @@ -0,0 +1,48 @@ +#include "ExpandedRow.h" + +namespace zxing { +namespace oned { +namespace rss { + +ExpandedRow::ExpandedRow(std::vector pairs, int rowNumber, bool wasReversed) { + m_pairs = std::vector(pairs); + m_rowNumber = rowNumber; + m_wasReversed = wasReversed; +} + +std::vector ExpandedRow::getPairs() { + return m_pairs; +} + +int ExpandedRow::getRowNumber() { + return m_rowNumber; +} + +bool ExpandedRow::isEquivalent(std::vector otherPairs) { + + if (m_pairs.size() != otherPairs.size()) { + return false; + } + + for (int i = 0; i < m_pairs.size(); i++) { + if (!m_pairs[i].equals(otherPairs[i])) { + return false; + } + } + + return true; +} + +String ExpandedRow::toString() { + String result("{ "); + for (auto i : m_pairs) { + result.append(i.toString().getText()); + } + result.append(" }"); + return result; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h new file mode 100644 index 0000000..9f9344a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h @@ -0,0 +1,80 @@ +#ifndef EXPANDED_ROW_H +#define EXPANDED_ROW_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +//package com.google.zxing.oned.rss.expanded; + +//import java.util.ArrayList; +//import java.util.List; + +#include "ExpandedPair.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs. + */ +class ExpandedRow +{ + +public: + ExpandedRow(std::vector pairs, int rowNumber, bool wasReversed); + + std::vector getPairs(); + + int getRowNumber(); + + bool isEquivalent(std::vector otherPairs); + + String toString(); + + /** + * Two rows are equal if they contain the same pairs in the same order. + */ + // @Override + // public boolean equals(Object o) { + // if (!(o instanceof ExpandedRow)) { + // return false; + // } + // ExpandedRow that = (ExpandedRow) o; + // return this.pairs.equals(that.getPairs()) && wasReversed == that.wasReversed; + // } + + // @Override + // public int hashCode() { + // return pairs.hashCode() ^ Boolean.valueOf(wasReversed).hashCode(); + // } + +private: + std::vector m_pairs; + int m_rowNumber; + /** Did this row of the image have to be reversed (mirrored) to recognize the pairs? */ + bool m_wasReversed; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp new file mode 100644 index 0000000..78bdc22 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp @@ -0,0 +1,720 @@ +#include "RSSExpandedReader.h" + +namespace zxing { +namespace oned { +namespace rss { + +using ::zxing::common::detector::MathUtils; + +static const std::vector SYMBOL_WIDEST = {7, 5, 4, 3, 1}; +static const std::vector EVEN_TOTAL_SUBSET = {4, 20, 52, 104, 204}; +static const std::vector GSUM = {0, 348, 1388, 2948, 3988}; + +static const std::vector> FINDER_PATTERNS = { + {1,8,4,1}, // A + {3,6,4,1}, // B + {3,4,6,1}, // C + {3,2,8,1}, // D + {2,6,5,1}, // E + {2,2,9,1} // F +}; + +static const std::vector> WEIGHTS = { + { 1, 3, 9, 27, 81, 32, 96, 77}, + { 20, 60, 180, 118, 143, 7, 21, 63}, + {189, 145, 13, 39, 117, 140, 209, 205}, + {193, 157, 49, 147, 19, 57, 171, 91}, + { 62, 186, 136, 197, 169, 85, 44, 132}, + {185, 133, 188, 142, 4, 12, 36, 108}, + {113, 128, 173, 97, 80, 29, 87, 50}, + {150, 28, 84, 41, 123, 158, 52, 156}, + { 46, 138, 203, 187, 139, 206, 196, 166}, + { 76, 17, 51, 153, 37, 111, 122, 155}, + { 43, 129, 176, 106, 107, 110, 119, 146}, + { 16, 48, 144, 10, 30, 90, 59, 177}, + {109, 116, 137, 200, 178, 112, 125, 164}, + { 70, 210, 208, 202, 184, 130, 179, 115}, + {134, 191, 151, 31, 93, 68, 204, 190}, + {148, 22, 66, 198, 172, 94, 71, 2}, + { 6, 18, 54, 162, 64, 192,154, 40}, + {120, 149, 25, 75, 14, 42,126, 167}, + { 79, 26, 78, 23, 69, 207,199, 175}, + {103, 98, 83, 38, 114, 131, 182, 124}, + {161, 61, 183, 127, 170, 88, 53, 159}, + { 55, 165, 73, 8, 24, 72, 5, 15}, + { 45, 135, 194, 160, 58, 174, 100, 89} +}; + +static const int FINDER_PAT_A = 0; +static const int FINDER_PAT_B = 1; +static const int FINDER_PAT_C = 2; +static const int FINDER_PAT_D = 3; +static const int FINDER_PAT_E = 4; +static const int FINDER_PAT_F = 5; + +static std::vector> FINDER_PATTERN_SEQUENCES = { + { FINDER_PAT_A, FINDER_PAT_A }, + { FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B }, + { FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D }, + { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_C }, + { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_F }, + { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, +}; + +static const int MAX_PAIRS = 11; + +Ref RSSExpandedReader::decodeRow(int rowNumber, Ref row, DecodeHints hints) +{ + // Rows can start with even pattern in case in prev rows there where odd number of patters. + // So lets try twice + m_pairs.clear(); + m_startFromEven = false; + try { + return constructResult(decodeRow2pairs(rowNumber, row)); + } catch (NotFoundException e) { + // OK + } + + m_pairs.clear(); + m_startFromEven = true; + return constructResult(decodeRow2pairs(rowNumber, row)); +} + +void RSSExpandedReader::reset() { + m_pairs.clear(); + m_rows.clear(); +} + +std::vector RSSExpandedReader::decodeRow2pairs(int rowNumber, Ref row) +{ + boolean done = false; + while (!done) { + try { + m_pairs.push_back(retrieveNextPair(row, m_pairs, rowNumber)); + } catch (NotFoundException nfe) { + if (m_pairs.size() == 0) { + throw nfe; + } + // exit this loop when retrieveNextPair() fails and throws + done = true; + } + } + + // TODO: verify sequence of finder patterns as in checkPairSequence() + if (checkChecksum()) { + return m_pairs; + } + + bool tryStackedDecode = !(m_rows.size() == 0); + storeRow(rowNumber, false); // TODO: deal with reversed rows + if (tryStackedDecode) { + // When the image is 180-rotated, then rows are sorted in wrong direction. + // Try twice with both the directions. + std::vector ps = checkRows(false); + if (ps.size() != 0) { + return ps; + } + ps = checkRows(true); + if (ps.size() != 0) { + return ps; + } + } + + throw NotFoundException(); +} + +std::vector RSSExpandedReader::checkRows(boolean reverse) { + // Limit number of rows we are checking + // We use recursive algorithm with pure complexity and don't want it to take forever + // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough + if (m_rows.size() > 25) { + m_rows.clear(); // We will never have a chance to get result, so clear it + return {}; + } + + m_pairs.clear(); + if (reverse) { + std::reverse(m_rows.begin(), m_rows.end()); + } + + std::vector ps; + try { + ps = checkRows({}, 0); + } catch (NotFoundException e) { + // OK + } + + if (reverse) { + std::reverse(m_rows.begin(), m_rows.end()); + } + + return ps; +} + +std::vector RSSExpandedReader::checkRows(std::vector collectedRows, int currentRow) +{ + for (int i = currentRow; i < m_rows.size(); i++) { + ExpandedRow row = m_rows[i]; + m_pairs.clear(); + for (ExpandedRow collectedRow : collectedRows) { + + std::vector collectedRowPairs = collectedRow.getPairs();///////////////////// + m_pairs.insert(m_pairs.begin(), collectedRowPairs.begin(), + collectedRowPairs.end()); + + // m_pairs.m(collectedRow.getPairs()); + } + std::vector rowPairs = row.getPairs(); + m_pairs.insert(m_pairs.begin(), rowPairs.begin(), + rowPairs.end()); + //m_pairs.addAll(row.getPairs()); + + if (isValidSequence(m_pairs)) { + if (checkChecksum()) { + return m_pairs; + } + + std::vector rs(collectedRows); + rs.push_back(row); + try { + // Recursion: try to add more rows + return checkRows(rs, i + 1); + } catch (NotFoundException e) { + // We failed, try the next candidate + } + } + } + + throw NotFoundException(); +} + +boolean RSSExpandedReader::isValidSequence(std::vector pairs) { + for (std::vector sequence : FINDER_PATTERN_SEQUENCES) { + if (pairs.size() <= sequence.size()) { + boolean stop = true; + for (int j = 0; j < pairs.size(); j++) { + if (pairs[j].getFinderPattern().getValue() != sequence[j]) { + stop = false; + break; + } + } + if (stop) { + return true; + } + } + + } + + return false; +} + +void RSSExpandedReader::storeRow(int rowNumber, bool wasReversed) +{ + // Discard if duplicate above or below; otherwise insert in order by row number. + int insertPos = 0; + bool prevIsSame = false; + bool nextIsSame = false; + while (insertPos < m_rows.size()) { + ExpandedRow erow = m_rows[insertPos]; + if (erow.getRowNumber() > rowNumber) { + nextIsSame = erow.isEquivalent(m_pairs); + break; + } + prevIsSame = erow.isEquivalent(m_pairs); + insertPos++; + } + if (nextIsSame || prevIsSame) { + return; + } + + // When the row was partially decoded (e.g. 2 pairs found instead of 3), + // it will prevent us from detecting the barcode. + // Try to merge partial rows + + // Check whether the row is part of an already detected row + if (isPartialRow(m_pairs, m_rows)) { + return; + } + + m_rows.insert(m_rows.begin() + insertPos, ExpandedRow(m_pairs, rowNumber, wasReversed)); ///////////////////// + + removePartialRows(m_pairs, m_rows); +} + +void RSSExpandedReader::removePartialRows(std::vector pairs, std::vector rows) { + for (std::vector::iterator iterator = rows.begin(); iterator != rows.end(); ++iterator) { + if (iterator->getPairs().size() != pairs.size()) { + boolean allFound = true; + for (ExpandedPair p : iterator->getPairs()) { + if (std::find(pairs.begin(), pairs.end(), p) == pairs.end()) { ////////////////////////////// + allFound = false; + break; + } + } + if (allFound) { + // 'pairs' contains all the pairs from the row 'r' + rows.erase(iterator--); + } + } + } +} + +bool RSSExpandedReader::isPartialRow(std::vector pairs, std::vector rows) { + for (ExpandedRow r : rows) { + bool allFound = true; + for (ExpandedPair p : pairs) { + bool found = false; + for (ExpandedPair pp : r.getPairs()) { + if (p.equals(pp)) { + found = true; + break; + } + } + if (!found) { + allFound = false; + break; + } + } + if (allFound) { + // the row 'r' contain all the pairs from 'pairs' + return true; + } + } + return false; +} + +std::vector RSSExpandedReader::getRows() { + return m_rows; +} + +Ref RSSExpandedReader::constructResult(std::vector pairs) +{ + Ref binary = BitArrayBuilder::buildBitArray(pairs); + + AbstractExpandedDecoder* decoder = AbstractExpandedDecoder::createDecoder(binary); + String resultingString = decoder->parseInformation(); + + // ArrayRef< Ref > firstPoints + + ArrayRef< Ref > firstPoints = pairs[0].getFinderPattern().getResultPoints(); + ArrayRef< Ref > lastPoints = pairs[pairs.size() - 1].getFinderPattern().getResultPoints(); + + ArrayRef< Ref > resultPoints(4); + resultPoints[0] = firstPoints[0]; + resultPoints[1] = firstPoints[1]; + resultPoints[2] = lastPoints[0]; + resultPoints[3] = lastPoints[1]; + + return Ref(new Result( + Ref(new String(resultingString)), + nullptr, + resultPoints, + BarcodeFormat::RSS_EXPANDED + )); +} + +bool RSSExpandedReader::checkChecksum() { + ExpandedPair firstPair = m_pairs[0]; + DataCharacter checkCharacter = firstPair.getLeftChar(); + DataCharacter firstCharacter = firstPair.getRightChar(); + + if (firstCharacter.getValue() == 0) { /////////////////////////////// + return false; + } + + int checksum = firstCharacter.getChecksumPortion(); + int s = 2; + + for (int i = 1; i < m_pairs.size(); ++i) { + ExpandedPair currentPair = m_pairs[i]; + checksum += currentPair.getLeftChar().getChecksumPortion(); + s++; + DataCharacter currentRightChar = currentPair.getRightChar(); ////////////////////////// + if (currentRightChar.getValue() == 0) { + checksum += currentRightChar.getChecksumPortion(); + s++; + } + } + + checksum %= 211; + + int checkCharacterValue = 211 * (s - 4) + checksum; + + return checkCharacterValue == checkCharacter.getValue(); +} + +int RSSExpandedReader::getNextSecondBar(Ref row, int initialPos) { + int currentPos; + if (row->get(initialPos)) { + currentPos = row->getNextUnset(initialPos); + currentPos = row->getNextSet(currentPos); + } else { + currentPos = row->getNextSet(initialPos); + currentPos = row->getNextUnset(currentPos); + } + return currentPos; +} + +ExpandedPair RSSExpandedReader::retrieveNextPair(Ref row, std::vector previousPairs, int rowNumber) +{ + bool isOddPattern = previousPairs.size() % 2 == 0; + if (m_startFromEven) { + isOddPattern = !isOddPattern; + } + + FinderPattern pattern; + + boolean keepFinding = true; + int forcedOffset = -1; + do { + findNextPair(row, previousPairs, forcedOffset); + pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern); + if (pattern.getValue() == 0) { /////////////////////////////////////////////////// + forcedOffset = getNextSecondBar(row, m_startEnd[0]); + } else { + keepFinding = false; + } + } while (keepFinding); + + // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not. + // boolean mayBeLast = checkPairSequence(previousPairs, pattern); + + DataCharacter leftChar = decodeDataCharacter(row, pattern, isOddPattern, true); + + if (!(previousPairs.size() == 0) && previousPairs[previousPairs.size() - 1].mustBeLast()) { + throw NotFoundException(); + } + + DataCharacter rightChar; + try { + rightChar = decodeDataCharacter(row, pattern, isOddPattern, false); + } catch (NotFoundException ignored) { + //rightChar = nullptr; + } + return ExpandedPair(leftChar, rightChar, pattern); +} + +void RSSExpandedReader::findNextPair(Ref row, std::vector previousPairs, int forcedOffset) +{ + std::vector counters = getDecodeFinderCounters(); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + + int width = row->getSize(); + + int rowOffset; + if (forcedOffset >= 0) { + rowOffset = forcedOffset; + } else if (previousPairs.size() == 0) { + rowOffset = 0; + } else { + ExpandedPair lastPair = previousPairs[previousPairs.size() - 1]; + rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; + } + boolean searchingEvenPair = previousPairs.size() % 2 != 0; + if (m_startFromEven) { + searchingEvenPair = !searchingEvenPair; + } + + boolean isWhite = false; + while (rowOffset < width) { + isWhite = !row->get(rowOffset); + if (!isWhite) { + break; + } + rowOffset++; + } + + int counterPosition = 0; + int patternStart = rowOffset; + for (int x = rowOffset; x < width; x++) { + if (row->get(x) != isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == 3) { + if (searchingEvenPair) { + std::reverse(counters.begin(), counters.end()); + // reverseCounters(counters); //////////////////////////////// + } + + if (isFinderPattern(counters)) { + m_startEnd[0] = patternStart; + m_startEnd[1] = x; + return; + } + + if (searchingEvenPair) { + std::reverse(counters.begin(), counters.end()); + // reverseCounters(counters); ////////////////////////////////// + } + + patternStart += counters[0] + counters[1]; + counters[0] = counters[2]; + counters[1] = counters[3]; + counters[2] = 0; + counters[3] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw NotFoundException(); +} + +FinderPattern RSSExpandedReader::parseFoundFinderPattern(Ref row, int rowNumber, bool oddPattern) { + // Actually we found elements 2-5. + int firstCounter; + int start; + int end; + + if (oddPattern) { + // If pattern number is odd, we need to locate element 1 *before* the current block. + + int firstElementStart = m_startEnd[0] - 1; + // Locate element 1 + while (firstElementStart >= 0 && !row->get(firstElementStart)) { + firstElementStart--; + } + + firstElementStart++; + firstCounter = m_startEnd[0] - firstElementStart; + start = firstElementStart; + end = m_startEnd[1]; + + } else { + // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block. + + start = m_startEnd[0]; + + end = row->getNextUnset(m_startEnd[1] + 1); + firstCounter = end - m_startEnd[1]; + } + + // Make 'counters' hold 1-4 + std::vector counters = getDecodeFinderCounters(); + + std::vector _counters = counters; + for (int i = 1; i < counters.size(); i++) { + counters[i] = _counters[i - 1]; + } + + // System.arraycopy(counters, 0, counters, 1, counters.length - 1); ///////////////////////// + + counters[0] = firstCounter; + int value; + try { + value = parseFinderValue(counters, FINDER_PATTERNS); + } catch (NotFoundException ignored) { + return FinderPattern(); + } + return FinderPattern(value, {start, end}, start, end, rowNumber); +} + +DataCharacter RSSExpandedReader::decodeDataCharacter(Ref row, FinderPattern pattern, bool isOddPattern, bool leftChar) +{ + std::vector counters = getDataCharacterCounters(); + for (int x = 0; x < counters.size(); x++) { + counters[x] = 0; + } + + if (leftChar) { + recordPattern(row, pattern.getStartEnd()[0], counters); ////////////////////////////// + } else { + recordPattern(row, pattern.getStartEnd()[1], counters); + // reverse it + for (int i = 0, j = counters.size() - 1; i < j; i++, j--) { + int temp = counters[i]; + counters[i] = counters[j]; + counters[j] = temp; + } + } //counters[] has the pixels of the module + + int numModules = 17; //left and right data characters have all the same length + float elementWidth = MathUtils::sum(counters) / (float) numModules; + + // Sanity check: element width for pattern and the character should match + float expectedElementWidth = (pattern.getStartEnd()[1] - pattern.getStartEnd()[0]) / 15.0f; + if (std::abs(elementWidth - expectedElementWidth) / expectedElementWidth > 0.3f) { + throw NotFoundException(); + } + + std::vector oddCounts = getOddCounts(); + std::vector evenCounts = getEvenCounts(); + std::vector oddRoundingErrors = getOddRoundingErrors(); + std::vector evenRoundingErrors = getEvenRoundingErrors(); + + for (int i = 0; i < counters.size(); i++) { + float value = 1.0f * counters[i] / elementWidth; + int count = (int) (value + 0.5f); // Round + if (count < 1) { + if (value < 0.3f) { + throw NotFoundException(); + } + count = 1; + } else if (count > 8) { + if (value > 8.7f) { + throw NotFoundException(); + } + count = 8; + } + int offset = i / 2; + if ((i & 0x01) == 0) { + oddCounts[offset] = count; + oddRoundingErrors[offset] = value - count; + } else { + evenCounts[offset] = count; + evenRoundingErrors[offset] = value - count; + } + } + + adjustOddEvenCounts(numModules); + + int weightRowNumber = 4 * pattern.getValue() + (isOddPattern ? 0 : 2) + (leftChar ? 0 : 1) - 1; + + int oddSum = 0; + int oddChecksumPortion = 0; + for (int i = oddCounts.size() - 1; i >= 0; i--) { + if (isNotA1left(pattern, isOddPattern, leftChar)) { + int weight = WEIGHTS[weightRowNumber][2 * i]; + oddChecksumPortion += oddCounts[i] * weight; + } + oddSum += oddCounts[i]; + } + int evenChecksumPortion = 0; + for (int i = evenCounts.size() - 1; i >= 0; i--) { + if (isNotA1left(pattern, isOddPattern, leftChar)) { + int weight = WEIGHTS[weightRowNumber][2 * i + 1]; + evenChecksumPortion += evenCounts[i] * weight; + } + } + int checksumPortion = oddChecksumPortion + evenChecksumPortion; + + if ((oddSum & 0x01) != 0 || oddSum > 13 || oddSum < 4) { + throw NotFoundException(); + } + + int group = (13 - oddSum) / 2; + int oddWidest = SYMBOL_WIDEST[group]; + int evenWidest = 9 - oddWidest; + int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, true); + int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, false); + int tEven = EVEN_TOTAL_SUBSET[group]; + int gSum = GSUM[group]; + int value = vOdd * tEven + vEven + gSum; + + return DataCharacter(value, checksumPortion); +} + +bool RSSExpandedReader::isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar) { + // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char + return !(pattern.getValue() == 0 && isOddPattern && leftChar); +} + +void RSSExpandedReader::adjustOddEvenCounts(int numModules){ + + int oddSum = MathUtils::sum(getOddCounts()); + int evenSum = MathUtils::sum(getEvenCounts()); + + boolean incrementOdd = false; + boolean decrementOdd = false; + + if (oddSum > 13) { + decrementOdd = true; + } else if (oddSum < 4) { + incrementOdd = true; + } + boolean incrementEven = false; + boolean decrementEven = false; + if (evenSum > 13) { + decrementEven = true; + } else if (evenSum < 4) { + incrementEven = true; + } + + int mismatch = oddSum + evenSum - numModules; + boolean oddParityBad = (oddSum & 0x01) == 1; + boolean evenParityBad = (evenSum & 0x01) == 0; + switch (mismatch) { + case 1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + decrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + decrementEven = true; + } + break; + case -1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + incrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + incrementEven = true; + } + break; + case 0: + if (oddParityBad) { + if (!evenParityBad) { + throw NotFoundException(); + } + // Both bad + if (oddSum < evenSum) { + incrementOdd = true; + decrementEven = true; + } else { + decrementOdd = true; + incrementEven = true; + } + } else { + if (evenParityBad) { + throw NotFoundException(); + } + // Nothing to do! + } + break; + default: + throw NotFoundException(); + } + + if (incrementOdd) { + if (decrementOdd) { + throw NotFoundException(); + } + increment(getOddCounts(), getOddRoundingErrors()); + } + if (decrementOdd) { + decrement(getOddCounts(), getOddRoundingErrors()); + } + if (incrementEven) { + if (decrementEven) { + throw NotFoundException(); + } + increment(getEvenCounts(), getOddRoundingErrors()); + } + if (decrementEven) { + decrement(getEvenCounts(), getEvenRoundingErrors()); + } +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h new file mode 100644 index 0000000..5b73a71 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h @@ -0,0 +1,128 @@ +#ifndef RSS_EXPANDED_READER_H +#define RSS_EXPANDED_READER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include +#include +#include "ExpandedPair.h" +#include "ExpandedRow.h" +#include "BitArrayBuilder.h" +#include "decoders/AbstractExpandedDecoder.h" + +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class RSSExpandedReader : public AbstractRSSReader +{ + +private: + std::vector m_pairs;// = new std::vector(MAX_PAIRS); + std::vector m_rows;// = new ArrayList<>(); + std::vector m_startEnd;// = new int[2]; + bool m_startFromEven; + +public: + Ref decodeRow(int rowNumber, + Ref row, + DecodeHints hints); + + void reset(); + + // Not private for testing + std::vector decodeRow2pairs(int rowNumber, Ref row); + + std::vector checkRows(boolean reverse); + + // Try to construct a valid rows sequence + // Recursion is used to implement backtracking + std::vector checkRows(std::vector collectedRows, int currentRow); + + // Whether the pairs form a valid find pattern sequence, + // either complete or a prefix + static boolean isValidSequence(std::vector pairs); + + void storeRow(int rowNumber, bool wasReversed); + + // Remove all the rows that contains only specified pairs + static void removePartialRows(std::vector pairs, std::vector rows); + + // Returns true when one of the rows already contains all the pairs + static bool isPartialRow(std::vector pairs, std::vector rows); + + // Only used for unit testing + std::vector getRows(); + + // Not private for unit testing + static Ref constructResult(std::vector pairs); + + bool checkChecksum(); + + static int getNextSecondBar(Ref row, int initialPos); + + // not private for testing + ExpandedPair retrieveNextPair(Ref row, std::vector previousPairs, int rowNumber); + + void findNextPair(Ref row, std::vector previousPairs, int forcedOffset); + + // private static void reverseCounters(int [] counters) { + // int length = counters.length; + // for (int i = 0; i < length / 2; ++i) { + // int tmp = counters[i]; + // counters[i] = counters[length - i - 1]; + // counters[length - i - 1] = tmp; + //} + //} + + FinderPattern parseFoundFinderPattern(Ref row, int rowNumber, bool oddPattern); + + DataCharacter decodeDataCharacter(Ref row, + FinderPattern pattern, + bool isOddPattern, + bool leftChar); + + static bool isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar); + + void adjustOddEvenCounts(int numModules); +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp new file mode 100644 index 0000000..0589ebf --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp @@ -0,0 +1,21 @@ +#include "AI013103decoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI013103decoder::AI013103decoder(Ref information) : AI013x0xDecoder(information) { +} + +void AI013103decoder::addWeightCode(String buf, int weight) { + buf.append("(3103)"); +} + +int AI013103decoder::checkWeight(int weight) { + return weight; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h new file mode 100644 index 0000000..fa2f169 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h @@ -0,0 +1,58 @@ +#ifndef AI013_103X_DECODER_H +#define AI013_103X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ +#include "AI013x0xDecoder.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class AI013103decoder : public AI013x0xDecoder +{ + +public: + AI013103decoder(Ref information); + +protected: + virtual void addWeightCode(String buf, int weight) override; + +protected: + virtual int checkWeight(int weight) override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp new file mode 100644 index 0000000..15e4e3f --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp @@ -0,0 +1,28 @@ +#include "AI01320xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01320xDecoder::AI01320xDecoder(Ref information) : AI013x0xDecoder(information) { +} + +void AI01320xDecoder::addWeightCode(String buf, int weight) { + if (weight < 10000) { + buf.append("(3202)"); + } else { + buf.append("(3203)"); + } +} + +int AI01320xDecoder::checkWeight(int weight) { + if (weight < 10000) { + return weight; + } + return weight - 10000; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h new file mode 100644 index 0000000..c96eef3 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h @@ -0,0 +1,58 @@ +#ifndef AI013_20X_DECODER_H +#define AI013_20X_DECODER_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI013x0xDecoder.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class AI01320xDecoder : public AI013x0xDecoder +{ + +public: + AI01320xDecoder(Ref information); + +protected: + virtual void addWeightCode(String buf, int weight) override; + + virtual int checkWeight(int weight) override; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp new file mode 100644 index 0000000..8eb57ed --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp @@ -0,0 +1,34 @@ +#include "AI01392xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01392xDecoder::AI01392xDecoder(Ref information) : AI01decoder(information) { +} + +String AI01392xDecoder::parseInformation() { + if (getInformation()->getSize() < HEADER_SIZE + GTIN_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + + int lastAIdigit = + getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); + buf.append("(392"); + buf.append(lastAIdigit); + buf.append(')'); + + DecodedInformation decodedInformation = + getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, String("")); + buf.append(decodedInformation.getNewString().getText()); + + return buf; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h new file mode 100644 index 0000000..018876b --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h @@ -0,0 +1,62 @@ +#ifndef AI013_392X_DECODER_H +#define AI013_393X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" +#include "DecodedInformation.h" +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ + +class AI01392xDecoder : public AI01decoder +{ + + static const int HEADER_SIZE = 5 + 1 + 2; + static const int LAST_DIGIT_SIZE = 2; +public: + AI01392xDecoder(Ref information); + + virtual String parseInformation() override; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp new file mode 100644 index 0000000..8282f0a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp @@ -0,0 +1,50 @@ +#include "AI01393xDecoder.h" + +#include "DecodedInformation.h" +#include +#include + +namespace zxing { +namespace oned { +namespace rss { + +AI01393xDecoder::AI01393xDecoder(Ref information) : AI01decoder(information) { +} + +String AI01393xDecoder::parseInformation() { + if (getInformation()->getSize() < HEADER_SIZE + GTIN_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + + int lastAIdigit = + getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); + + buf.append("(393"); + buf.append(lastAIdigit); + buf.append(')'); + + int firstThreeDigits = getGeneralDecoder().extractNumericValueFromBitArray( + HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE); + if (firstThreeDigits / 100 == 0) { + buf.append('0'); + } + if (firstThreeDigits / 10 == 0) { + buf.append('0'); + } + buf.append(firstThreeDigits); + + DecodedInformation generalInformation = getGeneralDecoder().decodeGeneralPurposeField( + HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, String("")); + buf.append(generalInformation.getNewString().getText()); + + return buf; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h new file mode 100644 index 0000000..7ed70a6 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h @@ -0,0 +1,59 @@ +#ifndef AI013_393X_DECODER_H +#define AI013_393X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ + +class AI01393xDecoder : public AI01decoder +{ + static const int HEADER_SIZE = 5 + 1 + 2; + static const int LAST_DIGIT_SIZE = 2; + static const int FIRST_THREE_DIGITS_SIZE = 10; + +public: + AI01393xDecoder(Ref information); + + virtual String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp new file mode 100644 index 0000000..100dd14 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp @@ -0,0 +1,70 @@ +#include "AI013x0x1xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI013x0x1xDecoder::AI013x0x1xDecoder(Ref information, String firstAIdigits, String dateCode) + : AI01weightDecoder(information), m_dateCode(dateCode), m_firstAIdigits(firstAIdigits) +{ + +} + +String AI013x0x1xDecoder::parseInformation() { + if (getInformation()->getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); + encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); + + return buf; +} + +void AI013x0x1xDecoder::encodeCompressedDate(String buf, int currentPos) { + int numericDate = getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE); + if (numericDate == 38400) { + return; + } + + buf.append('('); + buf.append(m_dateCode.getText()); + buf.append(')'); + + int day = numericDate % 32; + numericDate /= 32; + int month = numericDate % 12 + 1; + numericDate /= 12; + int year = numericDate; + + if (year / 10 == 0) { + buf.append('0'); + } + buf.append(year); + if (month / 10 == 0) { + buf.append('0'); + } + buf.append(month); + if (day / 10 == 0) { + buf.append('0'); + } + buf.append(day); +} + +void AI013x0x1xDecoder::addWeightCode(String buf, int weight) { + buf.append('('); + buf.append(m_firstAIdigits.getText()); + buf.append(weight / 100000); + buf.append(')'); +} + +int AI013x0x1xDecoder::checkWeight(int weight) { + return weight % 100000; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h new file mode 100644 index 0000000..df67bb2 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h @@ -0,0 +1,72 @@ +#ifndef AI013_X0X1X_DECODER_H +#define AI013_X0X1X_DECODER_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01weightDecoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ + +class AI013x0x1xDecoder : public AI01weightDecoder +{ + + static const int HEADER_SIZE = 7 + 1; + static const int WEIGHT_SIZE = 20; + static const int DATE_SIZE = 16; +public: + AI013x0x1xDecoder(Ref information, String firstAIdigits, String dateCode); + + virtual String parseInformation() override; + +private: + void encodeCompressedDate(String buf, int currentPos); + +protected: + virtual void addWeightCode(String buf, int weight) override; + + virtual int checkWeight(int weight) override; + +private: + String m_dateCode; + String m_firstAIdigits; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp new file mode 100644 index 0000000..a316615 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp @@ -0,0 +1,25 @@ +#include "AI013x0xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI013x0xDecoder::AI013x0xDecoder(Ref information) : AI01weightDecoder(information) { } + +String AI013x0xDecoder::parseInformation() { + if (getInformation()->getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); + + return buf; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h new file mode 100644 index 0000000..a25600d --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h @@ -0,0 +1,60 @@ +#ifndef AI013_X0X_DECODER_H +#define AI013_X0X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01weightDecoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ + +class AI013x0xDecoder : public AI01weightDecoder +{ + + static const int HEADER_SIZE = 4 + 1; + static const int WEIGHT_SIZE = 15; +public: + + AI013x0xDecoder(Ref information); + + virtual String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp new file mode 100644 index 0000000..03fed8c --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp @@ -0,0 +1,25 @@ +#include "AI01AndOtherAIs.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01AndOtherAIs::AI01AndOtherAIs(Ref information) : AI01decoder(information) { +} + +String AI01AndOtherAIs::parseInformation() { + String buff("(01)"); + + int initialGtinPosition = buff.length(); + int firstGtinDigit = getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4); + buff.append(firstGtinDigit); + + encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initialGtinPosition); + + return getGeneralDecoder().decodeAllCodes(buff, HEADER_SIZE + 44); +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h new file mode 100644 index 0000000..dd514e9 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h @@ -0,0 +1,60 @@ +#ifndef AI01_AND_OTHER_AIS_H +#define AI01_AND_OTHER_AIS_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" +#include +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ + +class AI01AndOtherAIs : public AI01decoder +{ + + static const int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag, + //the second one is the encodation method, and the other two are for the variable length +public: + AI01AndOtherAIs(Ref information); + + virtual String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp new file mode 100644 index 0000000..7764f8a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp @@ -0,0 +1,51 @@ +#include "AI01decoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01decoder::AI01decoder(Ref information) : AbstractExpandedDecoder(information){ +} + +void AI01decoder::encodeCompressedGtin(String buf, int currentPos) { + buf.append("(01)"); + int initialPosition = buf.length(); + buf.append('9'); + + encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition); +} + +void AI01decoder::encodeCompressedGtinWithoutAI(String buf, int currentPos, int initialBufferPosition) { + for (int i = 0; i < 4; ++i) { + int currentBlock = getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10); + if (currentBlock / 100 == 0) { + buf.append("0"); + } + if (currentBlock / 10 == 0) { + buf.append("0"); + } + buf.append(currentBlock); + } + + appendCheckDigit(buf, initialBufferPosition); +} + +void AI01decoder::appendCheckDigit(String buf, int currentPos) { + int checkDigit = 0; + for (int i = 0; i < 13; i++) { + int digit = buf.charAt(i + currentPos) - '0'; + checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; + } + + checkDigit = 10 - (checkDigit % 10); + if (checkDigit == 10) { + checkDigit = 0; + } + + buf.append(checkDigit); +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h new file mode 100644 index 0000000..5dcc1af --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h @@ -0,0 +1,63 @@ +#ifndef AI01_DECODER_H +#define AI01_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AbstractExpandedDecoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class AI01decoder : public AbstractExpandedDecoder +{ + +public: + static const int GTIN_SIZE = 40; + AI01decoder(Ref information); + + void encodeCompressedGtin(String buf, int currentPos); + + void encodeCompressedGtinWithoutAI(String buf, int currentPos, int initialBufferPosition); + + static void appendCheckDigit(String buf, int currentPos); + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp new file mode 100644 index 0000000..af68c08 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp @@ -0,0 +1,28 @@ +#include "AI01weightDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01weightDecoder::AI01weightDecoder(Ref information) : AI01decoder(information) { +} + +void AI01weightDecoder::encodeCompressedWeight(String buf, int currentPos, int weightSize) { + int originalWeightNumeric = getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); + addWeightCode(buf, originalWeightNumeric); + + int weightNumeric = checkWeight(originalWeightNumeric); + + int currentDivisor = 100000; + for (int i = 0; i < 5; ++i) { + if (weightNumeric / currentDivisor == 0) { + buf.append('0'); + } + currentDivisor /= 10; + } + buf.append(weightNumeric); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h new file mode 100644 index 0000000..a66463b --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h @@ -0,0 +1,60 @@ +#ifndef AI01_WEIGHT_DECODER_H +#define AI01_WEIGHT_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class AI01weightDecoder : public AI01decoder +{ +public: + AI01weightDecoder(Ref information); + + void encodeCompressedWeight(String buf, int currentPos, int weightSize); + +protected: + virtual void addWeightCode(String buf, int weight) = 0; + virtual int checkWeight(int weight) = 0; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp new file mode 100644 index 0000000..736a054 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp @@ -0,0 +1,69 @@ +#include "AbstractExpandedDecoder.h" + +#include "AI01AndOtherAIs.h" +#include "AI013x0x1xDecoder.h" +#include "AnyAIDecoder.h" +#include "AI013103decoder.h" +#include "AI01320xDecoder.h" +#include "AI01392xDecoder.h" +#include "AI01393xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AbstractExpandedDecoder::AbstractExpandedDecoder(Ref information) + : m_information(information), m_generalDecoder(GeneralAppIdDecoder(information)) +{ + +} + +Ref AbstractExpandedDecoder::getInformation() { + return m_information; +} + +GeneralAppIdDecoder AbstractExpandedDecoder::getGeneralDecoder() +{ + return m_generalDecoder; +} + +AbstractExpandedDecoder *AbstractExpandedDecoder::createDecoder(Ref information) { + if (information->get(1)) { + return new AI01AndOtherAIs(information); + } + if (!information->get(2)) { + return new AnyAIDecoder(information); + } + + int fourBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 4); + + switch (fourBitEncodationMethod) { + case 4: return new AI013103decoder(information); + case 5: return new AI01320xDecoder(information); + } + + int fiveBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 5); + switch (fiveBitEncodationMethod) { + case 12: return new AI01392xDecoder(information); + //case 13: return new AI01393xDecoder(information); + } + + int sevenBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 7); + switch (sevenBitEncodationMethod) { + case 56: return new AI013x0x1xDecoder(information, String("310"), String("11")); + case 57: return new AI013x0x1xDecoder(information, String("320"), String("11")); + case 58: return new AI013x0x1xDecoder(information, String("310"), String("13")); + case 59: return new AI013x0x1xDecoder(information, String("320"), String("13")); + case 60: return new AI013x0x1xDecoder(information, String("310"), String("15")); + case 61: return new AI013x0x1xDecoder(information, String("320"), String("15")); + case 62: return new AI013x0x1xDecoder(information, String("310"), String("17")); + case 63: return new AI013x0x1xDecoder(information, String("320"), String("17")); + } + + throw IllegalStateException(); +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h new file mode 100644 index 0000000..2f7d773 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h @@ -0,0 +1,70 @@ +#ifndef ABSTRACT_EXPANDED_DECODER_H +#define ABSTRACT_EXPANDED_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "GeneralAppIdDecoder.h" +#include +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class AbstractExpandedDecoder +{ + +public: + AbstractExpandedDecoder(Ref information); + + Ref getInformation(); + + virtual GeneralAppIdDecoder getGeneralDecoder(); + + virtual String parseInformation() = 0; + + static AbstractExpandedDecoder* createDecoder(Ref information); + +protected: + Ref m_information; + GeneralAppIdDecoder m_generalDecoder; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp new file mode 100644 index 0000000..349e24c --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp @@ -0,0 +1,17 @@ +#include "AnyAIDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AnyAIDecoder::AnyAIDecoder(Ref information) : AbstractExpandedDecoder(information) { } + +String AnyAIDecoder::parseInformation() { + String buf(""); + return getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE); +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h new file mode 100644 index 0000000..947f309 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h @@ -0,0 +1,60 @@ +#ifndef ANY_AI_DECODER_H +#define ANY_AI_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include +#include +#include "AbstractExpandedDecoder.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ + +class AnyAIDecoder : public AbstractExpandedDecoder +{ + static const int HEADER_SIZE = 2 + 1 + 2; + +public: + AnyAIDecoder(Ref information); + + String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp new file mode 100644 index 0000000..345c206 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp @@ -0,0 +1,31 @@ +#include "BlockParsedResult.h" + +namespace zxing { +namespace oned { +namespace rss { + +BlockParsedResult::BlockParsedResult(bool finished) : m_decodedInformation(nullptr), m_finished(finished) { +} + +BlockParsedResult::BlockParsedResult(const DecodedInformation &information, bool finished) { + m_finished = finished; + m_decodedInformation = information; +} + +BlockParsedResult::BlockParsedResult(const BlockParsedResult &other) { + m_finished = other.m_finished; + m_decodedInformation = other.m_decodedInformation; +} + +DecodedInformation BlockParsedResult::getDecodedInformation() { + return m_decodedInformation; +} + +bool BlockParsedResult::isFinished() { + return m_finished; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h new file mode 100644 index 0000000..79b4786 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h @@ -0,0 +1,65 @@ +#ifndef BLOCK_PARSED_RESULT_H +#define BLOCK_PARSED_RESULT_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedInformation.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class BlockParsedResult +{ + +public: + + BlockParsedResult(bool finished); + + BlockParsedResult(const DecodedInformation& information, bool finished); + + BlockParsedResult(const BlockParsedResult& other); + + DecodedInformation getDecodedInformation(); + + bool isFinished(); + +private: + DecodedInformation m_decodedInformation; + bool m_finished; +}; + +} +} +} +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp new file mode 100644 index 0000000..8f6f81f --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp @@ -0,0 +1,51 @@ +#include "CurrentParsingState.h" + +namespace zxing { +namespace oned { +namespace rss { + +CurrentParsingState::CurrentParsingState() { + position = 0; + encoding = State::NUMERIC; +} + +int CurrentParsingState::getPosition() { + return position; +} + +void CurrentParsingState::setPosition(int _position) { + position = _position; +} + +void CurrentParsingState::incrementPosition(int delta) { + position += delta; +} + +bool CurrentParsingState::isAlpha() { + return encoding == State::ALPHA; +} + +bool CurrentParsingState::isNumeric() { + return encoding == State::NUMERIC; +} + +bool CurrentParsingState::isIsoIec646() { + return encoding == State::ISO_IEC_646; +} + +void CurrentParsingState::setNumeric() { + encoding = State::NUMERIC; +} + +void CurrentParsingState::setAlpha() { + encoding = State::ALPHA; +} + +void CurrentParsingState::setIsoIec646() { + encoding = State::ISO_IEC_646; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h new file mode 100644 index 0000000..2b155f8 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h @@ -0,0 +1,78 @@ +#ifndef CURRENT_PARSING_STATE_H +#define CURRENT_PARSING_STATE_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class CurrentParsingState +{ +public: + enum State { + NUMERIC, + ALPHA, + ISO_IEC_646 + }; + + CurrentParsingState(); + + int getPosition(); + + void setPosition(int _position); + + void incrementPosition(int delta); + + bool isAlpha(); + + bool isNumeric(); + + bool isIsoIec646(); + + void setNumeric(); + + void setAlpha(); + + void setIsoIec646(); + +private: + int position; + State encoding; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp new file mode 100644 index 0000000..80bfd4e --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp @@ -0,0 +1,21 @@ +#include "DecodedChar.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedChar::DecodedChar(int newPosition, char value) : DecodedObject (newPosition) { + m_value = value; +} + +char DecodedChar::getValue() { + return m_value; +} + +bool DecodedChar::isFNC1() { + return m_value == FNC1; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h new file mode 100644 index 0000000..c98841c --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h @@ -0,0 +1,61 @@ +#ifndef DECODED_CHAR_H +#define DECODED_CHAR_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedObject.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class DecodedChar : public DecodedObject +{ +public: + static const char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset + DecodedChar(int newPosition, char value); + + char getValue(); + + bool isFNC1(); + +private: + char m_value; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp new file mode 100644 index 0000000..d0e2cba --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp @@ -0,0 +1,47 @@ +#include "DecodedInformation.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedInformation::DecodedInformation(const DecodedInformation *other) : + DecodedObject (other->m_newPosition), + m_newString(other->m_newString) +{ + m_newString = other->m_newString; + m_remaining = other->m_remaining; + m_remainingValue = other->m_remainingValue; +} + +DecodedInformation::DecodedInformation(int newPosition, String newString) : + DecodedObject (newPosition), + m_newString(newString) +{ + m_remaining = false; + m_remainingValue = 0; +} + +DecodedInformation::DecodedInformation(int newPosition, String newString, int remainingValue) : + DecodedObject (newPosition), + m_newString(newString) +{ + m_remaining = true; + m_remainingValue = remainingValue; +} + +String DecodedInformation::getNewString() { + return m_newString; +} + +bool DecodedInformation::isRemaining() { + return m_remaining; +} + +int DecodedInformation::getRemainingValue() { + return m_remainingValue; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h new file mode 100644 index 0000000..7f6e2e5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h @@ -0,0 +1,69 @@ +#ifndef DECODED_INFORMATION_H +#define DECODED_INFORMATION_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedObject.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class DecodedInformation : public DecodedObject +{ +public: + + DecodedInformation(const DecodedInformation* other = nullptr); + + DecodedInformation(int newPosition, String newString); + + DecodedInformation(int newPosition, String newString, int remainingValue); + + String getNewString(); + + bool isRemaining(); + + int getRemainingValue(); + +private: + String m_newString; + int m_remainingValue; + bool m_remaining; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp new file mode 100644 index 0000000..5bfb859 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp @@ -0,0 +1,41 @@ +#include "DecodedNumeric.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedNumeric::DecodedNumeric(int newPosition, int firstDigit, int secondDigit) + : DecodedObject(newPosition) { + + if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) { + throw FormatException::getFormatInstance(); + } + + m_newPosition = newPosition; + m_firstDigit = firstDigit; + m_secondDigit = secondDigit; +} + +int DecodedNumeric::getFirstDigit() { + return m_firstDigit; +} + +int DecodedNumeric::getSecondDigit() { + return m_secondDigit; +} + +int DecodedNumeric::getValue() { + return m_firstDigit * 10 + m_secondDigit; +} + +bool DecodedNumeric::isFirstDigitFNC1() { + return m_firstDigit == FNC1; +} + +bool DecodedNumeric::isSecondDigitFNC1() { + return m_secondDigit == FNC1; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h new file mode 100644 index 0000000..1f6f5a5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h @@ -0,0 +1,71 @@ +#ifndef DECODED_NUMERIC_H +#define DECODED_NUMERIC_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include "DecodedObject.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ + +class DecodedNumeric : public DecodedObject +{ + +public: + static const int FNC1 = 10; + DecodedNumeric(int newPosition, int firstDigit, int secondDigit); + + int getFirstDigit(); + + int getSecondDigit(); + + int getValue(); + + bool isFirstDigitFNC1(); + + bool isSecondDigitFNC1(); + +private: + int m_firstDigit; + int m_secondDigit; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp new file mode 100644 index 0000000..c116c13 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp @@ -0,0 +1,16 @@ +#include "DecodedObject.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedObject::DecodedObject(int newPosition) : m_newPosition(newPosition) { } + +int DecodedObject::getNewPosition() { + return m_newPosition; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h new file mode 100644 index 0000000..5f3f060 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h @@ -0,0 +1,52 @@ +#ifndef DECODED_OBJECT_H +#define DECODED_OBJECT_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ +namespace zxing { + +namespace oned { + +namespace rss { +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class DecodedObject +{ + +public: + DecodedObject(int newPosition); + + int getNewPosition(); + +protected: + int m_newPosition; +}; + +} +} +} +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp new file mode 100644 index 0000000..40cca69 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp @@ -0,0 +1,276 @@ +#include "FieldParser.h" + +namespace zxing { +namespace oned { +namespace rss { + +static const int VARIABLE_LENGTH = 99999; + +struct DigitData { + std::string digit; + int variableLength; + int length; +}; + +static const DigitData TWO_DIGIT_DATA_LENGTH[] { + // "DIGITS", new Integer(LENGTH) + // or + // "DIGITS", VARIABLE_LENGTH, new Integer(MAX_SIZE) + + { "00", 0, 18}, + { "01", 0, 14}, + { "02", 0, 14}, + + { "10", VARIABLE_LENGTH, 20}, + { "11", 0, 6}, + { "12", 0, 6}, + { "13", 0, 6}, + { "15", 0, 6}, + { "17", 0, 6}, + + { "20", 0, 2}, + { "21", VARIABLE_LENGTH, 20}, + { "22", VARIABLE_LENGTH, 29}, + + { "30", VARIABLE_LENGTH, 8}, + { "37", VARIABLE_LENGTH, 8}, + + //internal company codes + { "90", VARIABLE_LENGTH, 30}, + { "91", VARIABLE_LENGTH, 30}, + { "92", VARIABLE_LENGTH, 30}, + { "93", VARIABLE_LENGTH, 30}, + { "94", VARIABLE_LENGTH, 30}, + { "95", VARIABLE_LENGTH, 30}, + { "96", VARIABLE_LENGTH, 30}, + { "97", VARIABLE_LENGTH, 30}, + { "98", VARIABLE_LENGTH, 30}, + { "99", VARIABLE_LENGTH, 30}, +}; + +static const DigitData THREE_DIGIT_DATA_LENGTH[] { + // Same format as above + + { "240", VARIABLE_LENGTH, 30}, + { "241", VARIABLE_LENGTH, 30}, + { "242", VARIABLE_LENGTH, 6}, + { "250", VARIABLE_LENGTH, 30}, + { "251", VARIABLE_LENGTH, 30}, + { "253", VARIABLE_LENGTH, 17}, + { "254", VARIABLE_LENGTH, 20}, + + { "400", VARIABLE_LENGTH, 30}, + { "401", VARIABLE_LENGTH, 30}, + { "402", 0, 17}, + { "403", VARIABLE_LENGTH, 30}, + { "410", 0, 13}, + { "411", 0, 13}, + { "412", 0, 13}, + { "413", 0, 13}, + { "414", 0, 13}, + { "420", VARIABLE_LENGTH, 20}, + { "421", VARIABLE_LENGTH, 15}, + { "422", 0, 3}, + { "423", VARIABLE_LENGTH, 15}, + { "424", 0, 3}, + { "425", 0, 3}, + { "426", 0, 3}, +}; + +static const DigitData THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH[] { + // Same format as above + + { "310", 0, 6}, + { "311", 0, 6}, + { "312", 0, 6}, + { "313", 0, 6}, + { "314", 0, 6}, + { "315", 0, 6}, + { "316", 0, 6}, + { "320", 0, 6}, + { "321", 0, 6}, + { "322", 0, 6}, + { "323", 0, 6}, + { "324", 0, 6}, + { "325", 0, 6}, + { "326", 0, 6}, + { "327", 0, 6}, + { "328", 0, 6}, + { "329", 0, 6}, + { "330", 0, 6}, + { "331", 0, 6}, + { "332", 0, 6}, + { "333", 0, 6}, + { "334", 0, 6}, + { "335", 0, 6}, + { "336", 0, 6}, + { "340", 0, 6}, + { "341", 0, 6}, + { "342", 0, 6}, + { "343", 0, 6}, + { "344", 0, 6}, + { "345", 0, 6}, + { "346", 0, 6}, + { "347", 0, 6}, + { "348", 0, 6}, + { "349", 0, 6}, + { "350", 0, 6}, + { "351", 0, 6}, + { "352", 0, 6}, + { "353", 0, 6}, + { "354", 0, 6}, + { "355", 0, 6}, + { "356", 0, 6}, + { "357", 0, 6}, + { "360", 0, 6}, + { "361", 0, 6}, + { "362", 0, 6}, + { "363", 0, 6}, + { "364", 0, 6}, + { "365", 0, 6}, + { "366", 0, 6}, + { "367", 0, 6}, + { "368", 0, 6}, + { "369", 0, 6}, + { "390", VARIABLE_LENGTH, 15}, + { "391", VARIABLE_LENGTH, 18}, + { "392", VARIABLE_LENGTH, 15}, + { "393", VARIABLE_LENGTH, 18}, + { "703", VARIABLE_LENGTH, 30}, +}; + +static const DigitData FOUR_DIGIT_DATA_LENGTH[] { + // Same format as above + + { "7001", 0, 13}, + { "7002", VARIABLE_LENGTH, 30}, + { "7003", 0, 10}, + + { "8001", 0, 14}, + { "8002", VARIABLE_LENGTH, 20}, + { "8003", VARIABLE_LENGTH, 30}, + { "8004", VARIABLE_LENGTH, 30}, + { "8005", 0, 6}, + { "8006", 0, 18}, + { "8007", VARIABLE_LENGTH, 30}, + { "8008", VARIABLE_LENGTH, 12}, + { "8018", 0, 18}, + { "8020", VARIABLE_LENGTH, 25}, + { "8100", 0, 6}, + { "8101", 0, 10}, + { "8102", 0, 2}, + { "8110", VARIABLE_LENGTH, 70}, + { "8200", VARIABLE_LENGTH, 70}, +}; + +FieldParser::FieldParser() { +} + +String FieldParser::parseFieldsInGeneralPurpose(String rawInformation) { + if (rawInformation.getText().empty()) { + return String(""); + } + + // Processing 2-digit AIs + + if (rawInformation.length() < 2) { + throw NotFoundException(); + } + + String firstTwoDigits(rawInformation.substring(0, 2)->getText()); + + for (DigitData dataLength : TWO_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstTwoDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(2, dataLength.length, rawInformation); + } + return processFixedAI(2, dataLength.length, rawInformation); + } + } + + if (rawInformation.length() < 3) { + throw NotFoundException(); + } + + String firstThreeDigits(rawInformation.substring(0, 3)->getText()); + + for (DigitData dataLength : THREE_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstThreeDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(3, dataLength.length, rawInformation); + } + return processFixedAI(3, dataLength.length, rawInformation); + } + } + + + for (DigitData dataLength : THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstThreeDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(4, dataLength.length, rawInformation); + } + return processFixedAI(4, dataLength.length, rawInformation); + } + } + + if (rawInformation.length() < 4) { + throw NotFoundException(); + } + + String firstFourDigits(rawInformation.substring(0, 4)->getText()); + + for (DigitData dataLength : FOUR_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstFourDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(4, dataLength.length, rawInformation); + } + return processFixedAI(4, dataLength.length, rawInformation); + } + } + + throw NotFoundException(); +} + +String FieldParser::processFixedAI(int aiSize, int fieldSize, String rawInformation) +{ + if (rawInformation.length() < aiSize) { + throw NotFoundException(); + } + + String ai(rawInformation.substring(0, aiSize)->getText()); + + if (rawInformation.length() < aiSize + fieldSize) { + throw NotFoundException(); + } + + String field(rawInformation.substring(aiSize, aiSize + fieldSize)->getText()); + String remaining(rawInformation.substring(aiSize + fieldSize, 0)->getText()); + String result('(' + ai.getText() + ')' + field.getText()); + String parsedAI = parseFieldsInGeneralPurpose(remaining); + if (parsedAI.getText() == "") { + return result; + } else { + result.append(parsedAI.getText()); + return result; + } +} + +String FieldParser::processVariableAI(int aiSize, int variableFieldSize, String rawInformation) +{ + String ai(rawInformation.substring(0, aiSize)->getText()); + int maxSize = std::min(rawInformation.length(), aiSize + variableFieldSize); + String field(rawInformation.substring(aiSize, maxSize)->getText()); + String remaining(rawInformation.substring(maxSize, 0)->getText()); + String result('(' + ai.getText() + ')' + field.getText()); + String parsedAI = parseFieldsInGeneralPurpose(remaining); + if (parsedAI.getText() == "") { + return result; + } else { + result.append(parsedAI.getText()); + return result; + } +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h new file mode 100644 index 0000000..a5bd3bd --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h @@ -0,0 +1,66 @@ +#ifndef FIELD_PARSER_H +#define FIELD_PARSER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ + + +class FieldParser +{ + +public: + + FieldParser(); + + static String parseFieldsInGeneralPurpose(String rawInformation); + + static String processFixedAI(int aiSize, int fieldSize, String rawInformation); + + static String processVariableAI(int aiSize, int variableFieldSize, String rawInformation); +}; + +} +} +} + +#endif + diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp new file mode 100644 index 0000000..3d03553 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp @@ -0,0 +1,447 @@ +#include "GeneralAppIdDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +GeneralAppIdDecoder::GeneralAppIdDecoder(Ref information) : m_buffer("") { + m_information = information; +} + +String GeneralAppIdDecoder::decodeAllCodes(String buff, int initialPosition) { + int currentPosition = initialPosition; + String remaining(""); + do { + DecodedInformation info(decodeGeneralPurposeField(currentPosition, remaining)); + String parsedFields = FieldParser::parseFieldsInGeneralPurpose(info.getNewString()); + if (parsedFields.length() > 0) { + buff.append(parsedFields.getText()); + } + if (info.isRemaining()) { + remaining = String(info.getRemainingValue()); + } else { + remaining = String(""); + } + + if (currentPosition == info.getNewPosition()) { // No step forward! + break; + } + currentPosition = info.getNewPosition(); + } while (true); + + return buff; +} + +bool GeneralAppIdDecoder::isStillNumeric(int pos) { + // It's numeric if it still has 7 positions + // and one of the first 4 bits is "1". + if (pos + 7 > m_information->getSize()) { + return pos + 4 <= m_information->getSize(); + } + + for (int i = pos; i < pos + 3; ++i) { + if (m_information->get(i)) { + return true; + } + } + + return m_information->get(pos + 3); +} + +DecodedNumeric GeneralAppIdDecoder::decodeNumeric(int pos) +{ + if (pos + 7 > m_information->getSize()) { + int numeric = extractNumericValueFromBitArray(pos, 4); + if (numeric == 0) { + return DecodedNumeric(m_information->getSize(), DecodedNumeric::FNC1, DecodedNumeric::FNC1); + } + return DecodedNumeric(m_information->getSize(), numeric - 1, DecodedNumeric::FNC1); + } + int numeric = extractNumericValueFromBitArray(pos, 7); + + int digit1 = (numeric - 8) / 11; + int digit2 = (numeric - 8) % 11; + + return DecodedNumeric(pos + 7, digit1, digit2); +} + +int GeneralAppIdDecoder::extractNumericValueFromBitArray(int pos, int bits) { + return extractNumericValueFromBitArray(m_information, pos, bits); +} + +int GeneralAppIdDecoder::extractNumericValueFromBitArray(Ref information, int pos, int bits) { + int value = 0; + for (int i = 0; i < bits; ++i) { + if (information->get(pos + i)) { + value |= 1 << (bits - i - 1); + } + } + + return value; +} + +DecodedInformation GeneralAppIdDecoder::decodeGeneralPurposeField(int pos, String remaining){ + m_buffer = String(""); + + if (remaining.length() > 0) { + m_buffer.append(remaining.getText()); + } + + m_current.setPosition(pos); + + DecodedInformation lastDecoded(parseBlocks()); + if (lastDecoded.getNewString().length() > 0 && lastDecoded.isRemaining()) { /////////////////// + return DecodedInformation(m_current.getPosition(), m_buffer, lastDecoded.getRemainingValue()); + } + return DecodedInformation(m_current.getPosition(), m_buffer); +} + +DecodedInformation GeneralAppIdDecoder::parseBlocks() +{ + bool isFinished; + BlockParsedResult result(false); + do { + int initialPosition = m_current.getPosition(); + + if (m_current.isAlpha()) { + result = parseAlphaBlock(); + isFinished = result.isFinished(); + } else if (m_current.isIsoIec646()) { + result = parseIsoIec646Block(); + isFinished = result.isFinished(); + } else { // it must be numeric + result = parseNumericBlock(); + isFinished = result.isFinished(); + } + + boolean positionChanged = initialPosition != m_current.getPosition(); + if (!positionChanged && !isFinished) { + break; + } + } while (!isFinished); + + return result.getDecodedInformation(); +} + +BlockParsedResult GeneralAppIdDecoder::parseNumericBlock(){ + while (isStillNumeric(m_current.getPosition())) { + DecodedNumeric numeric = decodeNumeric(m_current.getPosition()); + m_current.setPosition(numeric.getNewPosition()); + + if (numeric.isFirstDigitFNC1()) { + DecodedInformation information(0, String("")); //////////////// + if (numeric.isSecondDigitFNC1()) { + // information = DecodedInformation(m_current.getPosition(), m_buffer.getText()); ///////////////// + return new BlockParsedResult(DecodedInformation(m_current.getPosition(), m_buffer), true); + } else { + // information = new DecodedInformation(m_current.getPosition(), m_buffer.getText(), numeric.getSecondDigit()); + return new BlockParsedResult(DecodedInformation(m_current.getPosition(), m_buffer, numeric.getSecondDigit()), true); + } + } + m_buffer.append(numeric.getFirstDigit()); + + if (numeric.isSecondDigitFNC1()) { + DecodedInformation information(m_current.getPosition(), m_buffer); + return new BlockParsedResult(information, true); + } + m_buffer.append(numeric.getSecondDigit()); + } + + if (isNumericToAlphaNumericLatch(m_current.getPosition())) { + m_current.setAlpha(); + m_current.incrementPosition(4); + } + return new BlockParsedResult(false); +} + +BlockParsedResult GeneralAppIdDecoder::parseIsoIec646Block() +{ + while (isStillIsoIec646(m_current.getPosition())) { + DecodedChar iso = decodeIsoIec646(m_current.getPosition()); + m_current.setPosition(iso.getNewPosition()); + + if (iso.isFNC1()) { + DecodedInformation information(m_current.getPosition(), m_buffer); + return new BlockParsedResult(information, true); + } + m_buffer.append(iso.getValue()); + } + + if (isAlphaOr646ToNumericLatch(m_current.getPosition())) { + m_current.incrementPosition(3); + m_current.setNumeric(); + } else if (isAlphaTo646ToAlphaLatch(m_current.getPosition())) { + if (m_current.getPosition() + 5 < m_information->getSize()) { + m_current.incrementPosition(5); + } else { + m_current.setPosition(m_information->getSize()); + } + + m_current.setAlpha(); + } + return new BlockParsedResult(false); +} + +BlockParsedResult GeneralAppIdDecoder::parseAlphaBlock() +{ + while (isStillAlpha(m_current.getPosition())) { + DecodedChar alpha(decodeAlphanumeric(m_current.getPosition())); + m_current.setPosition(alpha.getNewPosition()); + + if (alpha.isFNC1()) { + DecodedInformation information(m_current.getPosition(), m_buffer); + return new BlockParsedResult(information, true); //end of the char block + } + + m_buffer.append(alpha.getValue()); + } + + if (isAlphaOr646ToNumericLatch(m_current.getPosition())) { + m_current.incrementPosition(3); + m_current.setNumeric(); + } else if (isAlphaTo646ToAlphaLatch(m_current.getPosition())) { + if (m_current.getPosition() + 5 < m_information->getSize()) { + m_current.incrementPosition(5); + } else { + m_current.setPosition(m_information->getSize()); + } + + m_current.setIsoIec646(); + } + return new BlockParsedResult(false); +} + +bool GeneralAppIdDecoder::isStillIsoIec646(int pos) +{ + if (pos + 5 > m_information->getSize()) { + return false; + } + + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue >= 5 && fiveBitValue < 16) { + return true; + } + + if (pos + 7 > m_information->getSize()) { + return false; + } + + int sevenBitValue = extractNumericValueFromBitArray(pos, 7); + if (sevenBitValue >= 64 && sevenBitValue < 116) { + return true; + } + + if (pos + 8 > m_information->getSize()) { + return false; + } + + int eightBitValue = extractNumericValueFromBitArray(pos, 8); + return eightBitValue >= 232 && eightBitValue < 253; +} + +DecodedChar GeneralAppIdDecoder::decodeIsoIec646(int pos) +{ + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue == 15) { + return DecodedChar(pos + 5, DecodedChar::FNC1); //////////// + } + + if (fiveBitValue >= 5 && fiveBitValue < 15) { + return DecodedChar(pos + 5, static_cast('0' + fiveBitValue - 5)); + } + + int sevenBitValue = extractNumericValueFromBitArray(pos, 7); + + if (sevenBitValue >= 64 && sevenBitValue < 90) { + return DecodedChar(pos + 7, static_cast(sevenBitValue + 1)); + } + + if (sevenBitValue >= 90 && sevenBitValue < 116) { + return DecodedChar(pos + 7, static_cast(sevenBitValue + 7)); + } + + int eightBitValue = extractNumericValueFromBitArray(pos, 8); + char c; + switch (eightBitValue) { + case 232: + c = '!'; + break; + case 233: + c = '"'; + break; + case 234: + c = '%'; + break; + case 235: + c = '&'; + break; + case 236: + c = '\''; + break; + case 237: + c = '('; + break; + case 238: + c = ')'; + break; + case 239: + c = '*'; + break; + case 240: + c = '+'; + break; + case 241: + c = ','; + break; + case 242: + c = '-'; + break; + case 243: + c = '.'; + break; + case 244: + c = '/'; + break; + case 245: + c = ':'; + break; + case 246: + c = ';'; + break; + case 247: + c = '<'; + break; + case 248: + c = '='; + break; + case 249: + c = '>'; + break; + case 250: + c = '?'; + break; + case 251: + c = '_'; + break; + case 252: + c = ' '; + break; + default: + throw FormatException::getFormatInstance(); + } + return DecodedChar(pos + 8, c); +} + +bool GeneralAppIdDecoder::isStillAlpha(int pos) +{ + if (pos + 5 > m_information->getSize()) { + return false; + } + + // We now check if it's a valid 5-bit value (0..9 and FNC1) + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue >= 5 && fiveBitValue < 16) { + return true; + } + + if (pos + 6 > m_information->getSize()) { + return false; + } + + int sixBitValue = extractNumericValueFromBitArray(pos, 6); + return sixBitValue >= 16 && sixBitValue < 63; // 63 not included +} + +DecodedChar GeneralAppIdDecoder::decodeAlphanumeric(int pos) +{ + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue == 15) { + return DecodedChar(pos + 5, DecodedChar::FNC1); + } + + if (fiveBitValue >= 5 && fiveBitValue < 15) { + return DecodedChar(pos + 5, static_cast('0' + fiveBitValue - 5)); + } + + int sixBitValue = extractNumericValueFromBitArray(pos, 6); + + if (sixBitValue >= 32 && sixBitValue < 58) { + return DecodedChar(pos + 6, static_cast(sixBitValue + 33)); + } + + char c; + switch (sixBitValue) { + case 58: + c = '*'; + break; + case 59: + c = ','; + break; + case 60: + c = '-'; + break; + case 61: + c = '.'; + break; + case 62: + c = '/'; + break; + default: + throw new IllegalStateException("Decoding invalid alphanumeric value: " + sixBitValue); + } + return DecodedChar(pos + 6, c); +} + +boolean GeneralAppIdDecoder::isAlphaTo646ToAlphaLatch(int pos) +{ + if (pos + 1 > m_information->getSize()) { + return false; + } + + for (int i = 0; i < 5 && i + pos < m_information->getSize(); ++i) { + if (i == 2) { + if (!m_information->get(pos + 2)) { + return false; + } + } else if (m_information->get(pos + i)) { + return false; + } + } + + return true; +} + +boolean GeneralAppIdDecoder::isAlphaOr646ToNumericLatch(int pos) +{ + // Next is alphanumeric if there are 3 positions and they are all zeros + if (pos + 3 > m_information->getSize()) { + return false; + } + + for (int i = pos; i < pos + 3; ++i) { + if (m_information->get(i)) { + return false; + } + } + return true; +} + +boolean GeneralAppIdDecoder::isNumericToAlphaNumericLatch(int pos) { + // Next is alphanumeric if there are 4 positions and they are all zeros, or + // if there is a subset of this just before the end of the symbol + if (pos + 1 > m_information->getSize()) { + return false; + } + + for (int i = 0; i < 4 && i + pos < m_information->getSize(); ++i) { + if (m_information->get(pos + i)) { + return false; + } + } + return true; +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h new file mode 100644 index 0000000..9c84dae --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h @@ -0,0 +1,101 @@ +#ifndef GENERAL_APP_ID_DECODER_H +#define GENERAL_APP_ID_DECODER_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include +#include +#include +#include "CurrentParsingState.h" +#include "DecodedInformation.h" +#include "DecodedNumeric.h" +#include "FieldParser.h" +#include "BlockParsedResult.h" +#include "DecodedChar.h" + +// VC++ +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) + */ +class GeneralAppIdDecoder +{ + +public: + GeneralAppIdDecoder(Ref information); + + String decodeAllCodes(String buff, int initialPosition); + + bool isStillNumeric(int pos); + + DecodedNumeric decodeNumeric(int pos); + + int extractNumericValueFromBitArray(int pos, int bits); + + static int extractNumericValueFromBitArray(Ref information, int pos, int bits); + + DecodedInformation decodeGeneralPurposeField(int pos, String remaining); + + DecodedInformation parseBlocks(); + + BlockParsedResult parseNumericBlock(); + + BlockParsedResult parseIsoIec646Block(); + + BlockParsedResult parseAlphaBlock(); + + bool isStillIsoIec646(int pos); + + DecodedChar decodeIsoIec646(int pos); + + bool isStillAlpha(int pos); + + DecodedChar decodeAlphanumeric(int pos); + + boolean isAlphaTo646ToAlphaLatch(int pos); + + boolean isAlphaOr646ToNumericLatch(int pos); + + boolean isNumericToAlphaNumericLatch(int pos); + +private: + Ref m_information; + CurrentParsingState m_current; + String m_buffer; + +}; +} +} +} + +#endif From 8bf0bd08b199e048995589cb71d5f5679c0d437a Mon Sep 17 00:00:00 2001 From: Eism Date: Sun, 7 Jul 2019 12:04:37 +0200 Subject: [PATCH 67/83] Revert "rss verssion 0.1" This reverts commit a177fe97d19fe6c1096b4005d063ecc532644ddc. --- examples/QZXingLive/main.qml | 2 +- src/QZXing.pri | 62 +- src/zxing/zxing/DecodeHints.h | 2 +- src/zxing/zxing/common/Str.cpp | 4 +- src/zxing/zxing/common/Str.h | 2 +- src/zxing/zxing/common/detector/MathUtils.h | 9 - .../zxing/oned/MultiFormatOneDReader.cpp | 17 +- .../zxing/oned/rss/AbstractRSSReader.cpp | 101 --- src/zxing/zxing/oned/rss/AbstractRSSReader.h | 101 --- src/zxing/zxing/oned/rss/DataCharacter.cpp | 44 -- src/zxing/zxing/oned/rss/DataCharacter.h | 59 -- src/zxing/zxing/oned/rss/FinderPattern.cpp | 45 -- src/zxing/zxing/oned/rss/FinderPattern.h | 63 -- src/zxing/zxing/oned/rss/Pair.cpp | 32 - src/zxing/zxing/oned/rss/Pair.h | 51 -- src/zxing/zxing/oned/rss/RSS14Reader.cpp | 455 ----------- src/zxing/zxing/oned/rss/RSS14Reader.h | 71 -- src/zxing/zxing/oned/rss/RSSUtils.cpp | 74 -- src/zxing/zxing/oned/rss/RSSUtils.h | 42 - .../oned/rss/expanded/BitArrayBuilder.cpp | 53 -- .../zxing/oned/rss/expanded/BitArrayBuilder.h | 56 -- .../zxing/oned/rss/expanded/ExpandedPair.cpp | 49 -- .../zxing/oned/rss/expanded/ExpandedPair.h | 85 --- .../zxing/oned/rss/expanded/ExpandedRow.cpp | 48 -- .../zxing/oned/rss/expanded/ExpandedRow.h | 80 -- .../oned/rss/expanded/RSSExpandedReader.cpp | 720 ------------------ .../oned/rss/expanded/RSSExpandedReader.h | 128 ---- .../rss/expanded/decoders/AI013103decoder.cpp | 21 - .../rss/expanded/decoders/AI013103decoder.h | 58 -- .../rss/expanded/decoders/AI01320xDecoder.cpp | 28 - .../rss/expanded/decoders/AI01320xDecoder.h | 58 -- .../rss/expanded/decoders/AI01392xDecoder.cpp | 34 - .../rss/expanded/decoders/AI01392xDecoder.h | 62 -- .../rss/expanded/decoders/AI01393xDecoder.cpp | 50 -- .../rss/expanded/decoders/AI01393xDecoder.h | 59 -- .../expanded/decoders/AI013x0x1xDecoder.cpp | 70 -- .../rss/expanded/decoders/AI013x0x1xDecoder.h | 72 -- .../rss/expanded/decoders/AI013x0xDecoder.cpp | 25 - .../rss/expanded/decoders/AI013x0xDecoder.h | 60 -- .../rss/expanded/decoders/AI01AndOtherAIs.cpp | 25 - .../rss/expanded/decoders/AI01AndOtherAIs.h | 60 -- .../rss/expanded/decoders/AI01decoder.cpp | 51 -- .../oned/rss/expanded/decoders/AI01decoder.h | 63 -- .../expanded/decoders/AI01weightDecoder.cpp | 28 - .../rss/expanded/decoders/AI01weightDecoder.h | 60 -- .../decoders/AbstractExpandedDecoder.cpp | 69 -- .../decoders/AbstractExpandedDecoder.h | 70 -- .../rss/expanded/decoders/AnyAIDecoder.cpp | 17 - .../oned/rss/expanded/decoders/AnyAIDecoder.h | 60 -- .../expanded/decoders/BlockParsedResult.cpp | 31 - .../rss/expanded/decoders/BlockParsedResult.h | 65 -- .../expanded/decoders/CurrentParsingState.cpp | 51 -- .../expanded/decoders/CurrentParsingState.h | 78 -- .../rss/expanded/decoders/DecodedChar.cpp | 21 - .../oned/rss/expanded/decoders/DecodedChar.h | 61 -- .../expanded/decoders/DecodedInformation.cpp | 47 -- .../expanded/decoders/DecodedInformation.h | 69 -- .../rss/expanded/decoders/DecodedNumeric.cpp | 41 - .../rss/expanded/decoders/DecodedNumeric.h | 71 -- .../rss/expanded/decoders/DecodedObject.cpp | 16 - .../rss/expanded/decoders/DecodedObject.h | 52 -- .../rss/expanded/decoders/FieldParser.cpp | 276 ------- .../oned/rss/expanded/decoders/FieldParser.h | 66 -- .../expanded/decoders/GeneralAppIdDecoder.cpp | 447 ----------- .../expanded/decoders/GeneralAppIdDecoder.h | 101 --- 65 files changed, 14 insertions(+), 5034 deletions(-) delete mode 100644 src/zxing/zxing/oned/rss/AbstractRSSReader.cpp delete mode 100644 src/zxing/zxing/oned/rss/AbstractRSSReader.h delete mode 100644 src/zxing/zxing/oned/rss/DataCharacter.cpp delete mode 100644 src/zxing/zxing/oned/rss/DataCharacter.h delete mode 100644 src/zxing/zxing/oned/rss/FinderPattern.cpp delete mode 100644 src/zxing/zxing/oned/rss/FinderPattern.h delete mode 100644 src/zxing/zxing/oned/rss/Pair.cpp delete mode 100644 src/zxing/zxing/oned/rss/Pair.h delete mode 100644 src/zxing/zxing/oned/rss/RSS14Reader.cpp delete mode 100644 src/zxing/zxing/oned/rss/RSS14Reader.h delete mode 100644 src/zxing/zxing/oned/rss/RSSUtils.cpp delete mode 100644 src/zxing/zxing/oned/rss/RSSUtils.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedPair.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedRow.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp delete mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h diff --git a/examples/QZXingLive/main.qml b/examples/QZXingLive/main.qml index 6b1eb00..7268934 100644 --- a/examples/QZXingLive/main.qml +++ b/examples/QZXingLive/main.qml @@ -95,7 +95,7 @@ ApplicationWindow } decoder { - enabledDecoders: QZXing.DecoderFormat_RSS_14 | QZXing.DecoderFormat_UPC_A //| QZXing.DecoderFormat_CODE_39 | QZXing.DecoderFormat_QR_CODE + enabledDecoders: QZXing.DecoderFormat_EAN_13 | QZXing.DecoderFormat_CODE_39 | QZXing.DecoderFormat_QR_CODE onTagFound: { console.log(tag + " | " + decoder.foundedFormat() + " | " + decoder.charSet()); diff --git a/src/QZXing.pri b/src/QZXing.pri index 2b72bd4..97339bf 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -152,36 +152,7 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/EncodeHint.h \ $$PWD/zxing/zxing/UnsupportedEncodingException.h \ $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.h \ - $$PWD/zxing/zxing/common/Types.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h \ - $$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.h \ - $$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.h \ - $$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h \ - $$PWD/zxing/zxing/oned/rss/AbstractRSSReader.h \ - $$PWD/zxing/zxing/oned/rss/DataCharacter.h \ - $$PWD/zxing/zxing/oned/rss/FinderPattern.h \ - $$PWD/zxing/zxing/oned/rss/Pair.h \ - $$PWD/zxing/zxing/oned/rss/RSS14Reader.h \ - $$PWD/zxing/zxing/oned/rss/RSSUtils.h + $$PWD/zxing/zxing/common/Types.h SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/QZXing.cpp \ @@ -302,36 +273,7 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/qrcode/encoder/MatrixUtil.cpp \ $$PWD/zxing/zxing/qrcode/encoder/QRCode.cpp \ $$PWD/zxing/zxing/EncodeHint.cpp \ - $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp \ - $$PWD/zxing/zxing/oned/rss/AbstractRSSReader.cpp \ - $$PWD/zxing/zxing/oned/rss/DataCharacter.cpp \ - $$PWD/zxing/zxing/oned/rss/FinderPattern.cpp \ - $$PWD/zxing/zxing/oned/rss/Pair.cpp \ - $$PWD/zxing/zxing/oned/rss/RSS14Reader.cpp \ - $$PWD/zxing/zxing/oned/rss/RSSUtils.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp \ - $$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp + $$PWD/zxing/zxing/common/reedsolomon/ReedSolomonEncoder.cpp qzxing_multimedia { QT += multimedia diff --git a/src/zxing/zxing/DecodeHints.h b/src/zxing/zxing/DecodeHints.h index 7a6cb00..b24e349 100644 --- a/src/zxing/zxing/DecodeHints.h +++ b/src/zxing/zxing/DecodeHints.h @@ -62,7 +62,7 @@ class DecodeHints { static const DecodeHintType CHARACTER_SET; // static const DecodeHintType ALLOWED_LENGTHS = 1 << 29; // static const DecodeHintType ASSUME_CODE_39_CHECK_DIGIT = 1 << 28; - static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26; + // static const DecodeHintType NEED_RESULT_POINT_CALLBACK = 1 << 26; static const DecodeHints PRODUCT_HINT; static const DecodeHints ONED_HINT; diff --git a/src/zxing/zxing/common/Str.cpp b/src/zxing/zxing/common/Str.cpp index 232c25f..f48b6cd 100644 --- a/src/zxing/zxing/common/Str.cpp +++ b/src/zxing/zxing/common/Str.cpp @@ -43,8 +43,8 @@ int String::size() const { return int(text_.size()); } int String::length() const { return int(text_.size()); } -Ref String::substring(int i, int j) const { - return Ref(new String(text_.substr(i, j))); +Ref String::substring(int i) const { + return Ref(new String(text_.substr(i))); } void String::append(const std::string &tail) { diff --git a/src/zxing/zxing/common/Str.h b/src/zxing/zxing/common/Str.h index c37db22..8e8c8b3 100644 --- a/src/zxing/zxing/common/Str.h +++ b/src/zxing/zxing/common/Str.h @@ -37,7 +37,7 @@ public: explicit String(const std::string &text); explicit String(int); char charAt(int) const; - Ref substring(int, int = -1) const; + Ref substring(int) const; const std::string& getText() const; int size() const; void append(std::string const& tail); diff --git a/src/zxing/zxing/common/detector/MathUtils.h b/src/zxing/zxing/common/detector/MathUtils.h index 30811b9..900e33c 100644 --- a/src/zxing/zxing/common/detector/MathUtils.h +++ b/src/zxing/zxing/common/detector/MathUtils.h @@ -18,7 +18,6 @@ */ #include -#include namespace zxing { namespace common { @@ -49,14 +48,6 @@ class MathUtils { int yDiff = aY - bY; return sqrt(float(xDiff * xDiff + yDiff * yDiff)); } - - static inline int sum(std::vector array) { - int count = 0; - for (int a : array) { - count += a; - } - return count; - } }; } diff --git a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp index 2873a51..7b18345 100644 --- a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp @@ -23,16 +23,12 @@ #include #include #include -#include -#include #include #include using zxing::Ref; using zxing::Result; using zxing::oned::MultiFormatOneDReader; -using zxing::oned::rss::RSS14Reader; -using zxing::oned::rss::RSSExpandedReader; // VC++ using zxing::DecodeHints; @@ -60,15 +56,16 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { if (hints.containsFormat(BarcodeFormat::CODABAR)) { readers.push_back(Ref(new CodaBarReader())); } - +/* if (hints.containsFormat(BarcodeFormat::RSS_14)) { readers.push_back(Ref(new RSS14Reader())); } - +*/ +/* if (hints.containsFormat(BarcodeFormat::RSS_EXPANDED)) { - readers.push_back(Ref(new RSSExpandedReader())); + readers.push_back(Ref(new RSS14ExpandedReader())); } - +*/ if (readers.size() == 0) { readers.push_back(Ref(new MultiFormatUPCEANReader(hints))); readers.push_back(Ref(new Code39Reader())); @@ -76,8 +73,8 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { readers.push_back(Ref(new Code93Reader())); readers.push_back(Ref(new Code128Reader())); readers.push_back(Ref(new ITFReader())); - readers.push_back(Ref(new RSS14Reader())); - readers.push_back(Ref(new RSSExpandedReader())); + // readers.push_back(Ref(new RSS14Reader())); + // readers.push_back(Ref(new RSS14ExpandedReader())); } } diff --git a/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp b/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp deleted file mode 100644 index 9e21540..0000000 --- a/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "AbstractRSSReader.h" - -namespace zxing { -namespace oned { -namespace rss { - -AbstractRSSReader::AbstractRSSReader() -{ - m_decodeFinderCounters = std::vector(4); - m_dataCharacterCounters = std::vector(8); - m_oddRoundingErrors = std::vector(4); - m_evenRoundingErrors = std::vector(4); - m_oddCounts = std::vector(m_dataCharacterCounters.size() / 2); - m_evenCounts = std::vector(m_dataCharacterCounters.size() / 2); -} - -std::vector AbstractRSSReader::getDecodeFinderCounters() -{ - return m_decodeFinderCounters; -} - -std::vector AbstractRSSReader::getDataCharacterCounters() -{ - return m_dataCharacterCounters; -} - -std::vector AbstractRSSReader::getOddRoundingErrors() -{ - return m_oddRoundingErrors; -} - -std::vector AbstractRSSReader::getEvenRoundingErrors() -{ - return m_evenRoundingErrors; -} - -std::vector AbstractRSSReader::getOddCounts() -{ - return m_oddCounts; -} - -int AbstractRSSReader::parseFinderValue(std::vector counters, std::vector > finderPatterns) -{ - for (int value = 0; value < finderPatterns.size(); value++) { - if (patternMatchVariance(counters, finderPatterns[value], MAX_INDIVIDUAL_VARIANCE) < - MAX_AVG_VARIANCE) { - return value; - } - } - throw NotFoundException(); -} - -void AbstractRSSReader::increment(std::vector array, std::vector errors) { - int index = 0; - float biggestError = errors[0]; - for (int i = 1; i < array.size(); i++) { - if (errors[i] > biggestError) { - biggestError = errors[i]; - index = i; - } - } - array[index]++; -} - -void AbstractRSSReader::decrement(std::vector array, std::vector errors) { - int index = 0; - float biggestError = errors[0]; - for (int i = 1; i < array.size(); i++) { - if (errors[i] < biggestError) { - biggestError = errors[i]; - index = i; - } - } - array[index]--; -} - -bool AbstractRSSReader::isFinderPattern(std::vector counters) { - int firstTwoSum = counters[0] + counters[1]; - int sum = firstTwoSum + counters[2] + counters[3]; - float ratio = firstTwoSum / (float) sum; - if (ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO) { - // passes ratio test in spec, but see if the counts are unreasonable - int minCounter = INT_MAX; - int maxCounter = INT_MIN; - for (int counter : counters) { - if (counter > maxCounter) { - maxCounter = counter; - } - if (counter < minCounter) { - minCounter = counter; - } - } - return maxCounter < 10 * minCounter; - } - return false; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/AbstractRSSReader.h b/src/zxing/zxing/oned/rss/AbstractRSSReader.h deleted file mode 100644 index 3257cda..0000000 --- a/src/zxing/zxing/oned/rss/AbstractRSSReader.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef ABSTRACT_RSS_READER_H -#define ABSTRACT_RSS_READER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//package com.google.zxing.oned.rss; - -//import com.google.zxing.NotFoundException; -//import com.google.zxing.common.detector.MathUtils; -//import com.google.zxing.oned.OneDReader; - -#include -#include -#include - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * Superclass of {@link OneDReader} implementations that read barcodes in the RSS family - * of formats. - */ -class AbstractRSSReader : public OneDReader -{ - - static constexpr float MAX_AVG_VARIANCE = 0.2f; - static constexpr float MAX_INDIVIDUAL_VARIANCE = 0.45f; - - static constexpr float MIN_FINDER_PATTERN_RATIO = 9.5f / 12.0f; - static constexpr float MAX_FINDER_PATTERN_RATIO = 12.5f / 14.0f; - -protected: - AbstractRSSReader(); - - std::vector getDecodeFinderCounters(); - - std::vector getDataCharacterCounters(); - - std::vector getOddRoundingErrors(); - - std::vector getEvenRoundingErrors(); - - std::vector getOddCounts(); - - std::vector getEvenCounts() { - return m_evenCounts; - } - - static int parseFinderValue( std::vector counters, - std::vector< std::vector > finderPatterns); - - /** - * @param array values to sum - * @return sum of values - * @deprecated call {@link MathUtils#sum(int[])} - */ - // @Deprecated - // protected static int count( std::vector array) { - // return MathUtils.sum(array); - // } - - static void increment( std::vector array, std::vector errors); - - static void decrement(std::vector array, std::vector errors); - - static bool isFinderPattern(std::vector counters); - -private: - std::vector m_decodeFinderCounters; - std::vector m_dataCharacterCounters; - std::vector m_oddRoundingErrors; - std::vector m_evenRoundingErrors; - std::vector m_oddCounts; - std::vector m_evenCounts; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/DataCharacter.cpp b/src/zxing/zxing/oned/rss/DataCharacter.cpp deleted file mode 100644 index 3948a0d..0000000 --- a/src/zxing/zxing/oned/rss/DataCharacter.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "DataCharacter.h" - -namespace zxing { -namespace oned { -namespace rss { - -DataCharacter::DataCharacter(int value, int checksumPortion) - : m_value(value), m_checksumPortion(checksumPortion) -{ - -} - -DataCharacter::DataCharacter() - : m_value(0), m_checksumPortion(0) -{ } - -int DataCharacter::getValue() const -{ - return m_value; -} - -int DataCharacter::getChecksumPortion() const -{ - return m_checksumPortion; -} - -String DataCharacter::toString() const -{ - return String(m_value + "(" + m_checksumPortion + ')'); -} - -bool DataCharacter::equals(const DataCharacter &other) const -{ - return m_value == other.m_value && m_checksumPortion == other.m_checksumPortion; -} - -int DataCharacter::hashCode() const -{ - return m_value & m_checksumPortion; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/DataCharacter.h b/src/zxing/zxing/oned/rss/DataCharacter.h deleted file mode 100644 index e940df5..0000000 --- a/src/zxing/zxing/oned/rss/DataCharacter.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef DATA_CHARACTER_H -#define DATA_CHARACTER_H - -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * Encapsulates a since character value in an RSS barcode, including its checksum information. - */ -class DataCharacter -{ - -public: - DataCharacter(int value, int checksumPortion); - - DataCharacter(); - - int getValue() const; - - int getChecksumPortion() const; - - String toString() const; - - bool equals(const DataCharacter& other) const; - - int hashCode() const; - -private: - int m_value; - int m_checksumPortion; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/FinderPattern.cpp b/src/zxing/zxing/oned/rss/FinderPattern.cpp deleted file mode 100644 index e4b3d63..0000000 --- a/src/zxing/zxing/oned/rss/FinderPattern.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "FinderPattern.h" - -namespace zxing { -namespace oned { -namespace rss { - -FinderPattern::FinderPattern(int value, std::vector startEnd, int start, int end, int rowNumber) - : m_value(value), - m_startEnd(startEnd) -{ - ArrayRef< Ref > resultPoints(2); - resultPoints[0] = Ref(new OneDResultPoint(start, rowNumber)); - resultPoints[0] = Ref(new OneDResultPoint(end, rowNumber)); - m_resultPoints = resultPoints; -} - -FinderPattern::FinderPattern(const FinderPattern *other) { - m_value = other != nullptr ? other->m_value : 0; - m_startEnd = other != nullptr ? other->m_startEnd : std::vector (); - m_resultPoints = other != nullptr ? other->m_resultPoints : nullptr; -} - -int FinderPattern::getValue() { - return m_value; -} - -std::vector FinderPattern::getStartEnd() { - return m_startEnd; -} - -ArrayRef > FinderPattern::getResultPoints() { - return m_resultPoints; -} - -bool FinderPattern::equals(const FinderPattern &other) { - return m_value == other.m_value; -} - -int FinderPattern::hashCode() { - return m_value; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/FinderPattern.h b/src/zxing/zxing/oned/rss/FinderPattern.h deleted file mode 100644 index 338a590..0000000 --- a/src/zxing/zxing/oned/rss/FinderPattern.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef FINDER_PATTERN_H -#define FINDER_PATTERN_H - -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * Encapsulates an RSS barcode finder pattern, including its start/end position and row. - */ -class FinderPattern -{ - -public: - FinderPattern(int value, std::vector startEnd, int start, int end, int rowNumber); - - FinderPattern(const FinderPattern* other = nullptr); - - int getValue(); - - std::vector getStartEnd(); - - ArrayRef< Ref > getResultPoints(); - - bool equals(const FinderPattern& other); - - int hashCode(); - -private: - int m_value; - std::vector m_startEnd; - ArrayRef< Ref > m_resultPoints; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/Pair.cpp b/src/zxing/zxing/oned/rss/Pair.cpp deleted file mode 100644 index 535aca2..0000000 --- a/src/zxing/zxing/oned/rss/Pair.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Pair.h" - -namespace zxing { -namespace oned { -namespace rss { - -Pair::Pair(int value, int checksumPortion, FinderPattern finderPattern) - : DataCharacter (value, checksumPortion), m_finderPattern(finderPattern) -{ -} - -Pair::Pair() - : DataCharacter (0, 0), m_finderPattern(FinderPattern()) -{ -} - -FinderPattern Pair::getFinderPattern() { - return m_finderPattern; -} - -int Pair::getCount() { - return m_count; -} - -void Pair::incrementCount() { - m_count++; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/Pair.h b/src/zxing/zxing/oned/rss/Pair.h deleted file mode 100644 index 73bfcfa..0000000 --- a/src/zxing/zxing/oned/rss/Pair.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef RSS_PAIR_H -#define RSS_PAIR_H - -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "DataCharacter.h" -#include "FinderPattern.h" - -namespace zxing { - -namespace oned { - -namespace rss { - -class Pair : public DataCharacter -{ - -public: - Pair(int value, int checksumPortion, FinderPattern finderPattern); - Pair(); - - FinderPattern getFinderPattern(); - - int getCount(); - - void incrementCount(); - -private: - FinderPattern m_finderPattern; - int m_count; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.cpp b/src/zxing/zxing/oned/rss/RSS14Reader.cpp deleted file mode 100644 index a593215..0000000 --- a/src/zxing/zxing/oned/rss/RSS14Reader.cpp +++ /dev/null @@ -1,455 +0,0 @@ -#include "RSS14Reader.h" - -namespace zxing { -namespace oned { -namespace rss { - -using ::zxing::common::detector::MathUtils; - -static const std::vector OUTSIDE_EVEN_TOTAL_SUBSET = {1,10,34,70,126}; -static const std::vector INSIDE_ODD_TOTAL_SUBSET = {4,20,48,81}; -static const std::vector OUTSIDE_GSUM = {0,161,961,2015,2715}; -static const std::vector INSIDE_GSUM = {0,336,1036,1516}; -static const std::vector OUTSIDE_ODD_WIDEST = {8,6,4,3,1}; -static const std::vector INSIDE_ODD_WIDEST = {2,4,6,8}; - -static const std::vector> FINDER_PATTERNS = { - {3,8,2,1}, - {3,5,5,1}, - {3,3,7,1}, - {3,1,9,1}, - {2,7,4,1}, - {2,5,6,1}, - {2,3,8,1}, - {1,5,7,1}, - {1,3,9,1}, -}; - -RSS14Reader::RSS14Reader() - : m_possibleLeftPairs({}), - m_possibleRightPairs({}) -{ - -} - -Ref RSS14Reader::decodeRow(int rowNumber, Ref row, DecodeHints hints) -{ - Pair leftPair = decodePair(row, false, rowNumber, hints); - addOrTally(m_possibleLeftPairs, leftPair); - row->reverse(); - Pair rightPair = decodePair(row, true, rowNumber, hints); - addOrTally(m_possibleRightPairs, rightPair); - row->reverse(); - for (Pair left : m_possibleLeftPairs) { - if (left.getCount() > 1) { - for (Pair right : m_possibleRightPairs) { - if (right.getCount() > 1 && checkChecksum(left, right)) { - return constructResult(left, right); - } - } - } - } - throw NotFoundException(); -} - -void RSS14Reader::addOrTally(std::vector possiblePairs, Pair pair) { - if (pair.getCount() == 0) { - return; - } - boolean found = false; - for (Pair other : possiblePairs) { - if (other.getValue() == pair.getValue()) { - other.incrementCount(); - found = true; - break; - } - } - if (!found) { - possiblePairs.push_back(pair); - } -} - -void RSS14Reader::reset() -{ - m_possibleLeftPairs.clear(); - m_possibleRightPairs.clear(); -} - -Ref RSS14Reader::constructResult(Pair leftPair, Pair rightPair) -{ - long symbolValue = 4537077L * leftPair.getValue() + rightPair.getValue(); - String text(std::to_string(symbolValue)); - - String buffer(14); - for (int i = 13 - text.length(); i > 0; i--) { - buffer.append('0'); - } - buffer.append(text.getText()); - - int checkDigit = 0; - for (int i = 0; i < 13; i++) { - int digit = buffer.charAt(i) - '0'; - checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; - } - checkDigit = 10 - (checkDigit % 10); - if (checkDigit == 10) { - checkDigit = 0; - } - buffer.append(checkDigit); - - ArrayRef< Ref > leftPoints = leftPair.getFinderPattern().getResultPoints(); - ArrayRef< Ref > rightPoints = rightPair.getFinderPattern().getResultPoints(); - ArrayRef< Ref > resultPoints(5); - resultPoints[0] = leftPoints[0]; - resultPoints[1] = leftPoints[1]; - resultPoints[2] = rightPoints[0]; - resultPoints[3] = rightPoints[1]; - - return Ref(new Result( - Ref(new String(buffer)), - nullptr, - resultPoints, - BarcodeFormat::RSS_14)); -} - -Pair RSS14Reader::decodePair(Ref row, boolean right, int rowNumber, DecodeHints hints) -{ - try { - std::vector startEnd = findFinderPattern(row, right); - FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd); - - Ref resultPointCallback = hints.getResultPointCallback(); /////////////////////// - - if (resultPointCallback != nullptr) { - startEnd = pattern.getStartEnd(); - float center = (startEnd[0] + startEnd[1] - 1) / 2.0f; - if (right) { - // row is actually reversed - center = row->getSize() - 1 - center; - } - resultPointCallback->foundPossibleResultPoint(ResultPoint(center, static_cast(rowNumber))); - } - - DataCharacter outside = decodeDataCharacter(row, pattern, true); - DataCharacter inside = decodeDataCharacter(row, pattern, false); - return Pair(1597 * outside.getValue() + inside.getValue(), - outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), - pattern); - } catch (NotFoundException ignored) { - return Pair(); - } -} - -DataCharacter RSS14Reader::decodeDataCharacter(Ref row, FinderPattern pattern, boolean outsideChar) -{ - - std::vector counters = getDataCharacterCounters(); - for (int x = 0; x < counters.size(); x++) { - counters[x] = 0; - } - - if (outsideChar) { - recordPattern(row, pattern.getStartEnd()[0], counters); //////////////////////////////// - } else { - recordPattern(row, pattern.getStartEnd()[1], counters); - // reverse it - for (int i = 0, j = counters.size() - 1; i < j; i++, j--) { - int temp = counters[i]; - counters[i] = counters[j]; - counters[j] = temp; - } - } - - int numModules = outsideChar ? 16 : 15; - float elementWidth = MathUtils::sum(counters) / (float) numModules; - - std::vector oddCounts = getOddCounts(); - std::vector evenCounts = getEvenCounts(); - std::vector oddRoundingErrors = getOddRoundingErrors(); - std::vector evenRoundingErrors = getEvenRoundingErrors(); - - for (int i = 0; i < counters.size(); i++) { - float value = counters[i] / elementWidth; - int count = (int) (value + 0.5f); // Round - if (count < 1) { - count = 1; - } else if (count > 8) { - count = 8; - } - int offset = i / 2; - if ((i & 0x01) == 0) { - oddCounts[offset] = count; - oddRoundingErrors[offset] = value - count; - } else { - evenCounts[offset] = count; - evenRoundingErrors[offset] = value - count; - } - } - - adjustOddEvenCounts(outsideChar, numModules); - - int oddSum = 0; - int oddChecksumPortion = 0; - for (int i = oddCounts.size() - 1; i >= 0; i--) { - oddChecksumPortion *= 9; - oddChecksumPortion += oddCounts[i]; - oddSum += oddCounts[i]; - } - int evenChecksumPortion = 0; - int evenSum = 0; - for (int i = evenCounts.size() - 1; i >= 0; i--) { - evenChecksumPortion *= 9; - evenChecksumPortion += evenCounts[i]; - evenSum += evenCounts[i]; - } - int checksumPortion = oddChecksumPortion + 3 * evenChecksumPortion; - - if (outsideChar) { - if ((oddSum & 0x01) != 0 || oddSum > 12 || oddSum < 4) { - throw NotFoundException(); - } - int group = (12 - oddSum) / 2; - int oddWidest = OUTSIDE_ODD_WIDEST[group]; - int evenWidest = 9 - oddWidest; - int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, false); - int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, true); - int tEven = OUTSIDE_EVEN_TOTAL_SUBSET[group]; - int gSum = OUTSIDE_GSUM[group]; - return DataCharacter(vOdd * tEven + vEven + gSum, checksumPortion); - } else { - if ((evenSum & 0x01) != 0 || evenSum > 10 || evenSum < 4) { - throw NotFoundException(); - } - int group = (10 - evenSum) / 2; - int oddWidest = INSIDE_ODD_WIDEST[group]; - int evenWidest = 9 - oddWidest; - int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, true); - int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, false); - int tOdd = INSIDE_ODD_TOTAL_SUBSET[group]; - int gSum = INSIDE_GSUM[group]; - return DataCharacter(vEven * tOdd + vOdd + gSum, checksumPortion); - } - -} - -std::vector RSS14Reader::findFinderPattern(Ref row, bool rightFinderPattern) -{ - std::vector counters = getDecodeFinderCounters(); - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - - int width = row->getSize(); - boolean isWhite = false; - int rowOffset = 0; - while (rowOffset < width) { - isWhite = !row->get(rowOffset); - if (rightFinderPattern == isWhite) { - // Will encounter white first when searching for right finder pattern - break; - } - rowOffset++; - } - - int counterPosition = 0; - int patternStart = rowOffset; - for (int x = rowOffset; x < width; x++) { - if (row->get(x) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == 3) { - if (isFinderPattern(counters)) { - return std::vector{patternStart, x}; - } - patternStart += counters[0] + counters[1]; - counters[0] = counters[2]; - counters[1] = counters[3]; - counters[2] = 0; - counters[3] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException(); - -} - -FinderPattern RSS14Reader::parseFoundFinderPattern(Ref row, int rowNumber, bool right, std::vector startEnd) -{ - // Actually we found elements 2-5 - bool firstIsBlack = row->get(startEnd[0]); - int firstElementStart = startEnd[0] - 1; - // Locate element 1 - while (firstElementStart >= 0 && firstIsBlack != row->get(firstElementStart)) { - firstElementStart--; - } - firstElementStart++; - int firstCounter = startEnd[0] - firstElementStart; - // Make 'counters' hold 1-4 - std::vector counters = getDecodeFinderCounters(); - std::vector _counters = counters; - for (int i = 1; i < counters.size(); i++) { - counters[i] = _counters[i - 1]; - } - - //System.arraycopy(counters, 0, counters, 1, counters.length - 1); //////////////////////////////////////// - counters[0] = firstCounter; - int value = parseFinderValue(counters, FINDER_PATTERNS); - int start = firstElementStart; - int end = startEnd[1]; - if (right) { - // row is actually reversed - start = row->getSize() - 1 - start; - end = row->getSize() - 1 - end; - } - return new FinderPattern(value, {firstElementStart, startEnd[1]}, start, end, rowNumber); -} - -void RSS14Reader::adjustOddEvenCounts(boolean outsideChar, int numModules) -{ - int oddSum = MathUtils::sum(getOddCounts()); - int evenSum = MathUtils::sum(getEvenCounts()); - - boolean incrementOdd = false; - boolean decrementOdd = false; - boolean incrementEven = false; - boolean decrementEven = false; - - if (outsideChar) { - if (oddSum > 12) { - decrementOdd = true; - } else if (oddSum < 4) { - incrementOdd = true; - } - if (evenSum > 12) { - decrementEven = true; - } else if (evenSum < 4) { - incrementEven = true; - } - } else { - if (oddSum > 11) { - decrementOdd = true; - } else if (oddSum < 5) { - incrementOdd = true; - } - if (evenSum > 10) { - decrementEven = true; - } else if (evenSum < 4) { - incrementEven = true; - } - } - - int mismatch = oddSum + evenSum - numModules; - boolean oddParityBad = (oddSum & 0x01) == (outsideChar ? 1 : 0); - boolean evenParityBad = (evenSum & 0x01) == 1; - /*if (mismatch == 2) { - if (!(oddParityBad && evenParityBad)) { - throw ReaderException.getInstance(); - } - decrementOdd = true; - decrementEven = true; - } else if (mismatch == -2) { - if (!(oddParityBad && evenParityBad)) { - throw ReaderException.getInstance(); - } - incrementOdd = true; - incrementEven = true; - } else */ - switch (mismatch) { - case 1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException(); - } - decrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException(); - } - decrementEven = true; - } - break; - case -1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException(); - } - incrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException(); - } - incrementEven = true; - } - break; - case 0: - if (oddParityBad) { - if (!evenParityBad) { - throw NotFoundException(); - } - // Both bad - if (oddSum < evenSum) { - incrementOdd = true; - decrementEven = true; - } else { - decrementOdd = true; - incrementEven = true; - } - } else { - if (evenParityBad) { - throw NotFoundException(); - } - // Nothing to do! - } - break; - default: - throw NotFoundException(); - } - - if (incrementOdd) { - if (decrementOdd) { - throw NotFoundException(); - } - increment(getOddCounts(), getOddRoundingErrors()); - } - if (decrementOdd) { - decrement(getOddCounts(), getOddRoundingErrors()); - } - if (incrementEven) { - if (decrementEven) { - throw NotFoundException(); - } - increment(getEvenCounts(), getOddRoundingErrors()); - } - if (decrementEven) { - decrement(getEvenCounts(), getEvenRoundingErrors()); - } -} - -bool RSS14Reader::checkChecksum(Pair leftPair, Pair rightPair) -{ - //int leftFPValue = leftPair.getFinderPattern().getValue(); - //int rightFPValue = rightPair.getFinderPattern().getValue(); - //if ((leftFPValue == 0 && rightFPValue == 8) || - // (leftFPValue == 8 && rightFPValue == 0)) { - //} - int checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79; - int targetCheckValue = - 9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue(); - if (targetCheckValue > 72) { - targetCheckValue--; - } - if (targetCheckValue > 8) { - targetCheckValue--; - } - return checkValue == targetCheckValue; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.h b/src/zxing/zxing/oned/rss/RSS14Reader.h deleted file mode 100644 index 660167c..0000000 --- a/src/zxing/zxing/oned/rss/RSS14Reader.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef RSS14_READER_H -#define RSS14_READER_H -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AbstractRSSReader.h" -#include "Pair.h" -#include -#include "RSSUtils.h" - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * Decodes RSS-14, including truncated and stacked variants. See ISO/IEC 24724:2006. - */ -class RSS14Reader : public AbstractRSSReader -{ - -private: - std::vector m_possibleLeftPairs; - std::vector m_possibleRightPairs; - -public: - RSS14Reader(); - - Ref decodeRow(int rowNumber, Ref row, DecodeHints hints); - - static void addOrTally(std::vector possiblePairs, Pair pair); - - void reset(); - - Ref constructResult(Pair leftPair, Pair rightPair); - - static boolean checkChecksum(Pair leftPair, Pair rightPair); - - Pair decodePair(Ref row, boolean right, int rowNumber, DecodeHints hints); - - DataCharacter decodeDataCharacter(Ref row, FinderPattern pattern, boolean outsideChar); - - std::vector findFinderPattern(Ref row, bool rightFinderPattern); - - FinderPattern parseFoundFinderPattern(Ref row, int rowNumber, bool right, std::vector startEnd); - - void adjustOddEvenCounts(boolean outsideChar, int numModules); - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/RSSUtils.cpp b/src/zxing/zxing/oned/rss/RSSUtils.cpp deleted file mode 100644 index 63e99f5..0000000 --- a/src/zxing/zxing/oned/rss/RSSUtils.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "RSSUtils.h" - -namespace zxing { -namespace oned { -namespace rss { - -int RSSUtils::getRSSvalue(std::vector widths, int maxWidth, bool noNarrow) -{ - int n = 0; - for (int width : widths) { - n += width; - } - int val = 0; - int narrowMask = 0; - int elements = widths.size(); - for (int bar = 0; bar < elements - 1; bar++) { - int elmWidth; - for (elmWidth = 1, narrowMask |= 1 << bar; - elmWidth < widths[bar]; - elmWidth++, narrowMask &= ~(1 << bar)) { - int subVal = combins(n - elmWidth - 1, elements - bar - 2); - if (noNarrow && (narrowMask == 0) && - (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { - subVal -= combins(n - elmWidth - (elements - bar), - elements - bar - 2); - } - if (elements - bar - 1 > 1) { - int lessVal = 0; - for (int mxwElement = n - elmWidth - (elements - bar - 2); - mxwElement > maxWidth; mxwElement--) { - lessVal += combins(n - elmWidth - mxwElement - 1, - elements - bar - 3); - } - subVal -= lessVal * (elements - 1 - bar); - } else if (n - elmWidth > maxWidth) { - subVal--; - } - val += subVal; - } - n -= elmWidth; - } - return val; -} - -int RSSUtils::combins(int n, int r) -{ - int maxDenom; - int minDenom; - if (n - r > r) { - minDenom = r; - maxDenom = n - r; - } else { - minDenom = n - r; - maxDenom = r; - } - int val = 1; - int j = 1; - for (int i = n; i > maxDenom; i--) { - val *= i; - if (j <= minDenom) { - val /= j; - j++; - } - } - while (j <= minDenom) { - val /= j; - j++; - } - return val; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/RSSUtils.h b/src/zxing/zxing/oned/rss/RSSUtils.h deleted file mode 100644 index 26dc29c..0000000 --- a/src/zxing/zxing/oned/rss/RSSUtils.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef RSS_UTILS_H -#define RSS_UTILS_H - -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** Adapted from listings in ISO/IEC 24724 Appendix B and Appendix G. */ -class RSSUtils -{ - -public: - static int getRSSvalue(std::vector widths, int maxWidth, bool noNarrow); - - static int combins(int n, int r); -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp deleted file mode 100644 index 1c0633f..0000000 --- a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "BitArrayBuilder.h" - -namespace zxing { -namespace oned { -namespace rss { - -Ref BitArrayBuilder::buildBitArray(std::vector pairs) { - int charNumber = (pairs.size() * 2) - 1; - if (pairs[pairs.size() - 1].getRightChar().getValue() == 0) { - charNumber -= 1; - } - - int size = 12 * charNumber; - - Ref binary(new BitArray(int(size))); - int accPos = 0; - - ExpandedPair firstPair = pairs[0]; - int firstValue = firstPair.getRightChar().getValue(); - for (int i = 11; i >= 0; --i) { - if ((firstValue & (1 << i)) != 0) { - binary->set(accPos); - } - accPos++; - } - - for (int i = 1; i < pairs.size(); ++i) { - ExpandedPair currentPair = pairs[i]; - - int leftValue = currentPair.getLeftChar().getValue(); - for (int j = 11; j >= 0; --j) { - if ((leftValue & (1 << j)) != 0) { - binary->set(accPos); - } - accPos++; - } - - if (currentPair.getRightChar().getValue() != 0) { - int rightValue = currentPair.getRightChar().getValue(); - for (int j = 11; j >= 0; --j) { - if ((rightValue & (1 << j)) != 0) { - binary->set(accPos); - } - accPos++; - } - } - } - return binary; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h deleted file mode 100644 index 861015a..0000000 --- a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef BIT_ARRAY_BUILDER_H -#define BIT_ARRAY_BUILDER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include -#include "ExpandedPair.h" - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class BitArrayBuilder -{ - -public: - static Ref buildBitArray(std::vector pairs); -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp deleted file mode 100644 index c17ed4a..0000000 --- a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "ExpandedPair.h" - -namespace zxing { -namespace oned { -namespace rss { - -ExpandedPair::ExpandedPair(DataCharacter leftChar, DataCharacter rightChar, FinderPattern finderPattern) - : m_leftChar(leftChar), - m_rightChar(rightChar), - m_finderPattern(finderPattern) -{ } - -DataCharacter ExpandedPair::getLeftChar() { - return m_leftChar; -} - -DataCharacter ExpandedPair::getRightChar() { - return m_rightChar; -} - -FinderPattern ExpandedPair::getFinderPattern() { - return m_finderPattern; -} - -bool ExpandedPair::mustBeLast() { - return m_rightChar.toString().length() == 0; -} - -String ExpandedPair::toString() { - return - String(String("[ ").getText() + m_leftChar.toString().getText() + String(" , ").getText() + m_rightChar.toString().getText() + " : " + - (m_finderPattern.getValue() != 0 ? "null" : std::to_string(m_finderPattern.getValue())) + " ]"); -} - -bool ExpandedPair::equals(const ExpandedPair &other) { - return m_leftChar.equals(other.m_leftChar) && - m_rightChar.equals(other.m_rightChar) && - m_finderPattern.equals(other.m_finderPattern); -} - -int ExpandedPair::hashCode() { - return m_leftChar.hashCode() & m_rightChar.hashCode() & m_finderPattern.hashCode(); -} - - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h deleted file mode 100644 index 3cb9ea8..0000000 --- a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef EXPANDED_PAIR_H -#define EXPANDED_PAIR_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -//package com.google.zxing.oned.rss.expanded; - -//import com.google.zxing.oned.rss.DataCharacter; -//import com.google.zxing.oned.rss.FinderPattern; - -//import java.util.Objects; - -#include -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -class ExpandedPair -{ - -public: - ExpandedPair(DataCharacter leftChar, - DataCharacter rightChar, - FinderPattern finderPattern); - - DataCharacter getLeftChar(); - - DataCharacter getRightChar(); - - FinderPattern getFinderPattern(); - - bool mustBeLast(); - - String toString(); - - bool equals(const ExpandedPair& other); - - int hashCode(); - - bool operator == (const ExpandedPair &x) {return equals(x);} //////////////////// - -private: - DataCharacter m_leftChar; - DataCharacter m_rightChar; - FinderPattern m_finderPattern; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp deleted file mode 100644 index e0fdba9..0000000 --- a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "ExpandedRow.h" - -namespace zxing { -namespace oned { -namespace rss { - -ExpandedRow::ExpandedRow(std::vector pairs, int rowNumber, bool wasReversed) { - m_pairs = std::vector(pairs); - m_rowNumber = rowNumber; - m_wasReversed = wasReversed; -} - -std::vector ExpandedRow::getPairs() { - return m_pairs; -} - -int ExpandedRow::getRowNumber() { - return m_rowNumber; -} - -bool ExpandedRow::isEquivalent(std::vector otherPairs) { - - if (m_pairs.size() != otherPairs.size()) { - return false; - } - - for (int i = 0; i < m_pairs.size(); i++) { - if (!m_pairs[i].equals(otherPairs[i])) { - return false; - } - } - - return true; -} - -String ExpandedRow::toString() { - String result("{ "); - for (auto i : m_pairs) { - result.append(i.toString().getText()); - } - result.append(" }"); - return result; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h deleted file mode 100644 index 9f9344a..0000000 --- a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef EXPANDED_ROW_H -#define EXPANDED_ROW_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -//package com.google.zxing.oned.rss.expanded; - -//import java.util.ArrayList; -//import java.util.List; - -#include "ExpandedPair.h" - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs. - */ -class ExpandedRow -{ - -public: - ExpandedRow(std::vector pairs, int rowNumber, bool wasReversed); - - std::vector getPairs(); - - int getRowNumber(); - - bool isEquivalent(std::vector otherPairs); - - String toString(); - - /** - * Two rows are equal if they contain the same pairs in the same order. - */ - // @Override - // public boolean equals(Object o) { - // if (!(o instanceof ExpandedRow)) { - // return false; - // } - // ExpandedRow that = (ExpandedRow) o; - // return this.pairs.equals(that.getPairs()) && wasReversed == that.wasReversed; - // } - - // @Override - // public int hashCode() { - // return pairs.hashCode() ^ Boolean.valueOf(wasReversed).hashCode(); - // } - -private: - std::vector m_pairs; - int m_rowNumber; - /** Did this row of the image have to be reversed (mirrored) to recognize the pairs? */ - bool m_wasReversed; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp deleted file mode 100644 index 78bdc22..0000000 --- a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp +++ /dev/null @@ -1,720 +0,0 @@ -#include "RSSExpandedReader.h" - -namespace zxing { -namespace oned { -namespace rss { - -using ::zxing::common::detector::MathUtils; - -static const std::vector SYMBOL_WIDEST = {7, 5, 4, 3, 1}; -static const std::vector EVEN_TOTAL_SUBSET = {4, 20, 52, 104, 204}; -static const std::vector GSUM = {0, 348, 1388, 2948, 3988}; - -static const std::vector> FINDER_PATTERNS = { - {1,8,4,1}, // A - {3,6,4,1}, // B - {3,4,6,1}, // C - {3,2,8,1}, // D - {2,6,5,1}, // E - {2,2,9,1} // F -}; - -static const std::vector> WEIGHTS = { - { 1, 3, 9, 27, 81, 32, 96, 77}, - { 20, 60, 180, 118, 143, 7, 21, 63}, - {189, 145, 13, 39, 117, 140, 209, 205}, - {193, 157, 49, 147, 19, 57, 171, 91}, - { 62, 186, 136, 197, 169, 85, 44, 132}, - {185, 133, 188, 142, 4, 12, 36, 108}, - {113, 128, 173, 97, 80, 29, 87, 50}, - {150, 28, 84, 41, 123, 158, 52, 156}, - { 46, 138, 203, 187, 139, 206, 196, 166}, - { 76, 17, 51, 153, 37, 111, 122, 155}, - { 43, 129, 176, 106, 107, 110, 119, 146}, - { 16, 48, 144, 10, 30, 90, 59, 177}, - {109, 116, 137, 200, 178, 112, 125, 164}, - { 70, 210, 208, 202, 184, 130, 179, 115}, - {134, 191, 151, 31, 93, 68, 204, 190}, - {148, 22, 66, 198, 172, 94, 71, 2}, - { 6, 18, 54, 162, 64, 192,154, 40}, - {120, 149, 25, 75, 14, 42,126, 167}, - { 79, 26, 78, 23, 69, 207,199, 175}, - {103, 98, 83, 38, 114, 131, 182, 124}, - {161, 61, 183, 127, 170, 88, 53, 159}, - { 55, 165, 73, 8, 24, 72, 5, 15}, - { 45, 135, 194, 160, 58, 174, 100, 89} -}; - -static const int FINDER_PAT_A = 0; -static const int FINDER_PAT_B = 1; -static const int FINDER_PAT_C = 2; -static const int FINDER_PAT_D = 3; -static const int FINDER_PAT_E = 4; -static const int FINDER_PAT_F = 5; - -static std::vector> FINDER_PATTERN_SEQUENCES = { - { FINDER_PAT_A, FINDER_PAT_A }, - { FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B }, - { FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D }, - { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_C }, - { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_F }, - { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, - { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, -}; - -static const int MAX_PAIRS = 11; - -Ref RSSExpandedReader::decodeRow(int rowNumber, Ref row, DecodeHints hints) -{ - // Rows can start with even pattern in case in prev rows there where odd number of patters. - // So lets try twice - m_pairs.clear(); - m_startFromEven = false; - try { - return constructResult(decodeRow2pairs(rowNumber, row)); - } catch (NotFoundException e) { - // OK - } - - m_pairs.clear(); - m_startFromEven = true; - return constructResult(decodeRow2pairs(rowNumber, row)); -} - -void RSSExpandedReader::reset() { - m_pairs.clear(); - m_rows.clear(); -} - -std::vector RSSExpandedReader::decodeRow2pairs(int rowNumber, Ref row) -{ - boolean done = false; - while (!done) { - try { - m_pairs.push_back(retrieveNextPair(row, m_pairs, rowNumber)); - } catch (NotFoundException nfe) { - if (m_pairs.size() == 0) { - throw nfe; - } - // exit this loop when retrieveNextPair() fails and throws - done = true; - } - } - - // TODO: verify sequence of finder patterns as in checkPairSequence() - if (checkChecksum()) { - return m_pairs; - } - - bool tryStackedDecode = !(m_rows.size() == 0); - storeRow(rowNumber, false); // TODO: deal with reversed rows - if (tryStackedDecode) { - // When the image is 180-rotated, then rows are sorted in wrong direction. - // Try twice with both the directions. - std::vector ps = checkRows(false); - if (ps.size() != 0) { - return ps; - } - ps = checkRows(true); - if (ps.size() != 0) { - return ps; - } - } - - throw NotFoundException(); -} - -std::vector RSSExpandedReader::checkRows(boolean reverse) { - // Limit number of rows we are checking - // We use recursive algorithm with pure complexity and don't want it to take forever - // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough - if (m_rows.size() > 25) { - m_rows.clear(); // We will never have a chance to get result, so clear it - return {}; - } - - m_pairs.clear(); - if (reverse) { - std::reverse(m_rows.begin(), m_rows.end()); - } - - std::vector ps; - try { - ps = checkRows({}, 0); - } catch (NotFoundException e) { - // OK - } - - if (reverse) { - std::reverse(m_rows.begin(), m_rows.end()); - } - - return ps; -} - -std::vector RSSExpandedReader::checkRows(std::vector collectedRows, int currentRow) -{ - for (int i = currentRow; i < m_rows.size(); i++) { - ExpandedRow row = m_rows[i]; - m_pairs.clear(); - for (ExpandedRow collectedRow : collectedRows) { - - std::vector collectedRowPairs = collectedRow.getPairs();///////////////////// - m_pairs.insert(m_pairs.begin(), collectedRowPairs.begin(), - collectedRowPairs.end()); - - // m_pairs.m(collectedRow.getPairs()); - } - std::vector rowPairs = row.getPairs(); - m_pairs.insert(m_pairs.begin(), rowPairs.begin(), - rowPairs.end()); - //m_pairs.addAll(row.getPairs()); - - if (isValidSequence(m_pairs)) { - if (checkChecksum()) { - return m_pairs; - } - - std::vector rs(collectedRows); - rs.push_back(row); - try { - // Recursion: try to add more rows - return checkRows(rs, i + 1); - } catch (NotFoundException e) { - // We failed, try the next candidate - } - } - } - - throw NotFoundException(); -} - -boolean RSSExpandedReader::isValidSequence(std::vector pairs) { - for (std::vector sequence : FINDER_PATTERN_SEQUENCES) { - if (pairs.size() <= sequence.size()) { - boolean stop = true; - for (int j = 0; j < pairs.size(); j++) { - if (pairs[j].getFinderPattern().getValue() != sequence[j]) { - stop = false; - break; - } - } - if (stop) { - return true; - } - } - - } - - return false; -} - -void RSSExpandedReader::storeRow(int rowNumber, bool wasReversed) -{ - // Discard if duplicate above or below; otherwise insert in order by row number. - int insertPos = 0; - bool prevIsSame = false; - bool nextIsSame = false; - while (insertPos < m_rows.size()) { - ExpandedRow erow = m_rows[insertPos]; - if (erow.getRowNumber() > rowNumber) { - nextIsSame = erow.isEquivalent(m_pairs); - break; - } - prevIsSame = erow.isEquivalent(m_pairs); - insertPos++; - } - if (nextIsSame || prevIsSame) { - return; - } - - // When the row was partially decoded (e.g. 2 pairs found instead of 3), - // it will prevent us from detecting the barcode. - // Try to merge partial rows - - // Check whether the row is part of an already detected row - if (isPartialRow(m_pairs, m_rows)) { - return; - } - - m_rows.insert(m_rows.begin() + insertPos, ExpandedRow(m_pairs, rowNumber, wasReversed)); ///////////////////// - - removePartialRows(m_pairs, m_rows); -} - -void RSSExpandedReader::removePartialRows(std::vector pairs, std::vector rows) { - for (std::vector::iterator iterator = rows.begin(); iterator != rows.end(); ++iterator) { - if (iterator->getPairs().size() != pairs.size()) { - boolean allFound = true; - for (ExpandedPair p : iterator->getPairs()) { - if (std::find(pairs.begin(), pairs.end(), p) == pairs.end()) { ////////////////////////////// - allFound = false; - break; - } - } - if (allFound) { - // 'pairs' contains all the pairs from the row 'r' - rows.erase(iterator--); - } - } - } -} - -bool RSSExpandedReader::isPartialRow(std::vector pairs, std::vector rows) { - for (ExpandedRow r : rows) { - bool allFound = true; - for (ExpandedPair p : pairs) { - bool found = false; - for (ExpandedPair pp : r.getPairs()) { - if (p.equals(pp)) { - found = true; - break; - } - } - if (!found) { - allFound = false; - break; - } - } - if (allFound) { - // the row 'r' contain all the pairs from 'pairs' - return true; - } - } - return false; -} - -std::vector RSSExpandedReader::getRows() { - return m_rows; -} - -Ref RSSExpandedReader::constructResult(std::vector pairs) -{ - Ref binary = BitArrayBuilder::buildBitArray(pairs); - - AbstractExpandedDecoder* decoder = AbstractExpandedDecoder::createDecoder(binary); - String resultingString = decoder->parseInformation(); - - // ArrayRef< Ref > firstPoints - - ArrayRef< Ref > firstPoints = pairs[0].getFinderPattern().getResultPoints(); - ArrayRef< Ref > lastPoints = pairs[pairs.size() - 1].getFinderPattern().getResultPoints(); - - ArrayRef< Ref > resultPoints(4); - resultPoints[0] = firstPoints[0]; - resultPoints[1] = firstPoints[1]; - resultPoints[2] = lastPoints[0]; - resultPoints[3] = lastPoints[1]; - - return Ref(new Result( - Ref(new String(resultingString)), - nullptr, - resultPoints, - BarcodeFormat::RSS_EXPANDED - )); -} - -bool RSSExpandedReader::checkChecksum() { - ExpandedPair firstPair = m_pairs[0]; - DataCharacter checkCharacter = firstPair.getLeftChar(); - DataCharacter firstCharacter = firstPair.getRightChar(); - - if (firstCharacter.getValue() == 0) { /////////////////////////////// - return false; - } - - int checksum = firstCharacter.getChecksumPortion(); - int s = 2; - - for (int i = 1; i < m_pairs.size(); ++i) { - ExpandedPair currentPair = m_pairs[i]; - checksum += currentPair.getLeftChar().getChecksumPortion(); - s++; - DataCharacter currentRightChar = currentPair.getRightChar(); ////////////////////////// - if (currentRightChar.getValue() == 0) { - checksum += currentRightChar.getChecksumPortion(); - s++; - } - } - - checksum %= 211; - - int checkCharacterValue = 211 * (s - 4) + checksum; - - return checkCharacterValue == checkCharacter.getValue(); -} - -int RSSExpandedReader::getNextSecondBar(Ref row, int initialPos) { - int currentPos; - if (row->get(initialPos)) { - currentPos = row->getNextUnset(initialPos); - currentPos = row->getNextSet(currentPos); - } else { - currentPos = row->getNextSet(initialPos); - currentPos = row->getNextUnset(currentPos); - } - return currentPos; -} - -ExpandedPair RSSExpandedReader::retrieveNextPair(Ref row, std::vector previousPairs, int rowNumber) -{ - bool isOddPattern = previousPairs.size() % 2 == 0; - if (m_startFromEven) { - isOddPattern = !isOddPattern; - } - - FinderPattern pattern; - - boolean keepFinding = true; - int forcedOffset = -1; - do { - findNextPair(row, previousPairs, forcedOffset); - pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern); - if (pattern.getValue() == 0) { /////////////////////////////////////////////////// - forcedOffset = getNextSecondBar(row, m_startEnd[0]); - } else { - keepFinding = false; - } - } while (keepFinding); - - // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not. - // boolean mayBeLast = checkPairSequence(previousPairs, pattern); - - DataCharacter leftChar = decodeDataCharacter(row, pattern, isOddPattern, true); - - if (!(previousPairs.size() == 0) && previousPairs[previousPairs.size() - 1].mustBeLast()) { - throw NotFoundException(); - } - - DataCharacter rightChar; - try { - rightChar = decodeDataCharacter(row, pattern, isOddPattern, false); - } catch (NotFoundException ignored) { - //rightChar = nullptr; - } - return ExpandedPair(leftChar, rightChar, pattern); -} - -void RSSExpandedReader::findNextPair(Ref row, std::vector previousPairs, int forcedOffset) -{ - std::vector counters = getDecodeFinderCounters(); - counters[0] = 0; - counters[1] = 0; - counters[2] = 0; - counters[3] = 0; - - int width = row->getSize(); - - int rowOffset; - if (forcedOffset >= 0) { - rowOffset = forcedOffset; - } else if (previousPairs.size() == 0) { - rowOffset = 0; - } else { - ExpandedPair lastPair = previousPairs[previousPairs.size() - 1]; - rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; - } - boolean searchingEvenPair = previousPairs.size() % 2 != 0; - if (m_startFromEven) { - searchingEvenPair = !searchingEvenPair; - } - - boolean isWhite = false; - while (rowOffset < width) { - isWhite = !row->get(rowOffset); - if (!isWhite) { - break; - } - rowOffset++; - } - - int counterPosition = 0; - int patternStart = rowOffset; - for (int x = rowOffset; x < width; x++) { - if (row->get(x) != isWhite) { - counters[counterPosition]++; - } else { - if (counterPosition == 3) { - if (searchingEvenPair) { - std::reverse(counters.begin(), counters.end()); - // reverseCounters(counters); //////////////////////////////// - } - - if (isFinderPattern(counters)) { - m_startEnd[0] = patternStart; - m_startEnd[1] = x; - return; - } - - if (searchingEvenPair) { - std::reverse(counters.begin(), counters.end()); - // reverseCounters(counters); ////////////////////////////////// - } - - patternStart += counters[0] + counters[1]; - counters[0] = counters[2]; - counters[1] = counters[3]; - counters[2] = 0; - counters[3] = 0; - counterPosition--; - } else { - counterPosition++; - } - counters[counterPosition] = 1; - isWhite = !isWhite; - } - } - throw NotFoundException(); -} - -FinderPattern RSSExpandedReader::parseFoundFinderPattern(Ref row, int rowNumber, bool oddPattern) { - // Actually we found elements 2-5. - int firstCounter; - int start; - int end; - - if (oddPattern) { - // If pattern number is odd, we need to locate element 1 *before* the current block. - - int firstElementStart = m_startEnd[0] - 1; - // Locate element 1 - while (firstElementStart >= 0 && !row->get(firstElementStart)) { - firstElementStart--; - } - - firstElementStart++; - firstCounter = m_startEnd[0] - firstElementStart; - start = firstElementStart; - end = m_startEnd[1]; - - } else { - // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block. - - start = m_startEnd[0]; - - end = row->getNextUnset(m_startEnd[1] + 1); - firstCounter = end - m_startEnd[1]; - } - - // Make 'counters' hold 1-4 - std::vector counters = getDecodeFinderCounters(); - - std::vector _counters = counters; - for (int i = 1; i < counters.size(); i++) { - counters[i] = _counters[i - 1]; - } - - // System.arraycopy(counters, 0, counters, 1, counters.length - 1); ///////////////////////// - - counters[0] = firstCounter; - int value; - try { - value = parseFinderValue(counters, FINDER_PATTERNS); - } catch (NotFoundException ignored) { - return FinderPattern(); - } - return FinderPattern(value, {start, end}, start, end, rowNumber); -} - -DataCharacter RSSExpandedReader::decodeDataCharacter(Ref row, FinderPattern pattern, bool isOddPattern, bool leftChar) -{ - std::vector counters = getDataCharacterCounters(); - for (int x = 0; x < counters.size(); x++) { - counters[x] = 0; - } - - if (leftChar) { - recordPattern(row, pattern.getStartEnd()[0], counters); ////////////////////////////// - } else { - recordPattern(row, pattern.getStartEnd()[1], counters); - // reverse it - for (int i = 0, j = counters.size() - 1; i < j; i++, j--) { - int temp = counters[i]; - counters[i] = counters[j]; - counters[j] = temp; - } - } //counters[] has the pixels of the module - - int numModules = 17; //left and right data characters have all the same length - float elementWidth = MathUtils::sum(counters) / (float) numModules; - - // Sanity check: element width for pattern and the character should match - float expectedElementWidth = (pattern.getStartEnd()[1] - pattern.getStartEnd()[0]) / 15.0f; - if (std::abs(elementWidth - expectedElementWidth) / expectedElementWidth > 0.3f) { - throw NotFoundException(); - } - - std::vector oddCounts = getOddCounts(); - std::vector evenCounts = getEvenCounts(); - std::vector oddRoundingErrors = getOddRoundingErrors(); - std::vector evenRoundingErrors = getEvenRoundingErrors(); - - for (int i = 0; i < counters.size(); i++) { - float value = 1.0f * counters[i] / elementWidth; - int count = (int) (value + 0.5f); // Round - if (count < 1) { - if (value < 0.3f) { - throw NotFoundException(); - } - count = 1; - } else if (count > 8) { - if (value > 8.7f) { - throw NotFoundException(); - } - count = 8; - } - int offset = i / 2; - if ((i & 0x01) == 0) { - oddCounts[offset] = count; - oddRoundingErrors[offset] = value - count; - } else { - evenCounts[offset] = count; - evenRoundingErrors[offset] = value - count; - } - } - - adjustOddEvenCounts(numModules); - - int weightRowNumber = 4 * pattern.getValue() + (isOddPattern ? 0 : 2) + (leftChar ? 0 : 1) - 1; - - int oddSum = 0; - int oddChecksumPortion = 0; - for (int i = oddCounts.size() - 1; i >= 0; i--) { - if (isNotA1left(pattern, isOddPattern, leftChar)) { - int weight = WEIGHTS[weightRowNumber][2 * i]; - oddChecksumPortion += oddCounts[i] * weight; - } - oddSum += oddCounts[i]; - } - int evenChecksumPortion = 0; - for (int i = evenCounts.size() - 1; i >= 0; i--) { - if (isNotA1left(pattern, isOddPattern, leftChar)) { - int weight = WEIGHTS[weightRowNumber][2 * i + 1]; - evenChecksumPortion += evenCounts[i] * weight; - } - } - int checksumPortion = oddChecksumPortion + evenChecksumPortion; - - if ((oddSum & 0x01) != 0 || oddSum > 13 || oddSum < 4) { - throw NotFoundException(); - } - - int group = (13 - oddSum) / 2; - int oddWidest = SYMBOL_WIDEST[group]; - int evenWidest = 9 - oddWidest; - int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, true); - int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, false); - int tEven = EVEN_TOTAL_SUBSET[group]; - int gSum = GSUM[group]; - int value = vOdd * tEven + vEven + gSum; - - return DataCharacter(value, checksumPortion); -} - -bool RSSExpandedReader::isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar) { - // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char - return !(pattern.getValue() == 0 && isOddPattern && leftChar); -} - -void RSSExpandedReader::adjustOddEvenCounts(int numModules){ - - int oddSum = MathUtils::sum(getOddCounts()); - int evenSum = MathUtils::sum(getEvenCounts()); - - boolean incrementOdd = false; - boolean decrementOdd = false; - - if (oddSum > 13) { - decrementOdd = true; - } else if (oddSum < 4) { - incrementOdd = true; - } - boolean incrementEven = false; - boolean decrementEven = false; - if (evenSum > 13) { - decrementEven = true; - } else if (evenSum < 4) { - incrementEven = true; - } - - int mismatch = oddSum + evenSum - numModules; - boolean oddParityBad = (oddSum & 0x01) == 1; - boolean evenParityBad = (evenSum & 0x01) == 0; - switch (mismatch) { - case 1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException(); - } - decrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException(); - } - decrementEven = true; - } - break; - case -1: - if (oddParityBad) { - if (evenParityBad) { - throw NotFoundException(); - } - incrementOdd = true; - } else { - if (!evenParityBad) { - throw NotFoundException(); - } - incrementEven = true; - } - break; - case 0: - if (oddParityBad) { - if (!evenParityBad) { - throw NotFoundException(); - } - // Both bad - if (oddSum < evenSum) { - incrementOdd = true; - decrementEven = true; - } else { - decrementOdd = true; - incrementEven = true; - } - } else { - if (evenParityBad) { - throw NotFoundException(); - } - // Nothing to do! - } - break; - default: - throw NotFoundException(); - } - - if (incrementOdd) { - if (decrementOdd) { - throw NotFoundException(); - } - increment(getOddCounts(), getOddRoundingErrors()); - } - if (decrementOdd) { - decrement(getOddCounts(), getOddRoundingErrors()); - } - if (incrementEven) { - if (decrementEven) { - throw NotFoundException(); - } - increment(getEvenCounts(), getOddRoundingErrors()); - } - if (decrementEven) { - decrement(getEvenCounts(), getEvenRoundingErrors()); - } -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h deleted file mode 100644 index 5b73a71..0000000 --- a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef RSS_EXPANDED_READER_H -#define RSS_EXPANDED_READER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include -#include -#include -#include "ExpandedPair.h" -#include "ExpandedRow.h" -#include "BitArrayBuilder.h" -#include "decoders/AbstractExpandedDecoder.h" - -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class RSSExpandedReader : public AbstractRSSReader -{ - -private: - std::vector m_pairs;// = new std::vector(MAX_PAIRS); - std::vector m_rows;// = new ArrayList<>(); - std::vector m_startEnd;// = new int[2]; - bool m_startFromEven; - -public: - Ref decodeRow(int rowNumber, - Ref row, - DecodeHints hints); - - void reset(); - - // Not private for testing - std::vector decodeRow2pairs(int rowNumber, Ref row); - - std::vector checkRows(boolean reverse); - - // Try to construct a valid rows sequence - // Recursion is used to implement backtracking - std::vector checkRows(std::vector collectedRows, int currentRow); - - // Whether the pairs form a valid find pattern sequence, - // either complete or a prefix - static boolean isValidSequence(std::vector pairs); - - void storeRow(int rowNumber, bool wasReversed); - - // Remove all the rows that contains only specified pairs - static void removePartialRows(std::vector pairs, std::vector rows); - - // Returns true when one of the rows already contains all the pairs - static bool isPartialRow(std::vector pairs, std::vector rows); - - // Only used for unit testing - std::vector getRows(); - - // Not private for unit testing - static Ref constructResult(std::vector pairs); - - bool checkChecksum(); - - static int getNextSecondBar(Ref row, int initialPos); - - // not private for testing - ExpandedPair retrieveNextPair(Ref row, std::vector previousPairs, int rowNumber); - - void findNextPair(Ref row, std::vector previousPairs, int forcedOffset); - - // private static void reverseCounters(int [] counters) { - // int length = counters.length; - // for (int i = 0; i < length / 2; ++i) { - // int tmp = counters[i]; - // counters[i] = counters[length - i - 1]; - // counters[length - i - 1] = tmp; - //} - //} - - FinderPattern parseFoundFinderPattern(Ref row, int rowNumber, bool oddPattern); - - DataCharacter decodeDataCharacter(Ref row, - FinderPattern pattern, - bool isOddPattern, - bool leftChar); - - static bool isNotA1left(FinderPattern pattern, boolean isOddPattern, boolean leftChar); - - void adjustOddEvenCounts(int numModules); -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp deleted file mode 100644 index 0589ebf..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "AI013103decoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI013103decoder::AI013103decoder(Ref information) : AI013x0xDecoder(information) { -} - -void AI013103decoder::addWeightCode(String buf, int weight) { - buf.append("(3103)"); -} - -int AI013103decoder::checkWeight(int weight) { - return weight; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h deleted file mode 100644 index fa2f169..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef AI013_103X_DECODER_H -#define AI013_103X_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ -#include "AI013x0xDecoder.h" -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -class AI013103decoder : public AI013x0xDecoder -{ - -public: - AI013103decoder(Ref information); - -protected: - virtual void addWeightCode(String buf, int weight) override; - -protected: - virtual int checkWeight(int weight) override; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp deleted file mode 100644 index 15e4e3f..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "AI01320xDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI01320xDecoder::AI01320xDecoder(Ref information) : AI013x0xDecoder(information) { -} - -void AI01320xDecoder::addWeightCode(String buf, int weight) { - if (weight < 10000) { - buf.append("(3202)"); - } else { - buf.append("(3203)"); - } -} - -int AI01320xDecoder::checkWeight(int weight) { - if (weight < 10000) { - return weight; - } - return weight - 10000; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h deleted file mode 100644 index c96eef3..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef AI013_20X_DECODER_H -#define AI013_20X_DECODER_H -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI013x0xDecoder.h" -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -class AI01320xDecoder : public AI013x0xDecoder -{ - -public: - AI01320xDecoder(Ref information); - -protected: - virtual void addWeightCode(String buf, int weight) override; - - virtual int checkWeight(int weight) override; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp deleted file mode 100644 index 8eb57ed..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "AI01392xDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI01392xDecoder::AI01392xDecoder(Ref information) : AI01decoder(information) { -} - -String AI01392xDecoder::parseInformation() { - if (getInformation()->getSize() < HEADER_SIZE + GTIN_SIZE) { - throw NotFoundException(); - } - - String buf(""); - - encodeCompressedGtin(buf, HEADER_SIZE); - - int lastAIdigit = - getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); - buf.append("(392"); - buf.append(lastAIdigit); - buf.append(')'); - - DecodedInformation decodedInformation = - getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, String("")); - buf.append(decodedInformation.getNewString().getText()); - - return buf; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h deleted file mode 100644 index 018876b..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef AI013_392X_DECODER_H -#define AI013_393X_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI01decoder.h" -#include "DecodedInformation.h" -#include -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ - -class AI01392xDecoder : public AI01decoder -{ - - static const int HEADER_SIZE = 5 + 1 + 2; - static const int LAST_DIGIT_SIZE = 2; -public: - AI01392xDecoder(Ref information); - - virtual String parseInformation() override; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp deleted file mode 100644 index 8282f0a..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "AI01393xDecoder.h" - -#include "DecodedInformation.h" -#include -#include - -namespace zxing { -namespace oned { -namespace rss { - -AI01393xDecoder::AI01393xDecoder(Ref information) : AI01decoder(information) { -} - -String AI01393xDecoder::parseInformation() { - if (getInformation()->getSize() < HEADER_SIZE + GTIN_SIZE) { - throw NotFoundException(); - } - - String buf(""); - - encodeCompressedGtin(buf, HEADER_SIZE); - - int lastAIdigit = - getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); - - buf.append("(393"); - buf.append(lastAIdigit); - buf.append(')'); - - int firstThreeDigits = getGeneralDecoder().extractNumericValueFromBitArray( - HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE); - if (firstThreeDigits / 100 == 0) { - buf.append('0'); - } - if (firstThreeDigits / 10 == 0) { - buf.append('0'); - } - buf.append(firstThreeDigits); - - DecodedInformation generalInformation = getGeneralDecoder().decodeGeneralPurposeField( - HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, String("")); - buf.append(generalInformation.getNewString().getText()); - - return buf; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h deleted file mode 100644 index 7ed70a6..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef AI013_393X_DECODER_H -#define AI013_393X_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI01decoder.h" -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ - -class AI01393xDecoder : public AI01decoder -{ - static const int HEADER_SIZE = 5 + 1 + 2; - static const int LAST_DIGIT_SIZE = 2; - static const int FIRST_THREE_DIGITS_SIZE = 10; - -public: - AI01393xDecoder(Ref information); - - virtual String parseInformation() override; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp deleted file mode 100644 index 100dd14..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "AI013x0x1xDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI013x0x1xDecoder::AI013x0x1xDecoder(Ref information, String firstAIdigits, String dateCode) - : AI01weightDecoder(information), m_dateCode(dateCode), m_firstAIdigits(firstAIdigits) -{ - -} - -String AI013x0x1xDecoder::parseInformation() { - if (getInformation()->getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) { - throw NotFoundException(); - } - - String buf(""); - - encodeCompressedGtin(buf, HEADER_SIZE); - encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); - encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); - - return buf; -} - -void AI013x0x1xDecoder::encodeCompressedDate(String buf, int currentPos) { - int numericDate = getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE); - if (numericDate == 38400) { - return; - } - - buf.append('('); - buf.append(m_dateCode.getText()); - buf.append(')'); - - int day = numericDate % 32; - numericDate /= 32; - int month = numericDate % 12 + 1; - numericDate /= 12; - int year = numericDate; - - if (year / 10 == 0) { - buf.append('0'); - } - buf.append(year); - if (month / 10 == 0) { - buf.append('0'); - } - buf.append(month); - if (day / 10 == 0) { - buf.append('0'); - } - buf.append(day); -} - -void AI013x0x1xDecoder::addWeightCode(String buf, int weight) { - buf.append('('); - buf.append(m_firstAIdigits.getText()); - buf.append(weight / 100000); - buf.append(')'); -} - -int AI013x0x1xDecoder::checkWeight(int weight) { - return weight % 100000; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h deleted file mode 100644 index df67bb2..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef AI013_X0X1X_DECODER_H -#define AI013_X0X1X_DECODER_H -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI01weightDecoder.h" -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - -class AI013x0x1xDecoder : public AI01weightDecoder -{ - - static const int HEADER_SIZE = 7 + 1; - static const int WEIGHT_SIZE = 20; - static const int DATE_SIZE = 16; -public: - AI013x0x1xDecoder(Ref information, String firstAIdigits, String dateCode); - - virtual String parseInformation() override; - -private: - void encodeCompressedDate(String buf, int currentPos); - -protected: - virtual void addWeightCode(String buf, int weight) override; - - virtual int checkWeight(int weight) override; - -private: - String m_dateCode; - String m_firstAIdigits; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp deleted file mode 100644 index a316615..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "AI013x0xDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI013x0xDecoder::AI013x0xDecoder(Ref information) : AI01weightDecoder(information) { } - -String AI013x0xDecoder::parseInformation() { - if (getInformation()->getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { - throw NotFoundException(); - } - - String buf(""); - - encodeCompressedGtin(buf, HEADER_SIZE); - encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); - - return buf; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h deleted file mode 100644 index a25600d..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef AI013_X0X_DECODER_H -#define AI013_X0X_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI01weightDecoder.h" -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ - -class AI013x0xDecoder : public AI01weightDecoder -{ - - static const int HEADER_SIZE = 4 + 1; - static const int WEIGHT_SIZE = 15; -public: - - AI013x0xDecoder(Ref information); - - virtual String parseInformation() override; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp deleted file mode 100644 index 03fed8c..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "AI01AndOtherAIs.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI01AndOtherAIs::AI01AndOtherAIs(Ref information) : AI01decoder(information) { -} - -String AI01AndOtherAIs::parseInformation() { - String buff("(01)"); - - int initialGtinPosition = buff.length(); - int firstGtinDigit = getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4); - buff.append(firstGtinDigit); - - encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initialGtinPosition); - - return getGeneralDecoder().decodeAllCodes(buff, HEADER_SIZE + 44); -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h deleted file mode 100644 index dd514e9..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef AI01_AND_OTHER_AIS_H -#define AI01_AND_OTHER_AIS_H -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI01decoder.h" -#include -#include -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - -class AI01AndOtherAIs : public AI01decoder -{ - - static const int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag, - //the second one is the encodation method, and the other two are for the variable length -public: - AI01AndOtherAIs(Ref information); - - virtual String parseInformation() override; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp deleted file mode 100644 index 7764f8a..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "AI01decoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI01decoder::AI01decoder(Ref information) : AbstractExpandedDecoder(information){ -} - -void AI01decoder::encodeCompressedGtin(String buf, int currentPos) { - buf.append("(01)"); - int initialPosition = buf.length(); - buf.append('9'); - - encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition); -} - -void AI01decoder::encodeCompressedGtinWithoutAI(String buf, int currentPos, int initialBufferPosition) { - for (int i = 0; i < 4; ++i) { - int currentBlock = getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10); - if (currentBlock / 100 == 0) { - buf.append("0"); - } - if (currentBlock / 10 == 0) { - buf.append("0"); - } - buf.append(currentBlock); - } - - appendCheckDigit(buf, initialBufferPosition); -} - -void AI01decoder::appendCheckDigit(String buf, int currentPos) { - int checkDigit = 0; - for (int i = 0; i < 13; i++) { - int digit = buf.charAt(i + currentPos) - '0'; - checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; - } - - checkDigit = 10 - (checkDigit % 10); - if (checkDigit == 10) { - checkDigit = 0; - } - - buf.append(checkDigit); -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h deleted file mode 100644 index 5dcc1af..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef AI01_DECODER_H -#define AI01_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AbstractExpandedDecoder.h" -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class AI01decoder : public AbstractExpandedDecoder -{ - -public: - static const int GTIN_SIZE = 40; - AI01decoder(Ref information); - - void encodeCompressedGtin(String buf, int currentPos); - - void encodeCompressedGtinWithoutAI(String buf, int currentPos, int initialBufferPosition); - - static void appendCheckDigit(String buf, int currentPos); - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp deleted file mode 100644 index af68c08..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "AI01weightDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AI01weightDecoder::AI01weightDecoder(Ref information) : AI01decoder(information) { -} - -void AI01weightDecoder::encodeCompressedWeight(String buf, int currentPos, int weightSize) { - int originalWeightNumeric = getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); - addWeightCode(buf, originalWeightNumeric); - - int weightNumeric = checkWeight(originalWeightNumeric); - - int currentDivisor = 100000; - for (int i = 0; i < 5; ++i) { - if (weightNumeric / currentDivisor == 0) { - buf.append('0'); - } - currentDivisor /= 10; - } - buf.append(weightNumeric); -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h deleted file mode 100644 index a66463b..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef AI01_WEIGHT_DECODER_H -#define AI01_WEIGHT_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "AI01decoder.h" -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -class AI01weightDecoder : public AI01decoder -{ -public: - AI01weightDecoder(Ref information); - - void encodeCompressedWeight(String buf, int currentPos, int weightSize); - -protected: - virtual void addWeightCode(String buf, int weight) = 0; - virtual int checkWeight(int weight) = 0; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp deleted file mode 100644 index 736a054..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "AbstractExpandedDecoder.h" - -#include "AI01AndOtherAIs.h" -#include "AI013x0x1xDecoder.h" -#include "AnyAIDecoder.h" -#include "AI013103decoder.h" -#include "AI01320xDecoder.h" -#include "AI01392xDecoder.h" -#include "AI01393xDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AbstractExpandedDecoder::AbstractExpandedDecoder(Ref information) - : m_information(information), m_generalDecoder(GeneralAppIdDecoder(information)) -{ - -} - -Ref AbstractExpandedDecoder::getInformation() { - return m_information; -} - -GeneralAppIdDecoder AbstractExpandedDecoder::getGeneralDecoder() -{ - return m_generalDecoder; -} - -AbstractExpandedDecoder *AbstractExpandedDecoder::createDecoder(Ref information) { - if (information->get(1)) { - return new AI01AndOtherAIs(information); - } - if (!information->get(2)) { - return new AnyAIDecoder(information); - } - - int fourBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 4); - - switch (fourBitEncodationMethod) { - case 4: return new AI013103decoder(information); - case 5: return new AI01320xDecoder(information); - } - - int fiveBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 5); - switch (fiveBitEncodationMethod) { - case 12: return new AI01392xDecoder(information); - //case 13: return new AI01393xDecoder(information); - } - - int sevenBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 7); - switch (sevenBitEncodationMethod) { - case 56: return new AI013x0x1xDecoder(information, String("310"), String("11")); - case 57: return new AI013x0x1xDecoder(information, String("320"), String("11")); - case 58: return new AI013x0x1xDecoder(information, String("310"), String("13")); - case 59: return new AI013x0x1xDecoder(information, String("320"), String("13")); - case 60: return new AI013x0x1xDecoder(information, String("310"), String("15")); - case 61: return new AI013x0x1xDecoder(information, String("320"), String("15")); - case 62: return new AI013x0x1xDecoder(information, String("310"), String("17")); - case 63: return new AI013x0x1xDecoder(information, String("320"), String("17")); - } - - throw IllegalStateException(); -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h deleted file mode 100644 index 2f7d773..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef ABSTRACT_EXPANDED_DECODER_H -#define ABSTRACT_EXPANDED_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "GeneralAppIdDecoder.h" -#include -#include -#include -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class AbstractExpandedDecoder -{ - -public: - AbstractExpandedDecoder(Ref information); - - Ref getInformation(); - - virtual GeneralAppIdDecoder getGeneralDecoder(); - - virtual String parseInformation() = 0; - - static AbstractExpandedDecoder* createDecoder(Ref information); - -protected: - Ref m_information; - GeneralAppIdDecoder m_generalDecoder; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp deleted file mode 100644 index 349e24c..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "AnyAIDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -AnyAIDecoder::AnyAIDecoder(Ref information) : AbstractExpandedDecoder(information) { } - -String AnyAIDecoder::parseInformation() { - String buf(""); - return getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE); -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h deleted file mode 100644 index 947f309..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef ANY_AI_DECODER_H -#define ANY_AI_DECODER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include -#include -#include -#include "AbstractExpandedDecoder.h" - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - -class AnyAIDecoder : public AbstractExpandedDecoder -{ - static const int HEADER_SIZE = 2 + 1 + 2; - -public: - AnyAIDecoder(Ref information); - - String parseInformation() override; -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp deleted file mode 100644 index 345c206..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "BlockParsedResult.h" - -namespace zxing { -namespace oned { -namespace rss { - -BlockParsedResult::BlockParsedResult(bool finished) : m_decodedInformation(nullptr), m_finished(finished) { -} - -BlockParsedResult::BlockParsedResult(const DecodedInformation &information, bool finished) { - m_finished = finished; - m_decodedInformation = information; -} - -BlockParsedResult::BlockParsedResult(const BlockParsedResult &other) { - m_finished = other.m_finished; - m_decodedInformation = other.m_decodedInformation; -} - -DecodedInformation BlockParsedResult::getDecodedInformation() { - return m_decodedInformation; -} - -bool BlockParsedResult::isFinished() { - return m_finished; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h deleted file mode 100644 index 79b4786..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef BLOCK_PARSED_RESULT_H -#define BLOCK_PARSED_RESULT_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "DecodedInformation.h" - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class BlockParsedResult -{ - -public: - - BlockParsedResult(bool finished); - - BlockParsedResult(const DecodedInformation& information, bool finished); - - BlockParsedResult(const BlockParsedResult& other); - - DecodedInformation getDecodedInformation(); - - bool isFinished(); - -private: - DecodedInformation m_decodedInformation; - bool m_finished; -}; - -} -} -} -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp deleted file mode 100644 index 8f6f81f..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "CurrentParsingState.h" - -namespace zxing { -namespace oned { -namespace rss { - -CurrentParsingState::CurrentParsingState() { - position = 0; - encoding = State::NUMERIC; -} - -int CurrentParsingState::getPosition() { - return position; -} - -void CurrentParsingState::setPosition(int _position) { - position = _position; -} - -void CurrentParsingState::incrementPosition(int delta) { - position += delta; -} - -bool CurrentParsingState::isAlpha() { - return encoding == State::ALPHA; -} - -bool CurrentParsingState::isNumeric() { - return encoding == State::NUMERIC; -} - -bool CurrentParsingState::isIsoIec646() { - return encoding == State::ISO_IEC_646; -} - -void CurrentParsingState::setNumeric() { - encoding = State::NUMERIC; -} - -void CurrentParsingState::setAlpha() { - encoding = State::ALPHA; -} - -void CurrentParsingState::setIsoIec646() { - encoding = State::ISO_IEC_646; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h deleted file mode 100644 index 2b155f8..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef CURRENT_PARSING_STATE_H -#define CURRENT_PARSING_STATE_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -class CurrentParsingState -{ -public: - enum State { - NUMERIC, - ALPHA, - ISO_IEC_646 - }; - - CurrentParsingState(); - - int getPosition(); - - void setPosition(int _position); - - void incrementPosition(int delta); - - bool isAlpha(); - - bool isNumeric(); - - bool isIsoIec646(); - - void setNumeric(); - - void setAlpha(); - - void setIsoIec646(); - -private: - int position; - State encoding; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp deleted file mode 100644 index 80bfd4e..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "DecodedChar.h" - -namespace zxing { -namespace oned { -namespace rss { - -DecodedChar::DecodedChar(int newPosition, char value) : DecodedObject (newPosition) { - m_value = value; -} - -char DecodedChar::getValue() { - return m_value; -} - -bool DecodedChar::isFNC1() { - return m_value == FNC1; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h deleted file mode 100644 index c98841c..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef DECODED_CHAR_H -#define DECODED_CHAR_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "DecodedObject.h" - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class DecodedChar : public DecodedObject -{ -public: - static const char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset - DecodedChar(int newPosition, char value); - - char getValue(); - - bool isFNC1(); - -private: - char m_value; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp deleted file mode 100644 index d0e2cba..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "DecodedInformation.h" - -namespace zxing { -namespace oned { -namespace rss { - -DecodedInformation::DecodedInformation(const DecodedInformation *other) : - DecodedObject (other->m_newPosition), - m_newString(other->m_newString) -{ - m_newString = other->m_newString; - m_remaining = other->m_remaining; - m_remainingValue = other->m_remainingValue; -} - -DecodedInformation::DecodedInformation(int newPosition, String newString) : - DecodedObject (newPosition), - m_newString(newString) -{ - m_remaining = false; - m_remainingValue = 0; -} - -DecodedInformation::DecodedInformation(int newPosition, String newString, int remainingValue) : - DecodedObject (newPosition), - m_newString(newString) -{ - m_remaining = true; - m_remainingValue = remainingValue; -} - -String DecodedInformation::getNewString() { - return m_newString; -} - -bool DecodedInformation::isRemaining() { - return m_remaining; -} - -int DecodedInformation::getRemainingValue() { - return m_remainingValue; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h deleted file mode 100644 index 7f6e2e5..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef DECODED_INFORMATION_H -#define DECODED_INFORMATION_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include "DecodedObject.h" -#include - -namespace zxing { - -namespace oned { - -namespace rss { -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class DecodedInformation : public DecodedObject -{ -public: - - DecodedInformation(const DecodedInformation* other = nullptr); - - DecodedInformation(int newPosition, String newString); - - DecodedInformation(int newPosition, String newString, int remainingValue); - - String getNewString(); - - bool isRemaining(); - - int getRemainingValue(); - -private: - String m_newString; - int m_remainingValue; - bool m_remaining; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp deleted file mode 100644 index 5bfb859..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "DecodedNumeric.h" - -namespace zxing { -namespace oned { -namespace rss { - -DecodedNumeric::DecodedNumeric(int newPosition, int firstDigit, int secondDigit) - : DecodedObject(newPosition) { - - if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) { - throw FormatException::getFormatInstance(); - } - - m_newPosition = newPosition; - m_firstDigit = firstDigit; - m_secondDigit = secondDigit; -} - -int DecodedNumeric::getFirstDigit() { - return m_firstDigit; -} - -int DecodedNumeric::getSecondDigit() { - return m_secondDigit; -} - -int DecodedNumeric::getValue() { - return m_firstDigit * 10 + m_secondDigit; -} - -bool DecodedNumeric::isFirstDigitFNC1() { - return m_firstDigit == FNC1; -} - -bool DecodedNumeric::isSecondDigitFNC1() { - return m_secondDigit == FNC1; -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h deleted file mode 100644 index 1f6f5a5..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef DECODED_NUMERIC_H -#define DECODED_NUMERIC_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include -#include "DecodedObject.h" - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - -class DecodedNumeric : public DecodedObject -{ - -public: - static const int FNC1 = 10; - DecodedNumeric(int newPosition, int firstDigit, int secondDigit); - - int getFirstDigit(); - - int getSecondDigit(); - - int getValue(); - - bool isFirstDigitFNC1(); - - bool isSecondDigitFNC1(); - -private: - int m_firstDigit; - int m_secondDigit; - -}; - -} -} -} - -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp deleted file mode 100644 index c116c13..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "DecodedObject.h" - -namespace zxing { -namespace oned { -namespace rss { - -DecodedObject::DecodedObject(int newPosition) : m_newPosition(newPosition) { } - -int DecodedObject::getNewPosition() { - return m_newPosition; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h deleted file mode 100644 index 5f3f060..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef DECODED_OBJECT_H -#define DECODED_OBJECT_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ -namespace zxing { - -namespace oned { - -namespace rss { -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - */ -class DecodedObject -{ - -public: - DecodedObject(int newPosition); - - int getNewPosition(); - -protected: - int m_newPosition; -}; - -} -} -} -#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp deleted file mode 100644 index 40cca69..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp +++ /dev/null @@ -1,276 +0,0 @@ -#include "FieldParser.h" - -namespace zxing { -namespace oned { -namespace rss { - -static const int VARIABLE_LENGTH = 99999; - -struct DigitData { - std::string digit; - int variableLength; - int length; -}; - -static const DigitData TWO_DIGIT_DATA_LENGTH[] { - // "DIGITS", new Integer(LENGTH) - // or - // "DIGITS", VARIABLE_LENGTH, new Integer(MAX_SIZE) - - { "00", 0, 18}, - { "01", 0, 14}, - { "02", 0, 14}, - - { "10", VARIABLE_LENGTH, 20}, - { "11", 0, 6}, - { "12", 0, 6}, - { "13", 0, 6}, - { "15", 0, 6}, - { "17", 0, 6}, - - { "20", 0, 2}, - { "21", VARIABLE_LENGTH, 20}, - { "22", VARIABLE_LENGTH, 29}, - - { "30", VARIABLE_LENGTH, 8}, - { "37", VARIABLE_LENGTH, 8}, - - //internal company codes - { "90", VARIABLE_LENGTH, 30}, - { "91", VARIABLE_LENGTH, 30}, - { "92", VARIABLE_LENGTH, 30}, - { "93", VARIABLE_LENGTH, 30}, - { "94", VARIABLE_LENGTH, 30}, - { "95", VARIABLE_LENGTH, 30}, - { "96", VARIABLE_LENGTH, 30}, - { "97", VARIABLE_LENGTH, 30}, - { "98", VARIABLE_LENGTH, 30}, - { "99", VARIABLE_LENGTH, 30}, -}; - -static const DigitData THREE_DIGIT_DATA_LENGTH[] { - // Same format as above - - { "240", VARIABLE_LENGTH, 30}, - { "241", VARIABLE_LENGTH, 30}, - { "242", VARIABLE_LENGTH, 6}, - { "250", VARIABLE_LENGTH, 30}, - { "251", VARIABLE_LENGTH, 30}, - { "253", VARIABLE_LENGTH, 17}, - { "254", VARIABLE_LENGTH, 20}, - - { "400", VARIABLE_LENGTH, 30}, - { "401", VARIABLE_LENGTH, 30}, - { "402", 0, 17}, - { "403", VARIABLE_LENGTH, 30}, - { "410", 0, 13}, - { "411", 0, 13}, - { "412", 0, 13}, - { "413", 0, 13}, - { "414", 0, 13}, - { "420", VARIABLE_LENGTH, 20}, - { "421", VARIABLE_LENGTH, 15}, - { "422", 0, 3}, - { "423", VARIABLE_LENGTH, 15}, - { "424", 0, 3}, - { "425", 0, 3}, - { "426", 0, 3}, -}; - -static const DigitData THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH[] { - // Same format as above - - { "310", 0, 6}, - { "311", 0, 6}, - { "312", 0, 6}, - { "313", 0, 6}, - { "314", 0, 6}, - { "315", 0, 6}, - { "316", 0, 6}, - { "320", 0, 6}, - { "321", 0, 6}, - { "322", 0, 6}, - { "323", 0, 6}, - { "324", 0, 6}, - { "325", 0, 6}, - { "326", 0, 6}, - { "327", 0, 6}, - { "328", 0, 6}, - { "329", 0, 6}, - { "330", 0, 6}, - { "331", 0, 6}, - { "332", 0, 6}, - { "333", 0, 6}, - { "334", 0, 6}, - { "335", 0, 6}, - { "336", 0, 6}, - { "340", 0, 6}, - { "341", 0, 6}, - { "342", 0, 6}, - { "343", 0, 6}, - { "344", 0, 6}, - { "345", 0, 6}, - { "346", 0, 6}, - { "347", 0, 6}, - { "348", 0, 6}, - { "349", 0, 6}, - { "350", 0, 6}, - { "351", 0, 6}, - { "352", 0, 6}, - { "353", 0, 6}, - { "354", 0, 6}, - { "355", 0, 6}, - { "356", 0, 6}, - { "357", 0, 6}, - { "360", 0, 6}, - { "361", 0, 6}, - { "362", 0, 6}, - { "363", 0, 6}, - { "364", 0, 6}, - { "365", 0, 6}, - { "366", 0, 6}, - { "367", 0, 6}, - { "368", 0, 6}, - { "369", 0, 6}, - { "390", VARIABLE_LENGTH, 15}, - { "391", VARIABLE_LENGTH, 18}, - { "392", VARIABLE_LENGTH, 15}, - { "393", VARIABLE_LENGTH, 18}, - { "703", VARIABLE_LENGTH, 30}, -}; - -static const DigitData FOUR_DIGIT_DATA_LENGTH[] { - // Same format as above - - { "7001", 0, 13}, - { "7002", VARIABLE_LENGTH, 30}, - { "7003", 0, 10}, - - { "8001", 0, 14}, - { "8002", VARIABLE_LENGTH, 20}, - { "8003", VARIABLE_LENGTH, 30}, - { "8004", VARIABLE_LENGTH, 30}, - { "8005", 0, 6}, - { "8006", 0, 18}, - { "8007", VARIABLE_LENGTH, 30}, - { "8008", VARIABLE_LENGTH, 12}, - { "8018", 0, 18}, - { "8020", VARIABLE_LENGTH, 25}, - { "8100", 0, 6}, - { "8101", 0, 10}, - { "8102", 0, 2}, - { "8110", VARIABLE_LENGTH, 70}, - { "8200", VARIABLE_LENGTH, 70}, -}; - -FieldParser::FieldParser() { -} - -String FieldParser::parseFieldsInGeneralPurpose(String rawInformation) { - if (rawInformation.getText().empty()) { - return String(""); - } - - // Processing 2-digit AIs - - if (rawInformation.length() < 2) { - throw NotFoundException(); - } - - String firstTwoDigits(rawInformation.substring(0, 2)->getText()); - - for (DigitData dataLength : TWO_DIGIT_DATA_LENGTH) { - if (dataLength.digit == firstTwoDigits.getText()) { - if (dataLength.variableLength == VARIABLE_LENGTH) { - return processVariableAI(2, dataLength.length, rawInformation); - } - return processFixedAI(2, dataLength.length, rawInformation); - } - } - - if (rawInformation.length() < 3) { - throw NotFoundException(); - } - - String firstThreeDigits(rawInformation.substring(0, 3)->getText()); - - for (DigitData dataLength : THREE_DIGIT_DATA_LENGTH) { - if (dataLength.digit == firstThreeDigits.getText()) { - if (dataLength.variableLength == VARIABLE_LENGTH) { - return processVariableAI(3, dataLength.length, rawInformation); - } - return processFixedAI(3, dataLength.length, rawInformation); - } - } - - - for (DigitData dataLength : THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH) { - if (dataLength.digit == firstThreeDigits.getText()) { - if (dataLength.variableLength == VARIABLE_LENGTH) { - return processVariableAI(4, dataLength.length, rawInformation); - } - return processFixedAI(4, dataLength.length, rawInformation); - } - } - - if (rawInformation.length() < 4) { - throw NotFoundException(); - } - - String firstFourDigits(rawInformation.substring(0, 4)->getText()); - - for (DigitData dataLength : FOUR_DIGIT_DATA_LENGTH) { - if (dataLength.digit == firstFourDigits.getText()) { - if (dataLength.variableLength == VARIABLE_LENGTH) { - return processVariableAI(4, dataLength.length, rawInformation); - } - return processFixedAI(4, dataLength.length, rawInformation); - } - } - - throw NotFoundException(); -} - -String FieldParser::processFixedAI(int aiSize, int fieldSize, String rawInformation) -{ - if (rawInformation.length() < aiSize) { - throw NotFoundException(); - } - - String ai(rawInformation.substring(0, aiSize)->getText()); - - if (rawInformation.length() < aiSize + fieldSize) { - throw NotFoundException(); - } - - String field(rawInformation.substring(aiSize, aiSize + fieldSize)->getText()); - String remaining(rawInformation.substring(aiSize + fieldSize, 0)->getText()); - String result('(' + ai.getText() + ')' + field.getText()); - String parsedAI = parseFieldsInGeneralPurpose(remaining); - if (parsedAI.getText() == "") { - return result; - } else { - result.append(parsedAI.getText()); - return result; - } -} - -String FieldParser::processVariableAI(int aiSize, int variableFieldSize, String rawInformation) -{ - String ai(rawInformation.substring(0, aiSize)->getText()); - int maxSize = std::min(rawInformation.length(), aiSize + variableFieldSize); - String field(rawInformation.substring(aiSize, maxSize)->getText()); - String remaining(rawInformation.substring(maxSize, 0)->getText()); - String result('(' + ai.getText() + ')' + field.getText()); - String parsedAI = parseFieldsInGeneralPurpose(remaining); - if (parsedAI.getText() == "") { - return result; - } else { - result.append(parsedAI.getText()); - return result; - } -} - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h deleted file mode 100644 index a5bd3bd..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef FIELD_PARSER_H -#define FIELD_PARSER_H - -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include -#include - -#include - -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ - - -class FieldParser -{ - -public: - - FieldParser(); - - static String parseFieldsInGeneralPurpose(String rawInformation); - - static String processFixedAI(int aiSize, int fieldSize, String rawInformation); - - static String processVariableAI(int aiSize, int variableFieldSize, String rawInformation); -}; - -} -} -} - -#endif - diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp deleted file mode 100644 index 3d03553..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp +++ /dev/null @@ -1,447 +0,0 @@ -#include "GeneralAppIdDecoder.h" - -namespace zxing { -namespace oned { -namespace rss { - -GeneralAppIdDecoder::GeneralAppIdDecoder(Ref information) : m_buffer("") { - m_information = information; -} - -String GeneralAppIdDecoder::decodeAllCodes(String buff, int initialPosition) { - int currentPosition = initialPosition; - String remaining(""); - do { - DecodedInformation info(decodeGeneralPurposeField(currentPosition, remaining)); - String parsedFields = FieldParser::parseFieldsInGeneralPurpose(info.getNewString()); - if (parsedFields.length() > 0) { - buff.append(parsedFields.getText()); - } - if (info.isRemaining()) { - remaining = String(info.getRemainingValue()); - } else { - remaining = String(""); - } - - if (currentPosition == info.getNewPosition()) { // No step forward! - break; - } - currentPosition = info.getNewPosition(); - } while (true); - - return buff; -} - -bool GeneralAppIdDecoder::isStillNumeric(int pos) { - // It's numeric if it still has 7 positions - // and one of the first 4 bits is "1". - if (pos + 7 > m_information->getSize()) { - return pos + 4 <= m_information->getSize(); - } - - for (int i = pos; i < pos + 3; ++i) { - if (m_information->get(i)) { - return true; - } - } - - return m_information->get(pos + 3); -} - -DecodedNumeric GeneralAppIdDecoder::decodeNumeric(int pos) -{ - if (pos + 7 > m_information->getSize()) { - int numeric = extractNumericValueFromBitArray(pos, 4); - if (numeric == 0) { - return DecodedNumeric(m_information->getSize(), DecodedNumeric::FNC1, DecodedNumeric::FNC1); - } - return DecodedNumeric(m_information->getSize(), numeric - 1, DecodedNumeric::FNC1); - } - int numeric = extractNumericValueFromBitArray(pos, 7); - - int digit1 = (numeric - 8) / 11; - int digit2 = (numeric - 8) % 11; - - return DecodedNumeric(pos + 7, digit1, digit2); -} - -int GeneralAppIdDecoder::extractNumericValueFromBitArray(int pos, int bits) { - return extractNumericValueFromBitArray(m_information, pos, bits); -} - -int GeneralAppIdDecoder::extractNumericValueFromBitArray(Ref information, int pos, int bits) { - int value = 0; - for (int i = 0; i < bits; ++i) { - if (information->get(pos + i)) { - value |= 1 << (bits - i - 1); - } - } - - return value; -} - -DecodedInformation GeneralAppIdDecoder::decodeGeneralPurposeField(int pos, String remaining){ - m_buffer = String(""); - - if (remaining.length() > 0) { - m_buffer.append(remaining.getText()); - } - - m_current.setPosition(pos); - - DecodedInformation lastDecoded(parseBlocks()); - if (lastDecoded.getNewString().length() > 0 && lastDecoded.isRemaining()) { /////////////////// - return DecodedInformation(m_current.getPosition(), m_buffer, lastDecoded.getRemainingValue()); - } - return DecodedInformation(m_current.getPosition(), m_buffer); -} - -DecodedInformation GeneralAppIdDecoder::parseBlocks() -{ - bool isFinished; - BlockParsedResult result(false); - do { - int initialPosition = m_current.getPosition(); - - if (m_current.isAlpha()) { - result = parseAlphaBlock(); - isFinished = result.isFinished(); - } else if (m_current.isIsoIec646()) { - result = parseIsoIec646Block(); - isFinished = result.isFinished(); - } else { // it must be numeric - result = parseNumericBlock(); - isFinished = result.isFinished(); - } - - boolean positionChanged = initialPosition != m_current.getPosition(); - if (!positionChanged && !isFinished) { - break; - } - } while (!isFinished); - - return result.getDecodedInformation(); -} - -BlockParsedResult GeneralAppIdDecoder::parseNumericBlock(){ - while (isStillNumeric(m_current.getPosition())) { - DecodedNumeric numeric = decodeNumeric(m_current.getPosition()); - m_current.setPosition(numeric.getNewPosition()); - - if (numeric.isFirstDigitFNC1()) { - DecodedInformation information(0, String("")); //////////////// - if (numeric.isSecondDigitFNC1()) { - // information = DecodedInformation(m_current.getPosition(), m_buffer.getText()); ///////////////// - return new BlockParsedResult(DecodedInformation(m_current.getPosition(), m_buffer), true); - } else { - // information = new DecodedInformation(m_current.getPosition(), m_buffer.getText(), numeric.getSecondDigit()); - return new BlockParsedResult(DecodedInformation(m_current.getPosition(), m_buffer, numeric.getSecondDigit()), true); - } - } - m_buffer.append(numeric.getFirstDigit()); - - if (numeric.isSecondDigitFNC1()) { - DecodedInformation information(m_current.getPosition(), m_buffer); - return new BlockParsedResult(information, true); - } - m_buffer.append(numeric.getSecondDigit()); - } - - if (isNumericToAlphaNumericLatch(m_current.getPosition())) { - m_current.setAlpha(); - m_current.incrementPosition(4); - } - return new BlockParsedResult(false); -} - -BlockParsedResult GeneralAppIdDecoder::parseIsoIec646Block() -{ - while (isStillIsoIec646(m_current.getPosition())) { - DecodedChar iso = decodeIsoIec646(m_current.getPosition()); - m_current.setPosition(iso.getNewPosition()); - - if (iso.isFNC1()) { - DecodedInformation information(m_current.getPosition(), m_buffer); - return new BlockParsedResult(information, true); - } - m_buffer.append(iso.getValue()); - } - - if (isAlphaOr646ToNumericLatch(m_current.getPosition())) { - m_current.incrementPosition(3); - m_current.setNumeric(); - } else if (isAlphaTo646ToAlphaLatch(m_current.getPosition())) { - if (m_current.getPosition() + 5 < m_information->getSize()) { - m_current.incrementPosition(5); - } else { - m_current.setPosition(m_information->getSize()); - } - - m_current.setAlpha(); - } - return new BlockParsedResult(false); -} - -BlockParsedResult GeneralAppIdDecoder::parseAlphaBlock() -{ - while (isStillAlpha(m_current.getPosition())) { - DecodedChar alpha(decodeAlphanumeric(m_current.getPosition())); - m_current.setPosition(alpha.getNewPosition()); - - if (alpha.isFNC1()) { - DecodedInformation information(m_current.getPosition(), m_buffer); - return new BlockParsedResult(information, true); //end of the char block - } - - m_buffer.append(alpha.getValue()); - } - - if (isAlphaOr646ToNumericLatch(m_current.getPosition())) { - m_current.incrementPosition(3); - m_current.setNumeric(); - } else if (isAlphaTo646ToAlphaLatch(m_current.getPosition())) { - if (m_current.getPosition() + 5 < m_information->getSize()) { - m_current.incrementPosition(5); - } else { - m_current.setPosition(m_information->getSize()); - } - - m_current.setIsoIec646(); - } - return new BlockParsedResult(false); -} - -bool GeneralAppIdDecoder::isStillIsoIec646(int pos) -{ - if (pos + 5 > m_information->getSize()) { - return false; - } - - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue >= 5 && fiveBitValue < 16) { - return true; - } - - if (pos + 7 > m_information->getSize()) { - return false; - } - - int sevenBitValue = extractNumericValueFromBitArray(pos, 7); - if (sevenBitValue >= 64 && sevenBitValue < 116) { - return true; - } - - if (pos + 8 > m_information->getSize()) { - return false; - } - - int eightBitValue = extractNumericValueFromBitArray(pos, 8); - return eightBitValue >= 232 && eightBitValue < 253; -} - -DecodedChar GeneralAppIdDecoder::decodeIsoIec646(int pos) -{ - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue == 15) { - return DecodedChar(pos + 5, DecodedChar::FNC1); //////////// - } - - if (fiveBitValue >= 5 && fiveBitValue < 15) { - return DecodedChar(pos + 5, static_cast('0' + fiveBitValue - 5)); - } - - int sevenBitValue = extractNumericValueFromBitArray(pos, 7); - - if (sevenBitValue >= 64 && sevenBitValue < 90) { - return DecodedChar(pos + 7, static_cast(sevenBitValue + 1)); - } - - if (sevenBitValue >= 90 && sevenBitValue < 116) { - return DecodedChar(pos + 7, static_cast(sevenBitValue + 7)); - } - - int eightBitValue = extractNumericValueFromBitArray(pos, 8); - char c; - switch (eightBitValue) { - case 232: - c = '!'; - break; - case 233: - c = '"'; - break; - case 234: - c = '%'; - break; - case 235: - c = '&'; - break; - case 236: - c = '\''; - break; - case 237: - c = '('; - break; - case 238: - c = ')'; - break; - case 239: - c = '*'; - break; - case 240: - c = '+'; - break; - case 241: - c = ','; - break; - case 242: - c = '-'; - break; - case 243: - c = '.'; - break; - case 244: - c = '/'; - break; - case 245: - c = ':'; - break; - case 246: - c = ';'; - break; - case 247: - c = '<'; - break; - case 248: - c = '='; - break; - case 249: - c = '>'; - break; - case 250: - c = '?'; - break; - case 251: - c = '_'; - break; - case 252: - c = ' '; - break; - default: - throw FormatException::getFormatInstance(); - } - return DecodedChar(pos + 8, c); -} - -bool GeneralAppIdDecoder::isStillAlpha(int pos) -{ - if (pos + 5 > m_information->getSize()) { - return false; - } - - // We now check if it's a valid 5-bit value (0..9 and FNC1) - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue >= 5 && fiveBitValue < 16) { - return true; - } - - if (pos + 6 > m_information->getSize()) { - return false; - } - - int sixBitValue = extractNumericValueFromBitArray(pos, 6); - return sixBitValue >= 16 && sixBitValue < 63; // 63 not included -} - -DecodedChar GeneralAppIdDecoder::decodeAlphanumeric(int pos) -{ - int fiveBitValue = extractNumericValueFromBitArray(pos, 5); - if (fiveBitValue == 15) { - return DecodedChar(pos + 5, DecodedChar::FNC1); - } - - if (fiveBitValue >= 5 && fiveBitValue < 15) { - return DecodedChar(pos + 5, static_cast('0' + fiveBitValue - 5)); - } - - int sixBitValue = extractNumericValueFromBitArray(pos, 6); - - if (sixBitValue >= 32 && sixBitValue < 58) { - return DecodedChar(pos + 6, static_cast(sixBitValue + 33)); - } - - char c; - switch (sixBitValue) { - case 58: - c = '*'; - break; - case 59: - c = ','; - break; - case 60: - c = '-'; - break; - case 61: - c = '.'; - break; - case 62: - c = '/'; - break; - default: - throw new IllegalStateException("Decoding invalid alphanumeric value: " + sixBitValue); - } - return DecodedChar(pos + 6, c); -} - -boolean GeneralAppIdDecoder::isAlphaTo646ToAlphaLatch(int pos) -{ - if (pos + 1 > m_information->getSize()) { - return false; - } - - for (int i = 0; i < 5 && i + pos < m_information->getSize(); ++i) { - if (i == 2) { - if (!m_information->get(pos + 2)) { - return false; - } - } else if (m_information->get(pos + i)) { - return false; - } - } - - return true; -} - -boolean GeneralAppIdDecoder::isAlphaOr646ToNumericLatch(int pos) -{ - // Next is alphanumeric if there are 3 positions and they are all zeros - if (pos + 3 > m_information->getSize()) { - return false; - } - - for (int i = pos; i < pos + 3; ++i) { - if (m_information->get(i)) { - return false; - } - } - return true; -} - -boolean GeneralAppIdDecoder::isNumericToAlphaNumericLatch(int pos) { - // Next is alphanumeric if there are 4 positions and they are all zeros, or - // if there is a subset of this just before the end of the symbol - if (pos + 1 > m_information->getSize()) { - return false; - } - - for (int i = 0; i < 4 && i + pos < m_information->getSize(); ++i) { - if (m_information->get(pos + i)) { - return false; - } - } - return true; -} - - -} -} -} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h deleted file mode 100644 index 9c84dae..0000000 --- a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef GENERAL_APP_ID_DECODER_H -#define GENERAL_APP_ID_DECODER_H -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * These authors would like to acknowledge the Spanish Ministry of Industry, - * Tourism and Trade, for the support in the project TSI020301-2008-2 - * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled - * Mobile Dynamic Environments", led by Treelogic - * ( http://www.treelogic.com/ ): - * - * http://www.piramidepse.com/ - */ - -#include -#include -#include -#include -#include "CurrentParsingState.h" -#include "DecodedInformation.h" -#include "DecodedNumeric.h" -#include "FieldParser.h" -#include "BlockParsedResult.h" -#include "DecodedChar.h" - -// VC++ -namespace zxing { - -namespace oned { - -namespace rss { - -/** - * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) - * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es) - */ -class GeneralAppIdDecoder -{ - -public: - GeneralAppIdDecoder(Ref information); - - String decodeAllCodes(String buff, int initialPosition); - - bool isStillNumeric(int pos); - - DecodedNumeric decodeNumeric(int pos); - - int extractNumericValueFromBitArray(int pos, int bits); - - static int extractNumericValueFromBitArray(Ref information, int pos, int bits); - - DecodedInformation decodeGeneralPurposeField(int pos, String remaining); - - DecodedInformation parseBlocks(); - - BlockParsedResult parseNumericBlock(); - - BlockParsedResult parseIsoIec646Block(); - - BlockParsedResult parseAlphaBlock(); - - bool isStillIsoIec646(int pos); - - DecodedChar decodeIsoIec646(int pos); - - bool isStillAlpha(int pos); - - DecodedChar decodeAlphanumeric(int pos); - - boolean isAlphaTo646ToAlphaLatch(int pos); - - boolean isAlphaOr646ToNumericLatch(int pos); - - boolean isNumericToAlphaNumericLatch(int pos); - -private: - Ref m_information; - CurrentParsingState m_current; - String m_buffer; - -}; -} -} -} - -#endif From 024d1e26b7ecdd65174baf5308a2c7aea660cb40 Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Thu, 11 Jul 2019 18:04:47 +0300 Subject: [PATCH 68/83] Update travis to use ubuntu 16.04 (xenial) (#119) * Update travis to use ubuntu 16.04 (xenial) Update travis to use ubuntu 16.04 (xenial) instead of 14.04 (trusty) * add xvfb as a service to xenial distribution * removed explicit start of xvfb after adding the xvfb as a service, there is no reason to explicitly start it at "before_install" * install libGL during before_install * install libgl1-mesa-dev during "before_install" --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3535dff..8984fc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,10 @@ #Author: KangLin(kl222@126.com) sudo: required -dist: trusty +dist: xenial + +services: + - xvfb language: cpp @@ -34,7 +37,7 @@ env: before_install: - echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}" - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start + - sudo apt-get install -y libgl1-mesa-glx libgl1-mesa-dev install: - bash ${TRAVIS_BUILD_DIR}/ci/build-install-tools.sh #> /dev/null From ef0588198fc82413b77a987388b1f1b22fb48001 Mon Sep 17 00:00:00 2001 From: Eism Date: Wed, 17 Jul 2019 19:02:37 +0200 Subject: [PATCH 69/83] rss add recognition --- src/QZXing.pri | 12 + .../zxing/oned/rss/AbstractRSSReader.cpp | 117 +++++ src/zxing/zxing/oned/rss/AbstractRSSReader.h | 92 ++++ src/zxing/zxing/oned/rss/DataCharacter.cpp | 46 ++ src/zxing/zxing/oned/rss/DataCharacter.h | 61 +++ src/zxing/zxing/oned/rss/FinderPattern.cpp | 56 +++ src/zxing/zxing/oned/rss/FinderPattern.h | 67 +++ src/zxing/zxing/oned/rss/Pair.cpp | 41 ++ src/zxing/zxing/oned/rss/Pair.h | 56 +++ src/zxing/zxing/oned/rss/RSS14Reader.cpp | 466 ++++++++++++++++++ src/zxing/zxing/oned/rss/RSS14Reader.h | 76 +++ src/zxing/zxing/oned/rss/RSSUtils.cpp | 74 +++ src/zxing/zxing/oned/rss/RSSUtils.h | 44 ++ 13 files changed, 1208 insertions(+) create mode 100644 src/zxing/zxing/oned/rss/AbstractRSSReader.cpp create mode 100644 src/zxing/zxing/oned/rss/AbstractRSSReader.h create mode 100644 src/zxing/zxing/oned/rss/DataCharacter.cpp create mode 100644 src/zxing/zxing/oned/rss/DataCharacter.h create mode 100644 src/zxing/zxing/oned/rss/FinderPattern.cpp create mode 100644 src/zxing/zxing/oned/rss/FinderPattern.h create mode 100644 src/zxing/zxing/oned/rss/Pair.cpp create mode 100644 src/zxing/zxing/oned/rss/Pair.h create mode 100644 src/zxing/zxing/oned/rss/RSS14Reader.cpp create mode 100644 src/zxing/zxing/oned/rss/RSS14Reader.h create mode 100644 src/zxing/zxing/oned/rss/RSSUtils.cpp create mode 100644 src/zxing/zxing/oned/rss/RSSUtils.h diff --git a/src/QZXing.pri b/src/QZXing.pri index 97339bf..27ae62d 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -104,6 +104,12 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/oned/Code39Reader.h \ $$PWD/zxing/zxing/oned/CodaBarReader.h \ $$PWD/zxing/zxing/oned/Code93Reader.h \ + $$PWD/zxing/zxing/oned/rss/AbstractRSSReader.h \ + $$PWD/zxing/zxing/oned/rss/DataCharacter.h \ + $$PWD/zxing/zxing/oned/rss/FinderPattern.h \ + $$PWD/zxing/zxing/oned/rss/Pair.h \ + $$PWD/zxing/zxing/oned/rss/RSS14Reader.h \ + $$PWD/zxing/zxing/oned/rss/RSSUtils.h \ $$PWD/zxing/zxing/qrcode/Version.h \ $$PWD/zxing/zxing/qrcode/QRCodeReader.h \ $$PWD/zxing/zxing/qrcode/FormatInformation.h \ @@ -221,6 +227,12 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/oned/Code39Reader.cpp \ $$PWD/zxing/zxing/oned/CodaBarReader.cpp \ $$PWD/zxing/zxing/oned/Code93Reader.cpp \ + $$PWD/zxing/zxing/oned/rss/AbstractRSSReader.cpp \ + $$PWD/zxing/zxing/oned/rss/DataCharacter.cpp \ + $$PWD/zxing/zxing/oned/rss/FinderPattern.cpp \ + $$PWD/zxing/zxing/oned/rss/Pair.cpp \ + $$PWD/zxing/zxing/oned/rss/RSS14Reader.cpp \ + $$PWD/zxing/zxing/oned/rss/RSSUtils.cpp \ $$PWD/zxing/zxing/qrcode/QRCodeReader.cpp \ $$PWD/zxing/zxing/multi/MultipleBarcodeReader.cpp \ $$PWD/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp \ diff --git a/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp b/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp new file mode 100644 index 0000000..a29b55c --- /dev/null +++ b/src/zxing/zxing/oned/rss/AbstractRSSReader.cpp @@ -0,0 +1,117 @@ +#include "AbstractRSSReader.h" + +#include + +namespace zxing { +namespace oned { +namespace rss { + +using zxing::common::detector::MathUtils; + +AbstractRSSReader::AbstractRSSReader() +{ + m_decodeFinderCounters = std::vector(4); + m_dataCharacterCounters = std::vector(8); + m_oddRoundingErrors = std::vector(4); + m_evenRoundingErrors = std::vector(4); + m_oddCounts = std::vector(m_dataCharacterCounters.size() / 2); + m_evenCounts = std::vector(m_dataCharacterCounters.size() / 2); +} + +std::vector& AbstractRSSReader::getDecodeFinderCounters() +{ + return m_decodeFinderCounters; +} + +std::vector& AbstractRSSReader::getDataCharacterCounters() +{ + return m_dataCharacterCounters; +} + +std::vector& AbstractRSSReader::getOddRoundingErrors() +{ + return m_oddRoundingErrors; +} + +std::vector& AbstractRSSReader::getEvenRoundingErrors() +{ + return m_evenRoundingErrors; +} + +std::vector& AbstractRSSReader::getOddCounts() +{ + return m_oddCounts; +} + +std::vector& AbstractRSSReader::getEvenCounts() +{ + return m_evenCounts; +} + +int AbstractRSSReader::parseFinderValue(std::vector& counters, std::vector const& finderPatterns) +{ + for (size_t value = 0; value < finderPatterns.size(); value++) { + if (patternMatchVariance(counters, finderPatterns[value], MAX_INDIVIDUAL_VARIANCE) < + MAX_AVG_VARIANCE) { + return static_cast(value); + } + } + throw NotFoundException(); +} + +int AbstractRSSReader::count(std::vector& array) +{ + return MathUtils::sum(array); +} + +void AbstractRSSReader::increment(std::vector& array, std::vector& errors) +{ + size_t index = 0; + float biggestError = errors[0]; + for (size_t i = 1; i < array.size(); i++) { + if (errors[i] > biggestError) { + biggestError = errors[i]; + index = i; + } + } + array[index]++; +} + +void AbstractRSSReader::decrement(std::vector& array, std::vector& errors) +{ + size_t index = 0; + float biggestError = errors[0]; + for (size_t i = 1; i < array.size(); i++) { + if (errors[i] < biggestError) { + biggestError = errors[i]; + index = i; + } + } + array[index]--; +} + +bool AbstractRSSReader::isFinderPattern(std::vector &counters) +{ + int firstTwoSum = counters[0] + counters[1]; + int sum = firstTwoSum + counters[2] + counters[3]; + float ratio = static_cast(firstTwoSum) / static_cast(sum); + if (ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO) { + // passes ratio test in spec, but see if the counts are unreasonable + int minCounter = 5555; + int maxCounter = -5555; + for (int counter : counters) { + if (counter > maxCounter) { + maxCounter = counter; + } + if (counter < minCounter) { + minCounter = counter; + } + } + return maxCounter < 10 * minCounter; + } + return false; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/AbstractRSSReader.h b/src/zxing/zxing/oned/rss/AbstractRSSReader.h new file mode 100644 index 0000000..163d728 --- /dev/null +++ b/src/zxing/zxing/oned/rss/AbstractRSSReader.h @@ -0,0 +1,92 @@ +#ifndef ABSTRACT_RSS_READER_H +#define ABSTRACT_RSS_READER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include +#include +#include + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Superclass of {@link OneDReader} implementations that read barcodes in the RSS family + * of formats. + */ +class AbstractRSSReader : public OneDReader +{ + + static constexpr int MAX_AVG_VARIANCE = int(PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.2f); + static constexpr int MAX_INDIVIDUAL_VARIANCE = int(PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.45f); + + static constexpr float MIN_FINDER_PATTERN_RATIO = 9.5f / 12.0f; + static constexpr float MAX_FINDER_PATTERN_RATIO = 12.5f / 14.0f; + +protected: + AbstractRSSReader(); + + std::vector &getDecodeFinderCounters(); + + std::vector &getDataCharacterCounters(); + + std::vector &getOddRoundingErrors(); + + std::vector &getEvenRoundingErrors(); + + std::vector &getOddCounts(); + + std::vector &getEvenCounts(); + + static int parseFinderValue(std::vector& counters, + const std::vector &finderPatterns); + + /** + * @param array values to sum + * @return sum of values + * @deprecated call {@link MathUtils#sum(int[])} + */ + static int count(std::vector &array); + + static void increment(std::vector &array, std::vector &errors); + + static void decrement(std::vector &array, std::vector& errors); + + static bool isFinderPattern(std::vector& counters); + +private: + std::vector m_decodeFinderCounters; + std::vector m_dataCharacterCounters; + std::vector m_oddRoundingErrors; + std::vector m_evenRoundingErrors; + std::vector m_oddCounts; + std::vector m_evenCounts; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/DataCharacter.cpp b/src/zxing/zxing/oned/rss/DataCharacter.cpp new file mode 100644 index 0000000..008e88c --- /dev/null +++ b/src/zxing/zxing/oned/rss/DataCharacter.cpp @@ -0,0 +1,46 @@ +#include "DataCharacter.h" + +namespace zxing { +namespace oned { +namespace rss { + +DataCharacter::DataCharacter(int value, int checksumPortion) + : m_value(value), m_checksumPortion(checksumPortion) +{ + +} + +DataCharacter::DataCharacter() + : m_value(0), m_checksumPortion(0) +{ + +} + +int DataCharacter::getValue() const +{ + return m_value; +} + +int DataCharacter::getChecksumPortion() const +{ + return m_checksumPortion; +} + +String DataCharacter::toString() const +{ + return String(m_value + '(' + m_checksumPortion + ')'); +} + +bool DataCharacter::equals(const DataCharacter &other) const +{ + return m_value == other.m_value && m_checksumPortion == other.m_checksumPortion; +} + +int DataCharacter::hashCode() const +{ + return m_value & m_checksumPortion; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/DataCharacter.h b/src/zxing/zxing/oned/rss/DataCharacter.h new file mode 100644 index 0000000..dead68c --- /dev/null +++ b/src/zxing/zxing/oned/rss/DataCharacter.h @@ -0,0 +1,61 @@ +#ifndef DATA_CHARACTER_H +#define DATA_CHARACTER_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Encapsulates a since character value in an RSS barcode, including its checksum information. + */ +class DataCharacter +{ + +public: + DataCharacter(int value, int checksumPortion); + + DataCharacter(); + + int getValue() const; + + int getChecksumPortion() const; + + String toString() const; + + bool equals(const DataCharacter& other) const; + + int hashCode() const; + +private: + int m_value; + int m_checksumPortion; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/FinderPattern.cpp b/src/zxing/zxing/oned/rss/FinderPattern.cpp new file mode 100644 index 0000000..13a3698 --- /dev/null +++ b/src/zxing/zxing/oned/rss/FinderPattern.cpp @@ -0,0 +1,56 @@ +#include "FinderPattern.h" + +namespace zxing { +namespace oned { +namespace rss { + +FinderPattern::FinderPattern(int value, std::vector startEnd, int start, int end, int rowNumber) + : m_value(value), + m_startEnd(startEnd) +{ + ArrayRef< Ref > resultPoints(2); + resultPoints[0] = Ref(new OneDResultPoint(start, rowNumber)); + resultPoints[0] = Ref(new OneDResultPoint(end, rowNumber)); + m_resultPoints = resultPoints; +} + +FinderPattern::FinderPattern(const FinderPattern *other) +{ + m_value = other != nullptr ? other->m_value : 0; + m_startEnd = other != nullptr ? other->m_startEnd : std::vector (); + m_resultPoints = other != nullptr ? other->m_resultPoints : nullptr; +} + +int FinderPattern::getValue() const +{ + return m_value; +} + +std::vector& FinderPattern::getStartEnd() +{ + return m_startEnd; +} + +ArrayRef >& FinderPattern::getResultPoints() +{ + return m_resultPoints; +} + +bool FinderPattern::equals(const FinderPattern &other) const +{ + return m_value == other.m_value; +} + +int FinderPattern::hashCode() const +{ + return m_value; +} + +bool FinderPattern::isValid() const +{ + return m_startEnd.size() != 0; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/FinderPattern.h b/src/zxing/zxing/oned/rss/FinderPattern.h new file mode 100644 index 0000000..d679a81 --- /dev/null +++ b/src/zxing/zxing/oned/rss/FinderPattern.h @@ -0,0 +1,67 @@ +#ifndef FINDER_PATTERN_H +#define FINDER_PATTERN_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include +#include + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Encapsulates an RSS barcode finder pattern, including its start/end position and row. + */ +class FinderPattern +{ + +public: + FinderPattern(int value, std::vector startEnd, int start, int end, int rowNumber); + + FinderPattern(const FinderPattern* other = nullptr); + + int getValue() const; + + std::vector &getStartEnd(); + + ArrayRef > &getResultPoints(); + + bool equals(const FinderPattern& other) const; + + int hashCode() const; + + bool isValid() const; + +private: + int m_value; + std::vector m_startEnd; + ArrayRef< Ref > m_resultPoints; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/Pair.cpp b/src/zxing/zxing/oned/rss/Pair.cpp new file mode 100644 index 0000000..ab49357 --- /dev/null +++ b/src/zxing/zxing/oned/rss/Pair.cpp @@ -0,0 +1,41 @@ +#include "Pair.h" + +namespace zxing { +namespace oned { +namespace rss { + +Pair::Pair(int value, int checksumPortion, FinderPattern finderPattern) + : DataCharacter (value, checksumPortion), m_finderPattern(finderPattern) +{ + +} + +Pair::Pair() + : DataCharacter (0, 0), m_finderPattern(FinderPattern()), m_count(0) +{ + +} + +FinderPattern& Pair::getFinderPattern() +{ + return m_finderPattern; +} + +int Pair::getCount() const +{ + return m_count; +} + +void Pair::incrementCount() +{ + m_count++; +} + +bool Pair::isValid() const +{ + return m_finderPattern.isValid(); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/Pair.h b/src/zxing/zxing/oned/rss/Pair.h new file mode 100644 index 0000000..1b459e0 --- /dev/null +++ b/src/zxing/zxing/oned/rss/Pair.h @@ -0,0 +1,56 @@ +#ifndef RSS_PAIR_H +#define RSS_PAIR_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include "DataCharacter.h" +#include "FinderPattern.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +class Pair : public DataCharacter +{ + +public: + Pair(int value, int checksumPortion, FinderPattern finderPattern); + Pair(); + + FinderPattern &getFinderPattern(); + + int getCount() const; + + void incrementCount(); + + bool isValid() const; + +private: + FinderPattern m_finderPattern; + int m_count; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.cpp b/src/zxing/zxing/oned/rss/RSS14Reader.cpp new file mode 100644 index 0000000..cced013 --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSS14Reader.cpp @@ -0,0 +1,466 @@ +#include "RSS14Reader.h" + +namespace zxing { +namespace oned { +namespace rss { + +using ::zxing::common::detector::MathUtils; + +static const std::vector OUTSIDE_EVEN_TOTAL_SUBSET = {1,10,34,70,126}; +static const std::vector INSIDE_ODD_TOTAL_SUBSET = {4,20,48,81}; +static const std::vector OUTSIDE_GSUM = {0,161,961,2015,2715}; +static const std::vector INSIDE_GSUM = {0,336,1036,1516}; +static const std::vector OUTSIDE_ODD_WIDEST = {8,6,4,3,1}; +static const std::vector INSIDE_ODD_WIDEST = {2,4,6,8}; + +const int FINDER_PATTERNS_[][4] = { + {3,8,2,1}, + {3,5,5,1}, + {3,3,7,1}, + {3,1,9,1}, + {2,7,4,1}, + {2,5,6,1}, + {2,3,8,1}, + {1,5,7,1}, + {1,3,9,1} +}; + +#define VECTOR_INIT(v) v, v + sizeof(v)/sizeof(v[0]) + +const std::vector +RSS14Reader::FINDER_PATTERNS (VECTOR_INIT(FINDER_PATTERNS_)); + +RSS14Reader::RSS14Reader() + : m_possibleLeftPairs({}), + m_possibleRightPairs({}) +{ + +} + +Ref RSS14Reader::decodeRow(int rowNumber, Ref row, DecodeHints hints) +{ + Pair leftPair = decodePair(row, false, rowNumber, hints); + addOrTally(m_possibleLeftPairs, leftPair); + row->reverse(); + + Pair rightPair = decodePair(row, true, rowNumber, hints); + addOrTally(m_possibleRightPairs, rightPair); + row->reverse(); + + for (Pair left : m_possibleLeftPairs) { + if (left.getCount() > 1) { + for (Pair right : m_possibleRightPairs) { + if (right.getCount() > 1 && checkChecksum(left, right)) { + return constructResult(left, right); + } + } + } + } + + throw NotFoundException(); +} + +void RSS14Reader::addOrTally(std::vector& possiblePairs, Pair& pair) +{ + if (!pair.isValid()) { + return; + } + + bool found = false; + for (Pair& other : possiblePairs) { + if (other.getValue() == pair.getValue()) { + other.incrementCount(); + found = true; + break; + } + } + + if (!found) { + possiblePairs.push_back(pair); + } +} + +void RSS14Reader::reset() +{ + m_possibleLeftPairs.clear(); + m_possibleRightPairs.clear(); +} + +Ref RSS14Reader::constructResult(Pair leftPair, Pair rightPair) const +{ + long long symbolValue = 4537077LL * leftPair.getValue() + rightPair.getValue(); + String text(std::to_string(symbolValue)); + + String buffer(14); + for (int i = 13 - text.length(); i > 0; i--) { + buffer.append('0'); + } + buffer.append(text.getText()); + + int checkDigit = 0; + for (int i = 0; i < 13; i++) { + int digit = buffer.charAt(i) - '0'; + checkDigit += ((i & 0x01) == 0) ? (3 * digit) : digit; + } + checkDigit = 10 - (checkDigit % 10); + if (checkDigit == 10) { + checkDigit = 0; + } + buffer.append(std::to_string(checkDigit)); + + ArrayRef< Ref > leftPoints = leftPair.getFinderPattern().getResultPoints(); + ArrayRef< Ref > rightPoints = rightPair.getFinderPattern().getResultPoints(); + ArrayRef< Ref > resultPoints(5); + + return Ref(new Result( + Ref(new String(buffer)), + nullptr, + resultPoints, + BarcodeFormat::RSS_14)); +} + +Pair RSS14Reader::decodePair(Ref row, bool right, int rowNumber, DecodeHints hints) +{ + try { + std::vector startEnd = findFinderPattern(row, right); + if (startEnd.empty()) { + return Pair(); + } + FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd); + + Ref resultPointCallback = hints.getResultPointCallback(); + + if (resultPointCallback != nullptr) { + startEnd = pattern.getStartEnd(); + float center = (startEnd[0] + startEnd[1] - 1) / 2.0f; + if (right) { + // row is actually reversed + center = row->getSize() - 1 - center; + } + resultPointCallback->foundPossibleResultPoint(ResultPoint(center, static_cast(rowNumber))); + } + + DataCharacter outside = decodeDataCharacter(row, pattern, true); + DataCharacter inside = decodeDataCharacter(row, pattern, false); + return Pair(1597 * outside.getValue() + inside.getValue(), + outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), + pattern); + + } catch (NotFoundException ignored) { + return Pair(); + } +} + +DataCharacter RSS14Reader::decodeDataCharacter(Ref row, FinderPattern pattern, bool outsideChar) +{ + + std::vector& counters = getDataCharacterCounters(); + for (size_t x = 0; x < counters.size(); x++) { + counters[x] = 0; + } + + if (outsideChar) { + recordPatternInReverse(row, pattern.getStartEnd()[0], counters); + } else { + recordPattern(row, pattern.getStartEnd()[1], counters); + // reverse it + for (size_t i = 0, j = counters.size() - 1; i < j; i++, j--) { + int temp = counters[i]; + counters[i] = counters[j]; + counters[j] = temp; + } + } + + int numModules = outsideChar ? 16 : 15; + float elementWidth = MathUtils::sum(counters) / static_cast(numModules); + + std::vector& oddCounts = getOddCounts(); + std::vector& evenCounts = getEvenCounts(); + std::vector& oddRoundingErrors = getOddRoundingErrors(); + std::vector& evenRoundingErrors = getEvenRoundingErrors(); + + for (size_t i = 0; i < counters.size(); i++) { + float value = counters[i] / elementWidth; + int count = static_cast(value + 0.5f); // Round + if (count < 1) { + count = 1; + } else if (count > 8) { + count = 8; + } + size_t offset = i / 2; + if ((i & 0x01) == 0) { + oddCounts[offset] = count; + oddRoundingErrors[offset] = value - count; + } else { + evenCounts[offset] = count; + evenRoundingErrors[offset] = value - count; + } + } + + adjustOddEvenCounts(outsideChar, numModules); + + int oddSum = 0; + int oddChecksumPortion = 0; + for (size_t i = oddCounts.size() - 1; i-- > 0; ) { + oddChecksumPortion *= 9; + oddChecksumPortion += oddCounts[i]; + oddSum += oddCounts[i]; + } + int evenChecksumPortion = 0; + int evenSum = 0; + for (size_t i = evenCounts.size() - 1; i-- > 0; ) { + evenChecksumPortion *= 9; + evenChecksumPortion += evenCounts[i]; + evenSum += evenCounts[i]; + } + int checksumPortion = oddChecksumPortion + 3 * evenChecksumPortion; + + if (outsideChar) { + if ((oddSum & 0x01) != 0 || oddSum > 12 || oddSum < 4) { + throw NotFoundException(); + } + size_t group = static_cast((12 - oddSum) / 2); + int oddWidest = OUTSIDE_ODD_WIDEST[group]; + int evenWidest = 9 - oddWidest; + int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, false); + int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, true); + int tEven = OUTSIDE_EVEN_TOTAL_SUBSET[group]; + int gSum = OUTSIDE_GSUM[group]; + return DataCharacter(vOdd * tEven + vEven + gSum, checksumPortion); + } else { + if ((evenSum & 0x01) != 0 || evenSum > 10 || evenSum < 4) { + throw NotFoundException(); + } + size_t group = static_cast((10 - evenSum) / 2); + int oddWidest = INSIDE_ODD_WIDEST[group]; + int evenWidest = 9 - oddWidest; + int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, true); + int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, false); + int tOdd = INSIDE_ODD_TOTAL_SUBSET[group]; + int gSum = INSIDE_GSUM[group]; + return DataCharacter(vEven * tOdd + vOdd + gSum, checksumPortion); + } + +} + +std::vector RSS14Reader::findFinderPattern(Ref row, bool rightFinderPattern) +{ + std::vector& counters = getDecodeFinderCounters(); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + + int width = row->getSize(); + bool isWhite = false; + int rowOffset = 0; + while (rowOffset < width) { + isWhite = !row->get(rowOffset); + if (rightFinderPattern == isWhite) { + // Will encounter white first when searching for right finder pattern + break; + } + rowOffset++; + } + + size_t counterPosition = 0; + int patternStart = rowOffset; + for (int x = rowOffset; x < width; x++) { + if (row->get(x) != isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == 3) { + if (isFinderPattern(counters)) { + return std::vector{patternStart, x}; + } + patternStart += counters[0] + counters[1]; + counters[0] = counters[2]; + counters[1] = counters[3]; + counters[2] = 0; + counters[3] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + return std::vector(); + +} + +FinderPattern RSS14Reader::parseFoundFinderPattern(Ref row, int rowNumber, bool right, std::vector startEnd) +{ + // Actually we found elements 2-5 + bool firstIsBlack = row->get(startEnd[0]); + int firstElementStart = startEnd[0] - 1; + // Locate element 1 + while (firstElementStart >= 0 && firstIsBlack != row->get(firstElementStart)) { + firstElementStart--; + } + firstElementStart++; + int firstCounter = startEnd[0] - firstElementStart; + + // Make 'counters' hold 1-4 + std::vector& counters = getDecodeFinderCounters(); + std::vector _counters = counters; + for (size_t i = 1; i < counters.size(); i++) { + counters[i] = _counters[i - 1]; + } + + counters[0] = firstCounter; + int value = parseFinderValue(counters, FINDER_PATTERNS); + int start = firstElementStart; + int end = startEnd[1]; + if (right) { + // row is actually reversed + start = row->getSize() - 1 - start; + end = row->getSize() - 1 - end; + } + return new FinderPattern(value, {firstElementStart, startEnd[1]}, start, end, rowNumber); +} + +void RSS14Reader::adjustOddEvenCounts(bool outsideChar, int numModules) +{ + int oddSum = MathUtils::sum(getOddCounts()); + int evenSum = MathUtils::sum(getEvenCounts()); + + bool incrementOdd = false; + bool decrementOdd = false; + bool incrementEven = false; + bool decrementEven = false; + + if (outsideChar) { + if (oddSum > 12) { + decrementOdd = true; + } else if (oddSum < 4) { + incrementOdd = true; + } + if (evenSum > 12) { + decrementEven = true; + } else if (evenSum < 4) { + incrementEven = true; + } + } else { + if (oddSum > 11) { + decrementOdd = true; + } else if (oddSum < 5) { + incrementOdd = true; + } + if (evenSum > 10) { + decrementEven = true; + } else if (evenSum < 4) { + incrementEven = true; + } + } + + int mismatch = oddSum + evenSum - numModules; + bool oddParityBad = (oddSum & 0x01) == (outsideChar ? 1 : 0); + bool evenParityBad = (evenSum & 0x01) == 1; + /*if (mismatch == 2) { + if (!(oddParityBad && evenParityBad)) { + throw ReaderException.getInstance(); + } + decrementOdd = true; + decrementEven = true; + } else if (mismatch == -2) { + if (!(oddParityBad && evenParityBad)) { + throw ReaderException.getInstance(); + } + incrementOdd = true; + incrementEven = true; + } else */ + switch (mismatch) { + case 1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + decrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + decrementEven = true; + } + break; + case -1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + incrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + incrementEven = true; + } + break; + case 0: + if (oddParityBad) { + if (!evenParityBad) { + throw NotFoundException(); + } + // Both bad + if (oddSum < evenSum) { + incrementOdd = true; + decrementEven = true; + } else { + decrementOdd = true; + incrementEven = true; + } + } else { + if (evenParityBad) { + throw NotFoundException(); + } + // Nothing to do! + } + break; + default: + throw NotFoundException(); + } + + if (incrementOdd) { + if (decrementOdd) { + throw NotFoundException(); + } + increment(getOddCounts(), getOddRoundingErrors()); + } + if (decrementOdd) { + decrement(getOddCounts(), getOddRoundingErrors()); + } + if (incrementEven) { + if (decrementEven) { + throw NotFoundException(); + } + increment(getEvenCounts(), getOddRoundingErrors()); + } + if (decrementEven) { + decrement(getEvenCounts(), getEvenRoundingErrors()); + } +} + +bool RSS14Reader::checkChecksum(Pair leftPair, Pair rightPair) +{ + //int leftFPValue = leftPair.getFinderPattern().getValue(); + //int rightFPValue = rightPair.getFinderPattern().getValue(); + //if ((leftFPValue == 0 && rightFPValue == 8) || + // (leftFPValue == 8 && rightFPValue == 0)) { + //} + int checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79; + int targetCheckValue = + 9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue(); + if (targetCheckValue > 72) { + targetCheckValue--; + } + if (targetCheckValue > 8) { + targetCheckValue--; + } + return checkValue == targetCheckValue; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.h b/src/zxing/zxing/oned/rss/RSS14Reader.h new file mode 100644 index 0000000..525e24d --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSS14Reader.h @@ -0,0 +1,76 @@ +#ifndef RSS14_READER_H +#define RSS14_READER_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include "AbstractRSSReader.h" +#include "Pair.h" +#include "RSSUtils.h" + +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * Decodes RSS-14, including truncated and stacked variants. See ISO/IEC 24724:2006. + */ +class RSS14Reader : public AbstractRSSReader +{ + +public: + static const std::vector FINDER_PATTERNS; + + RSS14Reader(); + + Ref decodeRow(int rowNumber, Ref row, DecodeHints hints); + + static void addOrTally(std::vector &possiblePairs, Pair &pair); + + void reset(); + + Ref constructResult(Pair leftPair, Pair rightPair) const; + + static bool checkChecksum(Pair leftPair, Pair rightPair); + + Pair decodePair(Ref row, bool right, int rowNumber, DecodeHints hints); + + DataCharacter decodeDataCharacter(Ref row, FinderPattern pattern, bool outsideChar); + + std::vector findFinderPattern(Ref row, bool rightFinderPattern); + + FinderPattern parseFoundFinderPattern(Ref row, int rowNumber, bool right, std::vector startEnd); + + void adjustOddEvenCounts(bool outsideChar, int numModules); + +private: + std::vector m_possibleLeftPairs; + std::vector m_possibleRightPairs; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/RSSUtils.cpp b/src/zxing/zxing/oned/rss/RSSUtils.cpp new file mode 100644 index 0000000..63e99f5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSSUtils.cpp @@ -0,0 +1,74 @@ +#include "RSSUtils.h" + +namespace zxing { +namespace oned { +namespace rss { + +int RSSUtils::getRSSvalue(std::vector widths, int maxWidth, bool noNarrow) +{ + int n = 0; + for (int width : widths) { + n += width; + } + int val = 0; + int narrowMask = 0; + int elements = widths.size(); + for (int bar = 0; bar < elements - 1; bar++) { + int elmWidth; + for (elmWidth = 1, narrowMask |= 1 << bar; + elmWidth < widths[bar]; + elmWidth++, narrowMask &= ~(1 << bar)) { + int subVal = combins(n - elmWidth - 1, elements - bar - 2); + if (noNarrow && (narrowMask == 0) && + (n - elmWidth - (elements - bar - 1) >= elements - bar - 1)) { + subVal -= combins(n - elmWidth - (elements - bar), + elements - bar - 2); + } + if (elements - bar - 1 > 1) { + int lessVal = 0; + for (int mxwElement = n - elmWidth - (elements - bar - 2); + mxwElement > maxWidth; mxwElement--) { + lessVal += combins(n - elmWidth - mxwElement - 1, + elements - bar - 3); + } + subVal -= lessVal * (elements - 1 - bar); + } else if (n - elmWidth > maxWidth) { + subVal--; + } + val += subVal; + } + n -= elmWidth; + } + return val; +} + +int RSSUtils::combins(int n, int r) +{ + int maxDenom; + int minDenom; + if (n - r > r) { + minDenom = r; + maxDenom = n - r; + } else { + minDenom = n - r; + maxDenom = r; + } + int val = 1; + int j = 1; + for (int i = n; i > maxDenom; i--) { + val *= i; + if (j <= minDenom) { + val /= j; + j++; + } + } + while (j <= minDenom) { + val /= j; + j++; + } + return val; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/RSSUtils.h b/src/zxing/zxing/oned/rss/RSSUtils.h new file mode 100644 index 0000000..5dba5b8 --- /dev/null +++ b/src/zxing/zxing/oned/rss/RSSUtils.h @@ -0,0 +1,44 @@ +#ifndef RSS_UTILS_H +#define RSS_UTILS_H + +/* + * Copyright 2009 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** Adapted from listings in ISO/IEC 24724 Appendix B and Appendix G. */ +class RSSUtils +{ + +public: + static int getRSSvalue(std::vector widths, int maxWidth, bool noNarrow); + + static int combins(int n, int r); +}; + +} +} +} + +#endif From 635cfab83cf3ac82038e74b158af4a20c4b07472 Mon Sep 17 00:00:00 2001 From: Eism Date: Wed, 17 Jul 2019 19:11:11 +0200 Subject: [PATCH 70/83] rss expanded add recognition --- src/QZXing.pri | 46 ++ .../oned/rss/expanded/BitArrayBuilder.cpp | 54 ++ .../zxing/oned/rss/expanded/BitArrayBuilder.h | 54 ++ .../zxing/oned/rss/expanded/ExpandedPair.cpp | 64 ++ .../zxing/oned/rss/expanded/ExpandedPair.h | 77 ++ .../zxing/oned/rss/expanded/ExpandedRow.cpp | 64 ++ .../zxing/oned/rss/expanded/ExpandedRow.h | 67 ++ .../oned/rss/expanded/RSSExpandedReader.cpp | 750 ++++++++++++++++++ .../oned/rss/expanded/RSSExpandedReader.h | 121 +++ .../rss/expanded/decoders/AI013103decoder.cpp | 25 + .../rss/expanded/decoders/AI013103decoder.h | 57 ++ .../rss/expanded/decoders/AI01320xDecoder.cpp | 32 + .../rss/expanded/decoders/AI01320xDecoder.h | 57 ++ .../rss/expanded/decoders/AI01392xDecoder.cpp | 40 + .../rss/expanded/decoders/AI01392xDecoder.h | 61 ++ .../rss/expanded/decoders/AI01393xDecoder.cpp | 55 ++ .../rss/expanded/decoders/AI01393xDecoder.h | 58 ++ .../expanded/decoders/AI013x0x1xDecoder.cpp | 74 ++ .../rss/expanded/decoders/AI013x0x1xDecoder.h | 70 ++ .../rss/expanded/decoders/AI013x0xDecoder.cpp | 29 + .../rss/expanded/decoders/AI013x0xDecoder.h | 62 ++ .../rss/expanded/decoders/AI01AndOtherAIs.cpp | 28 + .../rss/expanded/decoders/AI01AndOtherAIs.h | 59 ++ .../rss/expanded/decoders/AI01decoder.cpp | 57 ++ .../oned/rss/expanded/decoders/AI01decoder.h | 62 ++ .../expanded/decoders/AI01weightDecoder.cpp | 32 + .../rss/expanded/decoders/AI01weightDecoder.h | 63 ++ .../decoders/AbstractExpandedDecoder.cpp | 70 ++ .../decoders/AbstractExpandedDecoder.h | 71 ++ .../rss/expanded/decoders/AnyAIDecoder.cpp | 21 + .../oned/rss/expanded/decoders/AnyAIDecoder.h | 57 ++ .../expanded/decoders/BlockParsedResult.cpp | 37 + .../rss/expanded/decoders/BlockParsedResult.h | 63 ++ .../expanded/decoders/CurrentParsingState.cpp | 60 ++ .../expanded/decoders/CurrentParsingState.h | 78 ++ .../rss/expanded/decoders/DecodedChar.cpp | 25 + .../oned/rss/expanded/decoders/DecodedChar.h | 61 ++ .../expanded/decoders/DecodedInformation.cpp | 51 ++ .../expanded/decoders/DecodedInformation.h | 69 ++ .../rss/expanded/decoders/DecodedNumeric.cpp | 55 ++ .../rss/expanded/decoders/DecodedNumeric.h | 71 ++ .../rss/expanded/decoders/DecodedObject.cpp | 20 + .../rss/expanded/decoders/DecodedObject.h | 52 ++ .../rss/expanded/decoders/FieldParser.cpp | 274 +++++++ .../oned/rss/expanded/decoders/FieldParser.h | 60 ++ .../expanded/decoders/GeneralAppIdDecoder.cpp | 453 +++++++++++ .../expanded/decoders/GeneralAppIdDecoder.h | 99 +++ 47 files changed, 3965 insertions(+) create mode 100644 src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedPair.h create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/ExpandedRow.h create mode 100644 src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp create mode 100644 src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h diff --git a/src/QZXing.pri b/src/QZXing.pri index 27ae62d..0d80c0d 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -110,6 +110,29 @@ HEADERS += $$PWD/QZXing_global.h \ $$PWD/zxing/zxing/oned/rss/Pair.h \ $$PWD/zxing/zxing/oned/rss/RSS14Reader.h \ $$PWD/zxing/zxing/oned/rss/RSSUtils.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.h \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.h \ + $$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h \ $$PWD/zxing/zxing/qrcode/Version.h \ $$PWD/zxing/zxing/qrcode/QRCodeReader.h \ $$PWD/zxing/zxing/qrcode/FormatInformation.h \ @@ -233,6 +256,29 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/oned/rss/Pair.cpp \ $$PWD/zxing/zxing/oned/rss/RSS14Reader.cpp \ $$PWD/zxing/zxing/oned/rss/RSSUtils.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp \ + $$PWD/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp \ $$PWD/zxing/zxing/qrcode/QRCodeReader.cpp \ $$PWD/zxing/zxing/multi/MultipleBarcodeReader.cpp \ $$PWD/zxing/zxing/multi/GenericMultipleBarcodeReader.cpp \ diff --git a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp new file mode 100644 index 0000000..09b38ae --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.cpp @@ -0,0 +1,54 @@ +#include "BitArrayBuilder.h" + +namespace zxing { +namespace oned { +namespace rss { + +Ref BitArrayBuilder::buildBitArray(std::vector pairs) +{ + int charNumber = static_cast(pairs.size() * 2) - 1; + if (pairs[pairs.size() - 1].getRightChar().getValue() == 0) { + charNumber -= 1; + } + + int size = 12 * charNumber; + + Ref binary(new BitArray(int(size))); + int accPos = 0; + + ExpandedPair firstPair = pairs[0]; + int firstValue = firstPair.getRightChar().getValue(); + for (int i = 11; i >= 0; --i) { + if ((firstValue & (1 << i)) != 0) { + binary->set(accPos); + } + accPos++; + } + + for (size_t i = 1; i < pairs.size(); ++i) { + ExpandedPair currentPair = pairs[i]; + + int leftValue = currentPair.getLeftChar().getValue(); + for (int j = 11; j >= 0; --j) { + if ((leftValue & (1 << j)) != 0) { + binary->set(accPos); + } + accPos++; + } + + if (currentPair.getRightChar().getValue() != 0) { + int rightValue = currentPair.getRightChar().getValue(); + for (int j = 11; j >= 0; --j) { + if ((rightValue & (1 << j)) != 0) { + binary->set(accPos); + } + accPos++; + } + } + } + return binary; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h new file mode 100644 index 0000000..5dc3221 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/BitArrayBuilder.h @@ -0,0 +1,54 @@ +#ifndef BIT_ARRAY_BUILDER_H +#define BIT_ARRAY_BUILDER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include "ExpandedPair.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class BitArrayBuilder +{ + +public: + static Ref buildBitArray(std::vector pairs); +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp new file mode 100644 index 0000000..2877f93 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.cpp @@ -0,0 +1,64 @@ +#include "ExpandedPair.h" + +namespace zxing { +namespace oned { +namespace rss { + +ExpandedPair::ExpandedPair(DataCharacter leftChar, DataCharacter rightChar, FinderPattern finderPattern) + : m_leftChar(leftChar), + m_rightChar(rightChar), + m_finderPattern(finderPattern) +{ + +} + +ExpandedPair::ExpandedPair(const ExpandedPair *other) +{ + m_leftChar = other != nullptr ? other->m_leftChar : DataCharacter(); + m_rightChar = other != nullptr ? other->m_rightChar : DataCharacter(); + m_finderPattern = other != nullptr ? other->m_finderPattern : nullptr; +} + +DataCharacter& ExpandedPair::getLeftChar() +{ + return m_leftChar; +} + +DataCharacter& ExpandedPair::getRightChar() +{ + return m_rightChar; +} + +FinderPattern& ExpandedPair::getFinderPattern() +{ + return m_finderPattern; +} + +bool ExpandedPair::mustBeLast() const +{ + return m_rightChar.getValue() == 0; +} + +String ExpandedPair::toString() const +{ + return String(String("[ ").getText() + m_leftChar.toString().getText() + String(" , ").getText() + + m_rightChar.toString().getText() + " : " + + (m_finderPattern.getValue() != 0 ? "null" : std::to_string(m_finderPattern.getValue())) + " ]"); +} + +bool ExpandedPair::equals(const ExpandedPair &other) const +{ + return m_leftChar.equals(other.m_leftChar) && + m_rightChar.equals(other.m_rightChar) && + m_finderPattern.equals(other.m_finderPattern); +} + + +int ExpandedPair::hashCode() const +{ + return m_leftChar.hashCode() & m_rightChar.hashCode() & m_finderPattern.hashCode(); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h new file mode 100644 index 0000000..798b06e --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedPair.h @@ -0,0 +1,77 @@ +#ifndef EXPANDED_PAIR_H +#define EXPANDED_PAIR_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class ExpandedPair +{ + +public: + ExpandedPair(DataCharacter leftChar, + DataCharacter rightChar, + FinderPattern finderPattern); + + ExpandedPair(const ExpandedPair* other = nullptr); + + DataCharacter &getLeftChar(); + + DataCharacter &getRightChar(); + + FinderPattern &getFinderPattern(); + + bool mustBeLast() const; + + String toString() const; + + bool equals(const ExpandedPair& other) const; + + int hashCode() const; + +private: + DataCharacter m_leftChar; + DataCharacter m_rightChar; + FinderPattern m_finderPattern; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp new file mode 100644 index 0000000..aa12392 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.cpp @@ -0,0 +1,64 @@ +#include "ExpandedRow.h" + +namespace zxing { +namespace oned { +namespace rss { + +ExpandedRow::ExpandedRow(std::vector pairs, int rowNumber, bool wasReversed) + : m_pairs(pairs), + m_rowNumber(rowNumber), + m_wasReversed(wasReversed) +{ + +} + +ExpandedRow::ExpandedRow(const ExpandedRow *other) +{ + m_pairs = other != nullptr ? other->m_pairs : std::vector(); + m_rowNumber = other != nullptr ? other->m_rowNumber : 0; + m_wasReversed = other != nullptr ? other->m_wasReversed : false; +} + +std::vector &ExpandedRow::getPairs() +{ + return m_pairs; +} + +int ExpandedRow::getRowNumber() +{ + return m_rowNumber; +} + +bool ExpandedRow::isEquivalent(std::vector otherPairs) const +{ + if (m_pairs.size() != otherPairs.size()) { + return false; + } + + for (size_t i = 0; i < m_pairs.size(); i++) { + if (!m_pairs[i].equals(otherPairs[i])) { + return false; + } + } + + return true; +} + +String ExpandedRow::toString() +{ + String result("{ "); + for (auto i : m_pairs) { + result.append(i.toString().getText()); + } + result.append(" }"); + return result; +} + +bool ExpandedRow::equals(const ExpandedRow &other) const +{ + return isEquivalent(other.m_pairs) && m_wasReversed == other.m_wasReversed; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h new file mode 100644 index 0000000..cc796e4 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/ExpandedRow.h @@ -0,0 +1,67 @@ +#ifndef EXPANDED_ROW_H +#define EXPANDED_ROW_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +#include "ExpandedPair.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs. + */ +class ExpandedRow +{ + +public: + ExpandedRow(std::vector pairs, int rowNumber, bool wasReversed); + + ExpandedRow(const ExpandedRow* other = nullptr); + + std::vector& getPairs(); + + int getRowNumber(); + + bool isEquivalent(std::vector otherPairs) const; + + String toString(); + + /** + * Two rows are equal if they contain the same pairs in the same order. + */ + bool equals(const ExpandedRow& other) const; + +private: + std::vector m_pairs; + int m_rowNumber; + /** Did this row of the image have to be reversed (mirrored) to recognize the pairs? */ + bool m_wasReversed; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp new file mode 100644 index 0000000..fe1acbd --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp @@ -0,0 +1,750 @@ +#include "RSSExpandedReader.h" + +namespace zxing { +namespace oned { +namespace rss { + +using ::zxing::common::detector::MathUtils; + +static const std::vector SYMBOL_WIDEST = {7, 5, 4, 3, 1}; +static const std::vector EVEN_TOTAL_SUBSET = {4, 20, 52, 104, 204}; +static const std::vector GSUM = {0, 348, 1388, 2948, 3988}; + +const int FINDER_PATTERNS_[][4] = { + {1,8,4,1}, // A + {3,6,4,1}, // B + {3,4,6,1}, // C + {3,2,8,1}, // D + {2,6,5,1}, // E + {2,2,9,1} // F +}; + +#define VECTOR_INIT(v) v, v + sizeof(v)/sizeof(v[0]) + +const std::vector +RSSExpandedReader::FINDER_PATTERNS (VECTOR_INIT(FINDER_PATTERNS_)); + +static const std::vector> WEIGHTS = { + { 1, 3, 9, 27, 81, 32, 96, 77}, + { 20, 60, 180, 118, 143, 7, 21, 63}, + {189, 145, 13, 39, 117, 140, 209, 205}, + {193, 157, 49, 147, 19, 57, 171, 91}, + { 62, 186, 136, 197, 169, 85, 44, 132}, + {185, 133, 188, 142, 4, 12, 36, 108}, + {113, 128, 173, 97, 80, 29, 87, 50}, + {150, 28, 84, 41, 123, 158, 52, 156}, + { 46, 138, 203, 187, 139, 206, 196, 166}, + { 76, 17, 51, 153, 37, 111, 122, 155}, + { 43, 129, 176, 106, 107, 110, 119, 146}, + { 16, 48, 144, 10, 30, 90, 59, 177}, + {109, 116, 137, 200, 178, 112, 125, 164}, + { 70, 210, 208, 202, 184, 130, 179, 115}, + {134, 191, 151, 31, 93, 68, 204, 190}, + {148, 22, 66, 198, 172, 94, 71, 2}, + { 6, 18, 54, 162, 64, 192,154, 40}, + {120, 149, 25, 75, 14, 42,126, 167}, + { 79, 26, 78, 23, 69, 207,199, 175}, + {103, 98, 83, 38, 114, 131, 182, 124}, + {161, 61, 183, 127, 170, 88, 53, 159}, + { 55, 165, 73, 8, 24, 72, 5, 15}, + { 45, 135, 194, 160, 58, 174, 100, 89} +}; + +static const int FINDER_PAT_A = 0; +static const int FINDER_PAT_B = 1; +static const int FINDER_PAT_C = 2; +static const int FINDER_PAT_D = 3; +static const int FINDER_PAT_E = 4; +static const int FINDER_PAT_F = 5; + +static std::vector> FINDER_PATTERN_SEQUENCES = { + { FINDER_PAT_A, FINDER_PAT_A }, + { FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B }, + { FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D }, + { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_C }, + { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_F }, + { FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, + { FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F }, +}; + +static const int MAX_PAIRS = 11; + +RSSExpandedReader::RSSExpandedReader() + : m_pairs(std::vector(MAX_PAIRS)), m_rows(std::vector()), + m_startEnd(std::vector(2)), m_startFromEven(false) +{ + +} + +Ref RSSExpandedReader::decodeRow(int rowNumber, Ref row, DecodeHints /*hints*/) +{ + // Rows can start with even pattern in case in prev rows there where odd number of patters. + // So lets try twice + m_pairs.clear(); + m_startFromEven = false; + try { + return constructResult(decodeRow2pairs(rowNumber, row)); + } catch (NotFoundException e) { + // OK + } + + m_pairs.clear(); + m_startFromEven = true; + return constructResult(decodeRow2pairs(rowNumber, row)); +} + +void RSSExpandedReader::reset() +{ + m_pairs.clear(); + m_rows.clear(); +} + +std::vector RSSExpandedReader::decodeRow2pairs(int rowNumber, Ref row) +{ + bool done = false; + while (!done) { + try { + m_pairs.push_back(retrieveNextPair(row, m_pairs, rowNumber)); + } catch (NotFoundException nfe) { + if (m_pairs.size() == 0) { + throw nfe; + } + // exit this loop when retrieveNextPair() fails and throws + done = true; + } + } + + // TODO: verify sequence of finder patterns as in checkPairSequence() + if (checkChecksum()) { + return m_pairs; + } + + bool tryStackedDecode = !(m_rows.size() == 0); + storeRow(rowNumber, false); // TODO: deal with reversed rows + if (tryStackedDecode) { + // When the image is 180-rotated, then rows are sorted in wrong direction. + // Try twice with both the directions. + std::vector ps = checkRows(false); + if (ps.size() != 0) { + return ps; + } + ps = checkRows(true); + if (ps.size() != 0) { + return ps; + } + } + + throw NotFoundException(); +} + +std::vector RSSExpandedReader::checkRows(bool reverse) +{ + // Limit number of rows we are checking + // We use recursive algorithm with pure complexity and don't want it to take forever + // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough + if (m_rows.size() > 25) { + m_rows.clear(); // We will never have a chance to get result, so clear it + return {}; + } + + m_pairs.clear(); + if (reverse) { + std::reverse(m_rows.begin(), m_rows.end()); + } + + std::vector ps; + try { + ps = checkRows({}, 0); + } catch (NotFoundException e) { + // OK + } + + if (reverse) { + std::reverse(m_rows.begin(), m_rows.end()); + } + + return ps; +} + +std::vector RSSExpandedReader::checkRows(std::vector collectedRows, int currentRow) +{ + for (size_t i = static_cast(currentRow); i < m_rows.size(); i++) { + ExpandedRow row = m_rows[i]; + m_pairs.clear(); + for (ExpandedRow collectedRow : collectedRows) { + + std::vector collectedRowPairs = collectedRow.getPairs(); + m_pairs.insert(m_pairs.end(), collectedRowPairs.begin(), + collectedRowPairs.end()); + } + std::vector rowPairs = row.getPairs(); + m_pairs.insert(m_pairs.end(), rowPairs.begin(), + rowPairs.end()); + + if (isValidSequence(m_pairs)) { + if (checkChecksum()) { + return m_pairs; + } + + std::vector rs(collectedRows); + rs.push_back(row); + try { + // Recursion: try to add more rows + return checkRows(rs, static_cast(i + 1)); + } catch (NotFoundException e) { + // We failed, try the next candidate + } + } + } + + throw NotFoundException(); +} + +bool RSSExpandedReader::isValidSequence(std::vector pairs) +{ + for (std::vector sequence : FINDER_PATTERN_SEQUENCES) { + if (pairs.size() <= sequence.size()) { + bool stop = true; + for (size_t j = 0; j < pairs.size(); j++) { + if (pairs[j].getFinderPattern().getValue() != sequence[j]) { + stop = false; + break; + } + } + if (stop) { + return true; + } + } + + } + + return false; +} + +void RSSExpandedReader::storeRow(int rowNumber, bool wasReversed) +{ + // Discard if duplicate above or below; otherwise insert in order by row number. + size_t insertPos = 0; + bool prevIsSame = false; + bool nextIsSame = false; + while (insertPos < m_rows.size()) { + ExpandedRow erow = m_rows[insertPos]; + if (erow.getRowNumber() > rowNumber) { + nextIsSame = erow.isEquivalent(m_pairs); + break; + } + prevIsSame = erow.isEquivalent(m_pairs); + insertPos++; + } + if (nextIsSame || prevIsSame) { + return; + } + + // When the row was partially decoded (e.g. 2 pairs found instead of 3), + // it will prevent us from detecting the barcode. + // Try to merge partial rows + + // Check whether the row is part of an already detected row + if (isPartialRow(m_pairs, m_rows)) { + return; + } + + m_rows.insert(m_rows.begin() + insertPos, ExpandedRow(m_pairs, rowNumber, wasReversed)); + + removePartialRows(); +} + +void RSSExpandedReader::removePartialRows() +{ + + for (size_t i = 0; i < m_rows.size(); i++) { + if (m_rows[i].getPairs().size() != m_pairs.size()) { + bool allFound = true; + for (ExpandedPair p : m_rows[i].getPairs()) { + bool found = false; + for (ExpandedPair pp : m_pairs) { + if (p.equals(pp)) + { + found = true; + break; + } + } + if (!found) + { + allFound = false; + break; + } + } + if (allFound) { + // 'pairs' contains all the pairs from the row 'r' + m_rows.erase(m_rows.begin() + i--); + } + } + } +} + +bool RSSExpandedReader::isPartialRow(std::vector& pairs, std::vector& rows) +{ + for (ExpandedRow r : rows) { + bool allFound = true; + for (ExpandedPair p : pairs) { + bool found = false; + for (ExpandedPair pp : r.getPairs()) { + if (p.equals(pp)) { + found = true; + break; + } + } + if (!found) { + allFound = false; + break; + } + } + if (allFound) { + // the row 'r' contain all the pairs from 'pairs' + return true; + } + } + return false; +} + +std::vector RSSExpandedReader::getRows() const +{ + return m_rows; +} + +Ref RSSExpandedReader::constructResult(std::vector pairs) +{ + Ref binary = BitArrayBuilder::buildBitArray(pairs); + + AbstractExpandedDecoder* decoder = AbstractExpandedDecoder::createDecoder(binary); + String resultingString = decoder->parseInformation(); + + ArrayRef< Ref > firstPoints = pairs[0].getFinderPattern().getResultPoints(); + ArrayRef< Ref > lastPoints = pairs[pairs.size() - 1].getFinderPattern().getResultPoints(); + + ArrayRef< Ref > resultPoints(4); + resultPoints[0] = firstPoints[0]; + resultPoints[1] = firstPoints[1]; + resultPoints[2] = lastPoints[0]; + resultPoints[3] = lastPoints[1]; + + return Ref(new Result( + Ref(new String(resultingString)), + nullptr, + resultPoints, + BarcodeFormat::RSS_EXPANDED + )); +} + +bool RSSExpandedReader::checkChecksum() +{ + ExpandedPair firstPair = m_pairs[0]; + DataCharacter checkCharacter = firstPair.getLeftChar(); + DataCharacter firstCharacter = firstPair.getRightChar(); + + if (firstCharacter.getChecksumPortion() == 0) { + return false; + } + + int checksum = firstCharacter.getChecksumPortion(); + int s = 2; + + for (size_t i = 1; i < m_pairs.size(); ++i) { + ExpandedPair currentPair = m_pairs[i]; + checksum += currentPair.getLeftChar().getChecksumPortion(); + s++; + DataCharacter currentRightChar = currentPair.getRightChar(); + if (currentRightChar.getValue() != 0) { + checksum += currentRightChar.getChecksumPortion(); + s++; + } + } + + checksum %= 211; + + int checkCharacterValue = 211 * (s - 4) + checksum; + + return checkCharacterValue == checkCharacter.getValue(); +} + +int RSSExpandedReader::getNextSecondBar(Ref row, int initialPos) +{ + int currentPos; + if (row->get(initialPos)) { + currentPos = row->getNextUnset(initialPos); + currentPos = row->getNextSet(currentPos); + } else { + currentPos = row->getNextSet(initialPos); + currentPos = row->getNextUnset(currentPos); + } + return currentPos; +} + +ExpandedPair RSSExpandedReader::retrieveNextPair(Ref row, std::vector& previousPairs, int rowNumber) +{ + bool isOddPattern = previousPairs.size() % 2 == 0; + if (m_startFromEven) { + isOddPattern = !isOddPattern; + } + + FinderPattern pattern; + + bool keepFinding = true; + int forcedOffset = -1; + do { + findNextPair(row, previousPairs, forcedOffset); + pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern); + if (!pattern.isValid()) { + forcedOffset = getNextSecondBar(row, m_startEnd[0]); + } else { + keepFinding = false; + } + } while (keepFinding); + + // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not. + // bool mayBeLast = checkPairSequence(previousPairs, pattern); + + DataCharacter leftChar = decodeDataCharacter(row, pattern, isOddPattern, true); + + if (!(previousPairs.size() == 0) && previousPairs[previousPairs.size() - 1].mustBeLast()) { + throw NotFoundException(); + } + + DataCharacter rightChar; + try { + rightChar = decodeDataCharacter(row, pattern, isOddPattern, false); + } catch (NotFoundException ignored) { + //rightChar = nullptr; + } + return ExpandedPair(leftChar, rightChar, pattern); +} + +void RSSExpandedReader::findNextPair(Ref row, std::vector previousPairs, int forcedOffset) +{ + std::vector& counters = getDecodeFinderCounters(); + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; + + int width = row->getSize(); + + int rowOffset; + if (forcedOffset >= 0) { + rowOffset = forcedOffset; + } else if (previousPairs.size() == 0) { + rowOffset = 0; + } else { + ExpandedPair lastPair = previousPairs[previousPairs.size() - 1]; + rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; + } + bool searchingEvenPair = previousPairs.size() % 2 != 0; + if (m_startFromEven) { + searchingEvenPair = !searchingEvenPair; + } + + bool isWhite = false; + while (rowOffset < width) { + isWhite = !row->get(rowOffset); + if (!isWhite) { + break; + } + rowOffset++; + } + + size_t counterPosition = 0; + int patternStart = rowOffset; + for (int x = rowOffset; x < width; x++) { + if (row->get(x) != isWhite) { + counters[counterPosition]++; + } else { + if (counterPosition == 3) { + if (searchingEvenPair) { + std::reverse(counters.begin(), counters.end()); + } + + if (isFinderPattern(counters)) { + m_startEnd[0] = patternStart; + m_startEnd[1] = x; + return; + } + + if (searchingEvenPair) { + std::reverse(counters.begin(), counters.end()); + } + + patternStart += counters[0] + counters[1]; + counters[0] = counters[2]; + counters[1] = counters[3]; + counters[2] = 0; + counters[3] = 0; + counterPosition--; + } else { + counterPosition++; + } + counters[counterPosition] = 1; + isWhite = !isWhite; + } + } + throw NotFoundException(); +} + +FinderPattern RSSExpandedReader::parseFoundFinderPattern(Ref row, int rowNumber, bool oddPattern) +{ + // Actually we found elements 2-5. + int firstCounter; + int start; + int end; + + if (oddPattern) { + // If pattern number is odd, we need to locate element 1 *before* the current block. + + int firstElementStart = m_startEnd[0] - 1; + // Locate element 1 + while (firstElementStart >= 0 && !row->get(firstElementStart)) { + firstElementStart--; + } + + firstElementStart++; + firstCounter = m_startEnd[0] - firstElementStart; + start = firstElementStart; + end = m_startEnd[1]; + + } else { + // If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block. + + start = m_startEnd[0]; + + end = row->getNextUnset(m_startEnd[1] + 1); + firstCounter = end - m_startEnd[1]; + } + + // Make 'counters' hold 1-4 + std::vector& counters = getDecodeFinderCounters(); + + std::vector _counters = counters; + for (size_t i = 1; i < counters.size(); i++) { + counters[i] = _counters[i - 1]; + } + + counters[0] = firstCounter; + int value; + try { + value = parseFinderValue(counters, FINDER_PATTERNS); + } catch (NotFoundException ignored) { + return FinderPattern(); + } + return FinderPattern(value, {start, end}, start, end, rowNumber); +} + +DataCharacter RSSExpandedReader::decodeDataCharacter(Ref row, FinderPattern pattern, bool isOddPattern, bool leftChar) +{ + std::vector& counters = getDataCharacterCounters(); + for (size_t x = 0; x < counters.size(); x++) { + counters[x] = 0; + } + + if (leftChar) { + recordPatternInReverse(row, pattern.getStartEnd()[0], counters); + } else { + recordPattern(row, pattern.getStartEnd()[1], counters); + // reverse it + for (size_t i = 0, j = counters.size() - 1; i < j; i++, j--) { + int temp = counters[i]; + counters[i] = counters[j]; + counters[j] = temp; + } + } //counters[] has the pixels of the module + + int numModules = 17; //left and right data characters have all the same length + float elementWidth = MathUtils::sum(counters) / static_cast(numModules); + + // Sanity check: element width for pattern and the character should match + float expectedElementWidth = (pattern.getStartEnd()[1] - pattern.getStartEnd()[0]) / 15.0f; + if (std::abs(elementWidth - expectedElementWidth) / expectedElementWidth > 0.3f) { + throw NotFoundException(); + } + + std::vector& oddCounts(getOddCounts()); + std::vector& evenCounts(getEvenCounts()); + std::vector& oddRoundingErrors(getOddRoundingErrors()); + std::vector& evenRoundingErrors(getEvenRoundingErrors()); + + for (size_t i = 0; i < counters.size(); i++) { + float value = 1.0f * counters[i] / elementWidth; + int count = static_cast(value + 0.5f); // Round + if (count < 1) { + if (value < 0.3f) { + throw NotFoundException(); + } + count = 1; + } else if (count > 8) { + if (value > 8.7f) { + throw NotFoundException(); + } + count = 8; + } + size_t offset = i / 2; + if ((i & 0x01) == 0) { + oddCounts[offset] = count; + oddRoundingErrors[offset] = value - count; + } else { + evenCounts[offset] = count; + evenRoundingErrors[offset] = value - count; + } + } + + adjustOddEvenCounts(numModules); + + size_t weightRowNumber = static_cast(4 * pattern.getValue() + (isOddPattern ? 0 : 2) + (leftChar ? 0 : 1) - 1); + + int oddSum = 0; + int oddChecksumPortion = 0; + for (int i = oddCounts.size() - 1; i >= 0; i--) { + if (isNotA1left(pattern, isOddPattern, leftChar)) { + int weight = WEIGHTS[weightRowNumber][2 * i]; + oddChecksumPortion += oddCounts[i] * weight; + } + oddSum += oddCounts[i]; + } + int evenChecksumPortion = 0; + for (int i = evenCounts.size() - 1; i >= 0; i--) { + if (isNotA1left(pattern, isOddPattern, leftChar)) { + int weight = WEIGHTS[weightRowNumber][2 * i + 1]; + evenChecksumPortion += evenCounts[i] * weight; + } + } + int checksumPortion = oddChecksumPortion + evenChecksumPortion; + + if ((oddSum & 0x01) != 0 || oddSum > 13 || oddSum < 4) { + throw NotFoundException(); + } + + size_t group = static_cast((13 - oddSum) / 2); + int oddWidest = SYMBOL_WIDEST[group]; + int evenWidest = 9 - oddWidest; + int vOdd = RSSUtils::getRSSvalue(oddCounts, oddWidest, true); + int vEven = RSSUtils::getRSSvalue(evenCounts, evenWidest, false); + int tEven = EVEN_TOTAL_SUBSET[group]; + int gSum = GSUM[group]; + int value = vOdd * tEven + vEven + gSum; + + return DataCharacter(value, checksumPortion); +} + +bool RSSExpandedReader::isNotA1left(FinderPattern pattern, bool isOddPattern, bool leftChar) { + // A1: pattern.getValue is 0 (A), and it's an oddPattern, and it is a left char + return !(pattern.getValue() == 0 && isOddPattern && leftChar); +} + +void RSSExpandedReader::adjustOddEvenCounts(int numModules){ + + int oddSum = MathUtils::sum(getOddCounts()); + int evenSum = MathUtils::sum(getEvenCounts()); + + bool incrementOdd = false; + bool decrementOdd = false; + + if (oddSum > 13) { + decrementOdd = true; + } else if (oddSum < 4) { + incrementOdd = true; + } + bool incrementEven = false; + bool decrementEven = false; + if (evenSum > 13) { + decrementEven = true; + } else if (evenSum < 4) { + incrementEven = true; + } + + int mismatch = oddSum + evenSum - numModules; + bool oddParityBad = (oddSum & 0x01) == 1; + bool evenParityBad = (evenSum & 0x01) == 0; + switch (mismatch) { + case 1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + decrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + decrementEven = true; + } + break; + case -1: + if (oddParityBad) { + if (evenParityBad) { + throw NotFoundException(); + } + incrementOdd = true; + } else { + if (!evenParityBad) { + throw NotFoundException(); + } + incrementEven = true; + } + break; + case 0: + if (oddParityBad) { + if (!evenParityBad) { + throw NotFoundException(); + } + // Both bad + if (oddSum < evenSum) { + incrementOdd = true; + decrementEven = true; + } else { + decrementOdd = true; + incrementEven = true; + } + } else { + if (evenParityBad) { + throw NotFoundException(); + } + // Nothing to do! + } + break; + default: + throw NotFoundException(); + } + + if (incrementOdd) { + if (decrementOdd) { + throw NotFoundException(); + } + std::vector& oddCounts(getOddCounts()); + std::vector& oddRoundingErrors(getOddRoundingErrors()); + increment(oddCounts, oddRoundingErrors); + } + if (decrementOdd) { + std::vector& oddCounts(getOddCounts()); + std::vector& oddRoundingErrors(getOddRoundingErrors()); + decrement(oddCounts, oddRoundingErrors); + } + if (incrementEven) { + if (decrementEven) { + throw NotFoundException(); + } + std::vector& evenCounts(getEvenCounts()); + std::vector& oddRoundingErrors(getOddRoundingErrors()); + increment(evenCounts, oddRoundingErrors); + } + if (decrementEven) { + std::vector& evenCounts(getEvenCounts()); + std::vector& evenRoundingErrors(getEvenRoundingErrors()); + decrement(evenCounts, evenRoundingErrors); + } +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h new file mode 100644 index 0000000..86bf22c --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.h @@ -0,0 +1,121 @@ +#ifndef RSS_EXPANDED_READER_H +#define RSS_EXPANDED_READER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "ExpandedPair.h" +#include "ExpandedRow.h" +#include "BitArrayBuilder.h" +#include "decoders/AbstractExpandedDecoder.h" + +#include +#include +#include + +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class RSSExpandedReader : public AbstractRSSReader +{ + +public: + static const std::vector FINDER_PATTERNS; + + RSSExpandedReader(); + + Ref decodeRow(int rowNumber, + Ref row, DecodeHints); + + void reset(); + + // Not private for testing + std::vector decodeRow2pairs(int rowNumber, Ref row); + + std::vector checkRows(bool reverse); + + // Try to construct a valid rows sequence + // Recursion is used to implement backtracking + std::vector checkRows(std::vector collectedRows, int currentRow); + + // Whether the pairs form a valid find pattern sequence, + // either complete or a prefix + static bool isValidSequence(std::vector pairs); + + void storeRow(int rowNumber, bool wasReversed); + + // Remove all the rows that contains only specified pairs + void removePartialRows(); + + // Returns true when one of the rows already contains all the pairs + static bool isPartialRow(std::vector &pairs, std::vector &rows); + + // Only used for unit testing + std::vector getRows() const; + + // Not private for unit testing + static Ref constructResult(std::vector pairs); + + bool checkChecksum(); + + static int getNextSecondBar(Ref row, int initialPos); + + // not private for testing + ExpandedPair retrieveNextPair(Ref row, std::vector &previousPairs, int rowNumber); + + void findNextPair(Ref row, std::vector previousPairs, int forcedOffset); + + FinderPattern parseFoundFinderPattern(Ref row, int rowNumber, bool oddPattern); + + DataCharacter decodeDataCharacter(Ref row, + FinderPattern pattern, + bool isOddPattern, + bool leftChar); + + static bool isNotA1left(FinderPattern pattern, bool isOddPattern, bool leftChar); + + void adjustOddEvenCounts(int numModules); + +private: + std::vector m_pairs; + std::vector m_rows; + std::vector m_startEnd; + bool m_startFromEven; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp new file mode 100644 index 0000000..0f3a83b --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.cpp @@ -0,0 +1,25 @@ +#include "AI013103decoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI013103decoder::AI013103decoder(Ref information) + : AI013x0xDecoder(information) +{ + +} + +void AI013103decoder::addWeightCode(String &buf, int /*weight*/) +{ + buf.append("(3103)"); +} + +int AI013103decoder::checkWeight(int weight) +{ + return weight; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h new file mode 100644 index 0000000..2d0352a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013103decoder.h @@ -0,0 +1,57 @@ +#ifndef AI013_103X_DECODER_H +#define AI013_103X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ +#include "AI013x0xDecoder.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI013103decoder : public AI013x0xDecoder +{ + +public: + AI013103decoder(Ref information); + +protected: + virtual void addWeightCode(String &buf, int) override; + +protected: + virtual int checkWeight(int weight) override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp new file mode 100644 index 0000000..c872e43 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.cpp @@ -0,0 +1,32 @@ +#include "AI01320xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01320xDecoder::AI01320xDecoder(Ref information) + : AI013x0xDecoder(information) +{ + +} + +void AI01320xDecoder::addWeightCode(String &buf, int weight) +{ + if (weight < 10000) { + buf.append("(3202)"); + } else { + buf.append("(3203)"); + } +} + +int AI01320xDecoder::checkWeight(int weight) +{ + if (weight < 10000) { + return weight; + } + return weight - 10000; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h new file mode 100644 index 0000000..3bf49c7 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01320xDecoder.h @@ -0,0 +1,57 @@ +#ifndef AI013_20X_DECODER_H +#define AI013_20X_DECODER_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI013x0xDecoder.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI01320xDecoder : public AI013x0xDecoder +{ + +public: + AI01320xDecoder(Ref information); + +protected: + virtual void addWeightCode(String &buf, int weight) override; + + virtual int checkWeight(int weight) override; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp new file mode 100644 index 0000000..2bb169d --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.cpp @@ -0,0 +1,40 @@ +#include "AI01392xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01392xDecoder::AI01392xDecoder(Ref information) + : AI01decoder(information) +{ + +} + +String AI01392xDecoder::parseInformation() +{ + if (getInformation()->getSize() < HEADER_SIZE + GTIN_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + + int lastAIdigit = + getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); + buf.append("(392"); + buf.append(std::to_string(lastAIdigit)); + buf.append(')'); + + String stub(""); + + DecodedInformation decodedInformation = + getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, stub); + buf.append(decodedInformation.getNewString().getText()); + + return buf; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h new file mode 100644 index 0000000..83f0e5c --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01392xDecoder.h @@ -0,0 +1,61 @@ +#ifndef AI01_392X_DECODER_H +#define AI01_392X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" +#include "DecodedInformation.h" +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI01392xDecoder : public AI01decoder +{ + + static const int HEADER_SIZE = 5 + 1 + 2; + static const int LAST_DIGIT_SIZE = 2; + +public: + AI01392xDecoder(Ref information); + + virtual String parseInformation() override; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp new file mode 100644 index 0000000..b5130c1 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.cpp @@ -0,0 +1,55 @@ +#include "AI01393xDecoder.h" + +#include "DecodedInformation.h" +#include +#include + +namespace zxing { +namespace oned { +namespace rss { + +AI01393xDecoder::AI01393xDecoder(Ref information) + : AI01decoder(information) +{ + +} + +String AI01393xDecoder::parseInformation() +{ + if (getInformation()->getSize() < HEADER_SIZE + GTIN_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + + int lastAIdigit = + getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE); + + buf.append("(393"); + buf.append(std::to_string(lastAIdigit)); + buf.append(')'); + + int firstThreeDigits = getGeneralDecoder().extractNumericValueFromBitArray( + HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE); + if (firstThreeDigits / 100 == 0) { + buf.append('0'); + } + if (firstThreeDigits / 10 == 0) { + buf.append('0'); + } + buf.append(std::to_string(firstThreeDigits)); + + String stub(""); + + DecodedInformation generalInformation = getGeneralDecoder().decodeGeneralPurposeField( + HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, stub); + buf.append(generalInformation.getNewString().getText()); + + return buf; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h new file mode 100644 index 0000000..fbfa1a5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01393xDecoder.h @@ -0,0 +1,58 @@ +#ifndef AI01_393X_DECODER_H +#define AI01_393X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI01393xDecoder : public AI01decoder +{ + static const int HEADER_SIZE = 5 + 1 + 2; + static const int LAST_DIGIT_SIZE = 2; + static const int FIRST_THREE_DIGITS_SIZE = 10; + +public: + AI01393xDecoder(Ref information); + + virtual String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp new file mode 100644 index 0000000..4f5324e --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.cpp @@ -0,0 +1,74 @@ +#include "AI013x0x1xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI013x0x1xDecoder::AI013x0x1xDecoder(Ref information, String firstAIdigits, String dateCode) + : AI01weightDecoder(information), m_dateCode(dateCode), m_firstAIdigits(firstAIdigits) +{ + +} + +String AI013x0x1xDecoder::parseInformation() +{ + if (getInformation()->getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); + encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); + + return buf; +} + +void AI013x0x1xDecoder::encodeCompressedDate(String &buf, int currentPos) +{ + int numericDate = getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE); + if (numericDate == 38400) { + return; + } + + buf.append('('); + buf.append(m_dateCode.getText()); + buf.append(')'); + + int day = numericDate % 32; + numericDate /= 32; + int month = numericDate % 12 + 1; + numericDate /= 12; + int year = numericDate; + + if (year / 10 == 0) { + buf.append('0'); + } + buf.append(std::to_string(year)); + if (month / 10 == 0) { + buf.append('0'); + } + buf.append(std::to_string(month)); + if (day / 10 == 0) { + buf.append('0'); + } + buf.append(std::to_string(day)); +} + +void AI013x0x1xDecoder::addWeightCode(String &buf, int weight) +{ + buf.append('('); + buf.append(m_firstAIdigits.getText()); + buf.append(std::to_string(weight / 100000)); + buf.append(')'); +} + +int AI013x0x1xDecoder::checkWeight(int weight) +{ + return weight % 100000; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h new file mode 100644 index 0000000..f682629 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.h @@ -0,0 +1,70 @@ +#ifndef AI013_X0X1X_DECODER_H +#define AI013_X0X1X_DECODER_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01weightDecoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI013x0x1xDecoder : public AI01weightDecoder +{ + + static const int HEADER_SIZE = 7 + 1; + static const int WEIGHT_SIZE = 20; + static const int DATE_SIZE = 16; + +public: + AI013x0x1xDecoder(Ref information, String firstAIdigits, String dateCode); + + virtual String parseInformation() override; + +private: + void encodeCompressedDate(String &buf, int currentPos); + +protected: + virtual void addWeightCode(String &buf, int weight) override; + + virtual int checkWeight(int weight) override; + +private: + String m_dateCode; + String m_firstAIdigits; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp new file mode 100644 index 0000000..49897d4 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.cpp @@ -0,0 +1,29 @@ +#include "AI013x0xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI013x0xDecoder::AI013x0xDecoder(Ref information) + : AI01weightDecoder(information) +{ + +} + +String AI013x0xDecoder::parseInformation() +{ + if (getInformation()->getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { + throw NotFoundException(); + } + + String buf(""); + + encodeCompressedGtin(buf, HEADER_SIZE); + encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); + + return buf; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h new file mode 100644 index 0000000..053cfe5 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.h @@ -0,0 +1,62 @@ +#ifndef AI013_X0X_DECODER_H +#define AI013_X0X_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01weightDecoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ + +class AI013x0xDecoder : public AI01weightDecoder +{ + + static const int HEADER_SIZE = 4 + 1; + static const int WEIGHT_SIZE = 15; + +public: + AI013x0xDecoder(Ref information); + + virtual String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp new file mode 100644 index 0000000..84d9f8d --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.cpp @@ -0,0 +1,28 @@ +#include "AI01AndOtherAIs.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01AndOtherAIs::AI01AndOtherAIs(Ref information) + : AI01decoder(information) +{ + +} + +String AI01AndOtherAIs::parseInformation() +{ + String buff("(01)"); + + int initialGtinPosition = buff.length(); + int firstGtinDigit = getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4); + buff.append(std::to_string(firstGtinDigit)); + + encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initialGtinPosition); + + return getGeneralDecoder().decodeAllCodes(buff, HEADER_SIZE + 44); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h new file mode 100644 index 0000000..51002e2 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.h @@ -0,0 +1,59 @@ +#ifndef AI01_AND_OTHER_AIS_H +#define AI01_AND_OTHER_AIS_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" + +#include +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI01AndOtherAIs : public AI01decoder +{ + + static const int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag, + //the second one is the encodation method, and the other two are for the variable length +public: + AI01AndOtherAIs(Ref information); + + virtual String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp new file mode 100644 index 0000000..8a4ea8e --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.cpp @@ -0,0 +1,57 @@ +#include "AI01decoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01decoder::AI01decoder(Ref information) + : AbstractExpandedDecoder(information) +{ + +} + +void AI01decoder::encodeCompressedGtin(String &buf, int currentPos) +{ + buf.append("(01)"); + int initialPosition = buf.length(); + buf.append('9'); + + encodeCompressedGtinWithoutAI(buf, currentPos, initialPosition); +} + +void AI01decoder::encodeCompressedGtinWithoutAI(String &buf, int currentPos, int initialBufferPosition) +{ + for (int i = 0; i < 4; ++i) { + int currentBlock = getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10); + if (currentBlock / 100 == 0) { + buf.append("0"); + } + if (currentBlock / 10 == 0) { + buf.append("0"); + } + buf.append(std::to_string(currentBlock)); + } + + appendCheckDigit(buf, initialBufferPosition); +} + +void AI01decoder::appendCheckDigit(String &buf, int currentPos) +{ + int checkDigit = 0; + for (int i = 0; i < 13; i++) { + int digit = buf.charAt(i + currentPos) - '0'; + checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; + } + + checkDigit = 10 - (checkDigit % 10); + if (checkDigit == 10) { + checkDigit = 0; + } + + buf.append(std::to_string(checkDigit)); +} + + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h new file mode 100644 index 0000000..2123051 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01decoder.h @@ -0,0 +1,62 @@ +#ifndef AI01_DECODER_H +#define AI01_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AbstractExpandedDecoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AI01decoder : public AbstractExpandedDecoder +{ + +public: + static const int GTIN_SIZE = 40; + + AI01decoder(Ref information); + + void encodeCompressedGtin(String &buf, int currentPos); + + void encodeCompressedGtinWithoutAI(String &buf, int currentPos, int initialBufferPosition); + + static void appendCheckDigit(String &buf, int currentPos); + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp new file mode 100644 index 0000000..ba180c3 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.cpp @@ -0,0 +1,32 @@ +#include "AI01weightDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AI01weightDecoder::AI01weightDecoder(Ref information) + : AI01decoder(information) +{ + +} + +void AI01weightDecoder::encodeCompressedWeight(String &buf, int currentPos, int weightSize) +{ + int originalWeightNumeric = getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize); + addWeightCode(buf, originalWeightNumeric); + + int weightNumeric = checkWeight(originalWeightNumeric); + + int currentDivisor = 100000; + for (int i = 0; i < 5; ++i) { + if (weightNumeric / currentDivisor == 0) { + buf.append('0'); + } + currentDivisor /= 10; + } + buf.append(std::to_string(weightNumeric)); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h new file mode 100644 index 0000000..3fcbf6f --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AI01weightDecoder.h @@ -0,0 +1,63 @@ +#ifndef AI01_WEIGHT_DECODER_H +#define AI01_WEIGHT_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "AI01decoder.h" +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +/** + * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es) + */ +class AI01weightDecoder : public AI01decoder +{ + +public: + AI01weightDecoder(Ref information); + + void encodeCompressedWeight(String &buf, int currentPos, int weightSize); + +protected: + virtual void addWeightCode(String &buf, int weight) = 0; + virtual int checkWeight(int weight) = 0; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp new file mode 100644 index 0000000..f70f0ec --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.cpp @@ -0,0 +1,70 @@ +#include "AbstractExpandedDecoder.h" + +#include "AI01AndOtherAIs.h" +#include "AI013x0x1xDecoder.h" +#include "AnyAIDecoder.h" +#include "AI013103decoder.h" +#include "AI01320xDecoder.h" +#include "AI01392xDecoder.h" +#include "AI01393xDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AbstractExpandedDecoder::AbstractExpandedDecoder(Ref information) + : m_information(information), m_generalDecoder(GeneralAppIdDecoder(information)) +{ + +} + +Ref AbstractExpandedDecoder::getInformation() const +{ + return m_information; +} + +GeneralAppIdDecoder AbstractExpandedDecoder::getGeneralDecoder() +{ + return m_generalDecoder; +} + +AbstractExpandedDecoder *AbstractExpandedDecoder::createDecoder(Ref information) +{ + if (information->get(1)) { + return new AI01AndOtherAIs(information); + } + if (!information->get(2)) { + return new AnyAIDecoder(information); + } + + int fourBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 4); + + switch (fourBitEncodationMethod) { + case 4: return new AI013103decoder(information); + case 5: return new AI01320xDecoder(information); + } + + int fiveBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 5); + switch (fiveBitEncodationMethod) { + case 12: return new AI01392xDecoder(information); + case 13: return new AI01393xDecoder(information); + } + + int sevenBitEncodationMethod = GeneralAppIdDecoder::extractNumericValueFromBitArray(information, 1, 7); + switch (sevenBitEncodationMethod) { + case 56: return new AI013x0x1xDecoder(information, String("310"), String("11")); + case 57: return new AI013x0x1xDecoder(information, String("320"), String("11")); + case 58: return new AI013x0x1xDecoder(information, String("310"), String("13")); + case 59: return new AI013x0x1xDecoder(information, String("320"), String("13")); + case 60: return new AI013x0x1xDecoder(information, String("310"), String("15")); + case 61: return new AI013x0x1xDecoder(information, String("320"), String("15")); + case 62: return new AI013x0x1xDecoder(information, String("310"), String("17")); + case 63: return new AI013x0x1xDecoder(information, String("320"), String("17")); + } + + throw IllegalStateException(); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h new file mode 100644 index 0000000..25667ae --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.h @@ -0,0 +1,71 @@ +#ifndef ABSTRACT_EXPANDED_DECODER_H +#define ABSTRACT_EXPANDED_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "GeneralAppIdDecoder.h" + +#include +#include +#include +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class AbstractExpandedDecoder +{ + +public: + AbstractExpandedDecoder(Ref information); + + virtual ~AbstractExpandedDecoder() {} + + Ref getInformation() const; + + virtual GeneralAppIdDecoder getGeneralDecoder(); + + virtual String parseInformation() = 0; + + static AbstractExpandedDecoder* createDecoder(Ref information); + +protected: + Ref m_information; + GeneralAppIdDecoder m_generalDecoder; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp new file mode 100644 index 0000000..ddd9643 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.cpp @@ -0,0 +1,21 @@ +#include "AnyAIDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +AnyAIDecoder::AnyAIDecoder(Ref information) + : AbstractExpandedDecoder(information) +{ + +} + +String AnyAIDecoder::parseInformation() +{ + String buf(""); + return getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE); +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h new file mode 100644 index 0000000..9a25a31 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/AnyAIDecoder.h @@ -0,0 +1,57 @@ +#ifndef ANY_AI_DECODER_H +#define ANY_AI_DECODER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include +#include +#include "AbstractExpandedDecoder.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +class AnyAIDecoder : public AbstractExpandedDecoder +{ + static const int HEADER_SIZE = 2 + 1 + 2; + +public: + AnyAIDecoder(Ref information); + + String parseInformation() override; +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp new file mode 100644 index 0000000..a0be3eb --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp @@ -0,0 +1,37 @@ +#include "BlockParsedResult.h" + +namespace zxing { +namespace oned { +namespace rss { + +BlockParsedResult::BlockParsedResult(bool finished) + : m_decodedInformation(nullptr), m_finished(finished) +{ + +} + +BlockParsedResult::BlockParsedResult(const DecodedInformation &information, bool finished) +{ + m_finished = finished; + m_decodedInformation = information; +} + +BlockParsedResult::BlockParsedResult(const BlockParsedResult &other) +{ + m_finished = other.m_finished; + m_decodedInformation = other.m_decodedInformation; +} + +DecodedInformation BlockParsedResult::getDecodedInformation() +{ + return m_decodedInformation; +} + +bool BlockParsedResult::isFinished() +{ + return m_finished; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h new file mode 100644 index 0000000..6e93ee9 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h @@ -0,0 +1,63 @@ +#ifndef BLOCK_PARSED_RESULT_H +#define BLOCK_PARSED_RESULT_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedInformation.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +class BlockParsedResult +{ + +public: + + BlockParsedResult(bool finished); + + BlockParsedResult(const DecodedInformation& information, bool finished); + + BlockParsedResult(const BlockParsedResult& other); + + DecodedInformation getDecodedInformation(); + + bool isFinished(); + +private: + DecodedInformation m_decodedInformation; + bool m_finished; +}; + +} +} +} +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp new file mode 100644 index 0000000..e6f4432 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.cpp @@ -0,0 +1,60 @@ +#include "CurrentParsingState.h" + +namespace zxing { +namespace oned { +namespace rss { + +CurrentParsingState::CurrentParsingState() +{ + position = 0; + encoding = State::NUMERIC; +} + +int CurrentParsingState::getPosition() const +{ + return position; +} + +void CurrentParsingState::setPosition(int _position) +{ + position = _position; +} + +void CurrentParsingState::incrementPosition(int delta) +{ + position += delta; +} + +bool CurrentParsingState::isAlpha() const +{ + return encoding == State::ALPHA; +} + +bool CurrentParsingState::isNumeric() const +{ + return encoding == State::NUMERIC; +} + +bool CurrentParsingState::isIsoIec646() const +{ + return encoding == State::ISO_IEC_646; +} + +void CurrentParsingState::setNumeric() +{ + encoding = State::NUMERIC; +} + +void CurrentParsingState::setAlpha() +{ + encoding = State::ALPHA; +} + +void CurrentParsingState::setIsoIec646() +{ + encoding = State::ISO_IEC_646; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h new file mode 100644 index 0000000..1db0cd0 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/CurrentParsingState.h @@ -0,0 +1,78 @@ +#ifndef CURRENT_PARSING_STATE_H +#define CURRENT_PARSING_STATE_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +namespace zxing { + +namespace oned { + +namespace rss { + +class CurrentParsingState +{ + +public: + enum State { + NUMERIC, + ALPHA, + ISO_IEC_646 + }; + + CurrentParsingState(); + + int getPosition() const; + + void setPosition(int _position); + + void incrementPosition(int delta); + + bool isAlpha() const; + + bool isNumeric() const; + + bool isIsoIec646() const; + + void setNumeric(); + + void setAlpha(); + + void setIsoIec646(); + +private: + int position; + State encoding; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp new file mode 100644 index 0000000..48fa6e8 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.cpp @@ -0,0 +1,25 @@ +#include "DecodedChar.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedChar::DecodedChar(int newPosition, char value) + : DecodedObject (newPosition), m_value(value) +{ + +} + +char DecodedChar::getValue() const +{ + return m_value; +} + +bool DecodedChar::isFNC1() const +{ + return m_value == FNC1; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h new file mode 100644 index 0000000..c7a015b --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedChar.h @@ -0,0 +1,61 @@ +#ifndef DECODED_CHAR_H +#define DECODED_CHAR_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedObject.h" + +namespace zxing { + +namespace oned { + +namespace rss { + +class DecodedChar : public DecodedObject +{ + +public: + static const char FNC1 = '$'; // It's not in Alphanumeric neither in ISO/IEC 646 charset + + DecodedChar(int newPosition, char value); + + char getValue() const; + + bool isFNC1() const; + +private: + char m_value; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp new file mode 100644 index 0000000..2c60c4a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.cpp @@ -0,0 +1,51 @@ +#include "DecodedInformation.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedInformation::DecodedInformation(const DecodedInformation *other) + : DecodedObject (other == nullptr ? 0 : other->m_newPosition), + m_newString(other == nullptr ? String("") : other->m_newString) +{ + m_newString = other == nullptr ? String("") : other->m_newString; + m_remaining = other == nullptr ? false : other->m_remaining; + m_remainingValue = other == nullptr ? 0 : other->m_remainingValue; +} + +DecodedInformation::DecodedInformation(int newPosition, String newString) + : DecodedObject (newPosition), + m_newString(newString), + m_remainingValue(0), + m_remaining(false) +{ + +} + +DecodedInformation::DecodedInformation(int newPosition, String newString, int remainingValue) + : DecodedObject (newPosition), + m_newString(newString), + m_remainingValue(remainingValue), + m_remaining(true) +{ + +} + +String DecodedInformation::getNewString() const +{ + return m_newString; +} + +bool DecodedInformation::isRemaining() const +{ + return m_remaining; +} + +int DecodedInformation::getRemainingValue() const +{ + return m_remainingValue; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h new file mode 100644 index 0000000..dcf9f72 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedInformation.h @@ -0,0 +1,69 @@ +#ifndef DECODED_INFORMATION_H +#define DECODED_INFORMATION_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedObject.h" +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class DecodedInformation : public DecodedObject +{ + +public: + + DecodedInformation(const DecodedInformation* other = nullptr); + + DecodedInformation(int newPosition, String newString); + + DecodedInformation(int newPosition, String newString, int remainingValue); + + String getNewString() const; + + bool isRemaining() const; + + int getRemainingValue() const; + +private: + String m_newString; + int m_remainingValue; + bool m_remaining; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp new file mode 100644 index 0000000..c9a6e1d --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.cpp @@ -0,0 +1,55 @@ +#include "DecodedNumeric.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedNumeric::DecodedNumeric(int newPosition, int firstDigit, int secondDigit) + : DecodedObject(newPosition) +{ + + if (firstDigit < 0 || firstDigit > 10 || secondDigit < 0 || secondDigit > 10) { + throw FormatException::getFormatInstance(); + } + + m_newPosition = newPosition; + m_firstDigit = firstDigit; + m_secondDigit = secondDigit; +} + +DecodedNumeric::DecodedNumeric(const DecodedNumeric *other) + : DecodedObject (other == nullptr ? 0 : other->m_newPosition) +{ + m_newPosition = other == nullptr ? 0 : other->m_newPosition; + m_firstDigit = other == nullptr ? 0 : other->m_firstDigit; + m_secondDigit = other == nullptr ? 0 : other->m_secondDigit; +} + +int DecodedNumeric::getFirstDigit() const +{ + return m_firstDigit; +} + +int DecodedNumeric::getSecondDigit() const +{ + return m_secondDigit; +} + +int DecodedNumeric::getValue() const +{ + return m_firstDigit * 10 + m_secondDigit; +} + +bool DecodedNumeric::isFirstDigitFNC1() const +{ + return m_firstDigit == FNC1; +} + +bool DecodedNumeric::isSecondDigitFNC1() const +{ + return m_secondDigit == FNC1; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h new file mode 100644 index 0000000..1c87fd4 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedNumeric.h @@ -0,0 +1,71 @@ +#ifndef DECODED_NUMERIC_H +#define DECODED_NUMERIC_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include "DecodedObject.h" + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class DecodedNumeric : public DecodedObject +{ + +public: + static const int FNC1 = 10; + DecodedNumeric(int newPosition, int firstDigit, int secondDigit); + + DecodedNumeric(const DecodedNumeric* other = nullptr); + + int getFirstDigit() const; + + int getSecondDigit() const; + + int getValue() const; + + bool isFirstDigitFNC1() const; + + bool isSecondDigitFNC1() const; + +private: + int m_firstDigit; + int m_secondDigit; + +}; + +} +} +} + +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp new file mode 100644 index 0000000..cb1bd8a --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.cpp @@ -0,0 +1,20 @@ +#include "DecodedObject.h" + +namespace zxing { +namespace oned { +namespace rss { + +DecodedObject::DecodedObject(int newPosition) + : m_newPosition(newPosition) +{ + +} + +int DecodedObject::getNewPosition() const +{ + return m_newPosition; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h new file mode 100644 index 0000000..07ff33f --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/DecodedObject.h @@ -0,0 +1,52 @@ +#ifndef DECODED_OBJECT_H +#define DECODED_OBJECT_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ +namespace zxing { + +namespace oned { + +namespace rss { + +class DecodedObject +{ + +public: + DecodedObject(int newPosition); + + int getNewPosition() const; + +protected: + int m_newPosition; +}; + +} +} +} +#endif diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp new file mode 100644 index 0000000..dd98ef4 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp @@ -0,0 +1,274 @@ +#include "FieldParser.h" + +namespace zxing { +namespace oned { +namespace rss { + +static const int VARIABLE_LENGTH = 99999; + +struct DigitData { + std::string digit; + int variableLength; + int length; +}; + +static const DigitData TWO_DIGIT_DATA_LENGTH[] { + // "DIGITS", new Integer(LENGTH) + // or + // "DIGITS", VARIABLE_LENGTH, new Integer(MAX_SIZE) + + { "00", 18, 0}, + { "01", 14, 0}, + { "02", 14, 0}, + + { "10", VARIABLE_LENGTH, 20}, + { "11", 6, 0}, + { "12", 6, 0}, + { "13", 6, 0}, + { "15", 6, 0}, + { "17", 6, 0}, + + { "20", 2, 0}, + { "21", VARIABLE_LENGTH, 20}, + { "22", VARIABLE_LENGTH, 29}, + + { "30", VARIABLE_LENGTH, 8}, + { "37", VARIABLE_LENGTH, 8}, + + //internal company codes + { "90", VARIABLE_LENGTH, 30}, + { "91", VARIABLE_LENGTH, 30}, + { "92", VARIABLE_LENGTH, 30}, + { "93", VARIABLE_LENGTH, 30}, + { "94", VARIABLE_LENGTH, 30}, + { "95", VARIABLE_LENGTH, 30}, + { "96", VARIABLE_LENGTH, 30}, + { "97", VARIABLE_LENGTH, 30}, + { "98", VARIABLE_LENGTH, 30}, + { "99", VARIABLE_LENGTH, 30}, +}; + +static const DigitData THREE_DIGIT_DATA_LENGTH[] { + // Same format as above + + { "240", VARIABLE_LENGTH, 30}, + { "241", VARIABLE_LENGTH, 30}, + { "242", VARIABLE_LENGTH, 6}, + { "250", VARIABLE_LENGTH, 30}, + { "251", VARIABLE_LENGTH, 30}, + { "253", VARIABLE_LENGTH, 17}, + { "254", VARIABLE_LENGTH, 20}, + + { "400", VARIABLE_LENGTH, 30}, + { "401", VARIABLE_LENGTH, 30}, + { "402", 17, 0}, + { "403", VARIABLE_LENGTH, 30}, + { "410", 13, 0}, + { "411", 13, 0}, + { "412", 13, 0}, + { "413", 13, 0}, + { "414", 13, 0}, + { "420", VARIABLE_LENGTH, 20}, + { "421", VARIABLE_LENGTH, 15}, + { "422", 3, 0}, + { "423", VARIABLE_LENGTH, 15}, + { "424", 3, 0}, + { "425", 3, 0}, + { "426", 3, 0}, +}; + +static const DigitData THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH[] { + // Same format as above + + { "310", 6, 0}, + { "311", 6, 0}, + { "312", 6, 0}, + { "313", 6, 0}, + { "314", 6, 0}, + { "315", 6, 0}, + { "316", 6, 0}, + { "320", 6, 0}, + { "321", 6, 0}, + { "322", 6, 0}, + { "323", 6, 0}, + { "324", 6, 0}, + { "325", 6, 0}, + { "326", 6, 0}, + { "327", 6, 0}, + { "328", 6, 0}, + { "329", 6, 0}, + { "330", 6, 0}, + { "331", 6, 0}, + { "332", 6, 0}, + { "333", 6, 0}, + { "334", 6, 0}, + { "335", 6, 0}, + { "336", 6, 0}, + { "340", 6, 0}, + { "341", 6, 0}, + { "342", 6, 0}, + { "343", 6, 0}, + { "344", 6, 0}, + { "345", 6, 0}, + { "346", 6, 0}, + { "347", 6, 0}, + { "348", 6, 0}, + { "349", 6, 0}, + { "350", 6, 0}, + { "351", 6, 0}, + { "352", 6, 0}, + { "353", 6, 0}, + { "354", 6, 0}, + { "355", 6, 0}, + { "356", 6, 0}, + { "357", 6, 0}, + { "360", 6, 0}, + { "361", 6, 0}, + { "362", 6, 0}, + { "363", 6, 0}, + { "364", 6, 0}, + { "365", 6, 0}, + { "366", 6, 0}, + { "367", 6, 0}, + { "368", 6, 0}, + { "369", 6, 0}, + { "390", VARIABLE_LENGTH, 15}, + { "391", VARIABLE_LENGTH, 18}, + { "392", VARIABLE_LENGTH, 15}, + { "393", VARIABLE_LENGTH, 18}, + { "703", VARIABLE_LENGTH, 30}, +}; + +static const DigitData FOUR_DIGIT_DATA_LENGTH[] { + // Same format as above + + { "7001", 13, 0}, + { "7002", VARIABLE_LENGTH, 30}, + { "7003", 10, 0}, + + { "8001", 14, 0}, + { "8002", VARIABLE_LENGTH, 20}, + { "8003", VARIABLE_LENGTH, 30}, + { "8004", VARIABLE_LENGTH, 30}, + { "8005", 6, 0}, + { "8006", 18, 0}, + { "8007", VARIABLE_LENGTH, 30}, + { "8008", VARIABLE_LENGTH, 12}, + { "8018", 18, 0}, + { "8020", VARIABLE_LENGTH, 25}, + { "8100", 6, 0}, + { "8101", 10, 0}, + { "8102", 2, 0}, + { "8110", VARIABLE_LENGTH, 70}, + { "8200", VARIABLE_LENGTH, 70}, +}; + +String FieldParser::parseFieldsInGeneralPurpose(String rawInformation) +{ + if (rawInformation.getText().empty()) { + return String(""); + } + + // Processing 2-digit AIs + + if (rawInformation.length() < 2) { + throw NotFoundException(); + } + + String firstTwoDigits(rawInformation.substring(0, 2)->getText()); + + for (DigitData dataLength : TWO_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstTwoDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(2, dataLength.length, rawInformation); + } + return processFixedAI(2, dataLength.variableLength, rawInformation); + } + } + + if (rawInformation.length() < 3) { + throw NotFoundException(); + } + + String firstThreeDigits(rawInformation.substring(0, 3)->getText()); + + for (DigitData dataLength : THREE_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstThreeDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(3, dataLength.length, rawInformation); + } + return processFixedAI(3, dataLength.variableLength, rawInformation); + } + } + + + for (DigitData dataLength : THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstThreeDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(4, dataLength.length, rawInformation); + } + return processFixedAI(4, dataLength.variableLength, rawInformation); + } + } + + if (rawInformation.length() < 4) { + throw NotFoundException(); + } + + String firstFourDigits(rawInformation.substring(0, 4)->getText()); + + for (DigitData dataLength : FOUR_DIGIT_DATA_LENGTH) { + if (dataLength.digit == firstFourDigits.getText()) { + if (dataLength.variableLength == VARIABLE_LENGTH) { + return processVariableAI(4, dataLength.length, rawInformation); + } + return processFixedAI(4, dataLength.variableLength, rawInformation); + } + } + + throw NotFoundException(); +} + +String FieldParser::processFixedAI(int aiSize, int fieldSize, String rawInformation) +{ + if (rawInformation.length() < aiSize) { + throw NotFoundException(); + } + + String ai(rawInformation.substring(0, aiSize)->getText()); + + if (rawInformation.length() < aiSize + fieldSize) { + throw NotFoundException(); + } + + String field(rawInformation.substring(aiSize, /*aiSize +*/ fieldSize)->getText()); + String remaining(rawInformation.substring(aiSize + fieldSize)->getText()); + String result('(' + ai.getText() + ')' + field.getText()); + String parsedAI = parseFieldsInGeneralPurpose(remaining); + if (parsedAI.getText() == "") { + return result; + } else { + result.append(parsedAI.getText()); + return result; + } +} + +String FieldParser::processVariableAI(int aiSize, int variableFieldSize, String rawInformation) +{ + String ai(rawInformation.substring(0, aiSize)->getText()); + int maxSize = std::min(rawInformation.length(), aiSize + variableFieldSize); + String field(rawInformation.substring(aiSize, maxSize - aiSize)->getText()); + String remaining(rawInformation.substring(maxSize)->getText()); + String result('(' + ai.getText() + ')' + field.getText()); + String parsedAI = parseFieldsInGeneralPurpose(remaining); + if (parsedAI.getText() == "") { + return result; + } else { + result.append(parsedAI.getText()); + return result; + } +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h new file mode 100644 index 0000000..9d7867f --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.h @@ -0,0 +1,60 @@ +#ifndef FIELD_PARSER_H +#define FIELD_PARSER_H + +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include + +#include + +namespace zxing { + +namespace oned { + +namespace rss { + +class FieldParser +{ + +public: + + static String parseFieldsInGeneralPurpose(String rawInformation); + + static String processFixedAI(int aiSize, int fieldSize, String rawInformation); + + static String processVariableAI(int aiSize, int variableFieldSize, String rawInformation); +}; + +} +} +} + +#endif + diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp new file mode 100644 index 0000000..e2d6750 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp @@ -0,0 +1,453 @@ +#include "GeneralAppIdDecoder.h" + +namespace zxing { +namespace oned { +namespace rss { + +GeneralAppIdDecoder::GeneralAppIdDecoder(Ref information) + : m_information(information), + m_buffer("") +{ + +} + +String GeneralAppIdDecoder::decodeAllCodes(String &buff, int initialPosition) +{ + int currentPosition = initialPosition; + String remaining(""); + do { + DecodedInformation info(decodeGeneralPurposeField(currentPosition, remaining)); + String parsedFields = FieldParser::parseFieldsInGeneralPurpose(info.getNewString()); + if (parsedFields.length() > 0) { + buff.append(parsedFields.getText()); + } + if (info.isRemaining()) { + remaining = String(info.getRemainingValue()); + } else { + remaining = String(""); + } + + if (currentPosition == info.getNewPosition()) { // No step forward! + break; + } + currentPosition = info.getNewPosition(); + } while (true); + + return buff; +} + +bool GeneralAppIdDecoder::isStillNumeric(int pos) const +{ + // It's numeric if it still has 7 positions + // and one of the first 4 bits is "1". + if (pos + 7 > m_information->getSize()) { + return pos + 4 <= m_information->getSize(); + } + + for (int i = pos; i < pos + 3; ++i) { + if (m_information->get(i)) { + return true; + } + } + + return m_information->get(pos + 3); +} + +DecodedNumeric* GeneralAppIdDecoder::decodeNumeric(int pos) +{ + if (pos + 7 > m_information->getSize()) { + int numeric = extractNumericValueFromBitArray(pos, 4); + if (numeric == 0) { + return new DecodedNumeric(m_information->getSize(), DecodedNumeric::FNC1, DecodedNumeric::FNC1); + } + return new DecodedNumeric(m_information->getSize(), numeric - 1, DecodedNumeric::FNC1); + } + int numeric = extractNumericValueFromBitArray(pos, 7); + + int digit1 = (numeric - 8) / 11; + int digit2 = (numeric - 8) % 11; + + return new DecodedNumeric(pos + 7, digit1, digit2); +} + +int GeneralAppIdDecoder::extractNumericValueFromBitArray(int pos, int bits) +{ + return extractNumericValueFromBitArray(m_information, pos, bits); +} + +int GeneralAppIdDecoder::extractNumericValueFromBitArray(Ref information, int pos, int bits) +{ + int value = 0; + for (int i = 0; i < bits; ++i) { + if (information->get(pos + i)) { + value |= 1 << (bits - i - 1); + } + } + + return value; +} + +DecodedInformation GeneralAppIdDecoder::decodeGeneralPurposeField(int pos, String &remaining) +{ + m_buffer = String(""); + + if (remaining.length() > 0) { + m_buffer.append(remaining.getText()); + } + + m_current.setPosition(pos); + + DecodedInformation lastDecoded(parseBlocks()); + if (lastDecoded.getNewString().length() > 0 && lastDecoded.isRemaining()) { + return DecodedInformation(m_current.getPosition(), m_buffer, lastDecoded.getRemainingValue()); + } + return DecodedInformation(m_current.getPosition(), m_buffer); +} + +DecodedInformation GeneralAppIdDecoder::parseBlocks() +{ + bool isFinished; + BlockParsedResult* result; + do { + int initialPosition = m_current.getPosition(); + + if (m_current.isAlpha()) { + result = parseAlphaBlock(); + isFinished = result->isFinished(); + } else if (m_current.isIsoIec646()) { + result = parseIsoIec646Block(); + isFinished = result->isFinished(); + } else { // it must be numeric + result = parseNumericBlock(); + isFinished = result->isFinished(); + } + + bool positionChanged = initialPosition != m_current.getPosition(); + if (!positionChanged && !isFinished) { + break; + } + } while (!isFinished); + + return result->getDecodedInformation(); +} + +BlockParsedResult* GeneralAppIdDecoder::parseNumericBlock() +{ + while (isStillNumeric(m_current.getPosition())) { + DecodedNumeric numeric(decodeNumeric(m_current.getPosition())); + m_current.setPosition(numeric.getNewPosition()); + + if (numeric.isFirstDigitFNC1()) { + DecodedInformation information(0, String("")); + if (numeric.isSecondDigitFNC1()) { + return new BlockParsedResult(DecodedInformation(m_current.getPosition(), m_buffer), true); + } else { + return new BlockParsedResult(DecodedInformation(m_current.getPosition(), m_buffer, numeric.getSecondDigit()), true); + } + } + m_buffer.append(std::to_string(numeric.getFirstDigit())); + + if (numeric.isSecondDigitFNC1()) { + DecodedInformation information(m_current.getPosition(), m_buffer); + return new BlockParsedResult(information, true); + } + m_buffer.append(std::to_string(numeric.getSecondDigit())); + } + + if (isNumericToAlphaNumericLatch(m_current.getPosition())) { + m_current.setAlpha(); + m_current.incrementPosition(4); + } + return new BlockParsedResult(false); +} + +BlockParsedResult* GeneralAppIdDecoder::parseIsoIec646Block() +{ + while (isStillIsoIec646(m_current.getPosition())) { + DecodedChar iso = decodeIsoIec646(m_current.getPosition()); + m_current.setPosition(iso.getNewPosition()); + + if (iso.isFNC1()) { + DecodedInformation information(m_current.getPosition(), m_buffer); + return new BlockParsedResult(information, true); + } + m_buffer.append(iso.getValue()); + } + + if (isAlphaOr646ToNumericLatch(m_current.getPosition())) { + m_current.incrementPosition(3); + m_current.setNumeric(); + } else if (isAlphaTo646ToAlphaLatch(m_current.getPosition())) { + if (m_current.getPosition() + 5 < m_information->getSize()) { + m_current.incrementPosition(5); + } else { + m_current.setPosition(m_information->getSize()); + } + + m_current.setAlpha(); + } + return new BlockParsedResult(false); +} + +BlockParsedResult* GeneralAppIdDecoder::parseAlphaBlock() +{ + while (isStillAlpha(m_current.getPosition())) { + DecodedChar alpha(decodeAlphanumeric(m_current.getPosition())); + m_current.setPosition(alpha.getNewPosition()); + + if (alpha.isFNC1()) { + DecodedInformation information(m_current.getPosition(), m_buffer); + return new BlockParsedResult(information, true); //end of the char block + } + + m_buffer.append(alpha.getValue()); + } + + if (isAlphaOr646ToNumericLatch(m_current.getPosition())) { + m_current.incrementPosition(3); + m_current.setNumeric(); + } else if (isAlphaTo646ToAlphaLatch(m_current.getPosition())) { + if (m_current.getPosition() + 5 < m_information->getSize()) { + m_current.incrementPosition(5); + } else { + m_current.setPosition(m_information->getSize()); + } + + m_current.setIsoIec646(); + } + return new BlockParsedResult(false); +} + +bool GeneralAppIdDecoder::isStillIsoIec646(int pos) +{ + if (pos + 5 > m_information->getSize()) { + return false; + } + + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue >= 5 && fiveBitValue < 16) { + return true; + } + + if (pos + 7 > m_information->getSize()) { + return false; + } + + int sevenBitValue = extractNumericValueFromBitArray(pos, 7); + if (sevenBitValue >= 64 && sevenBitValue < 116) { + return true; + } + + if (pos + 8 > m_information->getSize()) { + return false; + } + + int eightBitValue = extractNumericValueFromBitArray(pos, 8); + return eightBitValue >= 232 && eightBitValue < 253; +} + +DecodedChar GeneralAppIdDecoder::decodeIsoIec646(int pos) +{ + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue == 15) { + return DecodedChar(pos + 5, DecodedChar::FNC1); + } + + if (fiveBitValue >= 5 && fiveBitValue < 15) { + return DecodedChar(pos + 5, static_cast('0' + fiveBitValue - 5)); + } + + int sevenBitValue = extractNumericValueFromBitArray(pos, 7); + + if (sevenBitValue >= 64 && sevenBitValue < 90) { + return DecodedChar(pos + 7, static_cast(sevenBitValue + 1)); + } + + if (sevenBitValue >= 90 && sevenBitValue < 116) { + return DecodedChar(pos + 7, static_cast(sevenBitValue + 7)); + } + + int eightBitValue = extractNumericValueFromBitArray(pos, 8); + char c; + switch (eightBitValue) { + case 232: + c = '!'; + break; + case 233: + c = '"'; + break; + case 234: + c = '%'; + break; + case 235: + c = '&'; + break; + case 236: + c = '\''; + break; + case 237: + c = '('; + break; + case 238: + c = ')'; + break; + case 239: + c = '*'; + break; + case 240: + c = '+'; + break; + case 241: + c = ','; + break; + case 242: + c = '-'; + break; + case 243: + c = '.'; + break; + case 244: + c = '/'; + break; + case 245: + c = ':'; + break; + case 246: + c = ';'; + break; + case 247: + c = '<'; + break; + case 248: + c = '='; + break; + case 249: + c = '>'; + break; + case 250: + c = '?'; + break; + case 251: + c = '_'; + break; + case 252: + c = ' '; + break; + default: + throw FormatException::getFormatInstance(); + } + return DecodedChar(pos + 8, c); +} + +bool GeneralAppIdDecoder::isStillAlpha(int pos) +{ + if (pos + 5 > m_information->getSize()) { + return false; + } + + // We now check if it's a valid 5-bit value (0..9 and FNC1) + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue >= 5 && fiveBitValue < 16) { + return true; + } + + if (pos + 6 > m_information->getSize()) { + return false; + } + + int sixBitValue = extractNumericValueFromBitArray(pos, 6); + return sixBitValue >= 16 && sixBitValue < 63; // 63 not included +} + +DecodedChar GeneralAppIdDecoder::decodeAlphanumeric(int pos) +{ + int fiveBitValue = extractNumericValueFromBitArray(pos, 5); + if (fiveBitValue == 15) { + return DecodedChar(pos + 5, DecodedChar::FNC1); + } + + if (fiveBitValue >= 5 && fiveBitValue < 15) { + return DecodedChar(pos + 5, static_cast('0' + fiveBitValue - 5)); + } + + int sixBitValue = extractNumericValueFromBitArray(pos, 6); + + if (sixBitValue >= 32 && sixBitValue < 58) { + return DecodedChar(pos + 6, static_cast(sixBitValue + 33)); + } + + char c; + switch (sixBitValue) { + case 58: + c = '*'; + break; + case 59: + c = ','; + break; + case 60: + c = '-'; + break; + case 61: + c = '.'; + break; + case 62: + c = '/'; + break; + default: + throw new IllegalStateException("Decoding invalid alphanumeric value: " + sixBitValue); + } + return DecodedChar(pos + 6, c); +} + +bool GeneralAppIdDecoder::isAlphaTo646ToAlphaLatch(int pos) +{ + if (pos + 1 > m_information->getSize()) { + return false; + } + + for (int i = 0; i < 5 && i + pos < m_information->getSize(); ++i) { + if (i == 2) { + if (!m_information->get(pos + 2)) { + return false; + } + } else if (m_information->get(pos + i)) { + return false; + } + } + + return true; +} + +bool GeneralAppIdDecoder::isAlphaOr646ToNumericLatch(int pos) +{ + // Next is alphanumeric if there are 3 positions and they are all zeros + if (pos + 3 > m_information->getSize()) { + return false; + } + + for (int i = pos; i < pos + 3; ++i) { + if (m_information->get(i)) { + return false; + } + } + return true; +} + +bool GeneralAppIdDecoder::isNumericToAlphaNumericLatch(int pos) { + // Next is alphanumeric if there are 4 positions and they are all zeros, or + // if there is a subset of this just before the end of the symbol + if (pos + 1 > m_information->getSize()) { + return false; + } + + for (int i = 0; i < 4 && i + pos < m_information->getSize(); ++i) { + if (m_information->get(pos + i)) { + return false; + } + } + return true; +} + +} +} +} diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h new file mode 100644 index 0000000..e197d15 --- /dev/null +++ b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.h @@ -0,0 +1,99 @@ +#ifndef GENERAL_APP_ID_DECODER_H +#define GENERAL_APP_ID_DECODER_H +/* + * Copyright (C) 2010 ZXing authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 2019-07-17 translation from Java into C++ + */ + +/* + * These authors would like to acknowledge the Spanish Ministry of Industry, + * Tourism and Trade, for the support in the project TSI020301-2008-2 + * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled + * Mobile Dynamic Environments", led by Treelogic + * ( http://www.treelogic.com/ ): + * + * http://www.piramidepse.com/ + */ + +#include +#include +#include +#include +#include "CurrentParsingState.h" +#include "DecodedInformation.h" +#include "DecodedNumeric.h" +#include "FieldParser.h" +#include "BlockParsedResult.h" +#include "DecodedChar.h" + +// VC++ +namespace zxing { + +namespace oned { + +namespace rss { + +class GeneralAppIdDecoder +{ + +public: + GeneralAppIdDecoder(Ref information); + + String decodeAllCodes(String &buff, int initialPosition); + + bool isStillNumeric(int pos) const; + + DecodedNumeric *decodeNumeric(int pos); + + int extractNumericValueFromBitArray(int pos, int bits); + + static int extractNumericValueFromBitArray(Ref information, int pos, int bits); + + DecodedInformation decodeGeneralPurposeField(int pos, String &remaining); + + DecodedInformation parseBlocks(); + + BlockParsedResult *parseNumericBlock(); + + BlockParsedResult *parseIsoIec646Block(); + + BlockParsedResult *parseAlphaBlock(); + + bool isStillIsoIec646(int pos); + + DecodedChar decodeIsoIec646(int pos); + + bool isStillAlpha(int pos); + + DecodedChar decodeAlphanumeric(int pos); + + bool isAlphaTo646ToAlphaLatch(int pos); + + bool isAlphaOr646ToNumericLatch(int pos); + + bool isNumericToAlphaNumericLatch(int pos); + +private: + Ref m_information; + CurrentParsingState m_current; + String m_buffer; + +}; +} +} +} + +#endif From 0cd99217df0dbfc52fe95127650d71fc440832c8 Mon Sep 17 00:00:00 2001 From: Eism Date: Wed, 17 Jul 2019 19:17:18 +0200 Subject: [PATCH 71/83] added missing methods --- src/zxing/zxing/common/Str.cpp | 4 ++-- src/zxing/zxing/common/Str.h | 2 +- src/zxing/zxing/common/detector/MathUtils.h | 9 +++++++++ src/zxing/zxing/oned/OneDReader.cpp | 20 ++++++++++++++++++++ src/zxing/zxing/oned/OneDReader.h | 4 ++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/zxing/zxing/common/Str.cpp b/src/zxing/zxing/common/Str.cpp index f48b6cd..232c25f 100644 --- a/src/zxing/zxing/common/Str.cpp +++ b/src/zxing/zxing/common/Str.cpp @@ -43,8 +43,8 @@ int String::size() const { return int(text_.size()); } int String::length() const { return int(text_.size()); } -Ref String::substring(int i) const { - return Ref(new String(text_.substr(i))); +Ref String::substring(int i, int j) const { + return Ref(new String(text_.substr(i, j))); } void String::append(const std::string &tail) { diff --git a/src/zxing/zxing/common/Str.h b/src/zxing/zxing/common/Str.h index 8e8c8b3..c37db22 100644 --- a/src/zxing/zxing/common/Str.h +++ b/src/zxing/zxing/common/Str.h @@ -37,7 +37,7 @@ public: explicit String(const std::string &text); explicit String(int); char charAt(int) const; - Ref substring(int) const; + Ref substring(int, int = -1) const; const std::string& getText() const; int size() const; void append(std::string const& tail); diff --git a/src/zxing/zxing/common/detector/MathUtils.h b/src/zxing/zxing/common/detector/MathUtils.h index 900e33c..30811b9 100644 --- a/src/zxing/zxing/common/detector/MathUtils.h +++ b/src/zxing/zxing/common/detector/MathUtils.h @@ -18,6 +18,7 @@ */ #include +#include namespace zxing { namespace common { @@ -48,6 +49,14 @@ class MathUtils { int yDiff = aY - bY; return sqrt(float(xDiff * xDiff + yDiff * yDiff)); } + + static inline int sum(std::vector array) { + int count = 0; + for (int a : array) { + count += a; + } + return count; + } }; } diff --git a/src/zxing/zxing/oned/OneDReader.cpp b/src/zxing/zxing/oned/OneDReader.cpp index e48600c..21070c2 100644 --- a/src/zxing/zxing/oned/OneDReader.cpp +++ b/src/zxing/zxing/oned/OneDReader.cpp @@ -221,4 +221,24 @@ void OneDReader::recordPattern(Ref row, } } +void OneDReader::recordPatternInReverse(Ref row, + int start, + vector& counters) +{ + // This could be more efficient I guess + int numTransitionsLeft = int(counters.size()); + bool last = row->get(start); + while (start > 0 && numTransitionsLeft >= 0) { + if (row->get(--start) != last) { + numTransitionsLeft--; + last = !last; + } + } + if (numTransitionsLeft >= 0) + { + throw NotFoundException(); + } + recordPattern(row, start + 1, counters); +} + OneDReader::~OneDReader() {} diff --git a/src/zxing/zxing/oned/OneDReader.h b/src/zxing/zxing/oned/OneDReader.h index dd67ce8..84efb63 100644 --- a/src/zxing/zxing/oned/OneDReader.h +++ b/src/zxing/zxing/oned/OneDReader.h @@ -72,6 +72,10 @@ public: static void recordPattern(Ref row, int start, std::vector& counters); + + static void recordPatternInReverse(Ref row, + int start, + std::vector& counters); virtual ~OneDReader(); }; From 10b4dbbb516af20233f9fddb980d45bf7541f402 Mon Sep 17 00:00:00 2001 From: Eism Date: Wed, 17 Jul 2019 19:19:15 +0200 Subject: [PATCH 72/83] connect rss to the recognition module --- src/zxing/zxing/oned/MultiFormatOneDReader.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp index 7b18345..495fb7d 100644 --- a/src/zxing/zxing/oned/MultiFormatOneDReader.cpp +++ b/src/zxing/zxing/oned/MultiFormatOneDReader.cpp @@ -23,12 +23,16 @@ #include #include #include +#include +#include #include #include using zxing::Ref; using zxing::Result; using zxing::oned::MultiFormatOneDReader; +using zxing::oned::rss::RSS14Reader; +using zxing::oned::rss::RSSExpandedReader; // VC++ using zxing::DecodeHints; @@ -56,16 +60,16 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { if (hints.containsFormat(BarcodeFormat::CODABAR)) { readers.push_back(Ref(new CodaBarReader())); } -/* + if (hints.containsFormat(BarcodeFormat::RSS_14)) { readers.push_back(Ref(new RSS14Reader())); } -*/ -/* + + if (hints.containsFormat(BarcodeFormat::RSS_EXPANDED)) { - readers.push_back(Ref(new RSS14ExpandedReader())); + readers.push_back(Ref(new RSSExpandedReader())); } -*/ + if (readers.size() == 0) { readers.push_back(Ref(new MultiFormatUPCEANReader(hints))); readers.push_back(Ref(new Code39Reader())); @@ -73,8 +77,8 @@ MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { readers.push_back(Ref(new Code93Reader())); readers.push_back(Ref(new Code128Reader())); readers.push_back(Ref(new ITFReader())); - // readers.push_back(Ref(new RSS14Reader())); - // readers.push_back(Ref(new RSS14ExpandedReader())); + readers.push_back(Ref(new RSS14Reader())); + readers.push_back(Ref(new RSSExpandedReader())); } } From dcb75f721060de6e70ce6c1710b4ef46283167e7 Mon Sep 17 00:00:00 2001 From: Eism Date: Thu, 18 Jul 2019 14:10:06 +0200 Subject: [PATCH 73/83] reultpoints fix --- src/zxing/zxing/oned/rss/FinderPattern.cpp | 2 +- src/zxing/zxing/oned/rss/RSS14Reader.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/zxing/zxing/oned/rss/FinderPattern.cpp b/src/zxing/zxing/oned/rss/FinderPattern.cpp index 13a3698..d78ae81 100644 --- a/src/zxing/zxing/oned/rss/FinderPattern.cpp +++ b/src/zxing/zxing/oned/rss/FinderPattern.cpp @@ -10,7 +10,7 @@ FinderPattern::FinderPattern(int value, std::vector startEnd, int start, in { ArrayRef< Ref > resultPoints(2); resultPoints[0] = Ref(new OneDResultPoint(start, rowNumber)); - resultPoints[0] = Ref(new OneDResultPoint(end, rowNumber)); + resultPoints[1] = Ref(new OneDResultPoint(end, rowNumber)); m_resultPoints = resultPoints; } diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.cpp b/src/zxing/zxing/oned/rss/RSS14Reader.cpp index cced013..b08f289 100644 --- a/src/zxing/zxing/oned/rss/RSS14Reader.cpp +++ b/src/zxing/zxing/oned/rss/RSS14Reader.cpp @@ -110,7 +110,12 @@ Ref RSS14Reader::constructResult(Pair leftPair, Pair rightPair) const ArrayRef< Ref > leftPoints = leftPair.getFinderPattern().getResultPoints(); ArrayRef< Ref > rightPoints = rightPair.getFinderPattern().getResultPoints(); - ArrayRef< Ref > resultPoints(5); + + ArrayRef< Ref > resultPoints(4); + resultPoints[0] = leftPoints[0]; + resultPoints[1] = leftPoints[1]; + resultPoints[2] = rightPoints[0]; + resultPoints[3] = rightPoints[1]; return Ref(new Result( Ref(new String(buffer)), From 702b45d4e2ae3d21bfe609f9b5268d9ae76fb700 Mon Sep 17 00:00:00 2001 From: Eism Date: Thu, 18 Jul 2019 14:54:30 +0200 Subject: [PATCH 74/83] VS compilation fix --- src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp index dd98ef4..f043b2b 100644 --- a/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp +++ b/src/zxing/zxing/oned/rss/expanded/decoders/FieldParser.cpp @@ -1,5 +1,7 @@ #include "FieldParser.h" +#include + namespace zxing { namespace oned { namespace rss { From fad963c854f183377e16bf52bba89f504b075c98 Mon Sep 17 00:00:00 2001 From: Eism Date: Thu, 18 Jul 2019 14:57:34 +0200 Subject: [PATCH 75/83] fixed some warnings --- src/zxing/zxing/oned/rss/RSS14Reader.cpp | 2 +- .../zxing/oned/rss/expanded/RSSExpandedReader.cpp | 12 ++++++------ .../rss/expanded/decoders/GeneralAppIdDecoder.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/zxing/zxing/oned/rss/RSS14Reader.cpp b/src/zxing/zxing/oned/rss/RSS14Reader.cpp index b08f289..14562c6 100644 --- a/src/zxing/zxing/oned/rss/RSS14Reader.cpp +++ b/src/zxing/zxing/oned/rss/RSS14Reader.cpp @@ -151,7 +151,7 @@ Pair RSS14Reader::decodePair(Ref row, bool right, int rowNumber, Decod outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), pattern); - } catch (NotFoundException ignored) { + } catch (NotFoundException const& /*e*/) { return Pair(); } } diff --git a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp index fe1acbd..5d190a2 100644 --- a/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp +++ b/src/zxing/zxing/oned/rss/expanded/RSSExpandedReader.cpp @@ -87,7 +87,7 @@ Ref RSSExpandedReader::decodeRow(int rowNumber, Ref row, Decod m_startFromEven = false; try { return constructResult(decodeRow2pairs(rowNumber, row)); - } catch (NotFoundException e) { + } catch (NotFoundException const& /*e*/) { // OK } @@ -108,7 +108,7 @@ std::vector RSSExpandedReader::decodeRow2pairs(int rowNumber, Ref< while (!done) { try { m_pairs.push_back(retrieveNextPair(row, m_pairs, rowNumber)); - } catch (NotFoundException nfe) { + } catch (NotFoundException const& nfe) { if (m_pairs.size() == 0) { throw nfe; } @@ -158,7 +158,7 @@ std::vector RSSExpandedReader::checkRows(bool reverse) std::vector ps; try { ps = checkRows({}, 0); - } catch (NotFoundException e) { + } catch (NotFoundException const& /*e*/) { // OK } @@ -194,7 +194,7 @@ std::vector RSSExpandedReader::checkRows(std::vector try { // Recursion: try to add more rows return checkRows(rs, static_cast(i + 1)); - } catch (NotFoundException e) { + } catch (NotFoundException const& /*e*/) { // We failed, try the next candidate } } @@ -417,7 +417,7 @@ ExpandedPair RSSExpandedReader::retrieveNextPair(Ref row, std::vector< DataCharacter rightChar; try { rightChar = decodeDataCharacter(row, pattern, isOddPattern, false); - } catch (NotFoundException ignored) { + } catch (NotFoundException const& /*e*/) { //rightChar = nullptr; } return ExpandedPair(leftChar, rightChar, pattern); @@ -535,7 +535,7 @@ FinderPattern RSSExpandedReader::parseFoundFinderPattern(Ref row, int int value; try { value = parseFinderValue(counters, FINDER_PATTERNS); - } catch (NotFoundException ignored) { + } catch (NotFoundException const& /*e*/) { return FinderPattern(); } return FinderPattern(value, {start, end}, start, end, rowNumber); diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp index e2d6750..a4cce47 100644 --- a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp +++ b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp @@ -394,7 +394,7 @@ DecodedChar GeneralAppIdDecoder::decodeAlphanumeric(int pos) c = '/'; break; default: - throw new IllegalStateException("Decoding invalid alphanumeric value: " + sixBitValue); + throw IllegalStateException("Decoding invalid alphanumeric value: " + sixBitValue); } return DecodedChar(pos + 6, c); } From 7132bc96eaaeeeea9fb4081712f73af504721dbe Mon Sep 17 00:00:00 2001 From: Eism Date: Thu, 18 Jul 2019 15:02:48 +0200 Subject: [PATCH 76/83] remove copy constructor --- .../zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp | 6 ------ .../zxing/oned/rss/expanded/decoders/BlockParsedResult.h | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp index a0be3eb..2d5fb9a 100644 --- a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp +++ b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.cpp @@ -16,12 +16,6 @@ BlockParsedResult::BlockParsedResult(const DecodedInformation &information, bool m_decodedInformation = information; } -BlockParsedResult::BlockParsedResult(const BlockParsedResult &other) -{ - m_finished = other.m_finished; - m_decodedInformation = other.m_decodedInformation; -} - DecodedInformation BlockParsedResult::getDecodedInformation() { return m_decodedInformation; diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h index 6e93ee9..446cbcc 100644 --- a/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h +++ b/src/zxing/zxing/oned/rss/expanded/decoders/BlockParsedResult.h @@ -46,8 +46,6 @@ public: BlockParsedResult(const DecodedInformation& information, bool finished); - BlockParsedResult(const BlockParsedResult& other); - DecodedInformation getDecodedInformation(); bool isFinished(); From b213f9fab3b676a2b94c422587a429e6a75f552f Mon Sep 17 00:00:00 2001 From: Nikos Ftylitakis Date: Wed, 24 Jul 2019 07:34:58 +0300 Subject: [PATCH 77/83] Added support to ABGR32 introduced at Qt 5.13. Should fix #122 --- src/QZXingFilter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index f32aa77..e349681 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -246,6 +246,9 @@ void QZXingFilterRunnable::processVideoFrameProbed(SimpleVideoFrame & videoFrame image_ptr = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0, true); break; case QVideoFrame::Format_BGR32: +#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)) + case QVideoFrame::Format_ABGR32: +#endif image_ptr = rgbDataToGrayscale(data, captureRect, 3, 2, 1, 0); break; case QVideoFrame::Format_BGR24: From 5d9668b23ba401d0a3ba612b2de698a9bd73d719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Barbosa?= Date: Mon, 5 Aug 2019 13:58:34 +0100 Subject: [PATCH 78/83] Fix optional format in image provider --- src/QZXingImageProvider.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/QZXingImageProvider.cpp b/src/QZXingImageProvider.cpp index 30aab6d..7c4f42e 100644 --- a/src/QZXingImageProvider.cpp +++ b/src/QZXingImageProvider.cpp @@ -38,14 +38,15 @@ QImage QZXingImageProvider::requestImage(const QString &id, QSize *size, const Q // it could not recognize the first key-value pair provided QUrlQuery optionQuery("options?dummy=&" + id.mid(customSettingsIndex + 1)); - QString correctionLevelString = optionQuery.queryItemValue("corretionLevel"); - QString formatString = optionQuery.queryItemValue("format"); - if(formatString != "qrcode") - { - qWarning() << "Format not supported: " << formatString; - return QImage(); + if (optionQuery.hasQueryItem("format")) { + QString formatString = optionQuery.queryItemValue("format"); + if (formatString != "qrcode") { + qWarning() << "Format not supported: " << formatString; + return QImage(); + } } + QString correctionLevelString = optionQuery.queryItemValue("corretionLevel"); if(correctionLevelString == "H") correctionLevel = QZXing::EncodeErrorCorrectionLevel_H; else if(correctionLevelString == "Q") From 129caae5df2d4d698d9ecfb1bf2205e8a4a2b9a2 Mon Sep 17 00:00:00 2001 From: Stefano Di Martino Date: Thu, 8 Aug 2019 22:23:53 +0200 Subject: [PATCH 79/83] Fixing compiler warning: "Counted has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit" This fixed especially a memory leak with a certain gcc version compiled in release mode (no problems in debug mode and with older gcc versions). This could potentially fix #88 and #61. --- src/zxing/zxing/common/Counted.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/zxing/zxing/common/Counted.cpp diff --git a/src/zxing/zxing/common/Counted.cpp b/src/zxing/zxing/common/Counted.cpp new file mode 100644 index 0000000..e69de29 From 52626c6125ef5739c2977ecf0ac715c4449d1d96 Mon Sep 17 00:00:00 2001 From: Stefano Di Martino Date: Thu, 8 Aug 2019 22:26:48 +0200 Subject: [PATCH 80/83] This fixes the compiler warning: "'Counted' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit" This fixes especially memory leaks which we had with a certain gcc version in release mode. This fixes potential #61 and #88 --- src/QZXing.pri | 1 + src/zxing/zxing/common/Counted.cpp | 31 ++++++++++++++++++++++++++++++ src/zxing/zxing/common/Counted.h | 22 ++++++--------------- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/QZXing.pri b/src/QZXing.pri index 0d80c0d..08ac77e 100644 --- a/src/QZXing.pri +++ b/src/QZXing.pri @@ -209,6 +209,7 @@ SOURCES += $$PWD/CameraImageWrapper.cpp \ $$PWD/zxing/zxing/WriterException.cpp \ $$PWD/zxing/zxing/aztec/AztecReader.cpp \ $$PWD/zxing/zxing/aztec/AztecDetectorResult.cpp \ + $$PWD/zxing/zxing/common/Counted.cpp \ $$PWD/zxing/zxing/common/StringUtils.cpp \ $$PWD/zxing/zxing/common/Str.cpp \ $$PWD/zxing/zxing/common/PerspectiveTransform.cpp \ diff --git a/src/zxing/zxing/common/Counted.cpp b/src/zxing/zxing/common/Counted.cpp index e69de29..c0f5de0 100644 --- a/src/zxing/zxing/common/Counted.cpp +++ b/src/zxing/zxing/common/Counted.cpp @@ -0,0 +1,31 @@ +#include "Counted.h" + +namespace zxing { + +Counted::~Counted() +{ +} + +Counted *Counted::retain() +{ + count_++; + return this; +} + +void Counted::release() +{ + count_--; + if (count_ == 0) { + count_ = 0xDEADF001; + delete this; + } +} + +int Counted::count() const +{ + return count_; +} + + + +} diff --git a/src/zxing/zxing/common/Counted.h b/src/zxing/zxing/common/Counted.h index a52607c..2ccd7f7 100644 --- a/src/zxing/zxing/common/Counted.h +++ b/src/zxing/zxing/common/Counted.h @@ -30,25 +30,15 @@ public: Counted() : count_(0) { } - virtual ~Counted() { - } - Counted *retain() { - count_++; - return this; - } - void release() { - count_--; - if (count_ == 0) { - count_ = 0xDEADF001; - delete this; - } - } + virtual ~Counted(); + + Counted *retain(); + + void release(); /* return the current count for denugging purposes or similar */ - int count() const { - return count_; - } + int count() const; }; /* counting reference to reference-counted objects */ From 65085a7bb150226a03679f8d9404bf464e291daf Mon Sep 17 00:00:00 2001 From: Stefano Di Martino Date: Fri, 9 Aug 2019 07:55:45 +0200 Subject: [PATCH 81/83] Move constructor implemenation to cpp --- src/zxing/zxing/common/Counted.cpp | 5 +++++ src/zxing/zxing/common/Counted.h | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/zxing/zxing/common/Counted.cpp b/src/zxing/zxing/common/Counted.cpp index c0f5de0..a80807f 100644 --- a/src/zxing/zxing/common/Counted.cpp +++ b/src/zxing/zxing/common/Counted.cpp @@ -2,6 +2,11 @@ namespace zxing { +Counted::Counted() : + count_(0) +{ +} + Counted::~Counted() { } diff --git a/src/zxing/zxing/common/Counted.h b/src/zxing/zxing/common/Counted.h index 2ccd7f7..bcf4b17 100644 --- a/src/zxing/zxing/common/Counted.h +++ b/src/zxing/zxing/common/Counted.h @@ -27,9 +27,7 @@ class Counted { private: unsigned int count_; public: - Counted() : - count_(0) { - } + Counted(); virtual ~Counted(); From bbde505d8c992cfe25356c59a215614d85f0ac05 Mon Sep 17 00:00:00 2001 From: Stevyn Pompelio Date: Tue, 13 Aug 2019 12:50:31 -0400 Subject: [PATCH 82/83] fixed an issue preventing QR codes from being scanned --- src/QZXingFilter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QZXingFilter.cpp b/src/QZXingFilter.cpp index e349681..b025cab 100644 --- a/src/QZXingFilter.cpp +++ b/src/QZXingFilter.cpp @@ -19,9 +19,9 @@ namespace { const int D = int(U) - 128; const int E = int(V) - 128; return gray( - qBound(0, uchar((298 * C + 409 * E + 128) >> 8), 255), - qBound(0, uchar((298 * C - 100 * D - 208 * E + 128) >> 8), 255), - qBound(0, uchar((298 * C + 516 * D + 128) >> 8), 255) + qBound(0, ((298 * C + 409 * E + 128) >> 8), 255), + qBound(0, ((298 * C - 100 * D - 208 * E + 128) >> 8), 255), + qBound(0, ((298 * C + 516 * D + 128) >> 8), 255) ); } From 7b2e69421cadda4fc0d3e77a4d178d0cb0889b35 Mon Sep 17 00:00:00 2001 From: Eism Date: Tue, 3 Sep 2019 14:32:09 +0200 Subject: [PATCH 83/83] fix bug --- src/zxing/zxing/oned/rss/DataCharacter.cpp | 2 +- .../zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zxing/zxing/oned/rss/DataCharacter.cpp b/src/zxing/zxing/oned/rss/DataCharacter.cpp index 008e88c..9539854 100644 --- a/src/zxing/zxing/oned/rss/DataCharacter.cpp +++ b/src/zxing/zxing/oned/rss/DataCharacter.cpp @@ -28,7 +28,7 @@ int DataCharacter::getChecksumPortion() const String DataCharacter::toString() const { - return String(m_value + '(' + m_checksumPortion + ')'); + return String(std::to_string(m_value) + '(' + std::to_string(m_checksumPortion) + ')'); } bool DataCharacter::equals(const DataCharacter &other) const diff --git a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp index a4cce47..1fc326b 100644 --- a/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp +++ b/src/zxing/zxing/oned/rss/expanded/decoders/GeneralAppIdDecoder.cpp @@ -22,7 +22,7 @@ String GeneralAppIdDecoder::decodeAllCodes(String &buff, int initialPosition) buff.append(parsedFields.getText()); } if (info.isRemaining()) { - remaining = String(info.getRemainingValue()); + remaining = String(std::to_string(info.getRemainingValue())); } else { remaining = String(""); }