Package org.bytedeco.javacpp
Class PointerPointer<P extends Pointer>
java.lang.Object
org.bytedeco.javacpp.Pointer
org.bytedeco.javacpp.PointerPointer<P>
- All Implemented Interfaces:
AutoCloseable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bytedeco.javacpp.Pointer
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.DeallocatorReference, Pointer.DeallocatorThread, Pointer.NativeDeallocator, Pointer.ProxyDeallocator, Pointer.ReferenceCounter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Logger
private P[]
This is just to keep references to Pointer objects and prevent premature deallocation.Fields inherited from class org.bytedeco.javacpp.Pointer
address, capacity, deallocatorThread, limit, maxBytes, maxPhysicalBytes, maxRetries, position
-
Constructor Summary
ConstructorsConstructorDescriptionPointerPointer
(byte[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(char[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(double[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(float[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(int[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(long size) Allocates a native array ofvoid*
of the given size.PointerPointer
(long[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(short[]... array) Allocates enough memory for the array of arrays and copies it.PointerPointer
(String... array) Allocates enough memory for the array of strings and copies it.PointerPointer
(String[] array, String charsetName) Allocates enough memory for the array of strings and copies it.PointerPointer
(String[] array, Charset charset) Allocates enough memory for the array of strings and copies it.PointerPointer
(P... array) Allocates enough memory for the array and copies it. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
allocateArray
(long size) capacity
(long capacity) Sets the capacity and returns this.get()
get
(long i) getPointer
(long i) ReturnsgetPointer(getClass(), i)
.getString
(long i) limit
(long limit) Sets the limit and returns this.position
(long position) Sets the position and returns this.put
(byte[]... array) put
(char[]... array) put
(double[]... array) Creates one by one a newDoublePointer
for eachdouble[]
, and writes them into the nativevoid*
array.put
(float[]... array) Creates one by one a newFloatPointer
for eachfloat[]
, and writes them into the nativevoid*
array.put
(int[]... array) put
(long[]... array) Copies the Pointer value to the i-th element of a native array.put
(short[]... array) Creates one by one a newShortPointer
for eachshort[]
, and writes them into the nativevoid*
array.Calls in effectmemcpy(this.address + this.position, p.address + p.position, length)
, wherelength = sizeof(p) * (p.limit - p.position)
.Writes the Pointer values into the nativevoid*
array.Methods inherited from class org.bytedeco.javacpp.Pointer
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, init, interruptDeallocatorThread, isNull, isNull, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
-
Field Details
-
logger
-
pointerArray
This is just to keep references to Pointer objects and prevent premature deallocation.
-
-
Constructor Details
-
PointerPointer
Allocates enough memory for the array of strings and copies it.- Parameters:
array
- the array of strings to copy- See Also:
-
PointerPointer
Allocates enough memory for the array of strings and copies it.- Parameters:
array
- the array of strings to copycharsetName
- the charset in which the bytes are encoded- Throws:
UnsupportedEncodingException
- See Also:
-
PointerPointer
Allocates enough memory for the array of strings and copies it.- Parameters:
array
- the array of strings to copycharset
- the charset in which the bytes are encoded- See Also:
-
PointerPointer
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 ofvoid*
of the given size.- Parameters:
size
- the number ofvoid*
elements to allocate
-
PointerPointer
public PointerPointer()- See Also:
-
PointerPointer
- See Also:
-
-
Method Details
-
allocateArray
private void allocateArray(long size) -
position
Description copied from class:Pointer
Sets the position and returns this. That makes thearray.position(i)
statement sort of equivalent to thearray[i]
statement in C++. -
limit
Description copied from class:Pointer
Sets the limit and returns this. Used to limit the size of an operation on this object. -
capacity
Description copied from class:Pointer
Sets the capacity and returns this. Should not be called more than once after allocation. -
getPointer
Description copied from class:Pointer
ReturnsgetPointer(getClass(), i)
.- Overrides:
getPointer
in classPointer
-
getString
- Returns:
get(BytePointer.class, i).getString()
- See Also:
-
getString
- Returns:
get(BytePointer.class, i).getString(charsetName)
- Throws:
UnsupportedEncodingException
- See Also:
-
getString
- Returns:
get(BytePointer.class, i).getString(charset)
- See Also:
-
putString
- Parameters:
array
- the array ofString
to read from- Returns:
- this
-
putString
public PointerPointer<P> putString(String[] array, String charsetName) throws UnsupportedEncodingException - Parameters:
array
- the array ofString
to read fromcharsetName
- the charset in which the bytes are encoded- Returns:
- this
- Throws:
UnsupportedEncodingException
-
putString
- Parameters:
array
- the array ofString
to read fromcharset
- the charset in which the bytes are encoded- Returns:
- this
-
put
Writes the Pointer values into the nativevoid*
array.- Parameters:
array
- the array of Pointer values to read from- Returns:
- this
-
put
- Parameters:
array
- the array ofbyte[]
to read from- Returns:
- this
-
put
Creates one by one a newShortPointer
for eachshort[]
, and writes them into the nativevoid*
array.- Parameters:
array
- the array ofshort[]
to read from- Returns:
- this
-
put
- Parameters:
array
- the array ofint[]
to read from- Returns:
- this
-
put
- Parameters:
array
- the array oflong[]
to read from- Returns:
- this
-
put
Creates one by one a newFloatPointer
for eachfloat[]
, and writes them into the nativevoid*
array.- Parameters:
array
- the array offloat[]
to read from- Returns:
- this
-
put
Creates one by one a newDoublePointer
for eachdouble[]
, and writes them into the nativevoid*
array.- Parameters:
array
- the array ofdouble[]
to read from- Returns:
- this
-
put
- Parameters:
array
- the array ofchar[]
to read from- Returns:
- this
-
get
- Returns:
get(0)
-
get
- Returns:
get(cls, 0)
-
get
- Returns:
- the i-th Pointer value of a native array
-
get
- Returns:
- in the given class the i-th Pointer value of a native array
-
put
Description copied from class:Pointer
Calls in effectmemcpy(this.address + this.position, p.address + p.position, length)
, wherelength = sizeof(p) * (p.limit - p.position)
. If limit == 0, it uses position + 1 instead. The way the methods were designed allows constructs such asthis.position(0).put(p.position(13).limit(42))
. -
put
Copies the Pointer value to the i-th element of a native array.- Parameters:
i
- the index into the arrayp
- the Pointer value to copy- Returns:
- this
-