Class PointerPointer<P extends Pointer>

java.lang.Object
org.bytedeco.javacpp.Pointer
org.bytedeco.javacpp.PointerPointer<P>
All Implemented Interfaces:
AutoCloseable

@Properties(inherit=javacpp.class) public class PointerPointer<P extends Pointer> extends Pointer
The peer class to native pointers and arrays of void*. All operations take into account the position and limit, when appropriate.

To support higher levels of indirection, we can create out of the Pointer objects returned by get(long) additional PointerPointer objects.

  • Field Details

    • logger

      private static final Logger logger
    • pointerArray

      private P extends Pointer[] pointerArray
      This is just to keep references to Pointer objects and prevent premature deallocation.
  • Constructor Details

    • PointerPointer

      public PointerPointer(String... array)
      Allocates enough memory for the array of strings and copies it.
      Parameters:
      array - the array of strings to copy
      See Also:
    • PointerPointer

      public PointerPointer(String[] array, String charsetName) throws UnsupportedEncodingException
      Allocates enough memory for the array of strings and copies it.
      Parameters:
      array - the array of strings to copy
      charsetName - the charset in which the bytes are encoded
      Throws:
      UnsupportedEncodingException
      See Also:
    • PointerPointer

      public PointerPointer(String[] array, Charset charset)
      Allocates enough memory for the array of strings and copies it.
      Parameters:
      array - the array of strings to copy
      charset - the charset in which the bytes are encoded
      See Also:
    • PointerPointer

      public PointerPointer(P... array)
      Allocates enough memory for the array and copies it.
      Parameters:
      array - the array to copy
      See Also:
    • PointerPointer

      public PointerPointer(byte[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(short[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(int[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(long[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(float[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(double[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(char[]... array)
      Allocates enough memory for the array of arrays and copies it.
      Parameters:
      array - the array of arrays to copy
      See Also:
    • PointerPointer

      public PointerPointer(long size)
      Allocates a native array of void* of the given size.
      Parameters:
      size - the number of void* elements to allocate
    • PointerPointer

      public PointerPointer()
      See Also:
    • PointerPointer

      public PointerPointer(Pointer p)
      See Also:
  • Method Details

    • allocateArray

      private void allocateArray(long size)
    • position

      public PointerPointer<P> position(long position)
      Description copied from class: Pointer
      Sets the position and returns this. That makes the array.position(i) statement sort of equivalent to the array[i] statement in C++.
      Overrides:
      position in class Pointer
      Parameters:
      position - the new position
      Returns:
      this
      See Also:
    • limit

      public PointerPointer<P> limit(long limit)
      Description copied from class: Pointer
      Sets the limit and returns this. Used to limit the size of an operation on this object.
      Overrides:
      limit in class Pointer
      Parameters:
      limit - the new limit
      Returns:
      this
      See Also:
    • capacity

      public PointerPointer<P> capacity(long capacity)
      Description copied from class: Pointer
      Sets the capacity and returns this. Should not be called more than once after allocation.
      Overrides:
      capacity in class Pointer
      Parameters:
      capacity - the new capacity
      Returns:
      this
      See Also:
    • getPointer

      public PointerPointer<P> getPointer(long i)
      Description copied from class: Pointer
      Returns getPointer(getClass(), i).
      Overrides:
      getPointer in class Pointer
    • getString

      public String getString(long i)
      Returns:
      get(BytePointer.class, i).getString()
      See Also:
    • getString

      public String getString(long i, String charsetName) throws UnsupportedEncodingException
      Returns:
      get(BytePointer.class, i).getString(charsetName)
      Throws:
      UnsupportedEncodingException
      See Also:
    • getString

      public String getString(long i, Charset charset)
      Returns:
      get(BytePointer.class, i).getString(charset)
      See Also:
    • putString

      public PointerPointer<P> putString(String... array)
      Creates one by one a new BytePointer for each String, and writes them into the native void* array.
      Parameters:
      array - the array of String to read from
      Returns:
      this
    • putString

      public PointerPointer<P> putString(String[] array, String charsetName) throws UnsupportedEncodingException
      Creates one by one a new BytePointer for each String, and writes them into the native void* array.
      Parameters:
      array - the array of String to read from
      charsetName - the charset in which the bytes are encoded
      Returns:
      this
      Throws:
      UnsupportedEncodingException
    • putString

      public PointerPointer<P> putString(String[] array, Charset charset)
      Creates one by one a new BytePointer for each String, and writes them into the native void* array.
      Parameters:
      array - the array of String to read from
      charset - the charset in which the bytes are encoded
      Returns:
      this
    • put

      public PointerPointer<P> put(P... array)
      Writes the Pointer values into the native void* array.
      Parameters:
      array - the array of Pointer values to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(byte[]... array)
      Creates one by one a new BytePointer for each byte[], and writes them into the native void* array.
      Parameters:
      array - the array of byte[] to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(short[]... array)
      Creates one by one a new ShortPointer for each short[], and writes them into the native void* array.
      Parameters:
      array - the array of short[] to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(int[]... array)
      Creates one by one a new IntPointer for each int[], and writes them into the native void* array.
      Parameters:
      array - the array of int[] to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(long[]... array)
      Creates one by one a new LongPointer for each long[], and writes them into the native void* array.
      Parameters:
      array - the array of long[] to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(float[]... array)
      Creates one by one a new FloatPointer for each float[], and writes them into the native void* array.
      Parameters:
      array - the array of float[] to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(double[]... array)
      Creates one by one a new DoublePointer for each double[], and writes them into the native void* array.
      Parameters:
      array - the array of double[] to read from
      Returns:
      this
    • put

      public PointerPointer<P> put(char[]... array)
      Creates one by one a new CharPointer for each char[], and writes them into the native void* array.
      Parameters:
      array - the array of char[] to read from
      Returns:
      this
    • get

      public Pointer get()
      Returns:
      get(0)
    • get

      public P get(Class<P> cls)
      Returns:
      get(cls, 0)
    • get

      public Pointer get(long i)
      Returns:
      the i-th Pointer value of a native array
    • get

      public P get(Class<P> cls, long i)
      Returns:
      in the given class the i-th Pointer value of a native array
    • put

      public PointerPointer<P> put(Pointer p)
      Description copied from class: Pointer
      Calls in effect memcpy(this.address + this.position, p.address + p.position, length), where length = sizeof(p) * (p.limit - p.position). If limit == 0, it uses position + 1 instead. The way the methods were designed allows constructs such as this.position(0).put(p.position(13).limit(42)).
      Overrides:
      put in class Pointer
      Parameters:
      p - the Pointer from which to copy memory
      Returns:
      put(0, p)
    • put

      public PointerPointer<P> put(long i, Pointer p)
      Copies the Pointer value to the i-th element of a native array.
      Parameters:
      i - the index into the array
      p - the Pointer value to copy
      Returns:
      this