Package ghidra.program.model.data
Interface DataType
-
- All Known Subinterfaces:
Array
,ArrayStringable
,BuiltInDataType
,Composite
,DataTypeWithCharset
,Dynamic
,Enum
,FactoryDataType
,FunctionDefinition
,Pointer
,Structure
,TypeDef
,Union
- All Known Implementing Classes:
AbstractComplexDataType
,AbstractDataType
,AbstractFloatDataType
,AbstractIntegerDataType
,AbstractStringDataType
,AIFFDataType
,AlignmentDataType
,ArrayDataType
,AUDataType
,BadDataType
,BitFieldDataType
,BitmapResourceDataType
,BooleanDataType
,BuiltIn
,ByteDataType
,CharDataType
,CliAbstractSig.CliTypeCodeDataType
,CliBlobMarshalSpec.CliNativeTypeDataType
,CliFlags.CliEnumAssemblyFlags
,CliFlags.CliEnumAssemblyHashAlgorithm
,CliFlags.CliEnumEventAttributes
,CliFlags.CliEnumFieldAttributes
,CliFlags.CliEnumFileAttributes
,CliFlags.CliEnumGenericParamAttributes
,CliFlags.CliEnumManifestResourceAttributes
,CliFlags.CliEnumMethodAttributes
,CliFlags.CliEnumMethodImplAttributes
,CliFlags.CliEnumMethodSemanticsAttributes
,CliFlags.CliEnumParamAttributes
,CliFlags.CliEnumPInvokeAttributes
,CliFlags.CliEnumPropertyAttributes
,CliFlags.CliEnumTypeAttributes
,Complex16DataType
,Complex32DataType
,Complex8DataType
,CompositeDataTypeImpl
,CountedDynamicDataType
,DataTypeImpl
,DefaultDataType
,DialogResourceDataType
,DoubleComplexDataType
,DoubleDataType
,DWordDataType
,DynamicDataType
,ElfDataType
,EnumDataType
,FactoryStructureDataType
,FileTimeDataType
,Float10DataType
,Float16DataType
,Float2DataType
,Float4DataType
,Float8DataType
,FloatComplexDataType
,FloatDataType
,FunctionDefinitionDataType
,FunctionSignatureImpl
,GenericDataType
,GifDataType
,GroupIconResourceDataType
,GuidDataType
,HTMLResourceDataType
,IconMaskResourceDataType
,IconResourceDataType
,ImageBaseOffset32DataType
,ImageBaseOffset64DataType
,ImageCor20Header.ImageCor20Flags
,IndexedDynamicDataType
,Integer16DataType
,Integer3DataType
,Integer5DataType
,Integer6DataType
,Integer7DataType
,IntegerDataType
,JPEGDataType
,LongDataType
,LongDoubleComplexDataType
,LongDoubleDataType
,LongLongDataType
,MacintoshTimeStampDataType
,MenuResourceDataType
,MissingBuiltInDataType
,MUIResourceDataType
,PascalString255DataType
,PascalStringDataType
,PascalUnicodeDataType
,PeDataType
,PERichTableDataType
,PngDataType
,Pointer16DataType
,Pointer24DataType
,Pointer32DataType
,Pointer40DataType
,Pointer48DataType
,Pointer56DataType
,Pointer64DataType
,Pointer8DataType
,PointerDataType
,QWordDataType
,RepeatCountDataType
,RepeatedDynamicDataType
,RepeatedStringDataType
,RTTI0DataType
,RTTI1DataType
,RTTI2DataType
,RTTI3DataType
,RTTI4DataType
,RTTIDataType
,SegmentedCodePointerDataType
,ShiftedAddressDataType
,ShortDataType
,SignedByteDataType
,SignedCharDataType
,SignedDWordDataType
,SignedQWordDataType
,SignedWordDataType
,StringDataType
,StringUTF8DataType
,StructureDataType
,StructuredDynamicDataType
,TerminatedStringDataType
,TerminatedUnicode32DataType
,TerminatedUnicodeDataType
,TypedefDataType
,Undefined
,Undefined1DataType
,Undefined2DataType
,Undefined3DataType
,Undefined4DataType
,Undefined5DataType
,Undefined6DataType
,Undefined7DataType
,Undefined8DataType
,Unicode32DataType
,UnicodeDataType
,UnionDataType
,UnsignedCharDataType
,UnsignedInteger16DataType
,UnsignedInteger3DataType
,UnsignedInteger5DataType
,UnsignedInteger6DataType
,UnsignedInteger7DataType
,UnsignedIntegerDataType
,UnsignedLongDataType
,UnsignedLongLongDataType
,UnsignedShortDataType
,VoidDataType
,WAVEDataType
,WEVTResourceDataType
,WideChar16DataType
,WideChar32DataType
,WideCharDataType
,WordDataType
public interface DataType
The interface that all data types must implement.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONFLICT_SUFFIX
static DataType
DEFAULT
static long
NO_LAST_CHANGE_TIME
static long
NO_SOURCE_SYNC_TIME
static DataType
VOID
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addParent(DataType dt)
Inform this data type that it has the given parent
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!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
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 newDt)
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.boolean
dependsOn(DataType dt)
Returns true if this dataType depends on the existence of the given dataType.int
getAlignment()
Gets the alignment to be used when aligning this data type within another data type.CategoryPath
getCategoryPath()
Gets the categoryPath associated with this data typeDataOrganization
getDataOrganization()
Returns the DataOrganization associated with this data-typeDataTypeManager
getDataTypeManager()
Returns the DataTypeManager that is associated with this dataType.DataTypePath
getDataTypePath()
Returns the dataTypePath for this dataType;java.lang.String
getDefaultAbbreviatedLabelPrefix()
Returns the prefix to use for this datatype when an abbreviated prefix is desired.java.lang.String
getDefaultLabelPrefix()
Returns the appropriate string to use as the default label prefix in the absence of any data.java.lang.String
getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options)
Returns the appropriate string to use as the default label prefix.java.lang.String
getDefaultOffcutLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options, int offcutOffset)
Returns the appropriate string to use as the default label prefix, taking into account the fact that there exists a reference to the data that references offcutLength bytes into this typeSettings
getDefaultSettings()
Gets the default settings for this data type.java.lang.String
getDescription()
Get a String briefly describing this DataType.java.lang.String
getDisplayName()
Gets the name for referring to this data type.java.net.URL
getDocs()
The getDocs method should provide a URL pointing to extended documentation for this DataType if it exists.long
getLastChangeTime()
Get the timestamp corresponding to the last time this type was changed within its data type managerlong
getLastChangeTimeInSourceArchive()
Get the timestamp corresponding to the last time this type was sync'd within its source archiveint
getLength()
Get the length (number of 8-bit bytes) of this DataType.java.lang.String
getMnemonic(Settings settings)
Get the mnemonic for this DataType.java.lang.String
getName()
Return that name of the data typeDataType[]
getParents()
java.lang.String
getPathName()
Returns the full category path name that includes this dataType's name.java.lang.String
getRepresentation(MemBuffer buf, Settings settings, int length)
Get bytes from memory in a printable format for this type.SettingsDefinition[]
getSettingsDefinitions()
Gets a list of all the settingsDefinitions used by this data type.SourceArchive
getSourceArchive()
Get the source archive where this type originatedUniversalID
getUniversalID()
Get the universal ID for this data type.java.lang.Object
getValue(MemBuffer buf, Settings settings, int length)
Get the data in the form of the appropriate Object for this DataType.java.lang.Class<?>
getValueClass(Settings settings)
Get the Class of the value to be returned by this data type.boolean
isDeleted()
Returns true if this data type has been deleted and is no longer validboolean
isDynamicallySized()
Indicates if this data-type is dynamically sized based upon DataOrganization.boolean
isEquivalent(DataType dt)
Returns true if the given dataType is equivalent to this dataType.boolean
isNotYetDefined()
Indicates if type has not yet been defined.void
removeParent(DataType dt)
Remove a parent data type
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!void
replaceWith(DataType dataType)
For dataTypes that support change, this method replaces the internals of this dataType with the internals of the given dataType.void
setCategoryPath(CategoryPath path)
void
setDefaultSettings(Settings settings)
Set the default settings for this data type.void
setDescription(java.lang.String description)
Sets a String briefly describing this DataType.void
setLastChangeTime(long lastChangeTime)
Sets the lastChangeTime for this dataType.void
setLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive)
Sets the lastChangeTimeInSourceArchive for this dataType.void
setName(java.lang.String name)
Sets the name of the dataTypevoid
setNameAndCategory(CategoryPath path, java.lang.String name)
Sets the name and category of a dataType at the same time.void
setSourceArchive(SourceArchive archive)
Set the source archive where this type originated
-
-
-
Field Detail
-
DEFAULT
static final DataType DEFAULT
-
VOID
static final DataType VOID
-
CONFLICT_SUFFIX
static final java.lang.String CONFLICT_SUFFIX
- See Also:
- Constant Field Values
-
NO_SOURCE_SYNC_TIME
static final long NO_SOURCE_SYNC_TIME
- See Also:
- Constant Field Values
-
NO_LAST_CHANGE_TIME
static final long NO_LAST_CHANGE_TIME
- See Also:
- Constant Field Values
-
-
Method Detail
-
isDynamicallySized
boolean isDynamicallySized()
Indicates if this data-type is dynamically sized based upon DataOrganization.
-
isNotYetDefined
boolean isNotYetDefined()
Indicates if type has not yet been defined. Such types will always return a size of 1. (example: empty structure)- Returns:
- true if this type is not yet defined.
-
getSettingsDefinitions
SettingsDefinition[] getSettingsDefinitions()
Gets a list of all the settingsDefinitions used by this data type.- Returns:
- a list of the settingsDefinitions used by this data type.
-
getDefaultSettings
Settings getDefaultSettings()
Gets the default settings for this data type.- Returns:
- the default settings for this dataType.
-
clone
DataType clone(DataTypeManager dtm)
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.- Parameters:
dtm
- the data-type manager instance whose data-organization should apply.
-
copy
DataType copy(DataTypeManager dtm)
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.- Parameters:
dtm
- the data-type manager instance whose data-organization should apply.
-
getCategoryPath
CategoryPath getCategoryPath()
Gets the categoryPath associated with this data type- Returns:
- the datatype's category path
-
getDataTypePath
DataTypePath getDataTypePath()
Returns the dataTypePath for this dataType;- Returns:
- the dataTypePath for this dataType;
-
setCategoryPath
void setCategoryPath(CategoryPath path) throws DuplicateNameException
- Parameters:
path
- set the categoryPath associated with this data type- Throws:
DuplicateNameException
-
getDataTypeManager
DataTypeManager getDataTypeManager()
Returns the DataTypeManager that is associated with this dataType. This association should not be used to indicate whether this DataType has been resolved, but is intended to indicate whether the appropriate DataOrganization is being used.
-
getDisplayName
java.lang.String getDisplayName()
Gets the name for referring to this data type.- Returns:
- generic name for this Data Type (i.e.: Word)
-
getName
java.lang.String getName()
Return that name of the data type
-
getPathName
java.lang.String getPathName()
Returns the full category path name that includes this dataType's name. If the category is null, then this just returns the dataType's name.
-
setName
void setName(java.lang.String name) throws InvalidNameException, DuplicateNameException
Sets the name of the dataType- Parameters:
name
- the new name for this dataType.- Throws:
InvalidNameException
- if the given name does not form a valid name.DuplicateNameException
-
setNameAndCategory
void setNameAndCategory(CategoryPath path, java.lang.String name) throws InvalidNameException, DuplicateNameException
Sets the name and category of a dataType at the same time.- Parameters:
path
- the new category path.name
- the new name- Throws:
InvalidNameException
- if the name is invalidDuplicateNameException
- if a dataType already exists with that name and
-
getMnemonic
java.lang.String getMnemonic(Settings settings)
Get the mnemonic for this DataType.- Returns:
- the mnemonic for this DataType.
-
getLength
int getLength()
Get the length (number of 8-bit bytes) of this DataType.- Returns:
- the length of this DataType
-
getDescription
java.lang.String getDescription()
Get a String briefly describing this DataType.- Returns:
- a one-liner describing this DataType.
-
setDescription
void setDescription(java.lang.String description) throws java.lang.UnsupportedOperationException
Sets a String briefly describing this DataType.- Parameters:
description
- a one-liner describing this DataType.- Throws:
java.lang.UnsupportedOperationException
- if the description is not allowed to be set for this data type.
-
getDocs
java.net.URL getDocs()
The getDocs method should provide a URL pointing to extended documentation for this DataType if it exists. A typical use would be to return a URL pointing to the programmers reference for this instruction or a page describing this data structure.- Returns:
- null - there is no URL documentation for this prototype.
-
getValue
java.lang.Object getValue(MemBuffer buf, Settings settings, int length)
Get the data in the form of the appropriate Object for this DataType. For instance if the data type is an AddressDT, return an Address object. a Byte, return a Scalar* (maybe this should be a Byte) a Float, return a Float- Parameters:
buf
- the data buffer.settings
- the settings to use.length
- the number of bytes to get the value from.- Returns:
- the data Object.
-
getValueClass
java.lang.Class<?> getValueClass(Settings settings)
Get the Class of the value to be returned by this data type.- Parameters:
settings
- the relevant settings to use or null for default.- Returns:
- Class of the value to be returned by this data type or null if it can vary or is unspecified. Types which correspond to a string or char array will return the String class.
-
getDefaultLabelPrefix
java.lang.String getDefaultLabelPrefix()
Returns the appropriate string to use as the default label prefix in the absence of any data.- Returns:
- the default label prefix or null if none specified.
-
getDefaultAbbreviatedLabelPrefix
java.lang.String getDefaultAbbreviatedLabelPrefix()
Returns the prefix to use for this datatype when an abbreviated prefix is desired. For example, some data types will built a large default label, at which is is more desirable to have a shortened prefix.- Returns:
- the prefix to use for this datatype when an abbreviated prefix is desired. May return null.
-
getDefaultLabelPrefix
java.lang.String getDefaultLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options)
Returns the appropriate string to use as the default label prefix.- Parameters:
buf
- memory buffer containing the bytes.settings
- the Settings objectlength
- the length of the data.options
- options for how to format the default label prefix.- Returns:
- the default label prefix or null if none specified.
-
getDefaultOffcutLabelPrefix
java.lang.String getDefaultOffcutLabelPrefix(MemBuffer buf, Settings settings, int len, DataTypeDisplayOptions options, int offcutOffset)
Returns the appropriate string to use as the default label prefix, taking into account the fact that there exists a reference to the data that references offcutLength bytes into this type- Parameters:
buf
- memory buffer containing the bytes.settings
- the Settings objectlength
- the length of the data.options
- options for how to format the default label prefix.offcutOffset
-- Returns:
- the default label prefix.
-
getRepresentation
java.lang.String getRepresentation(MemBuffer buf, Settings settings, int length)
Get bytes from memory in a printable format for this type.- 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.
-
isDeleted
boolean isDeleted()
Returns true if this data type has been deleted and is no longer valid- Returns:
- true if this data type has been deleted and is no longer valid.
-
isEquivalent
boolean isEquivalent(DataType dt)
Returns true if the given dataType is equivalent to this dataType. The precise meaning of "equivalent" is dataType dependent.- Parameters:
dt
- the dataType being tested for equivalence.- Returns:
- true if the if the given dataType is equivalent to this dataType.
-
dataTypeSizeChanged
void dataTypeSizeChanged(DataType dt)
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!!- Parameters:
dt
- the dataType that has changed.
-
dataTypeDeleted
void dataTypeDeleted(DataType dt)
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!!- Parameters:
dt
- the dataType that has been deleted.
-
dataTypeReplaced
void dataTypeReplaced(DataType oldDt, DataType newDt)
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!!- Parameters:
oldDt
- old data typenewDt
- new data type
-
setDefaultSettings
void setDefaultSettings(Settings settings)
Set the default settings for this data type.
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Parameters:
settings
- the settings to be used as this dataTypes default settings.
-
addParent
void addParent(DataType dt)
Inform this data type that it has the given parent
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Parameters:
dt
- parent data type
-
removeParent
void removeParent(DataType dt)
Remove a parent data type
TODO: This method is reserved for internal DB use and should be removed from the public DataType interface!!- Parameters:
dt
- parent data type
-
dataTypeNameChanged
void dataTypeNameChanged(DataType dt, java.lang.String oldName)
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!!- Parameters:
dt
- the data type whose name changedoldName
- the data type's old name
-
getParents
DataType[] getParents()
- Returns:
- an array of parents of this data type
-
getAlignment
int getAlignment()
Gets the alignment to be used when aligning this data type within another data type.- Returns:
- this data type's alignment.
-
dependsOn
boolean dependsOn(DataType dt)
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.- Parameters:
dt
- the dataType to test that this dataType depends on.
-
getSourceArchive
SourceArchive getSourceArchive()
Get the source archive where this type originated- Returns:
- source archive object
-
setSourceArchive
void setSourceArchive(SourceArchive archive)
Set the source archive where this type originated- Parameters:
archive
- source archive object
-
getLastChangeTime
long getLastChangeTime()
Get the timestamp corresponding to the last time this type was changed within its data type manager- Returns:
- timestamp of last change within data type manager
-
getLastChangeTimeInSourceArchive
long getLastChangeTimeInSourceArchive()
Get the timestamp corresponding to the last time this type was sync'd within its source archive- Returns:
- timestamp of last sync with source archive
-
getUniversalID
UniversalID getUniversalID()
Get the universal ID for this data type. This value is intended to be a unique identifier across all programs and archives. The same ID indicates that two data types were originally the same one. Keep in mind names, categories, and component makeup may differ and have changed since there origin.- Returns:
- data type UniversalID
-
replaceWith
void replaceWith(DataType dataType)
For dataTypes that support change, this method replaces the internals of this dataType with the internals of the given dataType. The dataTypes must be of the same "type" (i.e. structure can only be replacedWith another structure.- Parameters:
dataType
- the dataType that contains the internals to upgrade to.- Throws:
java.lang.UnsupportedOperationException
- if the dataType does not support change.java.lang.IllegalArgumentException
- if the given dataType is not the same type as this dataType.
-
setLastChangeTime
void setLastChangeTime(long lastChangeTime)
Sets the lastChangeTime for this dataType. Normally, this is updated automatically when a dataType is changed, but when committing or updating while synchronizing an archive, the lastChangeTime may need to be updated externally.- Parameters:
lastChangeTime
- the time to use as the lastChangeTime for this dataType
-
setLastChangeTimeInSourceArchive
void setLastChangeTimeInSourceArchive(long lastChangeTimeInSourceArchive)
Sets the lastChangeTimeInSourceArchive for this dataType. This is used by when a dataType change is committed back to its source archive.- Parameters:
lastChangeTimeInSourceArchive
- the time to use as the lastChangeTimeInSourceArchive for this dataType
-
getDataOrganization
DataOrganization getDataOrganization()
Returns the DataOrganization associated with this data-type
-
-