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

pull/16/head
Project Nayuki 7 years ago
parent 514d23a19e
commit e0e905e3d1

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

@ -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 { int QrSegment::Mode::numCharCountBits(int ver) const {
if ( 1 <= ver && ver <= 9) return numBitsCharCount[0]; if ( 1 <= ver && ver <= 9) return numBitsCharCount[0];
else if (10 <= ver && ver <= 26) return numBitsCharCount[1]; else if (10 <= ver && ver <= 26) return numBitsCharCount[1];

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

Loading…
Cancel
Save