com.jstatcom.engine
Class CPtr
- java.lang.Object
-
- com.jstatcom.engine.CPtr
-
public class CPtr extends java.lang.ObjectAn abstraction for a C pointer data type. A CPtr instance represents, on the Java side, a C pointer. The C pointer could be any type of C pointer. Methods such ascopyIn,copyOut,getXXX, andsetXXX, provide means to indirect the underlying C pointer.- See Also:
CFunc
-
-
Field Summary
Fields Modifier and Type Field and Description static CPtrNULLA canonical representation of C's NULL pointer.static intSIZEThe size of a C pointer on the platform this Java virtual machine is running on.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcopyIn(int bOff, byte[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyIn(int bOff, char[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyIn(int bOff, double[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyIn(int bOff, float[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyIn(int bOff, int[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyIn(int bOff, long[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyIn(int bOff, short[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.voidcopyOut(int bOff, byte[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.voidcopyOut(int bOff, char[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.voidcopyOut(int bOff, double[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.voidcopyOut(int bOff, float[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.voidcopyOut(int bOff, int[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.voidcopyOut(int bOff, long[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.voidcopyOut(int bOff, short[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.booleanequals(java.lang.Object other)Compares thisCPtrto the specified object.bytegetByte(int offset)Indirect the C pointer as a pointer tobyte.CPtrgetCPtr(int offset)Indirect the C pointer as a pointer to pointer.doublegetDouble(int offset)Indirect the C pointer as a pointer todouble.floatgetFloat(int offset)Indirect the C pointer as a pointer tofloat.intgetInt(int offset)Indirect the C pointer as a pointer toint.longgetLong(int offset)Indirect the C pointer as a pointer tolong.shortgetShort(int offset)Indirect the C pointer as a pointer toshort.java.lang.StringgetString(int offset)Indirect the C pointer as a pointer tochar *, aNULL-terminated C string.inthashCode()Returns a hashcode for the C pointer represented by thisCptrobject.voidsetByte(int offset, byte value)Setvalueat location being pointed to.voidsetCPtr(int offset, CPtr value)Setvalueat location being pointed to.voidsetDouble(int offset, double value)Setvalueat location being pointed to.voidsetFloat(int offset, float value)Setvalueat location being pointed to.voidsetInt(int offset, int value)Setvalueat location being pointed to.voidsetLong(int offset, long value)Setvalueat location being pointed to.voidsetShort(int offset, short value)Setvalueat location being pointed to.voidsetString(int offset, java.lang.String value)Copy stringvalueto the location being pointed to.
-
-
-
Field Detail
-
SIZE
public static final int SIZE
The size of a C pointer on the platform this Java virtual machine is running on.
-
NULL
public static final CPtr NULL
A canonical representation of C's NULL pointer.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object other)
Compares thisCPtrto the specified object.- Overrides:
equalsin classjava.lang.Object- Parameters:
other- aCPtr- Returns:
- true if the class of this
CPtrobject and the class ofotherare exactly equal, and the C pointers being pointed to by these objects are also equal. Returns false otherwise.
-
hashCode
public int hashCode()
Returns a hashcode for the C pointer represented by thisCptrobject.- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for the represented C pointer.
-
copyIn
public void copyIn(int bOff, byte[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-bytearray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyIn
public void copyIn(int bOff, short[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-shortarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyIn
public void copyIn(int bOff, char[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-chararray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyIn
public void copyIn(int bOff, int[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-intarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyIn
public void copyIn(int bOff, long[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-longarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyIn
public void copyIn(int bOff, float[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-floatarray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyIn
public void copyIn(int bOff, double[] buf, int index, int length)Indirect the C pointer, copying into memory pointed to by C pointer, from the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-doublearray from which to copyindex- array index from which to start copyinglength- number of elements frombufthat must be copied
-
copyOut
public void copyOut(int bOff, byte[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer into which data is copiedbuf-bytearray into which data is copiedindex- array index from which to start copyinglength- number of elements from C pointer that must be copied
-
copyOut
public void copyOut(int bOff, short[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-shortarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied
-
copyOut
public void copyOut(int bOff, char[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-chararray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied
-
copyOut
public void copyOut(int bOff, int[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-intarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied
-
copyOut
public void copyOut(int bOff, long[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-longarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied
-
copyOut
public void copyOut(int bOff, float[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-floatarray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied
-
copyOut
public void copyOut(int bOff, double[] buf, int index, int length)Indirect the C pointer, copying from memory pointed to by C pointer, into the specified array.- Parameters:
bOff- byte offset from pointer from which data is copiedbuf-doublearray into which data is copiedindex- array index to which data is copiedlength- number of elements from C pointer that must be copied
-
getByte
public byte getByte(int offset)
Indirect the C pointer as a pointer tobyte. This is equivalent to the expression*((jbyte *)((char *)cptr + * offset)).- Parameters:
offset- offset from pointer to perform the indirection- Returns:
- the
bytevalue being pointed to
-
getShort
public short getShort(int offset)
Indirect the C pointer as a pointer toshort. This is equivalent to the expression*((jshort *)((char *)cptr + offset)).- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
shortvalue being pointed to
-
getInt
public int getInt(int offset)
Indirect the C pointer as a pointer toint. This is equivalent to the expression*((jint *)((char *)cptr + offset)).- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
intvalue being pointed to
-
getLong
public long getLong(int offset)
Indirect the C pointer as a pointer tolong. This is equivalent to the expression*((jlong *)((char *)cptr + offset)).- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
longvalue being pointed to
-
getFloat
public float getFloat(int offset)
Indirect the C pointer as a pointer tofloat. This is equivalent to the expression*((jfloat *)((char *)cptr + offset)).- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
floatvalue being pointed to
-
getDouble
public double getDouble(int offset)
Indirect the C pointer as a pointer todouble. This is equivalent to the expression*((jdouble *)((char *)cptr + offset)).- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
doublevalue being pointed to
-
getCPtr
public CPtr getCPtr(int offset)
Indirect the C pointer as a pointer to pointer. This is equivalent to the expression*((void **)((char *)cptr + offset)).- Parameters:
offset- byte offset from pointer to perform the indirection- Returns:
- the
pointervalue being pointed to
-
getString
public java.lang.String getString(int offset)
Indirect the C pointer as a pointer tochar *, aNULL-terminated C string. Convert the C string to aString.- Parameters:
offset- byte offset from pointer to obtain the C string- Returns:
- the
Stringvalue being pointed to
-
setByte
public void setByte(int offset, byte value)Setvalueat location being pointed to. This is equivalent to the expression*((jbyte *)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-bytevalue to set
-
setShort
public void setShort(int offset, short value)Setvalueat location being pointed to. This is equivalent to the expression*((jshort *)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-shortvalue to set
-
setInt
public void setInt(int offset, int value)Setvalueat location being pointed to. This is equivalent to the expression*((jint *)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-intvalue to set
-
setLong
public void setLong(int offset, long value)Setvalueat location being pointed to. This is equivalent to the expression*((jlong *)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-longvalue to set
-
setFloat
public void setFloat(int offset, float value)Setvalueat location being pointed to. This is equivalent to the expression*((jfloat *)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-floatvalue to set
-
setDouble
public void setDouble(int offset, double value)Setvalueat location being pointed to. This is equivalent to the expression*((jdouble *)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-doublevalue to set
-
setCPtr
public void setCPtr(int offset, CPtr value)Setvalueat location being pointed to. This is equivalent to the expression *((void **)((char *)cptr + offset)) = value.- Parameters:
offset- byte offset from pointer at whichvaluemust be setvalue-CPtrvalue to set
-
setString
public void setString(int offset, java.lang.String value)Copy stringvalueto the location being pointed to. Copy each element invalue, converted to native encoding, at anoffsetfrom the location pointed to by this pointer.- Parameters:
offset- byte offset from pointer at which characters invaluemust be setvalue-Stringvalue to set
-
-
DMelt 3.0 © DataMelt by jWork.ORG