retdec
Public Types | Public Member Functions | Private Attributes | Friends | List of all members
retdec::unpacker::Signature::Byte Class Reference

#include <signature.h>

Collaboration diagram for retdec::unpacker::Signature::Byte:
Collaboration graph
[legend]

Public Types

enum class  Type { NORMAL , WILDCARD , CAPTURE }
 

Public Member Functions

 Byte ()
 
 Byte (uint8_t byte)
 
 Byte (Type type, uint8_t expectedValue, uint8_t wildcardMask)
 
 Byte (const Byte &byte)
 
Type getType () const
 
uint8_t getExpectedValue () const
 
uint8_t getWildcardMask () const
 
Byteoperator= (uint8_t rhs)
 
Byteoperator= (Byte rhs)
 
bool operator== (uint8_t rhs) const
 
bool operator!= (uint8_t rhs) const
 

Private Attributes

Type _type
 Type of the byte. More...
 
uint8_t _expectedValue
 Expected value of the byte. More...
 
uint8_t _wildcardMask
 Wildcard mask specifying the bits that are wildcard and that are exact. More...
 

Friends

bool operator== (uint8_t lhs, const Byte &rhs)
 
bool operator!= (uint8_t lhs, const Byte &rhs)
 

Detailed Description

Represents single byte in signature that is used by Signature class. Bits that are set in wildcardMask to 1 are wildcarded and are matched as always equal. expectedValue contains the exact value of the bits that is expected. If there is collision between wildcard mask and expected value, the bits that are set in expected value and wildcard mask simultaneously are set back to 0 in expected value.

Examples:

There are macros which allow shorter initialization of Signature::Byte - these are ANY, CAP, ANYB and CAPB.

Member Enumeration Documentation

◆ Type

Type of the signature byte.

Enumerator
NORMAL 

Exact byte.

WILDCARD 

Wildcard byte.

CAPTURE 

Wildcard with capture.

Constructor & Destructor Documentation

◆ Byte() [1/4]

retdec::unpacker::Signature::Byte::Byte ( )

Default constructor. Initializes exact match byte with expected value 0.

◆ Byte() [2/4]

retdec::unpacker::Signature::Byte::Byte ( uint8_t  byte)

Single byte implicit constructor. Initializes exact match byte with specified expected value.

Parameters
byteExpected value of exact match byte.

◆ Byte() [3/4]

retdec::unpacker::Signature::Byte::Byte ( Type  type,
uint8_t  expectedValue,
uint8_t  wildcardMask 
)

Explicit constructor. Initializes bytes according to all specified values. In case of conflict between expectedValue and wildcardMask, all bits that are set to 1 in both are set back to 0 in expectedValue.

Parameters
typeType of the byte.
expectedValueExpected value of the byte.
wildcardMaskWildcard mask of the byte.

◆ Byte() [4/4]

retdec::unpacker::Signature::Byte::Byte ( const Byte byte)

Copy constructor.

Parameters
byteAnother Signature::Byte object.

Member Function Documentation

◆ getExpectedValue()

uint8_t retdec::unpacker::Signature::Byte::getExpectedValue ( ) const

Returns the expected value of the byte.

Returns
The expected value of the byte.

◆ getType()

Signature::Byte::Type retdec::unpacker::Signature::Byte::getType ( ) const

Returns the type of byte.

Returns
The type of the byte.

◆ getWildcardMask()

uint8_t retdec::unpacker::Signature::Byte::getWildcardMask ( ) const

Returns the wildcard mask of the byte.

Returns
The wildcard mask of the byte.

◆ operator!=()

bool retdec::unpacker::Signature::Byte::operator!= ( uint8_t  rhs) const

Non-equality operator for comparison with raw bytes.

Parameters
rhsRaw byte to compare with.
Returns
False if the expected value equals or wildcard mask matches the specified bits, otherwise true.

◆ operator=() [1/2]

Signature::Byte & retdec::unpacker::Signature::Byte::operator= ( Signature::Byte  rhs)

Assigment operator for Signature::Byte assignment.

Parameters
rhsSignature::Byte object to copy.
Returns
Newly created Signature::Byte object.

◆ operator=() [2/2]

Signature::Byte & retdec::unpacker::Signature::Byte::operator= ( uint8_t  rhs)

Assignment operator for raw byte assignment. Initializes exact match byte.

Parameters
rhsRaw byte to assign.
Returns
Newly created Signature::Byte object.

◆ operator==()

bool retdec::unpacker::Signature::Byte::operator== ( uint8_t  rhs) const

Equality operator for comparison with raw bytes.

Parameters
rhsRaw byte to compare with.
Returns
True if the expected value equals or wildcard mask matches the specified bits, otherwise false.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( uint8_t  lhs,
const Byte rhs 
)
friend

Non-equality operator for comparison with raw bytes.

Parameters
lhsRaw byte to compare with.
rhsSignature::Byte object to compare.
Returns
False if the expected value equals or wildcard mask matches the specified bits, otherwise true.

◆ operator==

bool operator== ( uint8_t  lhs,
const Byte rhs 
)
friend

Equality operator for comparison with raw bytes.

Parameters
lhsRaw byte to compare with.
rhsSignature::Byte object to compare.
Returns
True if the expected value equals or wildcard mask matches the specified bits, otherwise false.

Member Data Documentation

◆ _expectedValue

uint8_t retdec::unpacker::Signature::Byte::_expectedValue
private

Expected value of the byte.

◆ _type

Type retdec::unpacker::Signature::Byte::_type
private

Type of the byte.

◆ _wildcardMask

uint8_t retdec::unpacker::Signature::Byte::_wildcardMask
private

Wildcard mask specifying the bits that are wildcard and that are exact.


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