|
cds
2.3.2
|
Cuts a bit sequence from fixed-size bit-string. More...
#include <cds/algo/split_bitstring.h>
Public Types | |
| typedef BitString | bitstring |
| Bit-string type. | |
| typedef UInt | uint_type |
Result type of cut() function. | |
Public Member Functions | |
| split_bitstring (bitstring const &h) | |
Initializises the splitter with reference to h and zero start bit offset. | |
| split_bitstring (bitstring const &h, size_t nBitOffset) | |
Initializises the splitter with reference to h and start bit offset nBitOffset. | |
| operator bool () const | |
Returns true if end-of-string is not reached yet. | |
| bool | eos () const |
Returns true if end-of-stream encountered. | |
| uint_type | cut (unsigned count) |
Cuts next count bits from bit-string. More... | |
| uint_type | safe_cut (unsigned count) |
Cuts up to count from the bit-string. More... | |
| void | reset () noexcept |
| Resets the splitter. | |
| bitstring const * | source () const |
| Returns pointer to source bitstring. | |
| size_t | bit_offset () const |
| Returns current bit offset from beginning of bit-string. | |
| size_t | rest_count () const |
| Returns how many bits remain. | |
Static Public Member Functions | |
| static constexpr bool | is_correct (unsigned) |
Returns true for any argument. | |
Static Public Attributes | |
| static constexpr size_t const | c_bitstring_size = BitStringSize ? BitStringSize : sizeof( BitString ) |
size of BitString in bytes | |
Cuts a bit sequence from fixed-size bit-string.
The splitter can be used as an iterator over bit-string. Each call of cut() or safe_cut() cuts the bit count specified and keeps the position inside bit-string for the next call.
The splitter stores a const reference to bit-string, not a copy. The maximum count of bits that can be cut in a single call is sizeof(UInt) * 8
The splitter keeps byte order.
Template parameters:
BitString - a fixed-sized type that interprets as bit stringBitStringSize - the size of BitString in bytes, default is sizeof( BitString ). You can specify 0 for default.UInt - an unsigned integer, return type for cut(), default is unsigned There are specialized splitters:
byte_splitter algorithm that is suitable when count is multiple of 8.number_splitter algorithm is suitable for a number
|
inline |
Cuts next count bits from bit-string.
For performance reason, the function does not manage out-of-bound condition. To control that use safe_cut().
|
inline |