Package org.robovm.rt.bro.ptr
Class BytePtr
public final class BytePtr extends Struct<BytePtr>
Points to an 8-bit signed value (
char * in C).-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBytePtr.BytePtrPtrPointer toBytePtr(char **in C)Nested classes/interfaces inherited from class org.robovm.rt.bro.Struct
Struct.Marshaler -
Constructor Summary
-
Method Summary
Modifier and Type Method Description ByteBufferasByteBuffer(int n)Returns aByteBufferwhich reads and writes to the same memory location pointed to by thisBytePtr.byteget()Returns the current value.voidget(byte[] dst)voidget(byte[] dst, int offset, int count)voidset(byte value)Sets the value.voidset(byte[] src)voidset(byte[] src, int offset, int count)byte[]toByteArray(int n)static BytePtrtoBytePtrAsciiZ(String s)Converts the specifiedStringto a NUL-terminated C string of ASCII characters.static BytePtrtoBytePtrAsciiZ(String s, boolean useNativeHeap)Converts the specifiedStringto a NUL-terminated C string of ASCII characters.static BytePtrtoBytePtrZ(String s)static BytePtrtoBytePtrZ(String s, Charset charset)static BytePtrtoBytePtrZ(String s, Charset charset, boolean useNativeHeap)StringtoStringAsciiZ()StringtoStringZ()StringtoStringZ(Charset charset)Methods inherited from class org.robovm.rt.bro.Struct
_sizeOf, allocate, allocate, as, clear, clear, copy, copy, copyWithMalloc, copyWithMalloc, free, iterator, iterator, malloc, malloc, next, next, offsetOf, previous, previous, sizeOf, sizeOf, toArray, toList, toStruct, update, update, update, wrapMethods inherited from class org.robovm.rt.bro.NativeObject
equals, getHandle, hashCode, setHandle
-
Constructor Details
-
Method Details
-
get
public byte get()Returns the current value.- Returns:
- the value.
-
set
public void set(byte value)Sets the value.- Parameters:
value- the new value.
-
toStringAsciiZ
Returns aStringcreated from the NUL-terminated C string pointed to by thisBytePtr. Non ASCII characters will be replaced with '?' in the result. This method is more efficient than usingtoStringZ(Charset)with ASCII asCharset.- Returns:
- a
Stringcontaining the same characters as the C string pointed to.
-
toStringZ
Returns aStringcreated from the NUL-terminated C string pointed to by thisBytePtrusing the defaultCharset. Illegal characters will be replaced with '?' in the result. This assumes that the defaultCharsetis an 8-bit encoding or a variable length encoding with 8-bits as smallest bit length such as UTF-8.- Returns:
- a
Stringconverted from the C string bytes.
-
toStringZ
-
asByteBuffer
Returns aByteBufferwhich reads and writes to the same memory location pointed to by thisBytePtr.- Parameters:
n- the maximum number of bytes theByteBuffercan read/write. This will be theByteBuffer'scapacity.- Returns:
- the
ByteBuffer.
-
toByteArray
public byte[] toByteArray(int n)- Parameters:
n- the number of bytes to copy.- Returns:
- the
byte[].
-
get
public void get(byte[] dst)- Parameters:
dst- the destination.
-
get
public void get(byte[] dst, int offset, int count)- Parameters:
dst- the destination.offset- the offset within the destination array to start copying to.count- the number of elements to copy.
-
set
public void set(byte[] src)- Parameters:
src- the source.
-
set
public void set(byte[] src, int offset, int count)- Parameters:
src- the source.offset- the offset within the source array to start copying from.count- the number of elements to copy.
-
toBytePtrAsciiZ
Converts the specifiedStringto a NUL-terminated C string of ASCII characters. Non ASCII characters will be replaced with '?' in the result. The memory will be allocated on the GCed heaped. This method is more efficient than usingtoStringZ(Charset)with ASCII asCharset. -
toBytePtrAsciiZ
Converts the specifiedStringto a NUL-terminated C string of ASCII characters. Non ASCII characters will be replaced with '?' in the result. This method is more efficient than usingtoStringZ(Charset)with ASCII asCharset. -
toBytePtrZ
Converts the specifiedStringto a NUL-terminated C string using the defaultCharset. Illegal characters will be replaced with '?' in the result. The memory will be allocated on the GCed heaped. This assumes that the defaultCharsetis an 8-bit encoding or a variable length encoding with 8-bits as smallest bit length such as UTF-8. -
toBytePtrZ
-
toBytePtrZ
Converts the specifiedStringto a NUL-terminated C string using the specifiedCharset. Illegal characters will be replaced with '?' in the result.- Parameters:
s- theStringto convert.charset- theCharsetto use. Must be an 8-bit or variable length character encoding with 8-bits as smallest value and that can be NUL-terminated (e.g. UTF-8).useNativeHeap- whether the memory should be allocated on the native heap usingmalloc()or on the GCed heap.- Returns:
- a
BytePtrwhich points to the first character in the result.
-