java.lang.Object
io.qt.QNativePointer
Represents a native pointer.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe AutoDeleteMode enum describes how garbage collection of the QNativePointer handles the deletion of the native pointer.static classThis exception is thrown when trying to write on a read-only native pointer.static enumThe type of the pointer. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a native pointer of the specifiedtype.QNativePointer(QNativePointer.Type type, long size) Creates a native pointer to an array withsizelength 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.booleanbooleanAt(long pos) Returns the value of the native pointer at the specified position.booleanIf 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.bytebyteAt(long pos) Returns the value of the native pointer at the specified position.byteIf 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.charcharAt(long pos) Returns the value of the native pointer at the specified position.charIf the native pointer is of char type, this function returns its value.static QNativePointercreateCharPointer(String string) Creates a char* from the input stringstatic QNativePointercreateCharPointerPointer(String [] strings) Creates a char** native pointer from the array of input strings.voiddelete()This function deletes the internal pointer.voidThis 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.doubledoubleAt(long pos) Returns the value of the native pointer at the specified position.doubleIf 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.floatfloatAt(long pos) Returns the value of the native pointer at the specified position.floatIf the native pointer is of float type, this function returns its value.voidfree()This function deletes the internal pointer.static QNativePointerfromArray(boolean[] data) static QNativePointerfromArray(byte[] data) static QNativePointerfromArray(char[] data) static QNativePointerfromArray(double[] data) static QNativePointerfromArray(float[] data) static QNativePointerfromArray(int[] data) static QNativePointerfromArray(long[] data) static QNativePointerfromArray(short[] data) static QNativePointerstatic QNativePointerstatic QNativePointerstatic QNativePointerstatic QNativePointerstatic QNativePointerstatic QNativePointerstatic QNativePointerstatic QNativePointerstatic <T extends QtObjectInterface>
QNativePointerfromArray(T... array) static QNativePointerfromBuffer(Buffer buffer) static QNativePointerfromNative(long ptr) This function creates a QNativePointer from an existing c++ pointer of unknown type.static QNativePointerfromNative(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) intReturns the number of indirections of the pointer.int[]intArray()If the native pointer is of int type, this function returns its values as array.intintAt(long pos) Returns the value of the native pointer at the specified position.intintValue()If the native pointer is of int type, this function returns its value.final voidbooleanisNull()Returns true if the native pointer is 0; otherwise false.booleanlonglong[]If the native pointer is of long type, this function returns its values as array.longlongAt(long pos) Returns the value of the native pointer at the specified position.longIf 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) longpointer()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.voidsetAutoDeleteMode(QNativePointer.AutoDeleteMode autodelete) This function sets the auto delete mode of the QNativePointer.voidsetBooleanAt(long pos, boolean value) Sets the value of the array element atposto which this native pointer points.voidsetBooleanValue(boolean value) Sets the value of this pointer tovalue.voidsetByteAt(long pos, byte value) Sets the value of the array element atposto which this native pointer points.voidsetByteValue(byte value) Sets the value of this pointer tovalue.voidsetCharAt(long pos, char value) Sets the value of the array element atposto which this native pointer points.voidsetCharValue(char value) Sets the value of this pointer tovalue.voidsetDoubleAt(long pos, double value) Sets the value of the array element atposto which this native pointer points.voidsetDoubleValue(double value) Sets the value of this pointer tovalue.voidsetFloatAt(long pos, float value) Sets the value of the array element atposto which this native pointer points.voidsetFloatValue(float value) Sets the value of this pointer tovalue.voidsetIntAt(long pos, int value) Sets the value of the array element atposto which this native pointer points.voidsetIntValue(int value) Sets the value of this pointer tovalue.voidsetLongAt(long pos, long value) Sets the value of the array element atposto which this native pointer points.voidsetLongValue(long value) Sets the value of this pointer tovalue.<T extends QtObjectInterface>
voidsetObjectAt(long pos, T value) Sets the value of the array element atposto which this native pointer points.<T extends QtObjectInterface>
voidsetObjectValue(T value) Sets the value of this pointer tovalue.voidsetPointerAt(long pos, QNativePointer value) Sets the value of the array element atposto which this native pointer points.voidsetPointerValue(QNativePointer value) Sets the value of this pointer tovalue.voidsetShortAt(long pos, short value) Sets the value of the array element atposto which this native pointer points.voidsetShortValue(short value) Sets the value of this pointer tovalue.voidsetStringAt(long pos, String value) Sets the value of the array element atposto which this native pointer points.voidsetStringValue(String value) Sets the value of this pointer tovalue.voidsetVerificationEnabled(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.shortshortAt(long pos) Returns the value of the native pointer at the specified position.shortIf 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.booleanReturns 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 withsizelength 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 ifsizeis larger than one and have an indirection ofindirections. For instance, the following Java statement will create a**charpointer 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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. Ifposis 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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 atposto 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
This function creates a QNativePointer from an existing c++ pointer of unknown type. The long is thevoid *(i.e., address) value of the pointer.- Parameters:
ptr- the void * value of the pointer.- Returns:
- a QNativePointer object with ptr as 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()
-