30qrcodegen::QrSegment::Mode::Mode(
int mode,
int cc0,
int cc1,
int cc2) :
32 numBitsCharCount[0] = cc0;
33 numBitsCharCount[1] = cc1;
34 numBitsCharCount[2] = cc2;
39 if ( 1 <= ver && ver <= 9)
return numBitsCharCount[0];
40 else if (10 <= ver && ver <= 26)
return numBitsCharCount[1];
41 else if (27 <= ver && ver <= 40)
return numBitsCharCount[2];
42 else throw "Version number out of range";
63 for (; *digits !=
'\0'; digits++, charCount++) {
65 if (c <
'0' || c >
'9')
66 throw "String contains non-numeric characters";
67 accumData = accumData * 10 + (c -
'0');
69 if (accumCount == 3) {
86 for (; *text !=
'\0'; text++, charCount++) {
88 if (c <
' ' || c >
'Z')
89 throw "String contains unencodable characters in alphanumeric mode";
90 accumData = accumData * 45 + ALPHANUMERIC_ENCODING_TABLE[c -
' '];
92 if (accumCount == 2) {
106 std::vector<QrSegment>
result;
113 std::vector<uint8_t> bytes;
114 for (; *text !=
'\0'; text++)
115 bytes.push_back(
static_cast<uint8_t
>(*text));
127 if (numCh < 0 || bitLen < 0 || b.size() !=
static_cast<unsigned int>((bitLen + 7) / 8))
128 throw "Invalid value";
133 if (version < 1 || version > 40)
134 throw "Version number out of range";
136 for (
size_t i = 0; i < segs.size(); i++) {
149 for (; *text !=
'\0'; text++) {
151 if (c <
' ' || c >
'Z' || ALPHANUMERIC_ENCODING_TABLE[c -
' '] == -1)
159 for (; *text !=
'\0'; text++) {
161 if (c <
'0' || c >
'9')
168const int8_t qrcodegen::QrSegment::ALPHANUMERIC_ENCODING_TABLE[59] = {
170 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, -1,
171 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
std::vector< uint8_t > getBytes() const
void appendBits(uint32_t val, int len)
static const Mode ALPHANUMERIC
int numCharCountBits(int ver) const
static const Mode NUMERIC
static std::vector< QrSegment > makeSegments(const char *text)
static int getTotalBits(const std::vector< QrSegment > &segs, int version)
static QrSegment makeAlphanumeric(const char *text)
static QrSegment makeBytes(const std::vector< uint8_t > &data)
const std::vector< uint8_t > data
static bool isAlphanumeric(const char *text)
static QrSegment makeNumeric(const char *digits)
static bool isNumeric(const char *text)
QrSegment(const Mode &md, int numCh, const std::vector< uint8_t > &b, int bitLen)