Changed C++ QrSegment::Ecc class to eliminate const from fields, updated related code.

This commit is contained in:
Project Nayuki 2017-09-06 03:37:43 +00:00
parent 514d23a19e
commit e0e905e3d1
3 changed files with 13 additions and 4 deletions

View File

@ -90,7 +90,7 @@ QrCode QrCode::encodeSegments(const vector<QrSegment> &segs, const Ecc &ecl,
size_t dataCapacityBits = getNumDataCodewords(version, *newEcl) * 8;
BitBuffer bb;
for (const QrSegment &seg : segs) {
bb.appendBits(seg.mode.modeBits, 4);
bb.appendBits(seg.mode.getModeBits(), 4);
bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version));
bb.insert(bb.end(), seg.data.begin(), seg.data.end());
}

View File

@ -40,6 +40,11 @@ QrSegment::Mode::Mode(int mode, int cc0, int cc1, int cc2) :
}
int QrSegment::Mode::getModeBits() const {
return modeBits;
}
int QrSegment::Mode::numCharCountBits(int ver) const {
if ( 1 <= ver && ver <= 9) return numBitsCharCount[0];
else if (10 <= ver && ver <= 26) return numBitsCharCount[1];

View File

@ -58,8 +58,7 @@ class QrSegment final {
/*-- Fields --*/
/* (Package-private) An unsigned 4-bit integer value (range 0 to 15) representing the mode indicator bits for this mode object. */
public: const int modeBits;
private: int modeBits;
private: int numBitsCharCount[3];
@ -69,7 +68,12 @@ class QrSegment final {
private: Mode(int mode, int cc0, int cc1, int cc2);
/*-- Method --*/
/*-- Methods --*/
/*
* (Package-private) Returns the mode indicator bits, which is an unsigned 4-bit value (range 0 to 15).
*/
public: int getModeBits() const;
/*
* (Package-private) Returns the bit width of the segment character count field for this mode object at the given version number.