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
Modifier and TypeFieldDescriptionstatic final String
The default prefix for the name of a component. -
Method Summary
Modifier and TypeMethodDescriptionGet the comment for this dataTypeComponent.Returns the dataType in this component.default String
Returns a default field name for this component.Gets the default settings for this data type component.int
Get the byte offset of where this component ends relative to the start of the parent data type.Get this component's field name within its parent.int
Get the length of this component in 8-bit bytes.int
Get the byte offset of where this component begins relative to the start of the parent data type.int
Get the ordinal position within the parent dataType.returns the dataType that contains this component.boolean
Determine if the specified component corresponds to a bit-field.boolean
Returns true if the given dataTypeComponent is equivalent to this dataTypeComponent.boolean
Determine if the specified component corresponds to a zero-length bit-field.void
setComment
(String comment) Sets the comment for the component.void
setFieldName
(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 Details
-
DEFAULT_FIELD_NAME_PREFIX
The default prefix for the name of a component.- See Also:
-
-
Method Details
-
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 in 8-bit bytes. 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 in 8-bit bytes
-
getComment
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
-
setComment
Sets the comment for the component.- Parameters:
comment
- this components comment or null to clear comment.
-
getFieldName
String getFieldName()Get this component's field name within its parent. If this method returns nullgetDefaultFieldName()
can be used to obtain a default generated field name.- Returns:
- this component's field name within its parent or null if one has not been set.
-
setFieldName
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
Returns a default field name for this component. Used only if a field name is not set.- Returns:
- default field name (may be null for nameless fields such as a zero-length bitfield).
-
isEquivalent
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 dynamic 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
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
-