Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
BC_QRCoderVersion.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_QRCoderVersion.h"
24
25
#
include
<
memory
>
26
#
include
<
vector
>
27
28
#
include
"fxbarcode/qrcode/BC_QRCoderBitVector.h"
29
#
include
"fxbarcode/qrcode/BC_QRCoderECBlockData.h"
30
#
include
"fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
31
32
namespace
{
33
34
std::vector<std::unique_ptr<CBC_QRCoderVersion>>* g_VERSION =
nullptr
;
35
36
}
// namespace
37
38
CBC_QRCoderVersion
::
CBC_QRCoderVersion
(int32_t versionNumber,
39
const
ECBlockDataRow
& row)
40
: m_versionNumber(versionNumber) {
41
m_ecBlocksArray[0] = std::make_unique<CBC_QRCoderECBlockData>(row[0]);
42
m_ecBlocksArray[1] = std::make_unique<CBC_QRCoderECBlockData>(row[1]);
43
m_ecBlocksArray[2] = std::make_unique<CBC_QRCoderECBlockData>(row[2]);
44
m_ecBlocksArray[3] = std::make_unique<CBC_QRCoderECBlockData>(row[3]);
45
m_totalCodeWords = m_ecBlocksArray[0]->GetTotalDataCodeWords();
46
}
47
48
CBC_QRCoderVersion
::~
CBC_QRCoderVersion
() =
default
;
49
50
// static
51
void
CBC_QRCoderVersion
::
Initialize
() {
52
g_VERSION =
new
std::vector<std::unique_ptr<CBC_QRCoderVersion>>();
53
}
54
55
// static
56
void
CBC_QRCoderVersion
::
Finalize
() {
57
delete
g_VERSION;
58
g_VERSION =
nullptr
;
59
}
60
61
// static
62
const
CBC_QRCoderVersion
*
CBC_QRCoderVersion
::
GetVersionForNumber
(
63
int32_t versionNumber) {
64
if
(g_VERSION->empty()) {
65
for
(
int
i = 0; i <
kMaxVersion
; ++i) {
66
g_VERSION->push_back(
67
std
::make_unique<
CBC_QRCoderVersion
>(i + 1, kQRCoderECBDataTable[i]));
68
}
69
}
70
if
(versionNumber < 1 || versionNumber >
kMaxVersion
)
71
return
nullptr
;
72
return
(*g_VERSION)[versionNumber - 1].get();
73
}
74
75
int32_t
CBC_QRCoderVersion
::
GetVersionNumber
()
const
{
76
return
m_versionNumber;
77
}
78
79
int32_t
CBC_QRCoderVersion
::
GetTotalCodeWords
()
const
{
80
return
m_totalCodeWords;
81
}
82
83
int32_t
CBC_QRCoderVersion
::
GetDimensionForVersion
()
const
{
84
return
17 + 4 * m_versionNumber;
85
}
86
87
const
CBC_QRCoderECBlockData
*
CBC_QRCoderVersion
::
GetECBlocksForLevel
(
88
const
CBC_QRCoderErrorCorrectionLevel
& ecLevel)
const
{
89
return
m_ecBlocksArray[ecLevel.Ordinal()].get();
90
}
ECBlockDataRow
std::array< CBC_QRCoderECBlockData, 4 > ECBlockDataRow
Definition
BC_QRCoderECBlockData.h:29
CBC_QRCoderErrorCorrectionLevel
Definition
BC_QRCoderErrorCorrectionLevel.h:12
CBC_QRCoderVersion
Definition
BC_QRCoderVersion.h:17
CBC_QRCoderVersion::~CBC_QRCoderVersion
~CBC_QRCoderVersion()
CBC_QRCoderVersion::Initialize
static void Initialize()
Definition
BC_QRCoderVersion.cpp:51
CBC_QRCoderVersion::GetDimensionForVersion
int32_t GetDimensionForVersion() const
Definition
BC_QRCoderVersion.cpp:83
CBC_QRCoderVersion::Finalize
static void Finalize()
Definition
BC_QRCoderVersion.cpp:56
CBC_QRCoderVersion::GetVersionNumber
int32_t GetVersionNumber() const
Definition
BC_QRCoderVersion.cpp:75
CBC_QRCoderVersion::GetVersionForNumber
static const CBC_QRCoderVersion * GetVersionForNumber(int32_t versionNumber)
Definition
BC_QRCoderVersion.cpp:62
CBC_QRCoderVersion::kMaxVersion
static constexpr int32_t kMaxVersion
Definition
BC_QRCoderVersion.h:19
CBC_QRCoderVersion::GetECBlocksForLevel
const CBC_QRCoderECBlockData * GetECBlocksForLevel(const CBC_QRCoderErrorCorrectionLevel &ecLevel) const
Definition
BC_QRCoderVersion.cpp:87
CBC_QRCoderVersion::GetTotalCodeWords
int32_t GetTotalCodeWords() const
Definition
BC_QRCoderVersion.cpp:79
CBC_QRCoderVersion::CBC_QRCoderVersion
CBC_QRCoderVersion(int32_t versionNumber, const ECBlockDataRow &row)
Definition
BC_QRCoderVersion.cpp:38
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
CBC_QRCoderECBlockData
Definition
BC_QRCoderECBlockData.h:14
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
qrcode
BC_QRCoderVersion.cpp
Generated on
for Qt by
1.18.0