Package ghidra.program.model.data
Interface DataTypeComponent
-
- All Known Subinterfaces:
InternalDataTypeComponent
- All Known Implementing Classes:
DataTypeComponentImpl
,ReadOnlyDataTypeComponent
public interface DataTypeComponent
DataTypeComponents are holders for the dataTypes that make up composite (Structures and Unions) dataTypes.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FIELD_NAME_PREFIX
The default prefix for the name of a component.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.String
getComment()
Get the comment for this dataTypeComponent.DataType
getDataType()
Returns the dataType in this component.default java.lang.String
getDefaultFieldName()
Returns a default Field name.Settings
getDefaultSettings()
Gets the default settings for this data type component.int
getEndOffset()
Get the byte offset of where this component ends relative to the start of the parent data type.java.lang.String
getFieldName()
Get the name of the field name as a component of a Data Type.int
getLength()
Get the length of this component.int
getOffset()
Get the byte offset of where this component begins relative to the start of the parent data type.int
getOrdinal()
Get the ordinal position within the parent dataType.DataType
getParent()
returns the dataType that contains this component.boolean
isBitFieldComponent()
Determine if the specified component corresponds to a bit-field.boolean
isEquivalent(DataTypeComponent dtc)
Returns true if the given dataTypeComponent is equivalent to this dataTypeComponent.boolean
isZeroBitFieldComponent()
Determine if the specified component corresponds to a zero-length bit-field.void
setComment(java.lang.String comment)
Sets the comment for the component.void
setDefaultSettings(Settings settings)
Set default settings for this dataType.void
setFieldName(java.lang.String fieldName)
Sets the field name.static boolean
usesZeroLengthComponent(DataType dataType)
Determine if the specified dataType will be treated as a zero-length component allowing it to possibly overlap the next component.
-
-
-
Field Detail
-
DEFAULT_FIELD_NAME_PREFIX
static final java.lang.String DEFAULT_FIELD_NAME_PREFIX
The default prefix for the name of a component.- See Also:
- Constant Field Values
-
-
Method Detail
-
getDataType
DataType getDataType()
Returns the dataType in this component.- Returns:
- the dataType in this component
-
getParent
DataType getParent()
returns the dataType that contains this component.- Returns:
- the dataType that contains this component.
-
isBitFieldComponent
boolean isBitFieldComponent()
Determine if the specified component corresponds to a bit-field.- Returns:
- true if bit-field else false
-
isZeroBitFieldComponent
boolean isZeroBitFieldComponent()
Determine if the specified component corresponds to a zero-length bit-field.- Returns:
- true if zero-length bit-field else false
-
getOrdinal
int getOrdinal()
Get the ordinal position within the parent dataType.- Returns:
- ordinal of this component within the parent data type.
-
getOffset
int getOffset()
Get the byte offset of where this component begins relative to the start of the parent data type.- Returns:
- offset of start of component relative to the start of the parent data type.
-
getEndOffset
int getEndOffset()
Get the byte offset of where this component ends relative to the start of the parent data type.- Returns:
- offset of end of component relative to the start of the parent data type.
-
getLength
int getLength()
Get the length of this component. Zero-length components will report a length of 0 and may overlap other components at the same offset. Similarly, multiple adjacent bit-field components may appear to overlap at the byte-level.- Returns:
- the length of this component
-
getComment
java.lang.String getComment()
Get the comment for this dataTypeComponent.- Returns:
- component comment string or null if one has not been set
-
getDefaultSettings
Settings getDefaultSettings()
Gets the default settings for this data type component.- Returns:
- a Settings object that is the set of default values for this dataType component
-
setDefaultSettings
void setDefaultSettings(Settings settings)
Set default settings for this dataType.- Parameters:
settings
- the new default settings.
-
setComment
void setComment(java.lang.String comment)
Sets the comment for the component.- Parameters:
comment
- this components comment or null to clear comment.
-
getFieldName
java.lang.String getFieldName()
Get the name of the field name as a component of a Data Type.- Returns:
- the name as a component of another Data Type.
-
setFieldName
void setFieldName(java.lang.String fieldName) throws DuplicateNameException
Sets the field name. If the field name is empty it will be set to null, which is the default field name. An exception is thrown if one of the parent's other components already has the specified field name.- Parameters:
fieldName
- the new field name for this component.- Throws:
DuplicateNameException
- if another component of the parent has the specified field name.
-
getDefaultFieldName
default java.lang.String getDefaultFieldName()
Returns a default Field name. Used only if a field name is not set.- Returns:
- default field name
-
isEquivalent
boolean isEquivalent(DataTypeComponent dtc)
Returns true if the given dataTypeComponent is equivalent to this dataTypeComponent. A dataTypeComponent is "equivalent" if the other component has a data type that is equivalent to this component's data type. The dataTypeComponents must also have the same offset, field name, and comment. The length is only checked for components which are dyanmic and whose size must be specified when creating a component.- Parameters:
dtc
- the dataTypeComponent being tested for equivalence.- Returns:
- true if the given dataTypeComponent is equivalent to this dataTypeComponent.
-
usesZeroLengthComponent
static boolean usesZeroLengthComponent(DataType dataType)
Determine if the specified dataType will be treated as a zero-length component allowing it to possibly overlap the next component. If the specified dataType returns true forDataType.isZeroLength()
and true forDataType.isNotYetDefined()
this method will return false causing the associated component to use the reported dataType length of 1.- Parameters:
dataType
- datatype to be evaluated- Returns:
- true if zero-length component
-
-