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`

public interface Enum extends DataType

- ## 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 Type
  Method
  Description
  `void`
  `add(String name, long value)`
  Add a enum entry.
  `void`
  `add(String name, long value, String comment)`
  Add a enum entry.
  `boolean`
  `contains(long value)`
  Returns true if this enum has an entry with the given value.
  `boolean`
  `contains(String name)`
  Returns true if this enum has an entry with the given name.
  `String`
  `getComment(String name)`
  Get the comment for the given name.
  `int`
  `getCount()`
  Get the number of entries in this Enum.
  `long`
  `getMaxPossibleValue()`
  Returns the maximum value that this enum can represent based on its size and signedness.
  `int`
  `getMinimumPossibleLength()`
  Returns the smallest length (size in bytes) this enum can be and still represent all of it's current values.
  `long`
  `getMinPossibleValue()`
  Returns the maximum value that this enum can represent based on its size and signedness.
  `String`
  `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.
  `String`
  `getRepresentation(BigInteger bigInt, Settings settings, int bitLength)`
  Get enum representation of the big-endian value.
  `EnumSignedState`
  `getSignedState()`
  Returns the signed state.
  `long`
  `getValue(String name)`
  Get the value for the given name.
  `long[]`
  `getValues()`
  Get the values of the enum entries.
  `boolean`
  `isSigned()`
  Returns true if the enum contains at least one negative value.
  `void`
  `remove(String name)`
  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

    long getValue(String name) throws NoSuchElementException
    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

    String getName(long value)
    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

    String[] getNames(long value)
    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

    String getComment(String name)
    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

    void add(String name, long value)
    Add a enum entry.
    Parameters:
      `name` - name of the new entry
      `value` - value of the new entry

  - ### add

    void add(String name, long value, String comment)
    Add a enum entry.
    Parameters:
      `name` - name of the new entry
      `value` - value of the new entry
      `comment` - comment of the new entry

  - ### remove

    void remove(String name)
    Remove the enum entry with the given name.
    Parameters:
      `name` - name of entry to remove.

  - ### setDescription

    void setDescription(String description)
    Set the description for this Enum.
    Specified by:
      `setDescription` in interface `DataType`
    Parameters:
      `description` - the description

  - ### getRepresentation

    String getRepresentation(BigInteger bigInt, Settings settings, int bitLength)
    Get enum representation of the big-endian value.
    Parameters:
      `bigInt` - BigInteger value with the appropriate sign
      `settings` - integer format settings (PADDING, FORMAT, etc.)
      `bitLength` - the bit length
    Returns:
      formatted integer string

  - ### contains

    boolean contains(String name)
    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