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

pull/16/head
Project Nayuki 7 years ago
parent 71a69dd3d9
commit 70a181753a

@ -100,9 +100,9 @@ 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.getModeBits(), 4);
bb.appendBits(seg.numChars, seg.mode.numCharCountBits(version));
bb.insert(bb.end(), seg.data.begin(), seg.data.end());
bb.appendBits(seg.getMode().getModeBits(), 4);
bb.appendBits(seg.getNumChars(), seg.getMode().numCharCountBits(version));
bb.insert(bb.end(), seg.getData().begin(), seg.getData().end());
}
// Add terminator and pad up to a byte if applicable

@ -208,6 +208,21 @@ bool QrSegment::isNumeric(const char *text) {
}
QrSegment::Mode QrSegment::getMode() const {
return mode;
}
int QrSegment::getNumChars() const {
return numChars;
}
const std::vector<bool> &QrSegment::getData() const {
return data;
}
const char *QrSegment::ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
}

@ -138,13 +138,13 @@ class QrSegment final {
/*---- Instance fields ----*/
/* The mode indicator for this segment. */
public: const Mode mode;
private: Mode mode;
/* The length of this segment's unencoded data, measured in characters. Always zero or positive. */
public: const int numChars;
private: int numChars;
/* The data bits of this segment. */
public: const std::vector<bool> data;
private: std::vector<bool> data;
/*---- Constructor ----*/
@ -161,6 +161,17 @@ class QrSegment final {
public: QrSegment(const Mode &md, int numCh, std::vector<bool> &&dt);
/*---- Methods ----*/
public: Mode getMode() const;
public: int getNumChars() const;
public: const std::vector<bool> &getData() const;
// Package-private helper function.
public: static int getTotalBits(const std::vector<QrSegment> &segs, int version);

Loading…
Cancel
Save