/** @return {@code get(BytePointer.class, i).getString(charsetName)} * @see BytePointer#getString(String) */ public String getString(long i, String charsetName) throws UnsupportedEncodingException { BytePointer p = (BytePointer)get((Class<P>)BytePointer.class, i); return p != null ? p.getString(charsetName) : null; }
/** * A utility method to register easily a {@link CustomDeallocator} with a Pointer. * * @param p the Pointer with which to register the deallocator * @return the Pointer */ protected static <P extends Pointer> P withDeallocator(P p) { return (P)p.deallocator(new CustomDeallocator(p)); }
/** * Creates one by one a new {@link CharPointer} for each {@code char[]}, * and writes them into the native {@code void*} array. * * @param array the array of {@code char[]} to read from * @return this */ public PointerPointer<P> put(char[] ... array) { pointerArray = (P[])new CharPointer[array.length]; for (int i = 0; i < array.length; i++) { pointerArray[i] = array[i] != null ? (P)new CharPointer(array[i]) : null; } return put(pointerArray); }
/** @see Pointer#position(long) */ @Override public CharPointer position(long position) { return super.position(position); } /** @see Pointer#limit(long) */
/** Constructor to set the {@link #pointer}, {@link #sizes} and {@link #strides}. */ public FloatRawIndexer(FloatPointer pointer, long[] sizes, long[] strides) { super(sizes, strides); this.pointer = pointer; base = pointer.address() + pointer.position() * VALUE_BYTES; size = pointer.limit() - pointer.position(); }
/** Returns {@code load(cls, loadProperties(), Loader.pathsFirst)}. */ public static String load(Class cls) { return load(cls, loadProperties(), Loader.pathsFirst); } /**
/** @see Pointer#limit(long) */ @Override public BoolPointer limit(long limit) { return super.limit(limit); } /** @see Pointer#capacity(long) */
/** * Allocates enough memory for the array and copies it. * * @param array the array to copy * @see #put(float[]) */ public FloatPointer(float ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array and copies it. * * @param array the array to copy * @see #put(double[]) */ public DoublePointer(double ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array of arrays and copies it. * * @param array the array of arrays to copy * @see #put(long[][]) */ public PointerPointer(long[] ... array) { this(array.length); put(array); } /**
/** * Allocates enough memory for the array and copies it. * * @param array the array to copy * @see #put(int[]) */ public IntPointer(int ... array) { this(array.length); put(array); } /**
/** Calls {@code deallocate(true)}. */ public void deallocate() { deallocate(true); } /**
DeallocatorThread() { super("JavaCPP Deallocator"); setPriority(Thread.MAX_PRIORITY); setDaemon(true); start(); }
/** * Extracts resources using the {@link ClassLoader} of the caller class, * and returns the cached {@link File} objects. * * @param name of the resources passed to {@link #findResources(Class, String)} * @see #cacheResources(Class, String) */ public static File[] cacheResources(String name) throws IOException { Class cls = getCallerClass(2); return cacheResources(cls, name); } /**
/** Returns {@code findResources(cls, name, 1)[0]} or null if none. */ public static URL findResource(Class cls, String name) throws IOException { URL[] url = findResources(cls, name, 1); return url.length > 0 ? url[0] : null; }
/** * Copies the {@code bool} value to the i-th element of a native array. * * @param i the index into the array * @param b the {@code bool} value to copy * @return this */ public native BoolPointer put(long i, boolean b); }
/** @see Pointer#position(long) */ @Override public BooleanPointer position(long position) { return super.position(position); } /** @see Pointer#limit(long) */
/** @return {@code get(BytePointer.class, i).getString()} * @see BytePointer#getString() */ public String getString(long i) { BytePointer p = (BytePointer)get((Class<P>)BytePointer.class, i); return p != null ? p.getString() : null; } /** @return {@code get(BytePointer.class, i).getString(charsetName)}
/** @see Pointer#position(long) */ @Override public FloatPointer limit(long limit) { return super.limit(limit); } /** @see Pointer#capacity(long) */
/** @see Pointer#limit(long) */ @Override public BytePointer limit(long limit) { return super.limit(limit); } /** @see Pointer#capacity(long) */