Ghidra 11.4.2
Ghidra internal decompiler documentation.
Loading...
Searching...
No Matches
ghidra::SizeRestrictedFilter Class Reference

A base class for data-type filters that tests for either a range or an enumerated list of sizes. More...

#include <modelrules.hh>

Inheritance diagram for ghidra::SizeRestrictedFilter:
[legend]
Collaboration diagram for ghidra::SizeRestrictedFilter:
[legend]

Public Member Functions

 SizeRestrictedFilter (void)
 Constructor for use with decode()
 
 SizeRestrictedFilter (int4 min, int4 max)
 Constructor.
 
 SizeRestrictedFilter (const SizeRestrictedFilter &op2)
 Copy constructor.
 
bool filterOnSize (Datatype *dt) const
 Enforce any size bounds on a given data-type.
 
virtual DatatypeFilterclone (void) const
 Make a copy of this filter.
 
virtual bool filter (Datatype *dt) const
 Test whether the given data-type belongs to this filter's data-type class.
 
virtual void decode (Decoder &decoder)
 Configure details of the data-type class being filtered from the given stream.
 
- Public Member Functions inherited from ghidra::DatatypeFilter
virtual ~DatatypeFilter (void)
 Destructor.
 

Protected Member Functions

void initFromSizeList (const string &str)
 Initialize filter from enumerated list of sizes.
 

Protected Attributes

int4 minSize
 Minimum size of the data-type in bytes.
 
int4 maxSize
 Maximum size of the data-type in bytes.
 
set< int4 > sizes
 An enumerated list of sizes (if not empty)
 

Additional Inherited Members

- Static Public Member Functions inherited from ghidra::DatatypeFilter
static DatatypeFilterdecodeFilter (Decoder &decoder)
 Instantiate a filter from the given stream.
 

Detailed Description

A base class for data-type filters that tests for either a range or an enumerated list of sizes.

Any filter that inherits from this, can use ATTRIB_MINSIZE, ATTRIB_MAXSIZE, or ATTRIB_SIZES to place bounds on the possible sizes of data-types. The bounds are enforced by calling filterOnSize() within the inheriting classes filter() method.

Member Function Documentation

◆ clone()

virtual DatatypeFilter * ghidra::SizeRestrictedFilter::clone ( void  ) const
inlinevirtual

Make a copy of this filter.

Returns
the newly allocated copy

Implements ghidra::DatatypeFilter.

Reimplemented in ghidra::MetaTypeFilter, and ghidra::HomogeneousAggregate.

References SizeRestrictedFilter().

◆ decode()

void ghidra::SizeRestrictedFilter::decode ( Decoder decoder)
virtual

Configure details of the data-type class being filtered from the given stream.

Parameters
decoderis the given stream decoder

Implements ghidra::DatatypeFilter.

References ghidra::Decoder::getNextAttributeId(), initFromSizeList(), maxSize, minSize, ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), and sizes.

◆ filter()

virtual bool ghidra::SizeRestrictedFilter::filter ( Datatype dt) const
inlinevirtual

Test whether the given data-type belongs to this filter's data-type class.

Parameters
dtis the given data-type to test
Returns
true if the data-type is in the class, false otherwise

Implements ghidra::DatatypeFilter.

Reimplemented in ghidra::MetaTypeFilter, and ghidra::HomogeneousAggregate.

References filterOnSize().

◆ filterOnSize()

bool ghidra::SizeRestrictedFilter::filterOnSize ( Datatype dt) const

Enforce any size bounds on a given data-type.

If maxSize is not zero, the data-type is checked to see if its size in bytes falls between minSize and maxSize inclusive. If enumerated sizes are present, also check that the particular size is in the enumerated set.

Parameters
dtis the data-type to test
Returns
true if the data-type meets the size restrictions

References ghidra::Datatype::getSize(), maxSize, minSize, and sizes.

Referenced by filter(), and ghidra::MetaTypeFilter::filter().

◆ initFromSizeList()

void ghidra::SizeRestrictedFilter::initFromSizeList ( const string &  str)
protected

Initialize filter from enumerated list of sizes.

Parse the given string as a comma or space separated list of decimal integers, populating the sizes set.

Parameters
stris the given string to parse

References maxSize, minSize, and sizes.

Referenced by decode().


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