5 * Created by Christian Brunschen on 19/05/2008.
6 * Copyright 2008 ZXing authors All rights reserved.
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <zxing/qrcode/decoder/Mode.h>
22 #include <zxing/common/Counted.h>
23 #include <zxing/ReaderException.h>
24 #include <zxing/qrcode/Version.h>
31 Mode Mode::TERMINATOR(0, 0, 0);
32 Mode Mode::NUMERIC(10, 12, 14);
33 Mode Mode::ALPHANUMERIC(9, 11, 13);
34 Mode Mode::BYTE(8, 16, 16);
35 Mode Mode::KANJI(8, 10, 12);
37 Mode::Mode(int cbv0_9, int cbv10_26, int cbv27) :
38 characterCountBitsForVersions0To9_(cbv0_9), characterCountBitsForVersions10To26_(cbv10_26),
39 characterCountBitsForVersions27AndHigher_(cbv27) {
42 Mode& Mode::forBits(int bits) {
56 s << "Illegal mode bits: " << bits;
57 throw ReaderException(s.str().c_str());
61 int Mode::getCharacterCountBits(Version *version) {
62 int number = version->getVersionNumber();
64 return characterCountBitsForVersions0To9_;
65 } else if (number <= 26) {
66 return characterCountBitsForVersions10To26_;
68 return characterCountBitsForVersions27AndHigher_;