Package ghidra.util.data

# Class DataTypeParser

java.lang.Object
ghidra.util.data.DataTypeParser

public class DataTypeParser extends Object

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `DataTypeParser.AllowedDataTypes`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DataTypeParser(DataTypeQueryService dataTypeManagerService, DataTypeParser.AllowedDataTypes allowedTypes)`
  A constructor that does not use the source or destination data type managers.
  `DataTypeParser(DataTypeManager sourceDataTypeManager, DataTypeManager destinationDataTypeManager, DataTypeQueryService dataTypeManagerService, DataTypeParser.AllowedDataTypes allowedTypes)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `ensureIsAllowableType(DataType dt, DataTypeParser.AllowedDataTypes allowedTypes)`
  Throws exception if the data type does not match the specified `DataTypeParser.AllowedDataTypes`.
  `DataType`
  `parse(String dataTypeString)`
  Parse a data-type string specification
  `DataType`
  `parse(String dataTypeString, CategoryPath category)`
  Parse a data type string specification with category path.
  `DataType`
  `parse(String dataTypeString, DataType suggestedBaseDataType)`
  Parse a data type string specification using the specified baseDatatype.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DataTypeParser

    public DataTypeParser(DataTypeQueryService dataTypeManagerService, DataTypeParser.AllowedDataTypes allowedTypes)
    A constructor that does not use the source or destination data type managers. In terms of the source data type manager, this means that all data type managers will be used when resolving data types.
    Parameters:
      `dataTypeManagerService` - data-type manager tool service, or null
      `allowedTypes` - constrains which data-types may be parsed

  - ### DataTypeParser

    public DataTypeParser(DataTypeManager sourceDataTypeManager, DataTypeManager destinationDataTypeManager, DataTypeQueryService dataTypeManagerService, DataTypeParser.AllowedDataTypes allowedTypes)
    Constructor
    Parameters:
      `sourceDataTypeManager` - preferred source data-type manager, or null
      `destinationDataTypeManager` - target data-type manager, or null
      `dataTypeManagerService` - data-type manager tool service, or null
      `allowedTypes` - constrains which data-types may be parsed
    See Also:
      - `DataTypeParser(DataTypeQueryService, AllowedDataTypes)`

- ## Method Details

  - ### parse

    public DataType parse(String dataTypeString) throws InvalidDataTypeException, CancelledException
    Parse a data-type string specification
    Parameters:
      `dataTypeString` - a known data-type name followed by zero or more pointer/array decorations.
    Returns:
      parsed data-type or null if not found
    Throws:
      `InvalidDataTypeException` - if data-type string is invalid or length exceeds specified maxSize
      `CancelledException` - parse cancelled through user interaction

  - ### parse

    public DataType parse(String dataTypeString, CategoryPath category) throws InvalidDataTypeException, CancelledException
    Parse a data type string specification with category path. If category is not null, the dataTypeManagerService will not be queried.
    Parameters:
      `dataTypeString` - a known data-type name followed by zero or more pointer/array decorations.
      `category` - known path of data-type or null if unknown
    Returns:
      parsed data-type or null if not found
    Throws:
      `InvalidDataTypeException` - if data type string is invalid or length exceeds specified maxSize
      `CancelledException` - parse cancelled through user interaction (only if parser constructed with service)

  - ### parse

    public DataType parse(String dataTypeString, DataType suggestedBaseDataType) throws InvalidDataTypeException, CancelledException
    Parse a data type string specification using the specified baseDatatype.
    Parameters:
      `suggestedBaseDataType` - base data type (may be null), this will be used as the base data-type if its name matches the base name in the specified dataTypeString.
      `dataTypeString` - a base data-type followed by a sequence of zero or more pointer/array decorations to be applied. The string may start with the baseDataType's name.
    Returns:
      parsed data-type or null if not found
    Throws:
      `InvalidDataTypeException` - if data-type string is invalid or length exceeds specified maxSize
      `CancelledException` - parse cancelled through user interaction (only if parser constructed with service)

  - ### ensureIsAllowableType

    public static void ensureIsAllowableType(DataType dt, DataTypeParser.AllowedDataTypes allowedTypes) throws InvalidDataTypeException
    Throws exception if the data type does not match the specified `DataTypeParser.AllowedDataTypes`.
    Parameters:
      `dt` - `DataType` to check
      `allowedTypes` - `enum` specifying what category of data types are ok
    Throws:
      `InvalidDataTypeException` - if dt violates the specified allowedTypes