aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/qpdf/BitStream.hh
blob: 8be7c64def2fbf637ea420bf38dab3e59195dff1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Read bits from a bit stream.  See BitWriter for writing.

#ifndef BITSTREAM_HH
#define BITSTREAM_HH

#include <qpdf/DLL.h>
#include <stddef.h>

class BitStream
{
  public:
    QPDF_DLL
    BitStream(unsigned char const* p, size_t nbytes);
    QPDF_DLL
    void reset();
    QPDF_DLL
    unsigned long long getBits(size_t nbits);
    QPDF_DLL
    long long getBitsSigned(size_t nbits);
    // Only call getBitsInt when requesting a number of bits that will
    // definitely fit in an int.
    QPDF_DLL
    int getBitsInt(size_t nbits);
    QPDF_DLL
    void skipToNextByte();

  private:
    unsigned char const* start;
    size_t nbytes;

    unsigned char const* p;
    size_t bit_offset;
    size_t bits_available;
};

#endif // BITSTREAM_HH