In QR Mode, keep the 'bits' value and supported equal operator.

This commit is contained in:
favoritas37 2015-06-18 23:55:03 +03:00
parent 4ccc725f0b
commit c711a42231
2 changed files with 18 additions and 3 deletions

View File

@ -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);
};
}
}

View File

@ -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_ );
}