All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.djl.mxnet.jna.NativeSizeByReference Maven / Gradle / Ivy

There is a newer version: 0.30.0
Show newest version
package ai.djl.mxnet.jna;

import com.sun.jna.ptr.ByReference;

public class NativeSizeByReference extends ByReference {

    public NativeSizeByReference() {
        this(new NativeSize(0));
    }

    @SuppressWarnings("this-escape")
    public NativeSizeByReference(NativeSize value) {
        super(NativeSize.SIZE);
        setValue(value);
    }

    public void setValue(NativeSize value) {
        if (NativeSize.SIZE == 4) {
            getPointer().setInt(0, value.intValue());
        } else if (NativeSize.SIZE == 8) {
            getPointer().setLong(0, value.longValue());
        } else {
            throw new IllegalArgumentException("size_t has to be either 4 or 8 bytes.");
        }
    }

    public NativeSize getValue() {
        if (NativeSize.SIZE == 4) {
            return new NativeSize(getPointer().getInt(0));
        } else if (NativeSize.SIZE == 8) {
            return new NativeSize(getPointer().getLong(0));
        } else {
            throw new IllegalArgumentException("size_t has to be either 4 or 8 bytes.");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy