From c711a42231edc742e0e6030eebb5ac44e38d315c Mon Sep 17 00:00:00 2001 From: favoritas37 Date: Thu, 18 Jun 2015 23:55:03 +0300 Subject: [PATCH] In QR Mode, keep the 'bits' value and supported equal operator. --- source/zxing/zxing/qrcode/decoder/Mode.h | 4 ++++ source/zxing/zxing/qrcode/decoder/QRMode.cpp | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/source/zxing/zxing/qrcode/decoder/Mode.h b/source/zxing/zxing/qrcode/decoder/Mode.h index 8a36d2a..4d1b365 100644 --- a/source/zxing/zxing/qrcode/decoder/Mode.h +++ b/source/zxing/zxing/qrcode/decoder/Mode.h @@ -33,6 +33,7 @@ private: int characterCountBitsForVersions10To26_; int characterCountBitsForVersions27AndHigher_; std::string name_; + int bits_; Mode(int cbv0_9, int cbv10_26, int cbv27, int bits, char const* name); @@ -52,6 +53,9 @@ public: static Mode& forBits(int bits); int getCharacterCountBits(Version *version); + int getBits() { return bits_; } + + bool operator==(const Mode& other); }; } } diff --git a/source/zxing/zxing/qrcode/decoder/QRMode.cpp b/source/zxing/zxing/qrcode/decoder/QRMode.cpp index 6fe70d0..0e223db 100644 --- a/source/zxing/zxing/qrcode/decoder/QRMode.cpp +++ b/source/zxing/zxing/qrcode/decoder/QRMode.cpp @@ -43,9 +43,10 @@ Mode Mode::FNC1_FIRST_POSITION(0, 0, 0, 0x05, "FNC1_FIRST_POSITION"); Mode Mode::FNC1_SECOND_POSITION(0, 0, 0, 0x09, "FNC1_SECOND_POSITION"); Mode Mode::HANZI(8, 10, 12, 0x0D, "HANZI"); -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, char const* name) : characterCountBitsForVersions0To9_(cbv0_9), characterCountBitsForVersions10To26_(cbv10_26), - characterCountBitsForVersions27AndHigher_(cbv27), name_(name) { + characterCountBitsForVersions27AndHigher_(cbv27), bits_(bits), name_(name) +{ } Mode::Mode(const zxing::qrcode::Mode &mode) @@ -86,7 +87,8 @@ Mode& Mode::forBits(int bits) { } } -int Mode::getCharacterCountBits(Version *version) { +int Mode::getCharacterCountBits(Version *version) +{ int number = version->getVersionNumber(); if (number <= 9) { return characterCountBitsForVersions0To9_; @@ -96,3 +98,12 @@ int Mode::getCharacterCountBits(Version *version) { return characterCountBitsForVersions27AndHigher_; } } + +bool Mode::operator==(const Mode& other) +{ + return ( characterCountBitsForVersions0To9_ == other.characterCountBitsForVersions0To9_ + && characterCountBitsForVersions10To26_ == other.characterCountBitsForVersions10To26_ + && characterCountBitsForVersions27AndHigher_ == other.characterCountBitsForVersions27AndHigher_ + && name_ == other.name_ + && bits_ == other.bits_ ); +}