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_QRCoder.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 2008 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 <utility>
24
25#include "fxbarcode/common/BC_CommonByteMatrix.h"
26#include "fxbarcode/qrcode/BC_QRCoder.h"
27#include "fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
28#include "fxbarcode/qrcode/BC_QRCoderMode.h"
29#include "third_party/base/numerics/safe_conversions.h"
30
31CBC_QRCoder::CBC_QRCoder() = default;
32
33CBC_QRCoder::~CBC_QRCoder() = default;
34
35const CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() const {
36 return m_ecLevel;
37}
38
39int32_t CBC_QRCoder::GetVersion() const {
40 return m_version;
41}
42
43int32_t CBC_QRCoder::GetMatrixWidth() const {
44 return m_matrixWidth;
45}
46
47int32_t CBC_QRCoder::GetMaskPattern() const {
48 return m_maskPattern;
49}
50
51int32_t CBC_QRCoder::GetNumTotalBytes() const {
52 return m_numTotalBytes;
53}
54
55int32_t CBC_QRCoder::GetNumDataBytes() const {
56 return m_numDataBytes;
57}
58
59int32_t CBC_QRCoder::GetNumRSBlocks() const {
60 return m_numRSBlocks;
61}
62
64 return std::move(m_matrix);
65}
66
67bool CBC_QRCoder::IsValid() const {
68 return m_ecLevel && m_version != -1 && m_matrixWidth != -1 &&
69 m_maskPattern != -1 && m_numTotalBytes != -1 && m_numDataBytes != -1 &&
70 m_numECBytes != -1 && m_numRSBlocks != -1 &&
71 IsValidMaskPattern(m_maskPattern) &&
72 m_numTotalBytes == m_numDataBytes + m_numECBytes && m_matrix &&
73 m_matrixWidth ==
74 pdfium::base::checked_cast<int32_t>(m_matrix->GetWidth()) &&
75 m_matrix->GetWidth() == m_matrix->GetHeight();
76}
77
78void CBC_QRCoder::SetECLevel(const CBC_QRCoderErrorCorrectionLevel* ecLevel) {
79 m_ecLevel = ecLevel;
80}
81
82void CBC_QRCoder::SetVersion(int32_t version) {
83 m_version = version;
84}
85
86void CBC_QRCoder::SetMatrixWidth(int32_t width) {
87 m_matrixWidth = width;
88}
89
90void CBC_QRCoder::SetMaskPattern(int32_t pattern) {
91 m_maskPattern = pattern;
92}
93
94void CBC_QRCoder::SetNumDataBytes(int32_t bytes) {
95 m_numDataBytes = bytes;
96}
97
98void CBC_QRCoder::SetNumTotalBytes(int32_t value) {
99 m_numTotalBytes = value;
100}
101
102void CBC_QRCoder::SetNumRSBlocks(int32_t block) {
103 m_numRSBlocks = block;
104}
105
106void CBC_QRCoder::SetNumECBytes(int32_t value) {
107 m_numECBytes = value;
108}
109
110bool CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) {
111 return maskPattern >= 0 && maskPattern < kNumMaskPatterns;
112}
113
114void CBC_QRCoder::SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix) {
115 m_matrix = std::move(pMatrix);
116}
void SetMatrixWidth(int32_t width)
int32_t GetNumRSBlocks() const
void SetMatrix(std::unique_ptr< CBC_CommonByteMatrix > pMatrix)
int32_t GetNumTotalBytes() const
void SetNumECBytes(int32_t value)
void SetECLevel(const CBC_QRCoderErrorCorrectionLevel *ecLevel)
void SetNumRSBlocks(int32_t block)
const CBC_QRCoderErrorCorrectionLevel * GetECLevel() const
int32_t GetMatrixWidth() const
int32_t GetNumDataBytes() const
static constexpr int32_t kNumMaskPatterns
Definition BC_QRCoder.h:19
void SetMaskPattern(int32_t pattern)
int32_t GetMaskPattern() const
void SetNumDataBytes(int32_t bytes)
bool IsValid() const
void SetNumTotalBytes(int32_t value)
static bool IsValidMaskPattern(int32_t maskPattern)
std::unique_ptr< CBC_CommonByteMatrix > TakeMatrix()
int32_t GetVersion() const
void SetVersion(int32_t version)