Package com.sun.jna.ptr

# Class ByReference

java.lang.Object
com.sun.jna.PointerType
com.sun.jna.ptr.ByReference

All Implemented Interfaces:
  `NativeMapped`

Direct Known Subclasses:
  `BaseTSD.ULONG_PTRByReference`, `ByteByReference`, `DoubleByReference`, `FloatByReference`, `HighLevelMonitorConfigurationAPI.MC_COLOR_TEMPERATURE.ByReference`, `HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE.ByReference`, `IntByReference`, `LibCAPI.size_t.ByReference`, `LongByReference`, `LowLevelMonitorConfigurationAPI.MC_VCP_CODE_TYPE.ByReference`, `NativeLongByReference`, `OaIdl._VARIANT_BOOLByReference`, `OaIdl.DISPIDByReference`, `OaIdl.MEMBERIDByReference`, `OaIdl.VARIANT_BOOLByReference`, `PointerByReference`, `ShortByReference`, `WinDef.BOOLByReference`, `WinDef.CHARByReference`, `WinDef.DWORDByReference`, `WinDef.LONGByReference`, `WinDef.LONGLONGByReference`, `WinDef.SCODEByReference`, `WinDef.UINTByReference`, `WinDef.ULONGByReference`, `WinDef.ULONGLONGByReference`, `WinDef.USHORTByReference`, `WinDef.WORDByReference`, `WinNT.HANDLEByReference`, `WinNT.PACLByReference`, `WinNT.PSIDByReference`, `WinReg.HKEYByReference`, `WTypes.BSTRByReference`, `WTypes.VARTYPEByReference`, `X11.AtomByReference`, `X11.WindowByReference`

public abstract class ByReference extends PointerType
Provides generic "pointer to type" functionality, often used in C code to return values to the caller in addition to a function result.

Derived classes must define `setValue(<T>)` and `<T> getValue()` methods which write to/read from the allocated memory.

This class derives from PointerType instead of Memory in order to restrict the API to only `getValue/setValue`.

NOTE: this class would ideally be replaced by a generic.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `ByReference(int dataSize)`
  Allocates memory at this pointer, to contain the pointed-to value.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `toString()`

  ### Methods inherited from class com.sun.jna.PointerType

  `equals, fromNative, getPointer, hashCode, nativeType, setPointer, toNative`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ByReference

    protected ByReference(int dataSize)
    Allocates memory at this pointer, to contain the pointed-to value.
    Parameters:
      `dataSize` - The number of bytes to allocate. Must match the byte size of `T` in the derived class `setValue(<T>)` and `<T> getValue()` methods.

- ## Method Details

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `PointerType`