Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
BC_QRCoderMode.cpp
Go to the documentation of this file.
1// Copyright 2014 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6// Original code is licensed as follows:
7/*
8 * Copyright 2007 ZXing authors
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22
23#include "fxbarcode/qrcode/BC_QRCoderMode.h"
24
25#include <utility>
26
27#include "core/fxcrt/fx_system.h"
28#include "third_party/base/check.h"
29
30CBC_QRCoderMode* CBC_QRCoderMode::sBYTE = nullptr;
31CBC_QRCoderMode* CBC_QRCoderMode::sNUMERIC = nullptr;
32CBC_QRCoderMode* CBC_QRCoderMode::sALPHANUMERIC = nullptr;
33
34CBC_QRCoderMode::CBC_QRCoderMode(std::vector<int32_t> charCountBits,
35 int32_t bits)
36 : m_characterCountBitsForVersions(std::move(charCountBits)), m_bits(bits) {}
37
38CBC_QRCoderMode::~CBC_QRCoderMode() = default;
39
40void CBC_QRCoderMode::Initialize() {
41 sBYTE = new CBC_QRCoderMode({8, 16, 16}, 0x4);
42 sALPHANUMERIC = new CBC_QRCoderMode({9, 11, 13}, 0x2);
43 sNUMERIC = new CBC_QRCoderMode({10, 12, 14}, 0x1);
44}
45
46void CBC_QRCoderMode::Finalize() {
47 delete sBYTE;
48 sBYTE = nullptr;
49 delete sALPHANUMERIC;
50 sALPHANUMERIC = nullptr;
51 delete sNUMERIC;
52 sNUMERIC = nullptr;
53}
54
55int32_t CBC_QRCoderMode::GetBits() const {
56 return m_bits;
57}
58
59int32_t CBC_QRCoderMode::GetCharacterCountBits(int32_t number) const {
60 if (m_characterCountBitsForVersions.empty())
61 return 0;
62
63 int32_t offset;
64 if (number <= 9)
65 offset = 0;
66 else if (number <= 26)
67 offset = 1;
68 else
69 offset = 2;
70
71 int32_t result = m_characterCountBitsForVersions[offset];
72 DCHECK(result != 0);
73 return result;
74}
static CBC_QRCoderMode * sNUMERIC
int32_t GetCharacterCountBits(int32_t number) const
static CBC_QRCoderMode * sBYTE
int32_t GetBits() const
static void Finalize()
static void Initialize()
static CBC_QRCoderMode * sALPHANUMERIC