Class StructureDataType
- java.lang.Object
-
- ghidra.program.model.data.AbstractDataType
-
- ghidra.program.model.data.DataTypeImpl
-
- ghidra.program.model.data.GenericDataType
-
- ghidra.program.model.data.CompositeDataTypeImpl
-
- ghidra.program.model.data.StructureDataType
-
- All Implemented Interfaces:
Composite
,DataType
,Structure
,java.util.EventListener
,javax.swing.event.ChangeListener
public class StructureDataType extends CompositeDataTypeImpl implements Structure
Basic implementation of the structure data type
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ghidra.program.model.data.Composite
Composite.AlignmentType, Composite.NamedAlignment
-
Nested classes/interfaces inherited from interface ghidra.program.model.data.Structure
Structure.BitOffsetComparator, Structure.OffsetComparator, Structure.OrdinalComparator
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Comparator<java.lang.Object>
bitOffsetComparatorBE
protected static java.util.Comparator<java.lang.Object>
bitOffsetComparatorLE
protected java.util.List<DataTypeComponentImpl>
components
protected int
numComponents
protected static java.util.Comparator<java.lang.Object>
offsetComparator
protected int
structLength
-
Fields inherited from class ghidra.program.model.data.CompositeDataTypeImpl
aligned, alignmentType, externalAlignment, packingValue
-
Fields inherited from class ghidra.program.model.data.GenericDataType
packed
-
Fields inherited from class ghidra.program.model.data.DataTypeImpl
defaultSettings
-
Fields inherited from class ghidra.program.model.data.AbstractDataType
categoryPath, dataMgr, name
-
Fields inherited from interface ghidra.program.model.data.Composite
DEFAULT_ALIGNMENT_VALUE, NOT_PACKING
-
Fields inherited from interface ghidra.program.model.data.DataType
CONFLICT_SUFFIX, DEFAULT, NO_LAST_CHANGE_TIME, NO_SOURCE_SYNC_TIME, VOID
-
-
Constructor Summary
Constructors Constructor Description StructureDataType(CategoryPath path, java.lang.String name, int length)
Construct a new structure with the given name and number of undefined bytesStructureDataType(CategoryPath path, java.lang.String name, int length, DataTypeManager dtm)
StructureDataType(CategoryPath path, java.lang.String name, int length, UniversalID universalID, SourceArchive sourceArchive, long lastChangeTime, long lastChangeTimeInSourceArchive, DataTypeManager dtm)
Construct a new structure with the given name and number of undefined bytesStructureDataType(java.lang.String name, int length)
Construct a new structure with the given name and number of undefined bytesStructureDataType(java.lang.String name, int length, DataTypeManager dtm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataTypeComponent
add(DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Adds a new datatype to the end of this composite.DataTypeComponent
addBitField(DataType baseDataType, int bitSize, java.lang.String componentName, java.lang.String comment)
Adds a new bitfield to the end of this composite.protected boolean
adjustComponents()
Adjust the alignment, packing and padding of components within this structure based upon the current alignment and packing attributes for this structure.void
adjustInternalAlignment()
Adjusts the internal alignment of components within this composite based on the current settings of the internal alignment, packing, alignment type and minimum alignment value.void
clearComponent(int index)
Clears the defined component at the given component index.void
clearFlexibleArrayComponent()
Remove the optional trailing flexible array component associated with this structure.DataType
clone(DataTypeManager dtm)
Returns a new instance of this DataType with its universalID and SourceArchive identity retained.DataType
copy(DataTypeManager dtm)
Returns a new instance of this DataType with a new identity.void
dataTypeAlignmentChanged(DataType dt)
The overall (external) alignment changed for the specified data type.void
dataTypeDeleted(DataType dt)
Informs this dataType that the given dataType has been deleted.void
dataTypeNameChanged(DataType dt, java.lang.String oldName)
Informs this data type that its name has changed from the indicated old name.void
dataTypeReplaced(DataType oldDt, DataType replacementDt)
Informs this data type that the given oldDT has been replaced with newDT
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!void
dataTypeSizeChanged(DataType dt)
Notification that the given dataType's size has changed.void
delete(int ordinal)
Deletes the component at the given ordinal position.void
delete(int[] ordinals)
Deletes the components at the given ordinal positions.void
deleteAll()
Remove all components from this structure, effectively setting the length to zero.void
deleteAtOffset(int offset)
Deletes the component containing the specified offset in this structure.boolean
dependsOn(DataType dt)
Returns true if this dataType depends on the existence of the given dataType.protected void
dumpComponents(java.lang.StringBuilder buffer, java.lang.String pad)
Dump all components for use inCompositeDataTypeImpl.toString()
representation.int
getAlignment()
Gets the alignment to be used when aligning this data type within another data type.DataTypeComponent
getComponent(int index)
Returns the component of this structure with the indicated ordinal.DataTypeComponent
getComponentAt(int offset)
Gets the immediate child component that contains the byte at the given offset.DataTypeComponent[]
getComponents()
Returns a list of all components that make up this data type excluding any trailing flexible array component if present.DataTypeComponent
getDataTypeAt(int offset)
Returns the primitive Data Type that is at this offset.java.lang.String
getDefaultLabelPrefix()
Returns the appropriate string to use as the default label prefix in the absence of any data.DataTypeComponent[]
getDefinedComponents()
Returns the list of components that are defined.DataTypeComponent
getFlexibleArrayComponent()
Get the optional trailing flexible array component associated with this structure.int
getLength()
Get the length (number of 8-bit bytes) of this DataType.int
getNumComponents()
Gets the number of component data types in this data type excluding any trailing flexible array component if present.int
getNumDefinedComponents()
Returns the number of non-undefined components in this composite.protected int
getNumUndefinedBytes(int index)
Gets the number of Undefined bytes beginning at the indicated component index.java.lang.String
getRepresentation(MemBuffer buf, Settings settings, int length)
Get bytes from memory in a printable format for this type.void
growStructure(int amount)
Increases the size of the structure by the given amount by adding undefined datatypes at the end of the structure.boolean
hasFlexibleArrayComponent()
Determine if a trailing flexible array component has been defined.DataTypeComponent
insert(int index, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Inserts a new datatype at the specified ordinal position in this composite.DataTypeComponentImpl
insertAtOffset(int offset, DataType dataType, int length)
Inserts a new datatype at the specified offset into this structure.DataTypeComponentImpl
insertAtOffset(int offset, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Inserts a new datatype at the specified offset into this structure.DataTypeComponent
insertBitField(int ordinal, int byteWidth, int bitOffset, DataType baseDataType, int bitSize, java.lang.String componentName, java.lang.String comment)
Inserts a new bitfield at the specified ordinal position in this structure.DataTypeComponent
insertBitFieldAt(int byteOffset, int byteWidth, int bitOffset, DataType baseDataType, int bitSize, java.lang.String componentName, java.lang.String comment)
Inserts a new bitfield at the specified location in this composite.boolean
isEquivalent(DataType dataType)
Returns true if the given dataType is equivalent to this dataType.boolean
isNotYetDefined()
Indicates if type has not yet been defined.void
pack(int packingSize)
void
realign()
Updates the composite to any changes in the data organization.DataTypeComponent
replace(int index, DataType dataType, int length)
Replaces the component at the given component index with a new component of the indicated data type.DataTypeComponent
replace(int index, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Replaces the component at the given component index with a new component of the indicated data type.DataTypeComponent
replaceAtOffset(int offset, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Replaces the component at the specified byte offset with a new component of the indicated data type.void
replaceWith(DataType dataType)
Replaces the internal components of this structure with components of the given structure.DataTypeComponent
setFlexibleArrayComponent(DataType flexType, java.lang.String name, java.lang.String comment)
Set the optional trailing flexible array component associated with this structure.protected void
shiftOffset(DataTypeComponentImpl dtc, int deltaOrdinal, int deltaOffset)
-
Methods inherited from class ghidra.program.model.data.CompositeDataTypeImpl
add, add, add, checkAncestry, getDescription, getMinimumAlignment, getMnemonic, getPackingValue, getPreferredComponentLength, getValue, insert, insert, isDefaultAligned, isDynamicallySized, isInternallyAligned, isMachineAligned, isPartOf, notifyAlignmentChanged, setAlignment, setDescription, setInternallyAligned, setMinimumAlignment, setName, setPackingValue, setToDefaultAlignment, setToMachineAlignment, setValue, toString, updateBitFieldDataType, validateDataType
-
Methods inherited from class ghidra.program.model.data.GenericDataType
setCategoryPath, setNameAndCategory
-
Methods inherited from class ghidra.program.model.data.DataTypeImpl
addParent, equals, getDefaultSettings, getLastChangeTime, getLastChangeTimeInSourceArchive, getParents, getPathName, getSettingsDefinitions, getSourceArchive, getUniversalID, getValueClass, hashCode, notifyDeleted, notifyNameChanged, notifyReplaced, notifySizeChanged, removeParent, setDefaultSettings, setLastChangeTime, setLastChangeTimeInSourceArchive, setSourceArchive, stateChanged
-
Methods inherited from class ghidra.program.model.data.AbstractDataType
getCategoryPath, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDisplayName, getDocs, getName, isDeleted
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.data.Composite
add, add, add, getBitFieldPacking, getMinimumAlignment, getPackingValue, insert, insert, isDefaultAligned, isInternallyAligned, isMachineAligned, isPartOf, setDescription, setInternallyAligned, setMinimumAlignment, setPackingValue, setToDefaultAlignment, setToMachineAlignment
-
Methods inherited from interface ghidra.program.model.data.DataType
addParent, getCategoryPath, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDefaultSettings, getDescription, getDisplayName, getDocs, getLastChangeTime, getLastChangeTimeInSourceArchive, getMnemonic, getName, getParents, getPathName, getSettingsDefinitions, getSourceArchive, getUniversalID, getValue, getValueClass, isDeleted, isDynamicallySized, removeParent, setCategoryPath, setDefaultSettings, setLastChangeTime, setLastChangeTimeInSourceArchive, setName, setNameAndCategory, setSourceArchive
-
-
-
-
Field Detail
-
offsetComparator
protected static java.util.Comparator<java.lang.Object> offsetComparator
-
bitOffsetComparatorLE
protected static java.util.Comparator<java.lang.Object> bitOffsetComparatorLE
-
bitOffsetComparatorBE
protected static java.util.Comparator<java.lang.Object> bitOffsetComparatorBE
-
structLength
protected int structLength
-
numComponents
protected int numComponents
-
components
protected java.util.List<DataTypeComponentImpl> components
-
-
Constructor Detail
-
StructureDataType
public StructureDataType(java.lang.String name, int length)
Construct a new structure with the given name and number of undefined bytes- Parameters:
name
- the name of the new structurelength
- the initial size of the structure
-
StructureDataType
public StructureDataType(java.lang.String name, int length, DataTypeManager dtm)
-
StructureDataType
public StructureDataType(CategoryPath path, java.lang.String name, int length)
Construct a new structure with the given name and number of undefined bytes- Parameters:
path
- the category path indicating where this data type is located.name
- the name of the new structurelength
- the initial size of the structure
-
StructureDataType
public StructureDataType(CategoryPath path, java.lang.String name, int length, DataTypeManager dtm)
-
StructureDataType
public StructureDataType(CategoryPath path, java.lang.String name, int length, UniversalID universalID, SourceArchive sourceArchive, long lastChangeTime, long lastChangeTimeInSourceArchive, DataTypeManager dtm)
Construct a new structure with the given name and number of undefined bytes- Parameters:
path
- the category path indicating where this data type is located.name
- the name of the new structurelength
- the initial size of the structuredataTypeManager
- the data type manager associated with this data type. This can be null. Also, the data type manager may not contain this actual data type.
-
-
Method Detail
-
getRepresentation
public java.lang.String getRepresentation(MemBuffer buf, Settings settings, int length)
Description copied from interface:DataType
Get bytes from memory in a printable format for this type.- Specified by:
getRepresentation
in interfaceDataType
- Parameters:
buf
- the data.settings
- the settings to use for the representation.length
- the number of bytes to represent.- Returns:
- the representation of the data in this format, never null.
-
isNotYetDefined
public boolean isNotYetDefined()
Description copied from interface:DataType
Indicates if type has not yet been defined. Such types will always return a size of 1. (example: empty structure)- Specified by:
isNotYetDefined
in interfaceDataType
- Overrides:
isNotYetDefined
in classAbstractDataType
- Returns:
- true if this type is not yet defined.
-
getAlignment
public int getAlignment()
Description copied from interface:DataType
Gets the alignment to be used when aligning this data type within another data type.- Specified by:
getAlignment
in interfaceDataType
- Overrides:
getAlignment
in classCompositeDataTypeImpl
- Returns:
- this data type's alignment.
-
getComponentAt
public DataTypeComponent getComponentAt(int offset)
Description copied from interface:Structure
Gets the immediate child component that contains the byte at the given offset. If the specified offset corresponds to a bit-field,the first bit-field component containing the offset will be returned.- Specified by:
getComponentAt
in interfaceStructure
- Parameters:
offset
- the byte offset into this data type- Returns:
- the immediate child component.
-
getDataTypeAt
public DataTypeComponent getDataTypeAt(int offset)
Description copied from interface:Structure
Returns the primitive Data Type that is at this offset. This is useful for prototypes that have components that are made up of other components If the specified offset corresponds to a bit-field,the BitFieldDataType of the first bit-field component containing the offset will be returned.- Specified by:
getDataTypeAt
in interfaceStructure
- Parameters:
offset
- the byte offset into this data type.- Returns:
- the primitive data type at the offset.
-
getLength
public int getLength()
Description copied from interface:DataType
Get the length (number of 8-bit bytes) of this DataType.
-
delete
public void delete(int ordinal)
Description copied from interface:Composite
Deletes the component at the given ordinal position.
Note: Removal of bitfields from an unaligned structure will not shift other components with vacated bytes reverting to undefined.
-
delete
public void delete(int[] ordinals)
Description copied from interface:Composite
Deletes the components at the given ordinal positions.
Note: Removal of bitfields from an unaligned structure will not shift other components with vacated bytes reverting to undefined.
-
shiftOffset
protected void shiftOffset(DataTypeComponentImpl dtc, int deltaOrdinal, int deltaOffset)
-
getComponent
public DataTypeComponent getComponent(int index)
Description copied from interface:Structure
Returns the component of this structure with the indicated ordinal. If the specified ordinal equalsStructure.getNumComponents()
the defined flexible array component will be returned, otherwise an out of bounds exception will be thrown. Use ofStructure.getFlexibleArrayComponent()
is preferred for obtaining this special trailing component.- Specified by:
getComponent
in interfaceComposite
- Specified by:
getComponent
in interfaceStructure
- Parameters:
index
- the component's ordinal (zero based).- Returns:
- the data type component.
-
getNumComponents
public int getNumComponents()
Description copied from interface:Structure
Gets the number of component data types in this data type excluding any trailing flexible array component if present.- Specified by:
getNumComponents
in interfaceComposite
- Specified by:
getNumComponents
in interfaceStructure
- Returns:
- the number of components that make up this data prototype
-
getNumDefinedComponents
public int getNumDefinedComponents()
Description copied from interface:Structure
Returns the number of non-undefined components in this composite. For example, say a structure has an int (4 bytes) at offset 0 and another int at offset 8. This structure would have 6 total components (one for each undefined between the two ints), but only 2 defined components. Any trailing flexible array component will not be included in this count.- Specified by:
getNumDefinedComponents
in interfaceStructure
- Returns:
- the number of non-undefined components in this composite
-
insertAtOffset
public final DataTypeComponentImpl insertAtOffset(int offset, DataType dataType, int length)
Description copied from interface:Structure
Inserts a new datatype at the specified offset into this structure. Inserting a component will causing any conflicting component to shift down to the extent necessary to avoid a conflict.- Specified by:
insertAtOffset
in interfaceStructure
- Parameters:
offset
- the byte offset into the structure where the new datatype is to be inserted.dataType
- the datatype to insert.length
- the length to associate with the dataType. For fixed length types a length <= 0 will use the length of the resolved dataType.- Returns:
- the componentDataType created.
-
insertAtOffset
public DataTypeComponentImpl insertAtOffset(int offset, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Description copied from interface:Structure
Inserts a new datatype at the specified offset into this structure. Inserting a component will causing any conflicting component to shift down to the extent necessary to avoid a conflict.- Specified by:
insertAtOffset
in interfaceStructure
- Parameters:
offset
- the byte offset into the structure where the new datatype is to be inserted.dataType
- the datatype to insert.length
- the length to associate with the dataType. For fixed length types a length <= 0 will use the length of the resolved dataType.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the componentDataType created.
-
add
public DataTypeComponent add(DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Description copied from interface:Composite
Adds a new datatype to the end of this composite. This is the preferred method to use for adding components to an aligned structure for dynamic dataTypes such as strings whose length must be specified.- Specified by:
add
in interfaceComposite
- Parameters:
dataType
- the datatype to add.length
- the length to associate with the datatype. For fixed length types a length <= 0 will use the length of the resolved dataType.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the componentDataType created.
-
growStructure
public void growStructure(int amount)
Description copied from interface:Structure
Increases the size of the structure by the given amount by adding undefined datatypes at the end of the structure.- Specified by:
growStructure
in interfaceStructure
- Parameters:
amount
- the amount by which to grow the structure.
-
insert
public DataTypeComponent insert(int index, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Description copied from interface:Composite
Inserts a new datatype at the specified ordinal position in this composite.
Note: For an aligned structure the ordinal position will get adjusted automatically to provide the proper alignment.- Specified by:
insert
in interfaceComposite
- Parameters:
index
- the ordinal where the new datatype is to be inserted.dataType
- the datatype to insert.length
- the length to associate with the datatype. For fixed length types a length <= 0 will use the length of the resolved dataType.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the componentDataType created.
-
addBitField
public DataTypeComponent addBitField(DataType baseDataType, int bitSize, java.lang.String componentName, java.lang.String comment) throws InvalidDataTypeException
Description copied from interface:Composite
Adds a new bitfield to the end of this composite. This method is intended to be used with aligned structures/unions only where the bitfield will be appropriately packed. The minimum storage storage byte size will be applied. It will not provide useful results within unaligned composites.- Specified by:
addBitField
in interfaceComposite
- Parameters:
baseDataType
- the bitfield base datatype (certain restrictions apply).bitSize
- the bitfield size in bitscomponentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the componentDataType created whose associated data type will be BitFieldDataType.
- Throws:
InvalidDataTypeException
- if the specified data type is not a valid base type for bitfields.
-
insertBitField
public DataTypeComponent insertBitField(int ordinal, int byteWidth, int bitOffset, DataType baseDataType, int bitSize, java.lang.String componentName, java.lang.String comment) throws InvalidDataTypeException, java.lang.ArrayIndexOutOfBoundsException
Description copied from interface:Structure
Inserts a new bitfield at the specified ordinal position in this structure. Within aligned structures the specified byteWidth and bitOffset will be ignored since packing will occur at the specified ordinal position. The resulting component length and bitfield details will reflect the use of minimal storage sizing.For unaligned structures, a component shift will only occur if the bitfield placement conflicts with another component. If no conflict occurs, the bitfield will be placed at the specified location consuming any DEFAULT components as needed. When a conflict does occur a shift will be performed at the ordinal position based upon the specified byteWidth. When located onto existing bitfields they will be packed together provided they do not conflict, otherwise the conflict rule above applies.
Supported aligned packing starts with bit-0 (lsb) of the first byte for little-endian, and with bit-7 (msb) of the first byte for big-endian. This is the default behavior for most compilers. Insertion behavior may not work as expected if packing rules differ from this.
- Specified by:
insertBitField
in interfaceStructure
- Parameters:
ordinal
- the ordinal where the new datatype is to be inserted.byteWidth
- the storage allocation unit width which contains the bitfield. Must be large enough to contain the "effective bit size" and corresponding bitOffset. The actual component size used will be recomputed during insertion.bitOffset
- corresponds to the bitfield left-shift amount with the storage unit when viewed as big-endian. The final offset may be reduced based upon the minimal storage size determined during insertion.baseDataType
- the bitfield base datatype (certain restrictions apply).bitSize
- the declared bitfield size in bits. The effective bit size may be adjusted based upon the specified baseDataType.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the bitfield component created whose associated data type will be BitFieldDataType.
- Throws:
InvalidDataTypeException
- if the specified baseDataType is not a valid base type for bitfields.java.lang.ArrayIndexOutOfBoundsException
- if ordinal is less than 0 or greater than the current number of components.
-
insertBitFieldAt
public DataTypeComponent insertBitFieldAt(int byteOffset, int byteWidth, int bitOffset, DataType baseDataType, int bitSize, java.lang.String componentName, java.lang.String comment) throws InvalidDataTypeException
Description copied from interface:Structure
Inserts a new bitfield at the specified location in this composite. This method is intended to be used with unaligned structures where the bitfield will be precisely placed. Within an aligned structure the specified byteOffset, byteWidth and bitOffset will be used to identify the appropriate ordinal but may not be preserved. The component length will be computed based upon the specified parameters and will be reduced from byteWidth to its minimal size for the new component.For unaligned mode, a component shift will only occur if the bitfield placement conflicts with another component. If no conflict occurs, the bitfield will be placed at the specified location consuming any DEFAULT components as needed. When a conflict does occur a shift will be performed at the point of conflict based upon the specified byteWidth. When located onto existing bitfields they will be packed together provided they do not conflict, otherwise the conflict rule above applies.
Supported packing for little-endian fills lsb first, whereas big-endian fills msb first. Insertion behavior may not work as expected if packing rules differ from this.
Zero length bitfields may be inserted although they have no real affect for unaligned structures. Only the resulting byte offset within the structure is of significance in determining its' ordinal placement.
- Specified by:
insertBitFieldAt
in interfaceStructure
- Parameters:
byteOffset
- the first byte offset within this structure which corresponds to the first byte of the specified storage unit identified by its byteWidth.byteWidth
- the storage unit width which contains the bitfield. Must be large enough to contain the specified bitSize and corresponding bitOffset. The actual component size used will be recomputed during insertion.bitOffset
- corresponds to the bitfield left-shift amount with the storage unit when viewed as big-endian. The final offset may be reduced based upon the minimal storage size determined during insertion.baseDataType
- the bitfield base datatype (certain restrictions apply).bitSize
- the bitfield size in bits. A bitSize of 0 may be specified although its name will be ignored.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the componentDataType created whose associated data type will be BitFieldDataType.
- Throws:
InvalidDataTypeException
- if the specified data type is not a valid base type for bitfields.
-
deleteAtOffset
public void deleteAtOffset(int offset)
Description copied from interface:Structure
Deletes the component containing the specified offset in this structure. If the offset corresponds to a bit-field, all bit-fields whose base type group contains the offset will be removed.- Specified by:
deleteAtOffset
in interfaceStructure
- Parameters:
offset
- the byte offset into the structure where the datatype is to be deleted.
-
isEquivalent
public boolean isEquivalent(DataType dataType)
Description copied from interface:DataType
Returns true if the given dataType is equivalent to this dataType. The precise meaning of "equivalent" is dataType dependent.- Specified by:
isEquivalent
in interfaceDataType
- Parameters:
dataType
- the dataType being tested for equivalence.- Returns:
- true if the if the given dataType is equivalent to this dataType.
-
dataTypeSizeChanged
public void dataTypeSizeChanged(DataType dt)
Description copied from interface:DataType
Notification that the given dataType's size has changed. DataTypes may need to make internal changes in response.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeSizeChanged
in interfaceDataType
- Overrides:
dataTypeSizeChanged
in classAbstractDataType
- Parameters:
dt
- the dataType that has changed.
-
dataTypeAlignmentChanged
public void dataTypeAlignmentChanged(DataType dt)
Description copied from interface:Composite
The overall (external) alignment changed for the specified data type. In other words, the data type has a different alignment when placed inside other structures.- Specified by:
dataTypeAlignmentChanged
in interfaceComposite
- Parameters:
dt
- the data type whose alignment changed.
-
copy
public DataType copy(DataTypeManager dtm)
Description copied from interface:DataType
Returns a new instance of this DataType with a new identity. Note: for built-in DataType's, clone and copy should have the same affect.
-
clone
public DataType clone(DataTypeManager dtm)
Description copied from interface:DataType
Returns a new instance of this DataType with its universalID and SourceArchive identity retained. Note: for built-in DataType's, clone and copy should have the same affect.
-
clearComponent
public void clearComponent(int index)
Description copied from interface:Structure
Clears the defined component at the given component index. Clearing a component causes a defined component to be replaced with a number of undefined dataTypes to offset the removal of the defined dataType.- Specified by:
clearComponent
in interfaceStructure
- Parameters:
index
- the index of the component to clear.
-
replaceWith
public void replaceWith(DataType dataType)
Replaces the internal components of this structure with components of the given structure.- Specified by:
replaceWith
in interfaceDataType
- Overrides:
replaceWith
in classDataTypeImpl
- Parameters:
dataType
- the structure to get the component information from.- Throws:
java.lang.IllegalArgumentException
- if any of the component data types are not allowed to replace a component in this composite data type. For example, suppose dt1 contains dt2. Therefore it is not valid to replace a dt2 component with dt1 since this would cause a cyclic dependency.
-
dataTypeDeleted
public void dataTypeDeleted(DataType dt)
Description copied from interface:DataType
Informs this dataType that the given dataType has been deleted.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeDeleted
in interfaceDataType
- Overrides:
dataTypeDeleted
in classAbstractDataType
- Parameters:
dt
- the dataType that has been deleted.
-
dataTypeReplaced
public void dataTypeReplaced(DataType oldDt, DataType replacementDt)
Description copied from interface:DataType
Informs this data type that the given oldDT has been replaced with newDT
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeReplaced
in interfaceDataType
- Overrides:
dataTypeReplaced
in classAbstractDataType
- Parameters:
oldDt
- old data typereplacementDt
- new data type
-
getDefinedComponents
public DataTypeComponent[] getDefinedComponents()
Description copied from interface:Structure
Returns the list of components that are defined. (As opposed to "filler" undefined bytes.). Any trailing flexible array component will be omitted.- Specified by:
getDefinedComponents
in interfaceStructure
-
getComponents
public DataTypeComponent[] getComponents()
Description copied from interface:Structure
Returns a list of all components that make up this data type excluding any trailing flexible array component if present.- Specified by:
getComponents
in interfaceComposite
- Specified by:
getComponents
in interfaceStructure
- Returns:
- an array containing the components
-
replace
public DataTypeComponent replace(int index, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Description copied from interface:Structure
Replaces the component at the given component index with a new component of the indicated data type.- Specified by:
replace
in interfaceStructure
- Parameters:
index
- the index where the datatype is to be replaced.dataType
- the datatype to insert.length
- the length to associate with the dataType. For fixed length types a length <= 0 will use the length of the resolved dataType.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the new componentDataType at the index.
-
replace
public final DataTypeComponent replace(int index, DataType dataType, int length)
Description copied from interface:Structure
Replaces the component at the given component index with a new component of the indicated data type.- Specified by:
replace
in interfaceStructure
- Parameters:
index
- the index where the datatype is to be replaced.dataType
- the datatype to insert.length
- the length of the dataType to insert. For fixed length types a length <= 0 will use the length of the resolved dataType.- Returns:
- the new componentDataType at the index.
-
replaceAtOffset
public DataTypeComponent replaceAtOffset(int offset, DataType dataType, int length, java.lang.String componentName, java.lang.String comment)
Description copied from interface:Structure
Replaces the component at the specified byte offset with a new component of the indicated data type. If the offset corresponds to a bit-field, all bit-fields at that offset will be removed and replaced by the specified component. Keep in mind bit-field or any component removal must clear sufficient space for an unaligned structure to complete the replacement.- Specified by:
replaceAtOffset
in interfaceStructure
- Parameters:
offset
- the byte offset into the structure where the datatype is to be replaced.dataType
- the datatype to insert.length
- the length to associate with the dataType. For fixed length types a length <= 0 will use the length of the resolved dataType.componentName
- the field name to associate with this component.comment
- the comment to associate with this component.- Returns:
- the new componentDataType at the index.
-
getNumUndefinedBytes
protected int getNumUndefinedBytes(int index)
Gets the number of Undefined bytes beginning at the indicated component index. Undefined bytes that have a field name or comment specified are also included.- Parameters:
index
- the component index to begin checking at.- Returns:
- the number of contiguous undefined bytes
-
dataTypeNameChanged
public void dataTypeNameChanged(DataType dt, java.lang.String oldName)
Description copied from interface:DataType
Informs this data type that its name has changed from the indicated old name.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Specified by:
dataTypeNameChanged
in interfaceDataType
- Overrides:
dataTypeNameChanged
in classAbstractDataType
- Parameters:
dt
- the data type whose name changedoldName
- the data type's old name
-
dependsOn
public boolean dependsOn(DataType dt)
Description copied from interface:DataType
Returns true if this dataType depends on the existence of the given dataType. For example byte[] depends on byte. If byte were deleted, then byte[] would also be deleted.- Specified by:
dependsOn
in interfaceDataType
- Overrides:
dependsOn
in classAbstractDataType
- Parameters:
dt
- the dataType to test that this dataType depends on.
-
deleteAll
public void deleteAll()
Description copied from interface:Structure
Remove all components from this structure, effectively setting the length to zero.
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix()
Description copied from interface:DataType
Returns the appropriate string to use as the default label prefix in the absence of any data.- Specified by:
getDefaultLabelPrefix
in interfaceDataType
- Overrides:
getDefaultLabelPrefix
in classAbstractDataType
- Returns:
- the default label prefix or null if none specified.
-
realign
public void realign()
Description copied from interface:Composite
Updates the composite to any changes in the data organization. If the composite is not internally aligned, this method does nothing.
-
pack
public void pack(int packingSize) throws InvalidInputException
- Specified by:
pack
in interfaceStructure
- Throws:
InvalidInputException
-
adjustComponents
protected boolean adjustComponents()
Adjust the alignment, packing and padding of components within this structure based upon the current alignment and packing attributes for this structure. This method should be called to fix up the layout of the internal components of the structure after other code has changed the attributes of the structure.
When switching between internally aligned and unaligned this method corrects the component ordinal numbering also.- Returns:
- true if the structure was changed by this method.
-
adjustInternalAlignment
public void adjustInternalAlignment()
Description copied from class:CompositeDataTypeImpl
Adjusts the internal alignment of components within this composite based on the current settings of the internal alignment, packing, alignment type and minimum alignment value. This method should be called whenever any of the above settings are changed or whenever a components data type is changed or a component is added or removed.- Specified by:
adjustInternalAlignment
in classCompositeDataTypeImpl
-
hasFlexibleArrayComponent
public boolean hasFlexibleArrayComponent()
Description copied from interface:Structure
Determine if a trailing flexible array component has been defined.- Specified by:
hasFlexibleArrayComponent
in interfaceStructure
- Returns:
- true if trailing flexible array component has been defined.
-
getFlexibleArrayComponent
public DataTypeComponent getFlexibleArrayComponent()
Description copied from interface:Structure
Get the optional trailing flexible array component associated with this structure.- Specified by:
getFlexibleArrayComponent
in interfaceStructure
- Returns:
- optional trailing flexible array component associated with this structure or null if not present.
-
setFlexibleArrayComponent
public DataTypeComponent setFlexibleArrayComponent(DataType flexType, java.lang.String name, java.lang.String comment)
Description copied from interface:Structure
Set the optional trailing flexible array component associated with this structure.- Specified by:
setFlexibleArrayComponent
in interfaceStructure
- Parameters:
flexType
- the flexible array dataType (example: for 'char[0]' the type 'char' should be specified)name
- component field name or null for default namecomment
- component comment- Returns:
- updated flexible array component
-
clearFlexibleArrayComponent
public void clearFlexibleArrayComponent()
Description copied from interface:Structure
Remove the optional trailing flexible array component associated with this structure.- Specified by:
clearFlexibleArrayComponent
in interfaceStructure
-
dumpComponents
protected void dumpComponents(java.lang.StringBuilder buffer, java.lang.String pad)
Description copied from class:CompositeDataTypeImpl
Dump all components for use inCompositeDataTypeImpl.toString()
representation.- Overrides:
dumpComponents
in classCompositeDataTypeImpl
- Parameters:
buffer
- string bufferpad
- padding to be used with each component output line
-
-