T - public final class Field<T> extends java.lang.Object implements IDestructableField
There are two ways to use this. Callers can either use the "get" method to access the value of the field, or can use the public "offset" attribute to perform the reads manually. The get function is more convenient but allocates objects and so should probably not be used for frequently-accessed fields or primitive types that would end up being autoboxed unnecessarily.
| Modifier and Type | Field and Description |
|---|---|
ITypeFactory<T> |
factory |
protected int |
offset |
| Constructor and Description |
|---|
Field(ITypeFactory<T> objectFactory,
java.lang.String structName,
int fieldNumber) |
| Modifier and Type | Method and Description |
|---|---|
static <T> Field<T> |
create(StructDef<?> struct,
StructDef<T> fieldType)
Creates a new
Field in the given struct with the given type. |
void |
destruct(Nd nd,
long address) |
T |
get(Nd nd,
long address) |
int |
getAlignment()
Returns the required byte alignment for the field.
|
java.lang.String |
getFieldName()
Returns the name of the field.
|
int |
getOffset()
Returns the field offset, in bytes from the start of the struct.
|
int |
getRecordSize()
Returns the size of the field, in bytes.
|
boolean |
hasDestructor() |
protected void |
setFieldName(java.lang.String fieldName) |
void |
setOffset(int offset)
Sets the field offset (bytes from the start of the struct).
|
public final ITypeFactory<T> factory
protected int offset
public Field(ITypeFactory<T> objectFactory, java.lang.String structName, int fieldNumber)
public boolean hasDestructor()
public void destruct(Nd nd, long address)
destruct in interface IDestructableFieldpublic int getRecordSize()
IFieldgetRecordSize in interface IFieldpublic int getAlignment()
IFieldgetAlignment in interface IFieldpublic static <T> Field<T> create(StructDef<?> struct, StructDef<T> fieldType)
Field in the given struct with the given type.struct - the struct that will contain the newly-created field (must not have had
StructDef.done() called on it yet).fieldType - the data type for the contents of the newly created fieldprotected final void setFieldName(java.lang.String fieldName)
public final void setOffset(int offset)
IFieldpublic final int getOffset()
IFieldpublic final java.lang.String getFieldName()
IFieldgetFieldName in interface IField