zxing_cpp 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.rdoc +6 -0
- data/Gemfile +3 -0
- data/Manifest.txt +331 -0
- data/README.rdoc +138 -0
- data/Rakefile +28 -0
- data/bin/zxd +87 -0
- data/bin/zxe +53 -0
- data/ext/zxing/extconf.rb +27 -0
- data/ext/zxing/zxing-cpp/.gitignore +4 -0
- data/ext/zxing/zxing-cpp/AUTHORS +115 -0
- data/ext/zxing/zxing-cpp/CMakeLists.txt +84 -0
- data/ext/zxing/zxing-cpp/COPYING +201 -0
- data/ext/zxing/zxing-cpp/NOTICE +65 -0
- data/ext/zxing/zxing-cpp/README.md +50 -0
- data/ext/zxing/zxing-cpp/cli/src/ImageReaderSource.cpp +112 -0
- data/ext/zxing/zxing-cpp/cli/src/ImageReaderSource.h +40 -0
- data/ext/zxing/zxing-cpp/cli/src/jpgd.cpp +3174 -0
- data/ext/zxing/zxing-cpp/cli/src/jpgd.h +319 -0
- data/ext/zxing/zxing-cpp/cli/src/lodepng.cpp +6261 -0
- data/ext/zxing/zxing-cpp/cli/src/lodepng.h +1695 -0
- data/ext/zxing/zxing-cpp/cli/src/main.cpp +297 -0
- data/ext/zxing/zxing-cpp/cmake/FindCPPUNIT.cmake +54 -0
- data/ext/zxing/zxing-cpp/cmake/FindIconv.cmake +57 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/.gitignore +6 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigInteger.cc +405 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigInteger.hh +215 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerAlgorithms.cc +70 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerAlgorithms.hh +25 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerLibrary.hh +8 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerUtils.cc +50 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigIntegerUtils.hh +72 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsigned.cc +697 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsigned.hh +418 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsignedInABase.cc +125 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/BigUnsignedInABase.hh +122 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/ChangeLog +146 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/Makefile +73 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/NumberlikeArray.hh +177 -0
- data/ext/zxing/zxing-cpp/core/src/bigint/README +71 -0
- data/ext/zxing/zxing-cpp/core/src/win32/zxing/iconv.h +14 -0
- data/ext/zxing/zxing-cpp/core/src/win32/zxing/stdint.h +247 -0
- data/ext/zxing/zxing-cpp/core/src/win32/zxing/win_iconv.c +2035 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BarcodeFormat.cpp +40 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BarcodeFormat.h +60 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Binarizer.cpp +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Binarizer.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BinaryBitmap.cpp +70 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/BinaryBitmap.h +56 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ChecksumException.cpp +28 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ChecksumException.h +34 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/DecodeHints.cpp +142 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/DecodeHints.h +85 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Exception.cpp +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Exception.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/FormatException.cpp +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/FormatException.h +37 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/IllegalStateException.h +35 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/InvertedLuminanceSource.cpp +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/InvertedLuminanceSource.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/LuminanceSource.cpp +86 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/LuminanceSource.h +59 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/MultiFormatReader.cpp +124 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/MultiFormatReader.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/NotFoundException.h +35 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Reader.cpp +31 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Reader.h +40 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ReaderException.h +37 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Result.cpp +61 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/Result.h +55 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultIO.cpp +34 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPoint.cpp +108 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPoint.h +55 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPointCallback.cpp +26 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ResultPointCallback.h +39 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/ZXing.h +133 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecDetectorResult.cpp +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecDetectorResult.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecReader.cpp +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/AztecReader.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/decoder/Decoder.cpp +489 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/decoder/Decoder.h +69 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/detector/Detector.cpp +548 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/aztec/detector/Detector.h +92 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Array.h +170 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitArray.cpp +155 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitArray.h +81 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitArrayIO.cpp +31 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitMatrix.cpp +143 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitMatrix.h +91 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitSource.cpp +76 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/BitSource.h +74 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/CharacterSetECI.cpp +104 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/CharacterSetECI.h +53 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Counted.h +140 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DecoderResult.cpp +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DecoderResult.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DetectorResult.cpp +39 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/DetectorResult.h +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GlobalHistogramBinarizer.cpp +212 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GlobalHistogramBinarizer.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleLuminanceSource.cpp +80 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleLuminanceSource.h +53 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleRotatedLuminanceSource.cpp +81 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GreyscaleRotatedLuminanceSource.h +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GridSampler.cpp +122 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/GridSampler.h +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/HybridBinarizer.cpp +226 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/HybridBinarizer.h +67 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/IllegalArgumentException.cpp +27 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/IllegalArgumentException.h +36 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/PerspectiveTransform.cpp +107 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/PerspectiveTransform.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Point.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Str.cpp +61 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/Str.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/StringUtils.cpp +198 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/StringUtils.h +52 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/JavaMath.h +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MathUtils.h +57 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MonochromeRectangleDetector.cpp +174 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/MonochromeRectangleDetector.h +62 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp +330 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/detector/WhiteRectangleDetector.h +59 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGF.cpp +150 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGF.h +73 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.cpp +218 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/GenericGFPoly.h +56 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.cpp +174 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonDecoder.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonException.cpp +30 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/common/reedsolomon/ReedSolomonException.h +33 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/DataMatrixReader.h +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/Version.cpp +199 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/Version.h +87 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.cpp +361 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.h +59 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DataBlock.cpp +113 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DataBlock.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DecodedBitStreamParser.cpp +416 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/DecodedBitStreamParser.h +104 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/Decoder.cpp +93 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/decoder/Decoder.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/CornerPoint.cpp +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/CornerPoint.h +43 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/Detector.cpp +446 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/Detector.h +94 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/DetectorException.cpp +23 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/datamatrix/detector/DetectorException.h +23 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/ByQuadrantReader.cpp +75 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/ByQuadrantReader.h +42 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/GenericMultipleBarcodeReader.cpp +137 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/GenericMultipleBarcodeReader.h +51 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/MultipleBarcodeReader.cpp +29 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/MultipleBarcodeReader.h +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/QRCodeMultiReader.cpp +58 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/QRCodeMultiReader.h +36 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiDetector.cpp +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiDetector.h +37 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +236 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/CodaBarReader.cpp +340 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/CodaBarReader.h +57 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code128Reader.cpp +496 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code128Reader.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code39Reader.cpp +328 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code39Reader.h +63 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code93Reader.cpp +293 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/Code93Reader.h +58 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN13Reader.cpp +85 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN13Reader.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN8Reader.cpp +65 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/EAN8Reader.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/ITFReader.cpp +337 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/ITFReader.h +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp +96 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatOneDReader.h +38 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp +110 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/MultiFormatUPCEANReader.h +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDReader.cpp +227 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDReader.h +81 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDResultPoint.cpp +28 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/OneDResultPoint.h +35 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCAReader.cpp +71 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCAReader.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEANReader.cpp +309 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEANReader.h +88 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEReader.cpp +146 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/oned/UPCEReader.h +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/PDF417Reader.cpp +170 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/PDF417Reader.h +49 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/BitMatrixParser.cpp +997 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/BitMatrixParser.h +84 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/DecodedBitStreamParser.cpp +563 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/DecodedBitStreamParser.h +84 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/Decoder.cpp +118 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/Decoder.h +62 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ErrorCorrection.cpp +214 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ErrorCorrection.h +71 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusGF.cpp +120 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusGF.h +72 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusPoly.cpp +284 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/decoder/ec/ModulusPoly.h +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/Detector.cpp +664 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/Detector.h +106 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/LinesSampler.cpp +714 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/pdf417/detector/LinesSampler.h +122 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.cpp +65 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.h +52 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/FormatInformation.cpp +117 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/FormatInformation.h +54 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/QRCodeReader.cpp +52 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/QRCodeReader.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/Version.cpp +560 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/Version.h +85 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp +183 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.h +56 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataBlock.cpp +118 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataBlock.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataMask.cpp +159 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DataMask.h +50 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp +425 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.h +72 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Decoder.cpp +107 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Decoder.h +46 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Mode.cpp +90 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/decoder/Mode.h +57 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPattern.cpp +47 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPattern.h +45 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.cpp +208 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h +68 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/Detector.cpp +314 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/Detector.h +69 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPattern.cpp +69 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPattern.h +48 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.cpp +559 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternFinder.h +76 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternInfo.cpp +41 -0
- data/ext/zxing/zxing-cpp/core/src/zxing/qrcode/detector/FinderPatternInfo.h +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/TestRunner.cpp +30 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitArrayTest.cpp +216 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitArrayTest.h +61 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitMatrixTest.cpp +106 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitMatrixTest.h +55 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitSourceTest.cpp +49 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/BitSourceTest.h +42 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/CountedTest.cpp +58 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/CountedTest.h +46 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/PerspectiveTransformTest.cpp +69 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/PerspectiveTransformTest.h +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.cpp +129 -0
- data/ext/zxing/zxing-cpp/core/tests/src/common/reedsolomon/ReedSolomonTest.h +62 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/ErrorCorrectionLevelTest.cpp +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/ErrorCorrectionLevelTest.h +45 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/FormatInformationTest.cpp +88 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/FormatInformationTest.h +47 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/VersionTest.cpp +88 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/VersionTest.h +49 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/DataMaskTest.cpp +132 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/DataMaskTest.h +91 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/ModeTest.cpp +52 -0
- data/ext/zxing/zxing-cpp/core/tests/src/qrcode/decoder/ModeTest.h +47 -0
- data/ext/zxing/zxing.cc +224 -0
- data/lib/zxing.rb +50 -0
- data/lib/zxing/.gitignore +2 -0
- data/lib/zxing/aztec.rb +5 -0
- data/lib/zxing/aztec/aztec_reader.rb +14 -0
- data/lib/zxing/bad_image_exception.rb +4 -0
- data/lib/zxing/binarizer.rb +8 -0
- data/lib/zxing/binary_bitmap.rb +15 -0
- data/lib/zxing/checksum_exception.rb +4 -0
- data/lib/zxing/common.rb +7 -0
- data/lib/zxing/common/bit_matrix.rb +9 -0
- data/lib/zxing/common/hybrid_binarizer.rb +17 -0
- data/lib/zxing/common/illegal_argument_exception.rb +4 -0
- data/lib/zxing/datamatrix.rb +5 -0
- data/lib/zxing/datamatrix/data_matrix_reader.rb +14 -0
- data/lib/zxing/decodable.rb +11 -0
- data/lib/zxing/exception.rb +4 -0
- data/lib/zxing/ffi.rb +20 -0
- data/lib/zxing/ffi/aztec.rb +6 -0
- data/lib/zxing/ffi/aztec/aztec_reader.rb +9 -0
- data/lib/zxing/ffi/binarizer.rb +25 -0
- data/lib/zxing/ffi/binary_bitmap.rb +15 -0
- data/lib/zxing/ffi/common.rb +8 -0
- data/lib/zxing/ffi/common/bit_matrix.rb +12 -0
- data/lib/zxing/ffi/common/greyscale_luminance_source.rb +30 -0
- data/lib/zxing/ffi/common/hybrid_binarizer.rb +10 -0
- data/lib/zxing/ffi/datamatrix.rb +6 -0
- data/lib/zxing/ffi/datamatrix/data_matrix_reader.rb +9 -0
- data/lib/zxing/ffi/library.rb +102 -0
- data/lib/zxing/ffi/luminance_source.rb +18 -0
- data/lib/zxing/ffi/multi_format_reader.rb +9 -0
- data/lib/zxing/ffi/oned.rb +6 -0
- data/lib/zxing/ffi/oned/code_39_reader.rb +10 -0
- data/lib/zxing/ffi/qrcode.rb +8 -0
- data/lib/zxing/ffi/qrcode/decoder.rb +10 -0
- data/lib/zxing/ffi/qrcode/detector.rb +10 -0
- data/lib/zxing/ffi/reader.rb +58 -0
- data/lib/zxing/ffi/result.rb +23 -0
- data/lib/zxing/format_exception.rb +4 -0
- data/lib/zxing/illegal_argument_exception.rb +4 -0
- data/lib/zxing/image.rb +15 -0
- data/lib/zxing/luminance_source.rb +18 -0
- data/lib/zxing/multi_format_reader.rb +11 -0
- data/lib/zxing/not_found_exception.rb +4 -0
- data/lib/zxing/oned.rb +5 -0
- data/lib/zxing/oned/code_39_reader.rb +15 -0
- data/lib/zxing/qrcode.rb +8 -0
- data/lib/zxing/qrcode/decoder.rb +14 -0
- data/lib/zxing/qrcode/detector.rb +14 -0
- data/lib/zxing/qrcode/encoder.rb +8 -0
- data/lib/zxing/qrcode/encoder/byte_matrix.rb +18 -0
- data/lib/zxing/qrcode/encoder/encoder.rb +9 -0
- data/lib/zxing/qrcode/encoder/qrcode.rb +18 -0
- data/lib/zxing/reader.rb +8 -0
- data/lib/zxing/reader_exception.rb +4 -0
- data/lib/zxing/reed_solomon_exception.rb +2 -0
- data/lib/zxing/result.rb +18 -0
- data/lib/zxing/rmagick.rb +5 -0
- data/lib/zxing/rmagick/image.rb +104 -0
- data/lib/zxing/version.rb +33 -0
- data/test/qrcode.png +0 -0
- data/test/test_helper.rb +5 -0
- data/test/test_zxing.rb +58 -0
- data/test/vendor.rb +360 -0
- data/test/zxing/test_decodable.rb +38 -0
- data/zxing_cpp.gemspec +48 -0
- metadata +473 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
#ifndef BIGUNSIGNEDINABASE_H
|
2
|
+
#define BIGUNSIGNEDINABASE_H
|
3
|
+
|
4
|
+
#include "NumberlikeArray.hh"
|
5
|
+
#include "BigUnsigned.hh"
|
6
|
+
#include <string>
|
7
|
+
|
8
|
+
/*
|
9
|
+
* A BigUnsignedInABase object represents a nonnegative integer of size limited
|
10
|
+
* only by available memory, represented in a user-specified base that can fit
|
11
|
+
* in an `unsigned short' (most can, and this saves memory).
|
12
|
+
*
|
13
|
+
* BigUnsignedInABase is intended as an intermediary class with little
|
14
|
+
* functionality of its own. BigUnsignedInABase objects can be constructed
|
15
|
+
* from, and converted to, BigUnsigneds (requiring multiplication, mods, etc.)
|
16
|
+
* and `std::string's (by switching digit values for appropriate characters).
|
17
|
+
*
|
18
|
+
* BigUnsignedInABase is similar to BigUnsigned. Note the following:
|
19
|
+
*
|
20
|
+
* (1) They represent the number in exactly the same way, except that
|
21
|
+
* BigUnsignedInABase uses ``digits'' (or Digit) where BigUnsigned uses
|
22
|
+
* ``blocks'' (or Blk).
|
23
|
+
*
|
24
|
+
* (2) Both use the management features of NumberlikeArray. (In fact, my desire
|
25
|
+
* to add a BigUnsignedInABase class without duplicating a lot of code led me to
|
26
|
+
* introduce NumberlikeArray.)
|
27
|
+
*
|
28
|
+
* (3) The only arithmetic operation supported by BigUnsignedInABase is an
|
29
|
+
* equality test. Use BigUnsigned for arithmetic.
|
30
|
+
*/
|
31
|
+
|
32
|
+
class BigUnsignedInABase : protected NumberlikeArray<unsigned short> {
|
33
|
+
|
34
|
+
public:
|
35
|
+
// The digits of a BigUnsignedInABase are unsigned shorts.
|
36
|
+
typedef unsigned short Digit;
|
37
|
+
// That's also the type of a base.
|
38
|
+
typedef Digit Base;
|
39
|
+
|
40
|
+
protected:
|
41
|
+
// The base in which this BigUnsignedInABase is expressed
|
42
|
+
Base base;
|
43
|
+
|
44
|
+
// Creates a BigUnsignedInABase with a capacity; for internal use.
|
45
|
+
BigUnsignedInABase(int, Index c) : NumberlikeArray<Digit>(0, c) {}
|
46
|
+
|
47
|
+
// Decreases len to eliminate any leading zero digits.
|
48
|
+
void zapLeadingZeros() {
|
49
|
+
while (len > 0 && blk[len - 1] == 0)
|
50
|
+
len--;
|
51
|
+
}
|
52
|
+
|
53
|
+
public:
|
54
|
+
// Constructs zero in base 2.
|
55
|
+
BigUnsignedInABase() : NumberlikeArray<Digit>(), base(2) {}
|
56
|
+
|
57
|
+
// Copy constructor
|
58
|
+
BigUnsignedInABase(const BigUnsignedInABase &x) : NumberlikeArray<Digit>(x), base(x.base) {}
|
59
|
+
|
60
|
+
// Assignment operator
|
61
|
+
void operator =(const BigUnsignedInABase &x) {
|
62
|
+
NumberlikeArray<Digit>::operator =(x);
|
63
|
+
base = x.base;
|
64
|
+
}
|
65
|
+
|
66
|
+
// Constructor that copies from a given array of digits.
|
67
|
+
BigUnsignedInABase(const Digit *d, Index l, Base base);
|
68
|
+
|
69
|
+
// Destructor. NumberlikeArray does the delete for us.
|
70
|
+
~BigUnsignedInABase() {}
|
71
|
+
|
72
|
+
// LINKS TO BIGUNSIGNED
|
73
|
+
BigUnsignedInABase(const BigUnsigned &x, Base base);
|
74
|
+
operator BigUnsigned() const;
|
75
|
+
|
76
|
+
/* LINKS TO STRINGS
|
77
|
+
*
|
78
|
+
* These use the symbols ``0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'' to
|
79
|
+
* represent digits of 0 through 35. When parsing strings, lowercase is
|
80
|
+
* also accepted.
|
81
|
+
*
|
82
|
+
* All string representations are big-endian (big-place-value digits
|
83
|
+
* first). (Computer scientists have adopted zero-based counting; why
|
84
|
+
* can't they tolerate little-endian numbers?)
|
85
|
+
*
|
86
|
+
* No string representation has a ``base indicator'' like ``0x''.
|
87
|
+
*
|
88
|
+
* An exception is made for zero: it is converted to ``0'' and not the
|
89
|
+
* empty string.
|
90
|
+
*
|
91
|
+
* If you want different conventions, write your own routines to go
|
92
|
+
* between BigUnsignedInABase and strings. It's not hard.
|
93
|
+
*/
|
94
|
+
operator std::string() const;
|
95
|
+
BigUnsignedInABase(const std::string &s, Base base);
|
96
|
+
|
97
|
+
public:
|
98
|
+
|
99
|
+
// ACCESSORS
|
100
|
+
Base getBase() const { return base; }
|
101
|
+
|
102
|
+
// Expose these from NumberlikeArray directly.
|
103
|
+
using NumberlikeArray<Digit>::getCapacity;
|
104
|
+
using NumberlikeArray<Digit>::getLength;
|
105
|
+
|
106
|
+
/* Returns the requested digit, or 0 if it is beyond the length (as if
|
107
|
+
* the number had 0s infinitely to the left). */
|
108
|
+
Digit getDigit(Index i) const { return i >= len ? 0 : blk[i]; }
|
109
|
+
|
110
|
+
// The number is zero if and only if the canonical length is zero.
|
111
|
+
bool isZero() const { return NumberlikeArray<Digit>::isEmpty(); }
|
112
|
+
|
113
|
+
/* Equality test. For the purposes of this test, two BigUnsignedInABase
|
114
|
+
* values must have the same base to be equal. */
|
115
|
+
bool operator ==(const BigUnsignedInABase &x) const {
|
116
|
+
return base == x.base && NumberlikeArray<Digit>::operator ==(x);
|
117
|
+
}
|
118
|
+
bool operator !=(const BigUnsignedInABase &x) const { return !operator ==(x); }
|
119
|
+
|
120
|
+
};
|
121
|
+
|
122
|
+
#endif
|
@@ -0,0 +1,146 @@
|
|
1
|
+
Change Log
|
2
|
+
|
3
|
+
These entries tell you what was added, fixed, or improved in each version as
|
4
|
+
compared to the previous one. In case you haven't noticed, a version number
|
5
|
+
roughly corresponds to the release date of that version in `YYYY.MM.DD[.N]'
|
6
|
+
format, where `.N' goes `.2', `.3', etc. if there are multiple versions on the
|
7
|
+
same day. The topmost version listed is the one you have.
|
8
|
+
|
9
|
+
2010.04.30
|
10
|
+
----------
|
11
|
+
- Strengthen the advice about build/IDE configuration in the README.
|
12
|
+
|
13
|
+
2009.05.03
|
14
|
+
----------
|
15
|
+
- BigUnsigned::{get,set}Bit: Change two remaining `1 <<' to `Blk(1) <<' to work
|
16
|
+
on systems where sizeof(unsigned int) != sizeof(Blk). Bug reported by Brad
|
17
|
+
Spencer.
|
18
|
+
- dataToBigInteger: Change a `delete' to `delete []' to avoid leaking memory.
|
19
|
+
Bug reported by Nicolás Carrasco.
|
20
|
+
|
21
|
+
2009.03.26
|
22
|
+
----------
|
23
|
+
- BigUnsignedInABase(std::string) Reject digits too big for the base.
|
24
|
+
Bug reported by Niakam Kazemi.
|
25
|
+
|
26
|
+
2008.07.20
|
27
|
+
----------
|
28
|
+
Dennis Yew pointed out serious problems with ambiguities and unwanted
|
29
|
+
conversions when mixing BigInteger/BigUnsigned and primitive integers. To fix
|
30
|
+
these, I removed the implicit conversions from BigInteger/BigUnsigned to
|
31
|
+
primitive integers and from BigInteger to BigUnsigned. Removing the
|
32
|
+
BigInteger-to-BigUnsigned conversion required changing BigInteger to have a
|
33
|
+
BigUnsigned field instead of inheriting from it; this was a complex task but
|
34
|
+
ultimately gave a saner design. At the same time, I went through the entire
|
35
|
+
codebase, making the formatting and comments prettier and reworking anything I
|
36
|
+
thought was unclear. I also added a testsuite (currently for 32-bit systems
|
37
|
+
only); it doesn't yet cover the entire library but should help to ensure that
|
38
|
+
things work the way they should.
|
39
|
+
|
40
|
+
A number of changes from version 2007.07.07 break compatibility with existing
|
41
|
+
code that uses the library, but updating that code should be pretty easy:
|
42
|
+
- BigInteger can no longer be implicitly converted to BigUnsigned. Use
|
43
|
+
getMagnitude() instead.
|
44
|
+
- BigUnsigned and BigInteger can no longer be implicitly converted to primitive
|
45
|
+
integers. Use the toInt() family of functions instead.
|
46
|
+
- The easy* functions have been renamed to more mature names:
|
47
|
+
bigUnsignedToString, bigIntegerToString, stringToBigUnsigned,
|
48
|
+
stringToBigInteger, dataToBigInteger.
|
49
|
+
- BigInteger no longer supports bitwise operations. Get the magnitude with
|
50
|
+
getMagnitude() and operate on that instead.
|
51
|
+
- The old {BigUnsigned,BigInteger}::{divide,modulo} copy-less options have been
|
52
|
+
removed. Use divideWithRemainder instead.
|
53
|
+
- Added a base argument to BigUnsignedInABase's digit-array constructor. I
|
54
|
+
ope no one used that constructor in its broken state anyway.
|
55
|
+
|
56
|
+
Other notable changes:
|
57
|
+
- Added BigUnsigned functions setBlock, bitLength, getBit, setBit.
|
58
|
+
- The bit-shifting operations now support negative shift amounts, which shift in
|
59
|
+
the other direction.
|
60
|
+
- Added some big-integer algorithms in BigIntegerAlgorithms.hh: gcd,
|
61
|
+
extendedEuclidean, modinv, modexp.
|
62
|
+
|
63
|
+
2007.07.07
|
64
|
+
----------
|
65
|
+
Update the "Running the sample program produces this output:" comment in
|
66
|
+
sample.cc for the bitwise operators.
|
67
|
+
|
68
|
+
2007.06.14
|
69
|
+
----------
|
70
|
+
- Implement << and >> for BigUnsigned in response to email from Marco Schulze.
|
71
|
+
- Fix name: DOTR_ALIASED -> DTRT_ALIASED.
|
72
|
+
- Demonstrate all bitwise operators (&, |, ^, <<, >>) in sample.cc.
|
73
|
+
|
74
|
+
2007.02.16
|
75
|
+
----------
|
76
|
+
Boris Dessy pointed out that the library threw an exception on "a *= a", so I changed all the put-here operations to handle aliased calls correctly using a temporary copy instead of throwing exceptions.
|
77
|
+
|
78
|
+
2006.08.14
|
79
|
+
----------
|
80
|
+
In BigUnsigned::bitXor, change allocate(b2->len) to allocate(a2->len): we should allocate enough space for the longer number, not the shorter one! Thanks to Sriram Sankararaman for pointing this out.
|
81
|
+
|
82
|
+
2006.05.03
|
83
|
+
----------
|
84
|
+
I ran the sample program using valgrind and discovered a `delete s' that should be `delete [] s' and a `len++' before an `allocateAndCopy(len)' that should have been after an `allocateAndCopy(len + 1)'. I fixed both. Yay for valgrind!
|
85
|
+
|
86
|
+
2006.05.01
|
87
|
+
----------
|
88
|
+
I fixed incorrect results reported by Mohand Mezmaz and related memory corruption on platforms where Blk is bigger than int. I replaced (1 << x) with (Blk(1) << x) in two places in BigUnsigned.cc.
|
89
|
+
|
90
|
+
2006.04.24
|
91
|
+
----------
|
92
|
+
Two bug fixes: BigUnsigned "++x" no longer segfaults when x grows in length, and BigUnsigned == and != are now redeclared so as to be usable. I redid the Makefile: I removed the *.tag mechanism and hard-coded the library's header dependencies, I added comments, and I made the Makefile more useful for building one's own programs instead of just the sample.
|
93
|
+
|
94
|
+
2006.02.26
|
95
|
+
----------
|
96
|
+
A few tweaks in preparation for a group to distribute the library. The project Web site has moved; I updated the references. I fixed a typo and added a missing function in NumberlikeArray.hh. I'm using Eclipse now, so you get Eclipse project files.
|
97
|
+
|
98
|
+
2005.03.30
|
99
|
+
----------
|
100
|
+
Sam Larkin found a bug in `BigInteger::subtract'; I fixed it.
|
101
|
+
|
102
|
+
2005.01.18
|
103
|
+
----------
|
104
|
+
I fixed some problems with `easyDataToBI'. Due to some multiply declared variables, this function would not compile. However, it is a template function, so the compiler parses it and doesn't compile the parsed representation until something uses the function; this is how I missed the problems. I also removed debugging output from this function.
|
105
|
+
|
106
|
+
2005.01.17
|
107
|
+
----------
|
108
|
+
A fix to some out-of-bounds accesses reported by Milan Tomic (see the comment under `BigUnsigned::divideWithRemainder'). `BigUnsigned::multiply' and `BigUnsigned::divideWithRemainder' implementations neatened up a bit with the help of a function `getShiftedBlock'. I (finally!) introduced a constant `BigUnsigned::N', the number of bits in a `BigUnsigned::Blk', which varies depending on machine word size. In both code and comments, it replaces the much clunkier `8*sizeof(Blk)'. Numerous other small changes. There's a new conversion routine `easyDataToBI' that will convert almost any format of binary data to a `BigInteger'.
|
109
|
+
|
110
|
+
I have inserted a significant number of new comments. Most explain unobvious aspects of the code.
|
111
|
+
|
112
|
+
2005.01.06
|
113
|
+
----------
|
114
|
+
Some changes to the way zero-length arrays are handled by `NumberlikeArray', which fixed a memory leak reported by Milan Tomic.
|
115
|
+
|
116
|
+
2004.12.24.2
|
117
|
+
------------
|
118
|
+
I tied down a couple of loose ends involving division/modulo. I added an explanation of put-here vs. overloaded operators in the sample program; this has confused too many people. Miscellaneous other improvements.
|
119
|
+
|
120
|
+
I believe that, at this point, the Big Integer Library makes no assumptions about the word size of the machine it is using. `BigUnsigned::Blk' is always an `unsigned long', whatever that may be, and its size is computed with `sizeof' when necessary. However, just in case, I would be interested to have someone test the library on a non-32-bit machine to see if it works.
|
121
|
+
|
122
|
+
2004.12.24
|
123
|
+
----------
|
124
|
+
This is a _major_ upgrade to the library. Among the things that have changed:
|
125
|
+
|
126
|
+
I wrote the original version of the library, particularly the four ``classical algorithms'' in `BigUnsigned.cc', using array indexing. Then I rewrote it to use pointers because I thought that would be faster. But recently, I revisited the code in `BigUnsigned.cc' and found that I could not begin to understand what it was doing.
|
127
|
+
|
128
|
+
I have decided that the drawbacks of pointers, increased coding difficulty and reduced code readability, far outweigh their speed benefits. Plus, any modern optimizing compiler should produce fast code either way. Therefore, I rewrote the library to use array indexing again. (Thank goodness for regular-expression find-and-replace. It saved me a lot of time.)
|
129
|
+
|
130
|
+
The put-here operations `divide' and `modulo' of each of `BigUnsigned' and `BigInteger' have been supplanted by a single operation `divideWithRemainder'. Read the profuse comments for more information on its exact behavior.
|
131
|
+
|
132
|
+
There is a new class `BigUnsignedInABase' that is like `BigUnsigned' but uses a user-specified, small base instead of `256 ^ sizeof(unsigned long)'. Much of the code common to the two has been factored out into `NumberlikeArray'.
|
133
|
+
|
134
|
+
`BigUnsignedInABase' facilitates conversion between `BigUnsigned's and digit-by-digit string representations using `std::string'. Convenience routines to do this conversion are in `BigIntegerUtils.hh'. `iostream' compatibility has been improved.
|
135
|
+
|
136
|
+
I would like to thank Chris Morbitzer for the e-mail message that catalyzed this major upgrade. He wanted a way to convert a string to a BigInteger. One thing just led to another, roughly in reverse order from how they are listed here.
|
137
|
+
|
138
|
+
2004.1216
|
139
|
+
---------
|
140
|
+
Brad Spencer pointed out a memory leak in `BigUnsigned::divide'. It is fixed in the December 16, 2004 version.
|
141
|
+
|
142
|
+
2004.1205
|
143
|
+
---------
|
144
|
+
After months of inactivity, I fixed a bug in the `BigInteger' division routine; thanks to David Allen for reporting the bug. I also added simple routines for decimal output to `std::ostream's, and there is a demo that prints out powers of 3.
|
145
|
+
|
146
|
+
~~~~
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Mention default target.
|
2
|
+
all:
|
3
|
+
|
4
|
+
# Implicit rule to compile C++ files. Modify to your taste.
|
5
|
+
%.o: %.cc
|
6
|
+
g++ -c -O2 -Wall -Wextra -pedantic $<
|
7
|
+
|
8
|
+
# Components of the library.
|
9
|
+
library-objects = \
|
10
|
+
BigUnsigned.o \
|
11
|
+
BigInteger.o \
|
12
|
+
BigIntegerAlgorithms.o \
|
13
|
+
BigUnsignedInABase.o \
|
14
|
+
BigIntegerUtils.o \
|
15
|
+
|
16
|
+
library-headers = \
|
17
|
+
NumberlikeArray.hh \
|
18
|
+
BigUnsigned.hh \
|
19
|
+
BigInteger.hh \
|
20
|
+
BigIntegerAlgorithms.hh \
|
21
|
+
BigUnsignedInABase.hh \
|
22
|
+
BigIntegerLibrary.hh \
|
23
|
+
|
24
|
+
# To ``make the library'', make all its objects using the implicit rule.
|
25
|
+
library: $(library-objects)
|
26
|
+
|
27
|
+
# Conservatively assume that all the objects depend on all the headers.
|
28
|
+
$(library-objects): $(library-headers)
|
29
|
+
|
30
|
+
# TESTSUITE (NOTE: Currently expects a 32-bit system)
|
31
|
+
# Compiling the testsuite.
|
32
|
+
testsuite.o: $(library-headers)
|
33
|
+
testsuite: testsuite.o $(library-objects)
|
34
|
+
g++ $^ -o $@
|
35
|
+
# Extract the expected output from the testsuite source.
|
36
|
+
testsuite.expected: testsuite.cc
|
37
|
+
nl -ba -p -s: $< | sed -nre 's,^ +([0-9]+):.*//([^ ]),Line \1: \2,p' >$@
|
38
|
+
# Run the testsuite.
|
39
|
+
.PHONY: test
|
40
|
+
test: testsuite testsuite.expected
|
41
|
+
./run-testsuite
|
42
|
+
testsuite-cleanfiles = \
|
43
|
+
testsuite.o testsuite testsuite.expected \
|
44
|
+
testsuite.out testsuite.err
|
45
|
+
|
46
|
+
# The rules below build a program that uses the library. They are preset to
|
47
|
+
# build ``sample'' from ``sample.cc''. You can change the name(s) of the
|
48
|
+
# source file(s) and program file to build your own program, or you can write
|
49
|
+
# your own Makefile.
|
50
|
+
|
51
|
+
# Components of the program.
|
52
|
+
program = sample
|
53
|
+
program-objects = sample.o
|
54
|
+
|
55
|
+
# Conservatively assume all the program source files depend on all the library
|
56
|
+
# headers. You can change this if it is not the case.
|
57
|
+
$(program-objects) : $(library-headers)
|
58
|
+
|
59
|
+
# How to link the program. The implicit rule covers individual objects.
|
60
|
+
$(program) : $(program-objects) $(library-objects)
|
61
|
+
g++ $^ -o $@
|
62
|
+
|
63
|
+
# Delete all generated files we know about.
|
64
|
+
clean :
|
65
|
+
rm -f $(library-objects) $(testsuite-cleanfiles) $(program-objects) $(program)
|
66
|
+
|
67
|
+
# I removed the *.tag dependency tracking system because it had few advantages
|
68
|
+
# over manually entering all the dependencies. If there were a portable,
|
69
|
+
# reliable dependency tracking system, I'd use it, but I know of no such;
|
70
|
+
# cons and depcomp are almost good enough.
|
71
|
+
|
72
|
+
# Come back and define default target.
|
73
|
+
all : library $(program)
|
@@ -0,0 +1,177 @@
|
|
1
|
+
#ifndef NUMBERLIKEARRAY_H
|
2
|
+
#define NUMBERLIKEARRAY_H
|
3
|
+
|
4
|
+
// Make sure we have NULL.
|
5
|
+
#ifndef NULL
|
6
|
+
#define NULL 0
|
7
|
+
#endif
|
8
|
+
|
9
|
+
/* A NumberlikeArray<Blk> object holds a heap-allocated array of Blk with a
|
10
|
+
* length and a capacity and provides basic memory management features.
|
11
|
+
* BigUnsigned and BigUnsignedInABase both subclass it.
|
12
|
+
*
|
13
|
+
* NumberlikeArray provides no information hiding. Subclasses should use
|
14
|
+
* nonpublic inheritance and manually expose members as desired using
|
15
|
+
* declarations like this:
|
16
|
+
*
|
17
|
+
* public:
|
18
|
+
* NumberlikeArray< the-type-argument >::getLength;
|
19
|
+
*/
|
20
|
+
template <class Blk>
|
21
|
+
class NumberlikeArray {
|
22
|
+
public:
|
23
|
+
|
24
|
+
// Type for the index of a block in the array
|
25
|
+
typedef unsigned int Index;
|
26
|
+
// The number of bits in a block, defined below.
|
27
|
+
static const unsigned int N;
|
28
|
+
|
29
|
+
// The current allocated capacity of this NumberlikeArray (in blocks)
|
30
|
+
Index cap;
|
31
|
+
// The actual length of the value stored in this NumberlikeArray (in blocks)
|
32
|
+
Index len;
|
33
|
+
// Heap-allocated array of the blocks (can be NULL if len == 0)
|
34
|
+
Blk *blk;
|
35
|
+
|
36
|
+
// Constructs a ``zero'' NumberlikeArray with the given capacity.
|
37
|
+
NumberlikeArray(Index c) : cap(c), len(0) {
|
38
|
+
blk = (cap > 0) ? (new Blk[cap]) : NULL;
|
39
|
+
}
|
40
|
+
|
41
|
+
/* Constructs a zero NumberlikeArray without allocating a backing array.
|
42
|
+
* A subclass that doesn't know the needed capacity at initialization
|
43
|
+
* time can use this constructor and then overwrite blk without first
|
44
|
+
* deleting it. */
|
45
|
+
NumberlikeArray() : cap(0), len(0) {
|
46
|
+
blk = NULL;
|
47
|
+
}
|
48
|
+
|
49
|
+
// Destructor. Note that `delete NULL' is a no-op.
|
50
|
+
~NumberlikeArray() {
|
51
|
+
delete [] blk;
|
52
|
+
}
|
53
|
+
|
54
|
+
/* Ensures that the array has at least the requested capacity; may
|
55
|
+
* destroy the contents. */
|
56
|
+
void allocate(Index c);
|
57
|
+
|
58
|
+
/* Ensures that the array has at least the requested capacity; does not
|
59
|
+
* destroy the contents. */
|
60
|
+
void allocateAndCopy(Index c);
|
61
|
+
|
62
|
+
// Copy constructor
|
63
|
+
NumberlikeArray(const NumberlikeArray<Blk> &x);
|
64
|
+
|
65
|
+
// Assignment operator
|
66
|
+
void operator=(const NumberlikeArray<Blk> &x);
|
67
|
+
|
68
|
+
// Constructor that copies from a given array of blocks
|
69
|
+
NumberlikeArray(const Blk *b, Index blen);
|
70
|
+
|
71
|
+
// ACCESSORS
|
72
|
+
Index getCapacity() const { return cap; }
|
73
|
+
Index getLength() const { return len; }
|
74
|
+
Blk getBlock(Index i) const { return blk[i]; }
|
75
|
+
bool isEmpty() const { return len == 0; }
|
76
|
+
|
77
|
+
/* Equality comparison: checks if both objects have the same length and
|
78
|
+
* equal (==) array elements to that length. Subclasses may wish to
|
79
|
+
* override. */
|
80
|
+
bool operator ==(const NumberlikeArray<Blk> &x) const;
|
81
|
+
|
82
|
+
bool operator !=(const NumberlikeArray<Blk> &x) const {
|
83
|
+
return !operator ==(x);
|
84
|
+
}
|
85
|
+
};
|
86
|
+
|
87
|
+
/* BEGIN TEMPLATE DEFINITIONS. They are present here so that source files that
|
88
|
+
* include this header file can generate the necessary real definitions. */
|
89
|
+
|
90
|
+
template <class Blk>
|
91
|
+
const unsigned int NumberlikeArray<Blk>::N = 8 * sizeof(Blk);
|
92
|
+
|
93
|
+
template <class Blk>
|
94
|
+
void NumberlikeArray<Blk>::allocate(Index c) {
|
95
|
+
// If the requested capacity is more than the current capacity...
|
96
|
+
if (c > cap) {
|
97
|
+
// Delete the old number array
|
98
|
+
delete [] blk;
|
99
|
+
// Allocate the new array
|
100
|
+
cap = c;
|
101
|
+
blk = new Blk[cap];
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
template <class Blk>
|
106
|
+
void NumberlikeArray<Blk>::allocateAndCopy(Index c) {
|
107
|
+
// If the requested capacity is more than the current capacity...
|
108
|
+
if (c > cap) {
|
109
|
+
Blk *oldBlk = blk;
|
110
|
+
// Allocate the new number array
|
111
|
+
cap = c;
|
112
|
+
blk = new Blk[cap];
|
113
|
+
// Copy number blocks
|
114
|
+
Index i;
|
115
|
+
for (i = 0; i < len; i++)
|
116
|
+
blk[i] = oldBlk[i];
|
117
|
+
// Delete the old array
|
118
|
+
delete [] oldBlk;
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
template <class Blk>
|
123
|
+
NumberlikeArray<Blk>::NumberlikeArray(const NumberlikeArray<Blk> &x)
|
124
|
+
: len(x.len) {
|
125
|
+
// Create array
|
126
|
+
cap = len;
|
127
|
+
blk = new Blk[cap];
|
128
|
+
// Copy blocks
|
129
|
+
Index i;
|
130
|
+
for (i = 0; i < len; i++)
|
131
|
+
blk[i] = x.blk[i];
|
132
|
+
}
|
133
|
+
|
134
|
+
template <class Blk>
|
135
|
+
void NumberlikeArray<Blk>::operator=(const NumberlikeArray<Blk> &x) {
|
136
|
+
/* Calls like a = a have no effect; catch them before the aliasing
|
137
|
+
* causes a problem */
|
138
|
+
if (this == &x)
|
139
|
+
return;
|
140
|
+
// Copy length
|
141
|
+
len = x.len;
|
142
|
+
// Expand array if necessary
|
143
|
+
allocate(len);
|
144
|
+
// Copy number blocks
|
145
|
+
Index i;
|
146
|
+
for (i = 0; i < len; i++)
|
147
|
+
blk[i] = x.blk[i];
|
148
|
+
}
|
149
|
+
|
150
|
+
template <class Blk>
|
151
|
+
NumberlikeArray<Blk>::NumberlikeArray(const Blk *b, Index blen)
|
152
|
+
: cap(blen), len(blen) {
|
153
|
+
// Create array
|
154
|
+
blk = new Blk[cap];
|
155
|
+
// Copy blocks
|
156
|
+
Index i;
|
157
|
+
for (i = 0; i < len; i++)
|
158
|
+
blk[i] = b[i];
|
159
|
+
}
|
160
|
+
|
161
|
+
template <class Blk>
|
162
|
+
bool NumberlikeArray<Blk>::operator ==(const NumberlikeArray<Blk> &x) const {
|
163
|
+
if (len != x.len)
|
164
|
+
// Definitely unequal.
|
165
|
+
return false;
|
166
|
+
else {
|
167
|
+
// Compare corresponding blocks one by one.
|
168
|
+
Index i;
|
169
|
+
for (i = 0; i < len; i++)
|
170
|
+
if (blk[i] != x.blk[i])
|
171
|
+
return false;
|
172
|
+
// No blocks differed, so the objects are equal.
|
173
|
+
return true;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
#endif
|