MCPcopy Create free account
hub / github.com/devilsen/CZXing / BitArrayView

Class BitArrayView

czxing/src/main/cpp/zxing/src/BitArray.h:151–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151class BitArrayView
152{
153 const BitArray& bits;
154 BitArray::Iterator cur;
155
156public:
157 BitArrayView(const BitArray& bits) : bits(bits), cur(bits.begin()) {}
158
159 BitArrayView& skipBits(int n)
160 {
161 if (n > bits.size())
162 throw std::out_of_range("BitArrayView::skipBits() out of range.");
163 cur += n;
164 return *this;
165 }
166
167 int peakBits(int n) const
168 {
169 assert(n <= 32);
170 if (n > bits.size())
171 throw std::out_of_range("BitArrayView::peakBits() out of range.");
172 int res = 0;
173 for (auto i = cur; n > 0; --n, i++)
174 AppendBit(res, *i);
175 return res;
176 }
177
178 int readBits(int n)
179 {
180 int res = peakBits(n);
181 cur += n;
182 return res;
183 }
184
185 int size() const
186 {
187 return narrow_cast<int>(bits.end() - cur);
188 }
189
190 explicit operator bool() const { return size(); }
191};
192
193} // ZXing

Callers 2

DecodeExpandedBitsFunction · 0.85
DecodeContentFunction · 0.85

Calls 2

sizeFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected