Package ghidra.program.model.data
Interface Enum
- All Superinterfaces:
DataType
- All Known Implementing Classes:
CliAbstractSig.CliTypeCodeDataType
,CliBlobMarshalSpec.CliNativeTypeDataType
,CliBlobMarshalSpec.CliSafeArrayElemTypeDataType
,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
,EnumDataType
,ImageCor20Header.ImageCor20Flags
-
Field Summary
Fields inherited from interface ghidra.program.model.data.DataType
CONFLICT_SUFFIX, DEFAULT, NO_LAST_CHANGE_TIME, NO_SOURCE_SYNC_TIME, TYPEDEF_ATTRIBUTE_PREFIX, TYPEDEF_ATTRIBUTE_SUFFIX, VOID
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a enum entry.void
Add a enum entry.boolean
contains
(long value) Returns true if this enum has an entry with the given value.boolean
Returns true if this enum has an entry with the given name.getComment
(String name) Get the comment for the given name.int
getCount()
Get the number of entries in this Enum.long
Returns the maximum value that this enum can represent based on its size and signedness.int
Returns the smallest length (size in bytes) this enum can be and still represent all of it's current values.long
Returns the maximum value that this enum can represent based on its size and signedness.getName
(long value) Get the name for the given value.String[]
getNames()
Get the names of the enum entries.String[]
getNames
(long value) Returns all names that map to the given value.getRepresentation
(BigInteger bigInt, Settings settings, int bitLength) Get enum representation of the big-endian value.Returns the signed state.long
Get the value for the given name.long[]
Get the values of the enum entries.boolean
isSigned()
Returns true if the enum contains at least one negative value.void
Remove the enum entry with the given name.void
setDescription
(String description) Set the description for this Enum.Methods inherited from interface ghidra.program.model.data.DataType
addParent, clone, copy, dataTypeAlignmentChanged, dataTypeDeleted, dataTypeNameChanged, dataTypeReplaced, dataTypeSizeChanged, dependsOn, encodeRepresentation, encodeValue, getAlignedLength, getAlignment, getCategoryPath, getDataOrganization, getDataTypeManager, getDataTypePath, getDefaultAbbreviatedLabelPrefix, getDefaultLabelPrefix, getDefaultLabelPrefix, getDefaultOffcutLabelPrefix, getDefaultSettings, getDescription, getDisplayName, getDocs, getLastChangeTime, getLastChangeTimeInSourceArchive, getLength, getMnemonic, getName, getParents, getPathName, getRepresentation, getSettingsDefinitions, getSourceArchive, getTypeDefSettingsDefinitions, getUniversalID, getValue, getValueClass, hasLanguageDependantLength, isDeleted, isEncodable, isEquivalent, isNotYetDefined, isZeroLength, removeParent, replaceWith, setCategoryPath, setLastChangeTime, setLastChangeTimeInSourceArchive, setName, setNameAndCategory, setSourceArchive
-
Method Details
-
getValue
Get the value for the given name.- Parameters:
name
- name of the entry.- Returns:
- the value.
- Throws:
NoSuchElementException
- if the name does not exist in this Enum.
-
getName
Get the name for the given value.- Parameters:
value
- value of the enum entry.- Returns:
- null if the name with the given value was not found.
-
getNames
Returns all names that map to the given value.- Parameters:
value
- value for the enum entries.- Returns:
- all names; null if there is not name for the given value.
-
getComment
Get the comment for the given name.- Parameters:
name
- name of the entry.- Returns:
- the comment or the empty string if the name does not exist in this enum or if no comment is set.
-
getValues
long[] getValues()Get the values of the enum entries.- Returns:
- values sorted in ascending order
-
getNames
String[] getNames()Get the names of the enum entries. The returned names are first sorted by the enum int value, then sub-sorted by name value where there are multiple name values per int value.- Returns:
- the names of the enum entries.
-
getCount
int getCount()Get the number of entries in this Enum.- Returns:
- the number of entries in this Enum.
-
add
Add a enum entry.- Parameters:
name
- name of the new entryvalue
- value of the new entry
-
add
Add a enum entry.- Parameters:
name
- name of the new entryvalue
- value of the new entrycomment
- comment of the new entry
-
remove
Remove the enum entry with the given name.- Parameters:
name
- name of entry to remove.
-
setDescription
Set the description for this Enum.- Specified by:
setDescription
in interfaceDataType
- Parameters:
description
- the description
-
getRepresentation
Get enum representation of the big-endian value.- Parameters:
bigInt
- BigInteger value with the appropriate signsettings
- integer format settings (PADDING, FORMAT, etc.)bitLength
- the bit length- Returns:
- formatted integer string
-
contains
Returns true if this enum has an entry with the given name.- Parameters:
name
- the name to check for an entry- Returns:
- true if this enum has an entry with the given name
-
contains
boolean contains(long value) Returns true if this enum has an entry with the given value.- Parameters:
value
- the value to check for an entry- Returns:
- true if this enum has an entry with the given value
-
isSigned
boolean isSigned()Returns true if the enum contains at least one negative value. Internally, enums have three states, signed, unsigned, and none (can't tell from the values). If any of the values are negative, the enum is considered signed. If any of the values are large unsigned values (upper bit set), then it is considered unsigned. This method will return true if the enum is signed, and false if it is either unsigned or none (meaning that it doesn't matter for the values that are contained in the enum.- Returns:
- true if the enum contains at least one negative value
-
getSignedState
EnumSignedState getSignedState()Returns the signed state.- Returns:
- the signed state.
-
getMaxPossibleValue
long getMaxPossibleValue()Returns the maximum value that this enum can represent based on its size and signedness.- Returns:
- the maximum value that this enum can represent based on its size and signedness.
-
getMinPossibleValue
long getMinPossibleValue()Returns the maximum value that this enum can represent based on its size and signedness.- Returns:
- the maximum value that this enum can represent based on its size and signedness.
-
getMinimumPossibleLength
int getMinimumPossibleLength()Returns the smallest length (size in bytes) this enum can be and still represent all of it's current values. Note that that this will only return powers of 2 (1,2,4, or 8)- Returns:
- the smallest length (size in bytes) this enum can be and still represent all of it's current values
-