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_QRCoderBitVector.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_QRCoderBitVector.h"
24
25
#
include
"core/fxcrt/check.h"
26
#
include
"core/fxcrt/fx_system.h"
27
28
CBC_QRCoderBitVector
::
CBC_QRCoderBitVector
() =
default
;
29
30
CBC_QRCoderBitVector
::~
CBC_QRCoderBitVector
() =
default
;
31
32
int32_t
CBC_QRCoderBitVector
::
At
(size_t index)
const
{
33
CHECK
(index < m_sizeInBits);
34
int32_t value = m_array[index >> 3] & 0xff;
35
return
(value >> (7 - (index & 0x7))) & 1;
36
}
37
38
size_t
CBC_QRCoderBitVector
::
sizeInBytes
()
const
{
39
return
(m_sizeInBits + 7) >> 3;
40
}
41
42
size_t
CBC_QRCoderBitVector
::
Size
()
const
{
43
return
m_sizeInBits;
44
}
45
46
void
CBC_QRCoderBitVector
::
AppendBit
(int32_t bit) {
47
DCHECK
(bit == 0 || bit == 1);
48
int32_t numBitsInLastByte = m_sizeInBits & 0x7;
49
if
(numBitsInLastByte == 0) {
50
AppendByte(0);
51
m_sizeInBits -= 8;
52
}
53
m_array[m_sizeInBits >> 3] |= (bit << (7 - numBitsInLastByte));
54
++m_sizeInBits;
55
}
56
57
void
CBC_QRCoderBitVector
::
AppendBits
(int32_t value, int32_t numBits) {
58
DCHECK
(numBits > 0);
59
DCHECK
(numBits <= 32);
60
61
int32_t numBitsLeft = numBits;
62
while
(numBitsLeft > 0) {
63
if
((m_sizeInBits & 0x7) == 0 && numBitsLeft >= 8) {
64
AppendByte(
static_cast
<int8_t>((value >> (numBitsLeft - 8)) & 0xff));
65
numBitsLeft -= 8;
66
}
else
{
67
AppendBit
(
(value >> (numBitsLeft - 1)) & 1
)
;
68
--numBitsLeft;
69
}
70
}
71
}
72
73
void
CBC_QRCoderBitVector
::
AppendBitVector
(
const
CBC_QRCoderBitVector
* bits) {
74
for
(size_t i = 0; i < bits->Size(); i++)
75
AppendBit
(
bits->At(i)
)
;
76
}
77
78
bool
CBC_QRCoderBitVector
::
XOR
(
const
CBC_QRCoderBitVector
* other) {
79
if
(m_sizeInBits != other->Size())
80
return
false
;
81
82
pdfium::span<
const
uint8_t> other_span = other->GetArray();
83
for
(size_t i = 0; i < sizeInBytes(); ++i)
84
m_array[i] ^= other_span[i];
85
return
true
;
86
}
87
88
pdfium
::
span
<
const
uint8_t
>
CBC_QRCoderBitVector
::
GetArray
()
const
{
89
return
m_array;
90
}
91
92
void
CBC_QRCoderBitVector
::AppendByte(int8_t value) {
93
if
((m_sizeInBits >> 3) == m_array.size())
94
m_array.push_back(0);
95
m_array[m_sizeInBits >> 3] = value;
96
m_sizeInBits += 8;
97
}
DCHECK
#define DCHECK
Definition
check.h:33
CBC_QRCoderBitVector
Definition
BC_QRCoderBitVector.h:16
CBC_QRCoderBitVector::Size
size_t Size() const
Definition
BC_QRCoderBitVector.cpp:42
CBC_QRCoderBitVector::AppendBits
void AppendBits(int32_t value, int32_t numBits)
Definition
BC_QRCoderBitVector.cpp:57
CBC_QRCoderBitVector::At
int32_t At(size_t index) const
Definition
BC_QRCoderBitVector.cpp:32
CBC_QRCoderBitVector::sizeInBytes
size_t sizeInBytes() const
Definition
BC_QRCoderBitVector.cpp:38
CBC_QRCoderBitVector::AppendBitVector
void AppendBitVector(const CBC_QRCoderBitVector *bits)
Definition
BC_QRCoderBitVector.cpp:73
CBC_QRCoderBitVector::XOR
bool XOR(const CBC_QRCoderBitVector *other)
Definition
BC_QRCoderBitVector.cpp:78
CBC_QRCoderBitVector::~CBC_QRCoderBitVector
~CBC_QRCoderBitVector()
CBC_QRCoderBitVector::AppendBit
void AppendBit(int32_t bit)
Definition
BC_QRCoderBitVector.cpp:46
CBC_QRCoderBitVector::GetArray
pdfium::span< const uint8_t > GetArray() const
Definition
BC_QRCoderBitVector.cpp:88
CBC_QRCoderBitVector::CBC_QRCoderBitVector
CBC_QRCoderBitVector()
CHECK
#define CHECK(cvref)
Definition
q23utility.cpp:15
qtwebengine
src
3rdparty
chromium
third_party
pdfium
fxbarcode
qrcode
BC_QRCoderBitVector.cpp
Generated on
for Qt by
1.18.0