Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/zxing-cpp/core/src/BitSource.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 /* | |
| 2 * Copyright 2016 Nu-book Inc. | |
| 3 * Copyright 2016 ZXing authors | |
| 4 */ | |
| 5 // SPDX-License-Identifier: Apache-2.0 | |
| 6 | |
| 7 #pragma once | |
| 8 | |
| 9 namespace ZXing { | |
| 10 | |
| 11 class ByteArray; | |
| 12 | |
| 13 /** | |
| 14 * <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the | |
| 15 * number of bits read is not often a multiple of 8.</p> | |
| 16 * | |
| 17 * <p>This class is thread-safe but not reentrant -- unless the caller modifies the bytes array | |
| 18 * it passed in, in which case all bets are off.</p> | |
| 19 * | |
| 20 * @author Sean Owen | |
| 21 */ | |
| 22 class BitSource | |
| 23 { | |
| 24 const ByteArray& _bytes; | |
| 25 int _byteOffset = 0; | |
| 26 int _bitOffset = 0; | |
| 27 | |
| 28 public: | |
| 29 /** | |
| 30 * @param bytes bytes from which this will read bits. Bits will be read from the first byte first. | |
| 31 * Bits are read within a byte from most-significant to least-significant bit. | |
| 32 * IMPORTANT: Bit source DOES NOT copy data byte, thus make sure that the bytes outlive the bit source object. | |
| 33 */ | |
| 34 explicit BitSource(const ByteArray& bytes) : _bytes(bytes) {} | |
| 35 | |
| 36 BitSource(BitSource &) = delete; | |
| 37 BitSource& operator=(const BitSource &) = delete; | |
| 38 | |
| 39 /** | |
| 40 * @return index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. | |
| 41 */ | |
| 42 int bitOffset() const { | |
| 43 return _bitOffset; | |
| 44 } | |
| 45 | |
| 46 /** | |
| 47 * @return index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. | |
| 48 */ | |
| 49 int byteOffset() const { | |
| 50 return _byteOffset; | |
| 51 } | |
| 52 | |
| 53 /** | |
| 54 * @param numBits number of bits to read | |
| 55 * @return int representing the bits read. The bits will appear as the least-significant bits of the int | |
| 56 */ | |
| 57 int readBits(int numBits); | |
| 58 | |
| 59 /** | |
| 60 * @param numBits number of bits to peak | |
| 61 * @return int representing the bits peaked. The bits will appear as the least-significant | |
| 62 * bits of the int | |
| 63 */ | |
| 64 int peakBits(int numBits) const; | |
| 65 | |
| 66 /** | |
| 67 * @return number of bits that can be read successfully | |
| 68 */ | |
| 69 int available() const; | |
| 70 }; | |
| 71 | |
| 72 } // ZXing |
