ATLAS Offline Software
Loading...
Searching...
No Matches
BitUnpacker.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3/*
4 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5*/
6
7// $Id$
14
15
16#ifndef CXXUTILS_BITUNPACKER_H
17#define CXXUTILS_BITUNPACKER_H
18
19
20#include <stdint.h>
21#include <cassert>
22
23
24namespace CxxUtils {
25
26
37template <class STREAM>
39{
40public:
46 BitUnpacker (uint8_t nbits, STREAM& stream);
47
48
52 uint32_t unpack();
53
54
55private:
57 uint32_t m_buf;
58
60 uint8_t m_nbuf;
61
63 uint8_t m_nbits;
64
66 STREAM& m_stream;
67
69 uint32_t m_mask;
70};
71
72
83template <class STREAM>
85{
86public:
91 BitUnpacker8 (STREAM& stream);
92
93
99 BitUnpacker8 (uint8_t nbits, STREAM& stream);
100
101
105 uint32_t unpack();
106
107
108private:
110 uint32_t m_buf;
111
113 uint8_t m_nbuf;
114
116 STREAM& m_stream;
117};
118
119
130template <class STREAM>
132{
133public:
138 BitUnpacker16 (STREAM& stream);
139
140
146 BitUnpacker16 (uint8_t nbits, STREAM& stream);
147
148
152 uint32_t unpack();
153
154
155private:
157 uint32_t m_buf;
158
160 uint8_t m_nbuf;
161
163 STREAM& m_stream;
164};
165
166
167} // namespace CxxUtils
168
169
171
172
173#endif // not CXXUTILS_BITUNPACKER_H
BitUnpacker16(uint8_t nbits, STREAM &stream)
Constructor.
uint8_t m_nbuf
Number of valid words currently buffered.
uint32_t unpack()
Unpack one value from the stream.
BitUnpacker16(STREAM &stream)
Constructor.
STREAM & m_stream
The input stream.
uint32_t m_buf
Buffer for the current word being unpacked.
BitUnpacker8(STREAM &stream)
Constructor.
uint32_t unpack()
Unpack one value from the stream.
BitUnpacker8(uint8_t nbits, STREAM &stream)
Constructor.
uint32_t m_buf
Buffer for the current word being unpacked.
STREAM & m_stream
The input stream.
uint8_t m_nbuf
Number of valid bytes currently buffered.
uint8_t m_nbits
Number of bits to use for each item.
Definition BitUnpacker.h:63
uint32_t m_buf
Buffer for the current word being unpacked.
Definition BitUnpacker.h:57
uint32_t m_mask
Mask with the low m_nbits bits set.
Definition BitUnpacker.h:69
uint32_t unpack()
Unpack one value from the stream.
BitUnpacker(uint8_t nbits, STREAM &stream)
Constructor.
STREAM & m_stream
The input stream.
Definition BitUnpacker.h:66
uint8_t m_nbuf
Number of valid bits currently buffered.
Definition BitUnpacker.h:60