From 015c243fb2e0fd8dad46a403c12926a7592d0c59 Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Mon, 26 Feb 2018 19:56:44 +0000 Subject: [PATCH] Tweaked C++ worker program to be more robust to bad inputs. --- cpp/QrCodeGeneratorWorker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/QrCodeGeneratorWorker.cpp b/cpp/QrCodeGeneratorWorker.cpp index d93cba1..d00b03c 100644 --- a/cpp/QrCodeGeneratorWorker.cpp +++ b/cpp/QrCodeGeneratorWorker.cpp @@ -37,7 +37,7 @@ using qrcodegen::QrCode; using qrcodegen::QrSegment; -static const QrCode::Ecc ECC_LEVELS[] = { +static const std::vector ECC_LEVELS{ QrCode::Ecc::LOW, QrCode::Ecc::MEDIUM, QrCode::Ecc::QUARTILE, @@ -83,7 +83,7 @@ int main() { try { // Try to make QR Code symbol const QrCode qr = QrCode::encodeSegments(segs, - ECC_LEVELS[errCorLvl], minVersion, maxVersion, mask, boostEcl == 1); + ECC_LEVELS.at(errCorLvl), minVersion, maxVersion, mask, boostEcl == 1); // Print grid of modules std::cout << qr.getVersion() << std::endl; for (int y = 0; y < qr.getSize(); y++) {