Package ghidra.util.data
Class DataTypeParser
java.lang.Object
ghidra.util.data.DataTypeParser
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionDataTypeParser
(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 TypeMethodDescriptionstatic void
ensureIsAllowableType
(DataType dt, DataTypeParser.AllowedDataTypes allowedTypes) Throws exception if the data type does not match the specifiedDataTypeParser.AllowedDataTypes
.Parse a data-type string specificationparse
(String dataTypeString, CategoryPath category) Parse a data type string specification with category path.Parse a data type string specification using the specified baseDatatype.
-
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 nullallowedTypes
- 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 nulldestinationDataTypeManager
- target data-type manager, or nulldataTypeManagerService
- data-type manager tool service, or nullallowedTypes
- constrains which data-types may be parsed- See Also:
-
-
Method Details
-
parse
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 maxSizeCancelledException
- 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 maxSizeCancelledException
- 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:
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.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.- Returns:
- parsed data-type or null if not found
- Throws:
InvalidDataTypeException
- if data-type string is invalid or length exceeds specified maxSizeCancelledException
- 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 specifiedDataTypeParser.AllowedDataTypes
.- Parameters:
dt
-DataType
to checkallowedTypes
-enum
specifying what category of data types are ok- Throws:
InvalidDataTypeException
- if dt violates the specified allowedTypes
-