@Properties(inherit=javacpp.class) public class CharPointer extends Pointer
short
for UTF-16.
All operations take into account the position and limit, when appropriate.Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.DeallocatorReference, Pointer.DeallocatorThread, Pointer.NativeDeallocator, Pointer.ProxyDeallocator, Pointer.ReferenceCounter
Modifier and Type | Field and Description |
---|---|
private static Logger |
logger |
address, capacity, deallocatorThread, limit, maxBytes, maxPhysicalBytes, maxRetries, position
Constructor and Description |
---|
CharPointer() |
CharPointer(char... array)
Allocates enough memory for the array and copies it.
|
CharPointer(CharBuffer buffer)
For direct buffers, calls
Pointer.Pointer(Buffer) , while for buffers
backed with an array, allocates enough memory for the array and copies it. |
CharPointer(long size)
Allocates a native
short array of the given size. |
CharPointer(Pointer p) |
CharPointer(String s)
Allocates enough memory for the String and copies it.
|
Modifier and Type | Method and Description |
---|---|
private void |
allocateArray(long size) |
CharBuffer |
asBuffer()
Same as
Pointer.asByteBuffer() , but can be overridden to return subclasses of Buffer. |
CharPointer |
capacity(long capacity)
Sets the capacity and returns this.
|
char |
get() |
CharPointer |
get(char[] array) |
CharPointer |
get(char[] array,
int offset,
int length)
Reads a portion of the native array into a Java array.
|
char |
get(long i) |
String |
getString()
Returns the String, assuming a null-terminated string if
limit <= position . |
char[] |
getStringChars()
Returns the chars, assuming a null-terminated string if
limit <= position . |
CharPointer |
limit(long limit)
Sets the limit and returns this.
|
CharPointer |
position(long position)
Sets the position and returns this.
|
CharPointer |
put(char... array) |
CharPointer |
put(char c) |
CharPointer |
put(char[] array,
int offset,
int length)
Writes a portion of a Java array into the native array.
|
CharPointer |
put(long i,
char c)
Copies the
char value to the i-th element of a native array. |
CharPointer |
putString(String s)
Copies the String chars into native memory, including a terminating null char.
|
int |
sizeof()
Returns 1 for Pointer or BytePointer else
Loader.sizeof(getClass()) or -1 on error. |
address, asByteBuffer, availablePhysicalBytes, calloc, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, hashCode, init, isNull, isNull, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetof, parseBytes, physicalBytes, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, toString, totalBytes, totalPhysicalBytes, withDeallocator, zero
private static final Logger logger
public CharPointer(String s)
s
- the String to copyputString(String)
public CharPointer(char... array)
array
- the array to copyput(char[])
public CharPointer(CharBuffer buffer)
Pointer.Pointer(Buffer)
, while for buffers
backed with an array, allocates enough memory for the array and copies it.buffer
- the Buffer to reference or copyput(char[])
public CharPointer(long size)
short
array of the given size.size
- the number of short
elements to allocatepublic CharPointer()
Pointer.Pointer()
public CharPointer(Pointer p)
Pointer.Pointer(Pointer)
private void allocateArray(long size)
public CharPointer position(long position)
Pointer
array.position(i)
statement sort of equivalent to the array[i]
statement in C++.position
in class Pointer
position
- the new positionPointer.position(long)
public CharPointer limit(long limit)
Pointer
limit
in class Pointer
limit
- the new limitPointer.limit(long)
public CharPointer capacity(long capacity)
Pointer
capacity
in class Pointer
capacity
- the new capacityPointer.capacity(long)
public int sizeof()
Pointer
Loader.sizeof(getClass())
or -1 on error.public char[] getStringChars()
limit <= position
.public String getString()
limit <= position
.public CharPointer putString(String s)
s
- the String to copyString.toCharArray()
,
put(char[])
public char get()
get(0)
public char get(long i)
char
value of a native arraypublic CharPointer put(char c)
put(0, c)
public CharPointer put(long i, char c)
char
value to the i-th element of a native array.i
- the index into the arrayc
- the char
value to copypublic CharPointer get(char[] array)
get(array, 0, array.length)
public CharPointer put(char... array)
put(array, 0, array.length)
public CharPointer get(char[] array, int offset, int length)
array
- the array to write tooffset
- the offset into the array where to start writinglength
- the length of data to read and writepublic CharPointer put(char[] array, int offset, int length)
array
- the array to read fromoffset
- the offset into the array where to start readinglength
- the length of data to read and writepublic final CharBuffer asBuffer()
Pointer
Pointer.asByteBuffer()
, but can be overridden to return subclasses of Buffer.asBuffer
in class Pointer
asByteBuffer().asCharBuffer()
BytePointer.asBuffer()
,
ShortPointer.asBuffer()
,
IntPointer.asBuffer()
,
LongPointer.asBuffer()
,
FloatPointer.asBuffer()
,
DoublePointer.asBuffer()
,
asBuffer()
Copyright © 2020. All rights reserved.