|
Worldstone
|
Provides access to a variable bitsize values stream. More...
#include <BitStream.h>
Public Member Functions | |
| BitStreamView (const void *inputBuffer, size_t sizeInBits, size_t firstBitOffsetInBuffer=0) | |
| Creates a bitstream from raw memory. | |
| BitStreamView | createSubView (size_t newbufferSizeInBits) const |
| size_t | tell () const |
| Returns the current position in the stream in bits. | |
| void | setPosition (size_t newPosition) |
| Set the current position, in bits. | |
| size_t | bitPositionInBuffer () const |
| Returns the current position in the buffer (ignoring the first bit position) in bits. | |
| void | skip (size_t nbBits) |
| Skips the next nbBits bits. | |
| void | alignToByte () |
| size_t | bufferSizeInBytes () const |
| size_t | bufferSizeInBits () const |
| Returns the total size of the current stream buffer in bits. More... | |
| size_t | sizeInBits () const |
| Returns the total size of the current stream buffer in bytes. | |
| bool | readBool () |
| Reads a single bit from the stream. | |
| uint32_t | readBit () |
| Reads a single bit from the stream (uint32_t version) | |
| template<typename RetType = uint32_t> | |
| RetType | readUnsigned (unsigned nbBits) |
| Reads an unsigned value of variable bit size. More... | |
| uint8_t | readUnsigned8OrLess (const int nbBits) |
| uint32_t | read0Bits () |
| Return 0u, used for member function tables as replacement for BitStream::readUnsigned<0> | |
| template<unsigned NbBits, typename std::enable_if<(NbBits > 0> | |
| int32_t | readSigned () |
| Reads an signed value of variable bit size. More... | |
| template<unsigned NbBits, typename std::enable_if<(NbBits==0)>::type * = nullptr> | |
| int32_t | readSigned () |
| Return 0 if reading less than 2 bits. More... | |
Public Member Functions inherited from WorldStone::IOBase | |
| operator bool () const | |
| bool | operator! () const |
| bool | good () const |
| bool | eof () const |
| bool | fail () const |
| bool | bad () const |
Additional Inherited Members | |
Public Types inherited from WorldStone::IOBase | |
| using | Path = std::string |
| using | iostate = int |
Protected Member Functions inherited from WorldStone::IOBase | |
| void | setstate (iostate state) |
Protected Attributes inherited from WorldStone::IOBase | |
| iostate | _state = goodbit |
Static Protected Attributes inherited from WorldStone::IOBase | |
| static constexpr iostate | goodbit = 0x0 |
| static constexpr iostate | eofbit = 0x1 |
| static constexpr iostate | failbit = 0x2 |
| static constexpr iostate | badbit = 0x4 |
Provides access to a variable bitsize values stream.
The bitstream operates as a view on raw memory to get values of different sizes. This assumes that the data is ordered in a little endian fashion, and signed values are encoded using 2's complement.
Add some bounds checking and set io flags on error ?
Implement a MemoryStream class
Definition at line 33 of file BitStream.h.
|
inline |
Returns the total size of the current stream buffer in bits.
Definition at line 91 of file BitStream.h.
|
inline |
Reads an signed value of variable bit size.
Values are using 2's complement.
| NbBits | The number of bits to read from the stream |
Definition at line 161 of file BitStream.h.
|
inline |
Return 0 if reading less than 2 bits.
Definition at line 172 of file BitStream.h.
|
inline |
Reads an unsigned value of variable bit size.
| RetType | The type of the value to return, must be at least NbBits bits big. |
| nbBits | The number of bits to read from the stream |
Definition at line 112 of file BitStream.h.