Changed C++ QrCode class to eliminate const from fields, updated related code.
This commit is contained in:
parent
70a181753a
commit
a138e6fbc3
|
@ -164,6 +164,21 @@ QrCode::QrCode(const QrCode &qr, int mask) :
|
|||
}
|
||||
|
||||
|
||||
int QrCode::getVersion() const {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
int QrCode::getSize() const {
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
QrCode::Ecc QrCode::getErrorCorrectionLevel() const {
|
||||
return errorCorrectionLevel;
|
||||
}
|
||||
|
||||
|
||||
int QrCode::getMask() const {
|
||||
return mask;
|
||||
}
|
||||
|
|
|
@ -99,17 +99,17 @@ class QrCode final {
|
|||
|
||||
/*---- Instance fields ----*/
|
||||
|
||||
// Public immutable scalar parameters
|
||||
// Immutable scalar parameters
|
||||
|
||||
/* This QR Code symbol's version number, which is always between 1 and 40 (inclusive). */
|
||||
public: const int version;
|
||||
private: int version;
|
||||
|
||||
/* The width and height of this QR Code symbol, measured in modules.
|
||||
* Always equal to version × 4 + 17, in the range 21 to 177. */
|
||||
public: const int size;
|
||||
private: int size;
|
||||
|
||||
/* The error correction level used in this QR Code symbol. */
|
||||
public: const Ecc &errorCorrectionLevel;
|
||||
private: Ecc errorCorrectionLevel;
|
||||
|
||||
/* The mask pattern used in this QR Code symbol, in the range 0 to 7 (i.e. unsigned 3-bit integer).
|
||||
* Note that even if a constructor was called with automatic masking requested
|
||||
|
@ -143,6 +143,15 @@ class QrCode final {
|
|||
|
||||
/*---- Public instance methods ----*/
|
||||
|
||||
public: int getVersion() const;
|
||||
|
||||
|
||||
public: int getSize() const;
|
||||
|
||||
|
||||
public: Ecc getErrorCorrectionLevel() const;
|
||||
|
||||
|
||||
public: int getMask() const;
|
||||
|
||||
|
||||
|
|
|
@ -166,8 +166,8 @@ static void doSegmentDemo() {
|
|||
// Prints the given QR Code to the console.
|
||||
static void printQr(const QrCode &qr) {
|
||||
int border = 4;
|
||||
for (int y = -border; y < qr.size + border; y++) {
|
||||
for (int x = -border; x < qr.size + border; x++) {
|
||||
for (int y = -border; y < qr.getSize() + border; y++) {
|
||||
for (int x = -border; x < qr.getSize() + border; x++) {
|
||||
std::cout << (qr.getModule(x, y) ? "##" : " ");
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
|
|
@ -85,9 +85,9 @@ int main() {
|
|||
const QrCode qr = QrCode::encodeSegments(segs,
|
||||
*ECC_LEVELS[errCorLvl], minVersion, maxVersion, mask, boostEcl == 1);
|
||||
// Print grid of modules
|
||||
std::cout << qr.version << std::endl;
|
||||
for (int y = 0; y < qr.size; y++) {
|
||||
for (int x = 0; x < qr.size; x++)
|
||||
std::cout << qr.getVersion() << std::endl;
|
||||
for (int y = 0; y < qr.getSize(); y++) {
|
||||
for (int x = 0; x < qr.getSize(); x++)
|
||||
std::cout << (qr.getModule(x, y) ? 1 : 0) << std::endl;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue