diff --git a/source/zxing/zxing/qrcode/QRVersion.cpp b/source/zxing/zxing/qrcode/QRVersion.cpp index 6f8f5f0..8cc6ffd 100644 --- a/source/zxing/zxing/qrcode/QRVersion.cpp +++ b/source/zxing/zxing/qrcode/QRVersion.cpp @@ -43,17 +43,23 @@ int ECB::getDataCodewords() { return dataCodewords_; } -ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks) : - ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks) { +ECBlocks::ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks) : + ecCodewordsPerBloc_(ecCodewordsPerBloc), ecBlocks_(1, ecBlocks) { } -ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2) : - ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks1) { +ECBlocks::ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks1, ECB *ecBlocks2) : + ecCodewordsPerBloc_(ecCodewordsPerBloc), ecBlocks_(1, ecBlocks1) { ecBlocks_.push_back(ecBlocks2); } -int ECBlocks::getECCodewords() { - return ecCodewords_; +int ECBlocks::getECCodewordsPerBloc() +{ + return ecCodewordsPerBloc_; +} + +int ECBlocks::getTotalECCodewords() +{ + return ecBlocks_.size(); } std::vector& ECBlocks::getECBlocks() { @@ -91,11 +97,11 @@ int Version::getDimensionForVersion() { return 17 + 4 * versionNumber_; } -ECBlocks& Version::getECBlocksForLevel(ErrorCorrectionLevel &ecLevel) { +ECBlocks& Version::getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) const { return *ecBlocks_[ecLevel.ordinal()]; } -Version *Version::getProvisionalVersionForDimension(int dimension) { +Ref Version::getProvisionalVersionForDimension(int dimension) { if (dimension % 4 != 1) { throw FormatException(); } @@ -107,7 +113,7 @@ Version *Version::getProvisionalVersionForDimension(int dimension) { } } -Version *Version::getVersionForNumber(int versionNumber) { +Ref Version::getVersionForNumber(int versionNumber) { if (versionNumber < 1 || versionNumber > N_VERSIONS) { throw ReaderException("versionNumber must be between 1 and 40"); } @@ -124,7 +130,7 @@ Version::Version(int versionNumber, vector *alignmentPatternCenters, ECBloc ecBlocks_[3] = ecBlocks4; int total = 0; - int ecCodewords = ecBlocks1->getECCodewords(); + int ecCodewords = ecBlocks1->getECCodewordsPerBloc(); vector &ecbArray = ecBlocks1->getECBlocks(); for (size_t i = 0; i < ecbArray.size(); i++) { ECB *ecBlock = ecbArray[i]; @@ -140,7 +146,7 @@ Version::~Version() { } } -Version *Version::decodeVersionInformation(unsigned int versionBits) { +Ref Version::decodeVersionInformation(unsigned int versionBits) { int bestDifference = numeric_limits::max(); size_t bestVersion = 0; for (int i = 0; i < N_VERSION_DECODE_INFOS; i++) { @@ -163,7 +169,7 @@ Version *Version::decodeVersionInformation(unsigned int versionBits) { return getVersionForNumber(bestVersion); } // If we didn't find a close enough match, fail - return 0; + return Ref(NULL); } Ref Version::buildFunctionPattern() { diff --git a/source/zxing/zxing/qrcode/Version.h b/source/zxing/zxing/qrcode/Version.h index 5923e48..0af4416 100644 --- a/source/zxing/zxing/qrcode/Version.h +++ b/source/zxing/zxing/qrcode/Version.h @@ -42,12 +42,13 @@ public: class ECBlocks { private: - int ecCodewords_; + int ecCodewordsPerBloc_; std::vector ecBlocks_; public: - ECBlocks(int ecCodewords, ECB *ecBlocks); - ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2); - int getECCodewords(); + ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks); + ECBlocks(int ecCodewordsPerBloc, ECB *ecBlocks1, ECB *ecBlocks2); + int getECCodewordsPerBloc(); + int getTotalECCodewords(); std::vector& getECBlocks(); ~ECBlocks(); }; @@ -72,10 +73,10 @@ public: std::vector &getAlignmentPatternCenters(); int getTotalCodewords(); int getDimensionForVersion(); - ECBlocks &getECBlocksForLevel(ErrorCorrectionLevel &ecLevel); - static Version *getProvisionalVersionForDimension(int dimension); - static Version *getVersionForNumber(int versionNumber); - static Version *decodeVersionInformation(unsigned int versionBits); + ECBlocks &getECBlocksForLevel(const ErrorCorrectionLevel &ecLevel) const; + static Ref getProvisionalVersionForDimension(int dimension); + static Ref getVersionForNumber(int versionNumber); + static Ref decodeVersionInformation(unsigned int versionBits); Ref buildFunctionPattern(); static int buildVersions(); };