This class manages the offset and size of a value that occupies a number of contiguous bits within some container - generally a byte array.
More...
|
| bitrange_t (uint16 bit_ofs=0, uint16 size_in_bits=0) |
| Constructor.
|
void | init (uint16 bit_ofs, uint16 size_in_bits) |
| Initialize offset and size to given values.
|
void | reset () |
| Make the bitrange empty.
|
bool | empty () const |
| Is the bitrange empty?
|
uint | bitoff () const |
| Get offset of 1st bit.
|
uint | bitsize () const |
| Get size of the value in bits.
|
uint | bytesize () const |
| Size of the value in bytes.
|
uint64 | mask64 () const |
| Convert to mask of 64 bits.
|
bool | has_common (const bitrange_t &r) const |
| Does have common bits with another bitrange?
|
bool | apply_mask (const bitrange_t &subrange) |
| Apply mask to a bitrange.
|
void | intersect (const bitrange_t &r) |
| Intersect two ranges.
|
void | create_union (const bitrange_t &r) |
| Create union of 2 ranges including the hole between them.
|
bool | sub (const bitrange_t &r) |
| Subtract a bitrange.
|
void | shift_down (uint cnt) |
| Shift range down (left)
|
void | shift_up (uint cnt) |
| Shift range up (right)
|
template<class T> |
void | assign_max_nonzero (T mask) |
| Initialize bitrange_t with offset/size defined by given mask.
|
| DECLARE_COMPARISONS (bitrange_t) |
Extract a value from 'src' according to the bitrange
- Parameters
-
dst | vector the extracted value will be stored to |
src | source buffer |
src_size | size of source buffer |
is_mf | is Msb First? (TRUE-big endian, FALSE-little endian) |
|
bool | extract (bytevec_t *dst, const void *src, size_t src_size, bool is_mf) const |
bool | extract (void *dst, size_t dst_size, const void *src, size_t src_size, bool is_mf) const |
Inject a value into 'dst' according to the bitrange
- Parameters
-
dst | a buffer the value will be injected into |
dst_size | size of buffer |
src | source value |
is_mf | is Msb First? (TRUE-big endian, FALSE-little endian) |
|
bool | inject (void *dst, size_t dst_size, const void *src, size_t src_size, bool is_mf) const |
bool | inject (void *dst, size_t dst_size, const bytevec_t &src, bool is_mf) const |
This class manages the offset and size of a value that occupies a number of contiguous bits within some container - generally a byte array.
A special state - empty range (both offset and size are zeroes) - determines the value as all bits of the container.