1
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
3
* ErrorCorrectionLevel.cpp
6
* Created by Christian Brunschen on 15/05/2008.
7
* Copyright 2008-2011 ZXing authors All rights reserved.
9
* Licensed under the Apache License, Version 2.0 (the "License");
10
* you may not use this file except in compliance with the License.
11
* You may obtain a copy of the License at
13
* http://www.apache.org/licenses/LICENSE-2.0
15
* Unless required by applicable law or agreed to in writing, software
16
* distributed under the License is distributed on an "AS IS" BASIS,
17
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
* See the License for the specific language governing permissions and
19
* limitations under the License.
22
#include <zxing/qrcode/ErrorCorrectionLevel.h>
29
ErrorCorrectionLevel::ErrorCorrectionLevel(int inOrdinal,
32
ordinal_(inOrdinal), bits_(bits), name_(name) {}
34
int ErrorCorrectionLevel::ordinal() const {
38
int ErrorCorrectionLevel::bits() const {
42
string const& ErrorCorrectionLevel::name() const {
46
ErrorCorrectionLevel::operator string const& () const {
50
ErrorCorrectionLevel& ErrorCorrectionLevel::forBits(int bits) {
51
if (bits < 0 || bits >= N_LEVELS) {
52
throw ReaderException("Ellegal error correction level bits");
54
return *FOR_BITS[bits];
57
ErrorCorrectionLevel ErrorCorrectionLevel::L(0, 0x01, "L");
58
ErrorCorrectionLevel ErrorCorrectionLevel::M(1, 0x00, "M");
59
ErrorCorrectionLevel ErrorCorrectionLevel::Q(2, 0x03, "Q");
60
ErrorCorrectionLevel ErrorCorrectionLevel::H(3, 0x02, "H");
61
ErrorCorrectionLevel *ErrorCorrectionLevel::FOR_BITS[] = { &M, &L, &H, &Q };
62
int ErrorCorrectionLevel::N_LEVELS = 4;