Simplified C++ code with vector range constructor.
This commit is contained in:
parent
fca2a8a27c
commit
6f9116dfcb
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -124,9 +125,7 @@ static void doSegmentDemo() {
|
|||
QrCode::Ecc::LOW);
|
||||
printQr(qr2);
|
||||
|
||||
std::vector<uint8_t> bytes;
|
||||
for (const char *temp = golden0; *temp != '\0'; temp++)
|
||||
bytes.push_back(static_cast<uint8_t>(*temp));
|
||||
std::vector<uint8_t> bytes(golden0, golden0 + std::strlen(golden0));
|
||||
const QrCode qr3 = QrCode::encodeSegments(
|
||||
{QrSegment::makeBytes(bytes), QrSegment::makeNumeric(golden1), QrSegment::makeAlphanumeric(golden2)},
|
||||
QrCode::Ecc::LOW);
|
||||
|
|
|
@ -75,9 +75,7 @@ int main() {
|
|||
// Make list of segments
|
||||
std::vector<QrSegment> segs;
|
||||
if (isAscii) {
|
||||
std::vector<char> text;
|
||||
for (std::vector<uint8_t>::iterator it = data.begin(); it != data.end(); ++it)
|
||||
text.push_back((char)*it);
|
||||
std::vector<char> text(data.cbegin(), data.cend());
|
||||
text.push_back('\0');
|
||||
segs = QrSegment::makeSegments(text.data());
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue