IDA C++ SDK 9.2
Loading...
Searching...
No Matches
bitrange_t Class Reference

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...

#include <bitrange.hpp>

Public Member Functions

 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

Extract a value from 'src' according to the bitrange

Parameters
dstvector the extracted value will be stored to
srcsource buffer
src_sizesize of source buffer
is_mfis 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

Inject a value into 'dst' according to the bitrange

Parameters
dsta buffer the value will be injected into
dst_sizesize of buffer
srcsource value
is_mfis 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

Detailed Description

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.

Constructor & Destructor Documentation

◆ bitrange_t()

bitrange_t::bitrange_t ( uint16 bit_ofs = 0,
uint16 size_in_bits = 0 )
inlineexplicit

Constructor.

Member Function Documentation

◆ init()

void bitrange_t::init ( uint16 bit_ofs,
uint16 size_in_bits )
inline

Initialize offset and size to given values.

◆ reset()

void bitrange_t::reset ( )
inline

Make the bitrange empty.

◆ empty()

bool bitrange_t::empty ( ) const
inline

Is the bitrange empty?

◆ bitoff()

uint bitrange_t::bitoff ( ) const
inline

Get offset of 1st bit.

◆ bitsize()

uint bitrange_t::bitsize ( ) const
inline

Get size of the value in bits.

◆ bytesize()

uint bitrange_t::bytesize ( ) const
inline

Size of the value in bytes.

◆ mask64()

uint64 bitrange_t::mask64 ( ) const
inline

Convert to mask of 64 bits.

◆ has_common()

bool bitrange_t::has_common ( const bitrange_t & r) const
inline

Does have common bits with another bitrange?

◆ apply_mask()

bool bitrange_t::apply_mask ( const bitrange_t & subrange)
inline

Apply mask to a bitrange.

Parameters
subrangerange inside the main bitrange to keep After this operation the main bitrange will be truncated to have only the bits that are specified by subrange. Example: [off=8,nbits=4], subrange[off=1,nbits=2] => [off=9,nbits=2]
Returns
success

◆ intersect()

void bitrange_t::intersect ( const bitrange_t & r)
inline

Intersect two ranges.

◆ create_union()

void bitrange_t::create_union ( const bitrange_t & r)
inline

Create union of 2 ranges including the hole between them.

◆ sub()

bool bitrange_t::sub ( const bitrange_t & r)
inline

Subtract a bitrange.

◆ shift_down()

void bitrange_t::shift_down ( uint cnt)
inline

Shift range down (left)

◆ shift_up()

void bitrange_t::shift_up ( uint cnt)
inline

Shift range up (right)

◆ assign_max_nonzero()

template<class T>
void bitrange_t::assign_max_nonzero ( T mask)
inline

Initialize bitrange_t with offset/size defined by given mask.

◆ extract() [1/2]

bool bitrange_t::extract ( bytevec_t * dst,
const void * src,
size_t src_size,
bool is_mf ) const
inline

◆ extract() [2/2]

bool bitrange_t::extract ( void * dst,
size_t dst_size,
const void * src,
size_t src_size,
bool is_mf ) const
inline

◆ inject() [1/2]

bool bitrange_t::inject ( void * dst,
size_t dst_size,
const void * src,
size_t src_size,
bool is_mf ) const
inline

◆ inject() [2/2]

bool bitrange_t::inject ( void * dst,
size_t dst_size,
const bytevec_t & src,
bool is_mf ) const
inline

◆ DECLARE_COMPARISONS()

bitrange_t::DECLARE_COMPARISONS ( bitrange_t )

The documentation for this class was generated from the following file: