java.lang.Object
io.qt.QNativePointer
Represents a native pointer.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The AutoDeleteMode enum describes how garbage collection of the QNativePointer handles the deletion of the native pointer.static class
static enum
The type of the pointer. -
Constructor Summary
ConstructorDescriptionCreates a native pointer of the specifiedtype
.QNativePointer
(QNativePointer.Type type, long size) Creates a native pointer to an array withsize
length of the specifiedtype
.QNativePointer
(QNativePointer.Type type, long size, int indirections) Creates a native pointer of the specifiedtype
. -
Method Summary
Modifier and TypeMethodDescriptionReturns the auto-delete mode of the pointer.boolean[]
If the native pointer is of boolean type, this function returns its values as array.boolean
booleanAt
(long pos) Returns the value of the native pointer at the specified position.boolean
If the native pointer is of boolean type, this function returns its value.byte[]
If the native pointer is of byte type, this function returns its values as array.byte
byteAt
(long pos) Returns the value of the native pointer at the specified position.byte
If the native pointer is of byte type, this function returns its value.char[]
If the native pointer is of char type, this function returns its values as array.char
charAt
(long pos) Returns the value of the native pointer at the specified position.char
If the native pointer is of char type, this function returns its value.static QNativePointer
createCharPointer
(String string) Creates a char* from the input stringstatic QNativePointer
createCharPointerPointer
(String[] strings) Creates a char** native pointer from the array of input strings.void
delete()
This function deletes the internal pointer.void
This function deletes elements in the array of this QNativePointer.double[]
If the native pointer is of double type, this function returns its values as array.double
doubleAt
(long pos) Returns the value of the native pointer at the specified position.double
If the native pointer is of double type, this function returns its value.float[]
If the native pointer is of float type, this function returns its values as array.float
floatAt
(long pos) Returns the value of the native pointer at the specified position.float
If the native pointer is of float type, this function returns its value.void
free()
This function deletes the internal pointer.static QNativePointer
fromArray
(boolean[] data) static QNativePointer
fromArray
(byte[] data) static QNativePointer
fromArray
(char[] data) static QNativePointer
fromArray
(double[] data) static QNativePointer
fromArray
(float[] data) static QNativePointer
fromArray
(int[] data) static QNativePointer
fromArray
(long[] data) static QNativePointer
fromArray
(short[] data) static QNativePointer
static QNativePointer
static QNativePointer
static QNativePointer
static QNativePointer
static QNativePointer
static QNativePointer
static QNativePointer
static QNativePointer
static <T extends QtObjectInterface>
QNativePointerfromArray
(T... array) static QNativePointer
fromBuffer
(Buffer buffer) static QNativePointer
fromNative
(long ptr, QNativePointer.Type type, long size, int indirections, boolean readOnly) This function creates a QNativePointer from an existing c++ pointer.static <T extends QtObjectInterface>
QNativePointerfromObject
(T object) int
Returns the number of indirections of the pointer.int[]
intArray()
If the native pointer is of int type, this function returns its values as array.int
intAt
(long pos) Returns the value of the native pointer at the specified position.int
intValue()
If the native pointer is of int type, this function returns its value.final void
boolean
isNull()
Returns true if the native pointer is 0; otherwise false.boolean
long
long[]
If the native pointer is of long type, this function returns its values as array.long
longAt
(long pos) Returns the value of the native pointer at the specified position.long
If the native pointer is of long type, this function returns its value.<T extends QtObjectInterface>
TIf the native pointer is of pointer type, this function returns its value matching the given valueType.<T extends QtObjectInterface>
T[]objectArray
(Class<T> valueType) If the native pointer is of pointer type, this function returns its value matching the given valueType.<T extends QtObjectInterface>
TReturns the value of the native pointer matching the given valueType at the specified position.openAsDevice
(QIODeviceBase.OpenMode openMode) openAsDevice
(QIODeviceBase.OpenModeFlag... openMode) long
pointer()
Returns the native pointer.pointerAt
(long pos) Returns the value of the native pointer at the specified position.If the native pointer is of pointer type, this function returns its value.void
setAutoDeleteMode
(QNativePointer.AutoDeleteMode autodelete) This function sets the auto delete mode of the QNativePointer.void
setBooleanAt
(long pos, boolean value) Sets the value of the array element atpos
to which this native pointer points.void
setBooleanValue
(boolean value) Sets the value of this pointer tovalue
.void
setByteAt
(long pos, byte value) Sets the value of the array element atpos
to which this native pointer points.void
setByteValue
(byte value) Sets the value of this pointer tovalue
.void
setCharAt
(long pos, char value) Sets the value of the array element atpos
to which this native pointer points.void
setCharValue
(char value) Sets the value of this pointer tovalue
.void
setDoubleAt
(long pos, double value) Sets the value of the array element atpos
to which this native pointer points.void
setDoubleValue
(double value) Sets the value of this pointer tovalue
.void
setFloatAt
(long pos, float value) Sets the value of the array element atpos
to which this native pointer points.void
setFloatValue
(float value) Sets the value of this pointer tovalue
.void
setIntAt
(long pos, int value) Sets the value of the array element atpos
to which this native pointer points.void
setIntValue
(int value) Sets the value of this pointer tovalue
.void
setLongAt
(long pos, long value) Sets the value of the array element atpos
to which this native pointer points.void
setLongValue
(long value) Sets the value of this pointer tovalue
.<T extends QtObjectInterface>
voidsetObjectAt
(long pos, T value) Sets the value of the array element atpos
to which this native pointer points.<T extends QtObjectInterface>
voidsetObjectValue
(T value) Sets the value of this pointer tovalue
.void
setPointerAt
(long pos, QNativePointer value) Sets the value of the array element atpos
to which this native pointer points.void
setPointerValue
(QNativePointer value) Sets the value of this pointer tovalue
.void
setShortAt
(long pos, short value) Sets the value of the array element atpos
to which this native pointer points.void
setShortValue
(short value) Sets the value of this pointer tovalue
.void
setStringAt
(long pos, String value) Sets the value of the array element atpos
to which this native pointer points.void
setStringValue
(String value) Sets the value of this pointer tovalue
.void
setVerificationEnabled
(boolean a) Sets if the any accesses should be type verified or not.short[]
If the native pointer is of short type, this function returns its values as array.short
shortAt
(long pos) Returns the value of the native pointer at the specified position.short
If the native pointer is of short type, this function returns its value.String[]
If the native pointer is of string type, this function returns its values as array.stringAt
(long pos) Returns the value of the native pointer at the specified position.If the native pointer is of string type, this function returns its value.type()
Returns the type of the native pointer.boolean
Returns if verification is enabled or not.
-
Constructor Details
-
QNativePointer
Creates a native pointer of the specifiedtype
. The object has an indirection of 1 and the internal pointer will be deleted when the QNativePointer object is deleted.- Parameters:
type
- the type of pointer to create.
-
QNativePointer
Creates a native pointer to an array withsize
length of the specifiedtype
. The pointer will have an indirection of 1 and be deleted when the QNativePointer is garbage collected.- Parameters:
type
- the type of pointer to create.size
- the size of the array.
-
QNativePointer
Creates a native pointer of the specifiedtype
. It will be an array ifsize
is larger than one and have an indirection ofindirections
. For instance, the following Java statement will create a**char
pointer with the first array dimension of length 5:QNativePointer ptr = new QNativePointer(QNativePointer.Type.Int, 5, 2);
- Parameters:
type
- the type of pointer to create.size
- the length of the array.indirections
- the number of indirections for the pointer.
-
-
Method Details
-
booleanValue
public boolean booleanValue()If the native pointer is of boolean type, this function returns its value. If it is an array of booleans, the first element is returned.- Returns:
- the value of the pointer.
-
byteValue
public byte byteValue()If the native pointer is of byte type, this function returns its value. If it is an array of bytes, the first element is returned.- Returns:
- the value of the pointer.
-
charValue
public char charValue()If the native pointer is of char type, this function returns its value. If it is an array of chars, the first element is returned.- Returns:
- the value of the pointer.
-
shortValue
public short shortValue()If the native pointer is of short type, this function returns its value. If it is an array of shorts, the first element is returned.- Returns:
- the value of the pointer.
-
intValue
public int intValue()If the native pointer is of int type, this function returns its value. If it is an array of ints, the first element is returned.- Returns:
- the value of the pointer.
-
longValue
public long longValue()If the native pointer is of long type, this function returns its value. If it is an array of longs, the first element is returned.- Returns:
- the value of the pointer.
-
floatValue
public float floatValue()If the native pointer is of float type, this function returns its value. If it is an array of floats, the first element is returned.- Returns:
- the value of the pointer.
-
doubleValue
public double doubleValue()If the native pointer is of double type, this function returns its value. If it is an array of doubles, the first element is returned.- Returns:
- the value of the pointer.
-
booleanArray
public boolean[] booleanArray()If the native pointer is of boolean type, this function returns its values as array.- Returns:
- the values of the pointer.
-
byteArray
public byte[] byteArray()If the native pointer is of byte type, this function returns its values as array.- Returns:
- the values of the pointer.
-
charArray
public char[] charArray()If the native pointer is of char type, this function returns its values as array.- Returns:
- the values of the pointer.
-
shortArray
public short[] shortArray()If the native pointer is of short type, this function returns its values as array.- Returns:
- the values of the pointer.
-
intArray
public int[] intArray()If the native pointer is of int type, this function returns its values as array.- Returns:
- the values of the pointer.
-
longArray
public long[] longArray()If the native pointer is of long type, this function returns its values as array.- Returns:
- the values of the pointer.
-
floatArray
public float[] floatArray()If the native pointer is of float type, this function returns its values as array.- Returns:
- the values of the pointer.
-
doubleArray
public double[] doubleArray()If the native pointer is of double type, this function returns its values as array.- Returns:
- the values of the pointer.
-
objectArray
If the native pointer is of pointer type, this function returns its value matching the given valueType.- Parameters:
valueType
- the type of the value- Returns:
- the value of the pointer.
-
pointerValue
If the native pointer is of pointer type, this function returns its value. If it is an array of pointers, the first element is returned.- Returns:
- the value of the pointer.
-
object
If the native pointer is of pointer type, this function returns its value matching the given valueType. If it is an array of pointers, the first element is returned.- Parameters:
valueType
- the type of the value- Returns:
- the value of the pointer.
-
stringValue
If the native pointer is of string type, this function returns its value. If it is an array of strings, the first element is returned.- Returns:
- the value of the pointer.
-
stringArray
If the native pointer is of string type, this function returns its values as array.- Returns:
- the values of the pointer.
-
setBooleanValue
public void setBooleanValue(boolean value) Sets the value of this pointer tovalue
. The type of the pointer must be boolean.- Parameters:
value
- the value to which the pointer is set.
-
setByteValue
public void setByteValue(byte value) Sets the value of this pointer tovalue
. The type of the pointer must be byte.- Parameters:
value
- the value to which the pointer is set.
-
setCharValue
public void setCharValue(char value) Sets the value of this pointer tovalue
. The type of the pointer must be char.- Parameters:
value
- the value to which the pointer is set.
-
setShortValue
public void setShortValue(short value) Sets the value of this pointer tovalue
. The type of the pointer must be short.- Parameters:
value
- the value to which the pointer is set.
-
setIntValue
public void setIntValue(int value) Sets the value of this pointer tovalue
. The type of the pointer must be int.- Parameters:
value
- the value to which the pointer is set.
-
setLongValue
public void setLongValue(long value) Sets the value of this pointer tovalue
. The type of the pointer must be long.- Parameters:
value
- the value to which the pointer is set.
-
setFloatValue
public void setFloatValue(float value) Sets the value of this pointer tovalue
. The type of the pointer must be float.- Parameters:
value
- the value to which the pointer is set.
-
setDoubleValue
public void setDoubleValue(double value) Sets the value of this pointer tovalue
. The type of the pointer must double.- Parameters:
value
- the value to which the pointer is set.
-
setPointerValue
Sets the value of this pointer tovalue
. The pointer must be of pointer type.- Parameters:
value
- the value to which the pointer is set.
-
setObjectValue
Sets the value of this pointer tovalue
. The pointer must be of pointer type.- Parameters:
value
- the value to which the pointer is set.
-
setStringValue
Sets the value of this pointer tovalue
. The pointer must point to a string.- Parameters:
value
- the value to which the pointer is set.
-
booleanAt
public boolean booleanAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
byteAt
public byte byteAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
charAt
public char charAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
shortAt
public short shortAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
intAt
public int intAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
longAt
public long longAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
floatAt
public float floatAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
doubleAt
public double doubleAt(long pos) Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
byteBuffer
-
charBuffer
-
shortBuffer
-
intBuffer
-
longBuffer
-
floatBuffer
-
doubleBuffer
-
pointerAt
Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
objectAt
Returns the value of the native pointer matching the given valueType at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
valueType
- the type of the valuepos
- the array index- Returns:
- the value of the pointer.
-
stringAt
Returns the value of the native pointer at the specified position. Ifpos
is larger than 1, QNativePointer will check that the position is within the array bounds.- Parameters:
pos
- the array index
-
setBooleanAt
public void setBooleanAt(long pos, boolean value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setByteAt
public void setByteAt(long pos, byte value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setCharAt
public void setCharAt(long pos, char value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setShortAt
public void setShortAt(long pos, short value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setIntAt
public void setIntAt(long pos, int value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setLongAt
public void setLongAt(long pos, long value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setFloatAt
public void setFloatAt(long pos, float value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setDoubleAt
public void setDoubleAt(long pos, double value) Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setPointerAt
Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setObjectAt
Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
setStringAt
Sets the value of the array element atpos
to which this native pointer points.- Parameters:
pos
- the array indexvalue
- the value to set the index to
-
type
Returns the type of the native pointer.- Returns:
- the data type of the native pointer
-
indirections
public int indirections()Returns the number of indirections of the pointer.- Returns:
- the number of indirections of the pointer
-
knownSize
public long knownSize() -
isNull
public boolean isNull()Returns true if the native pointer is 0; otherwise false.- Returns:
- true if the native pointer is 0.
-
autoDeleteMode
Returns the auto-delete mode of the pointer.- Returns:
- the auto-delete mode of this QNativePointer
-
setAutoDeleteMode
This function sets the auto delete mode of the QNativePointer. The internal pointer is deleted by default when the QNativePointer object is garbage collected, so you only need to call this function when you want to keep the pointer valid after the Java object is garbage collected.- Parameters:
autodelete
- the new auto delete mode.
-
free
public void free()This function deletes the internal pointer. Currently, all QNativePointers should be deleted using the delete() function. After the pointer has been deleted, you cannot use the same QNativePointer to allocate further data. Note also that the pointer will by default be deleted upon garbage collection. -
delete
public void delete()This function deletes the internal pointer. After the pointer has been deleted, you cannot allocate it again. The pointer is by default deleted when the QNativePointer object is garbage collected. -
deleteArray
public void deleteArray()This function deletes elements in the array of this QNativePointer. After the pointer has been deleted, you cannot use this QNativePointer object again. -
pointer
public long pointer()Returns the native pointer. The returned long is thevoid *
value in c++.- Returns:
- the native pointer.
-
fromNative
public static QNativePointer fromNative(long ptr, QNativePointer.Type type, long size, int indirections, boolean readOnly) This function creates a QNativePointer from an existing c++ pointer. The long is thevoid *
(i.e., address) value of the pointer. There are several ways of acquiring a native pointer. For instance, QNativePointer internal pointer is returned by pointer(), and QtJambiObject.nativeId() returns the c++ pointer to its Qt object.- Parameters:
ptr
- the void * value of the pointer.type
- the Type of the pointerindirections
- the number of pointer indirections- Returns:
- a QNativePointer object with ptr as the native pointer
-
fromArray
-
fromObject
-
fromBuffer
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
fromArray
-
verificationEnabled
public boolean verificationEnabled()Returns if verification is enabled or not.- Returns:
- true if verification is enabled; otherwise false.
-
isReadOnly
public boolean isReadOnly() -
setVerificationEnabled
public void setVerificationEnabled(boolean a) Sets if the any accesses should be type verified or not. By default this value is set to true, meaning that trying to access a char pointer as an int pointer will trigger an exception. Disabling this value allows complete access, but without any safety, so incorrect usage may lead to memory corruption in the C++ implementation.- Parameters:
a
- Set to true if verification should be enabled.
-
createCharPointerPointer
Creates a char** native pointer from the array of input strings.- Parameters:
strings
- the input strings- Returns:
- a char **
-
createCharPointer
Creates a char* from the input string- Parameters:
string
- The input string- Returns:
- The char*
-
openAsDevice
-
openAsDevice
-
invalidate
public final void invalidate()
-