Package ghidra.util.data
Class DataTypeParser
- java.lang.Object
-
- ghidra.util.data.DataTypeParser
-
public class DataTypeParser extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
ensureIsAllowableType(DataType dt, DataTypeParser.AllowedDataTypes allowedTypes)
Throws exception if the data type does not match the specifiedDataTypeParser.AllowedDataTypes
.DataType
parse(java.lang.String dataTypeString)
Parse a data-type string specificationDataType
parse(java.lang.String dataTypeString, CategoryPath category)
Parse a data type string specification with category path.DataType
parse(java.lang.String dataTypeString, DataType suggestedBaseDataType)
Parse a data type string specification using the specified baseDatatype.
-
-
-
Constructor Detail
-
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:
DataTypeParser(DataTypeQueryService, AllowedDataTypes)
-
-
Method Detail
-
parse
public DataType parse(java.lang.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 maxSizeCancelledException
- parse cancelled through user interaction
-
parse
public DataType parse(java.lang.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(java.lang.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 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
-
-