com.jniwrapper
Class ArithmeticalPointer

java.lang.Object
  extended by com.jniwrapper.Parameter
      extended by com.jniwrapper.Pointer
          extended by com.jniwrapper.ArithmeticalPointer
All Implemented Interfaces:
PointerParameter

public class ArithmeticalPointer
extends Pointer

Pointer to a place within an allocated structure that handles reading and writing of offset pointer values. A referenced object is always read and written at the same location.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jniwrapper.Pointer
Pointer.Const, Pointer.OutOnly, Pointer.Void
 
Field Summary
 
Fields inherited from class com.jniwrapper.Pointer
POINTER_LENGTH
 
Fields inherited from class com.jniwrapper.Parameter
LICENSE_TYPE, V
 
Constructor Summary
ArithmeticalPointer(Parameter ref)
          Constructs a pointer to a given object.
 
Method Summary
 void add(int i)
          Offsets this pointer by i bytes forward.
 int getArithmeticOffset()
          Returns offset in bytes of this pointer from its initial value.
protected  void readPointer(DataBuffer stackBuffer, int offset)
          Reads a pointer value and referenced object.
 void subtract(int i)
          Offsets this pointer by i bytes backward.
protected  void writePointer(DataBuffer stackBuffer, int offset)
          Writes a pointer value using pointer arithmetic offset.
 
Methods inherited from class com.jniwrapper.Pointer
acceptIOPerformer, asTypedPointer, asVoidPointer, castTo, castTo, checkMemHandleLength, clone, equals, getDebugInfo, getLength, getParameterClass, getPointerHandle, getReferencedObject, isNull, pop, push, read, read, readReferencedObject, setExternalSource, setNull, setReferencedObject, setReferencedObject, write, write, writeReferencedObject
 
Methods inherited from class com.jniwrapper.Parameter
asReturnValue, dataBufferAssigned, getAlignedLength, getAlignmentRequirement, getDataBuffer, getDataBufferOffset, hashCode, indent, read, setDataBuffer, toByteArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArithmeticalPointer

public ArithmeticalPointer(Parameter ref)
Constructs a pointer to a given object. The new pointer initially points to the object start location.

Parameters:
ref - a referenced object
Method Detail

add

public void add(int i)
Offsets this pointer by i bytes forward.

Parameters:
i - byte offset

subtract

public void subtract(int i)
Offsets this pointer by i bytes backward.

Parameters:
i - byte offset

getArithmeticOffset

public int getArithmeticOffset()
Returns offset in bytes of this pointer from its initial value.


writePointer

protected void writePointer(DataBuffer stackBuffer,
                            int offset)
                     throws MemoryAccessViolationException
Writes a pointer value using pointer arithmetic offset. The written value is (original_pointer_value + arithmetic_offset).

Note: The referenced object will be written by the original pointer, disregarding the offset value.

Overrides:
writePointer in class Pointer
Parameters:
stackBuffer - the buffer to write into
offset - the offset in the buffer to write pointer at
Throws:
MemoryAccessViolationException

readPointer

protected void readPointer(DataBuffer stackBuffer,
                           int offset)
                    throws MemoryAccessViolationException
Reads a pointer value and referenced object. The offset value is updated if needed, the referenced object location is not.

Overrides:
readPointer in class Pointer
Throws:
MemoryAccessViolationException