Package ghidra.app.util.bin.format.golang.structmapping

# Class StructureMappingInfo<T>

java.lang.Object
ghidra.app.util.bin.format.golang.structmapping.StructureMappingInfo<T>

Type Parameters:
  `T` - the class that is being mapped into a structure

public class StructureMappingInfo<T> extends Object
Contains immutable information about a structure mapped class needed to deserialize a new object from the data found in a Ghidra program.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `assignContextFieldValues(StructureContext<T> context)`
  Initializes any `ContextField` fields in a new structure instance.
  `Structure`
  `createStructureDataType(StructureContext<T> context)`
  Creates a new customized `structure data type` for a variable length structure mapped class.
  `static <T> StructureMappingInfo<T>`
  `fromClass(Class<T> targetClass, Structure structDataType)`
  Returns the mapping info for a class, using annotations found in that class.
  `List<Method>`
  `getAfterMethods()`
  `String`
  `getDescription()`
  `List<FieldMappingInfo<T>>`
  `getFields()`
  `ghidra.app.util.bin.format.golang.structmapping.StructureMappingInfo.ObjectInstanceCreator<T>`
  `getInstanceCreator()`
  `List<StructureMarkupFunction<T>>`
  `getMarkupFuncs()`
  `Structure`
  `getStructureDataType()`
  `static String`
  `getStructureDataTypeNameForClass(Class<?> targetClass)`
  Returns the name of the structure data type that will define the binary layout of the mapped fields in the target class.
  `int`
  `getStructureLength()`
  `String`
  `getStructureName()`
  `Class<T>`
  `getTargetClass()`
  `void`
  `readStructure(StructureContext<T> context)`
  Deserializes a structure mapped instance by assigning values to its `@FieldMapping mapped` java fields.
  `StructureContext<T>`
  `recoverStructureContext(T structureInstance)`
  Reaches into a structure mapped instance and extracts its StructureContext field value.

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

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

- ## Method Details

  - ### getStructureDataTypeNameForClass

    public static String getStructureDataTypeNameForClass(Class<?> targetClass)
    Returns the name of the structure data type that will define the binary layout of the mapped fields in the target class.
    Parameters:
      `targetClass` - structure mapped class
    Returns:
      the structure name

  - ### fromClass

    public static <T> StructureMappingInfo<T> fromClass(Class<T> targetClass, Structure structDataType)
    Returns the mapping info for a class, using annotations found in that class.
    Type Parameters:
      `T` - structure mapped class
    Parameters:
      `targetClass` - structure mapped class
      `structDataType` - Ghidra `DataType` that defines the binary layout of the mapped fields of the class, or null if this is a self-reading `StructureReader` class
    Returns:
      new `StructureMappingInfo` for the specified class
    Throws:
      `IllegalArgumentException` - if targetClass isn't tagged as a structure mapped class

  - ### getDescription

    public String getDescription()

  - ### getStructureDataType

    public Structure getStructureDataType()

  - ### getStructureName

    public String getStructureName()

  - ### getStructureLength

    public int getStructureLength()

  - ### getTargetClass

    public Class<T> getTargetClass()

  - ### getInstanceCreator

    public ghidra.app.util.bin.format.golang.structmapping.StructureMappingInfo.ObjectInstanceCreator<T> getInstanceCreator()

  - ### getFields

    public List<FieldMappingInfo<T>> getFields()

  - ### getAfterMethods

    public List<Method> getAfterMethods()

  - ### readStructure

    public void readStructure(StructureContext<T> context) throws IOException
    Deserializes a structure mapped instance by assigning values to its `@FieldMapping mapped` java fields.
    Parameters:
      `context` - `StructureContext`
    Throws:
      `IOException` - if error reading the structure

  - ### getMarkupFuncs

    public List<StructureMarkupFunction<T>> getMarkupFuncs()

  - ### createStructureDataType

    public Structure createStructureDataType(StructureContext<T> context) throws IOException
    Creates a new customized `structure data type` for a variable length structure mapped class.
    Parameters:
      `context` - `StructureContext` of a variable length structure mapped instance
    Returns:
      new `structure data type` with a name that encodes the size information of the variable length fields
    Throws:
      `IOException` - if error creating the Ghidra data type

  - ### recoverStructureContext

    public StructureContext<T> recoverStructureContext(T structureInstance)
    Reaches into a structure mapped instance and extracts its StructureContext field value.
    Parameters:
      `structureInstance` - instance to query
    Returns:
      `StructureContext`, or null if error extracting value

  - ### assignContextFieldValues

    public void assignContextFieldValues(StructureContext<T> context) throws IOException
    Initializes any `ContextField` fields in a new structure instance.
    Parameters:
      `context` - `StructureContext`
    Throws:
      `IOException` - if error assigning values to context fields in the structure mapped instance