org.robovm.rt.bro.ptr.BytePtr.asByteBuffer()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中org.robovm.rt.bro.ptr.BytePtr.asByteBuffer()方法的一些代码示例,展示了BytePtr.asByteBuffer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BytePtr.asByteBuffer()方法的具体详情如下:
包路径:org.robovm.rt.bro.ptr.BytePtr
类名称:BytePtr
方法名:asByteBuffer

BytePtr.asByteBuffer介绍

[英]Returns a ByteBuffer which reads and writes to the same memory location pointed to by this BytePtr.
[中]返回一个ByteBuffer,该ByteBuffer读取和写入此BytePtr指向的同一内存位置。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Copies {@code count} bytes from the memory pointed to by this 
 * {@link BytePtr} to {@code dst} starting at offset {@code offset}.
 * 
 * @param dst the destination.
 * @param offset the offset within the destination array to start copying to.
 * @param count the number of elements to copy.
 */
public void get(byte[] dst, int offset, int count) {
  asByteBuffer(count).get(dst, offset, count);
}

代码示例来源:origin: robovm/robovm

/**
 * Copies {@code count} bytes from {@code src} starting at offset {@code offset}
 * to the memory pointed to by this {@link BytePtr}.
 * 
 * @param src the source.
 * @param offset the offset within the source array to start copying from.
 * @param count the number of elements to copy.
 */
public void set(byte[] src, int offset, int count) {
  asByteBuffer(count).put(src, offset, count);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link DoubleBuffer} which reads and writes to the same memory
 * location pointed to by this {@link DoublePtr}.
 * 
 * @param n the maximum number of doubles the {@link DoubleBuffer} can 
 *        read/write. This will be the {@link DoubleBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link DoubleBuffer}.
 */
public DoubleBuffer asDoubleBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 3).order(ByteOrder.nativeOrder()).asDoubleBuffer();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link ShortBuffer} which reads and writes to the same memory
 * location pointed to by this {@link ShortPtr}.
 * 
 * @param n the maximum number of shorts the {@link ShortBuffer} can 
 *        read/write. This will be the {@link ShortBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link ShortBuffer}.
 */
public ShortBuffer asShortBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 1).order(ByteOrder.nativeOrder()).asShortBuffer();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link LongBuffer} which reads and writes to the same memory
 * location pointed to by this {@link LongPtr}.
 * 
 * @param n the maximum number of longs the {@link LongBuffer} can 
 *        read/write. This will be the {@link LongBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link LongBuffer}.
 */
public LongBuffer asLongBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 3).order(ByteOrder.nativeOrder()).asLongBuffer();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link IntBuffer} which reads and writes to the same memory
 * location pointed to by this {@link IntPtr}.
 * 
 * @param n the maximum number of ints the {@link IntBuffer} can 
 *        read/write. This will be the {@link IntBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link IntBuffer}.
 */
public IntBuffer asIntBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link FloatBuffer} which reads and writes to the same memory
 * location pointed to by this {@link FloatPtr}.
 * 
 * @param n the maximum number of floats the {@link FloatBuffer} can 
 *        read/write. This will be the {@link FloatBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link FloatBuffer}.
 */
public FloatBuffer asFloatBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link CharBuffer} which reads and writes to the same memory
 * location pointed to by this {@link CharPtr}.
 * 
 * @param n the maximum number of chars the {@link CharBuffer} can 
 *        read/write. This will be the {@link CharBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link ShortBuffer}.
 */
public CharBuffer asCharBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 1).order(ByteOrder.nativeOrder()).asCharBuffer();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a {@link String} created from the NUL-terminated C string pointed 
 * to by this {@link BytePtr} using the specified {@link Charset}. Illegal 
 * characters will be replaced with '?' in the result.
 * 
 * @param charset the {@link Charset} to 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).
 * @return a {@link String} converted from the C string bytes.
 */
public String toStringZ(Charset charset) {
  int length = 0;
  long address = getHandle();
  while (VM.getByte(address++) != 0) {
    length++;
  }
  return charset.decode(asByteBuffer(length)).toString();
}

代码示例来源:origin: robovm/robovm

public ByteBuffer getDataAsByteBuffer() {
  return getData0().asByteBuffer(getLength0());
}
public MIDIRawData setData(byte[] data) {

代码示例来源:origin: robovm/robovm

public ByteBuffer getDataAsByteBuffer() {
  return getData0().asByteBuffer(getDataLength0());
}
public MIDIMetaEvent setData(byte[] data) {

代码示例来源:origin: robovm/robovm

public ByteBuffer getDataAsByteBuffer() {
  return getData0().asByteBuffer(getLength0());
}
public MusicEventUserData setData(byte[] data) {

代码示例来源:origin: robovm/robovm

@SuppressWarnings("unchecked")
public <T extends Buffer> T getOutputDataAsBuffer(Class<T> bufferType) {
  VoidPtr ptr = getOutputDataPointer();
  if (bufferType == ByteBuffer.class) {
    return (T) ptr.as(BytePtr.class).asByteBuffer(getOutputDataSize());
  } else if (bufferType == CharBuffer.class) {
    return (T) ptr.as(CharPtr.class).asCharBuffer(getOutputDataSize());
  } else if (bufferType == ShortBuffer.class) {
    return (T) ptr.as(ShortPtr.class).asShortBuffer(getOutputDataSize());
  } else if (bufferType == IntBuffer.class) {
    return (T) ptr.as(IntPtr.class).asIntBuffer(getOutputDataSize());
  } else if (bufferType == LongBuffer.class) {
    return (T) ptr.as(LongPtr.class).asLongBuffer(getOutputDataSize());
  } else if (bufferType == FloatBuffer.class) {
    return (T) ptr.as(FloatPtr.class).asFloatBuffer(getOutputDataSize());
  } else if (bufferType == DoubleBuffer.class) {
    return (T) ptr.as(DoublePtr.class).asDoubleBuffer(getOutputDataSize());
  } else {
    throw new UnsupportedOperationException("Buffer type not supported: " + bufferType);
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Copies {@code count} bytes from {@code src} starting at offset {@code offset}
 * to the memory pointed to by this {@link BytePtr}.
 * 
 * @param src the source.
 * @param offset the offset within the source array to start copying from.
 * @param count the number of elements to copy.
 */
public void set(byte[] src, int offset, int count) {
  asByteBuffer(count).put(src, offset, count);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Copies {@code count} bytes from the memory pointed to by this 
 * {@link BytePtr} to {@code dst} starting at offset {@code offset}.
 * 
 * @param dst the destination.
 * @param offset the offset within the destination array to start copying to.
 * @param count the number of elements to copy.
 */
public void get(byte[] dst, int offset, int count) {
  asByteBuffer(count).get(dst, offset, count);
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a {@link FloatBuffer} which reads and writes to the same memory
 * location pointed to by this {@link FloatPtr}.
 * 
 * @param n the maximum number of floats the {@link FloatBuffer} can 
 *        read/write. This will be the {@link FloatBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link FloatBuffer}.
 */
public FloatBuffer asFloatBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a {@link ShortBuffer} which reads and writes to the same memory
 * location pointed to by this {@link ShortPtr}.
 * 
 * @param n the maximum number of shorts the {@link ShortBuffer} can 
 *        read/write. This will be the {@link ShortBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link ShortBuffer}.
 */
public ShortBuffer asShortBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 1).order(ByteOrder.nativeOrder()).asShortBuffer();
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a {@link DoubleBuffer} which reads and writes to the same memory
 * location pointed to by this {@link DoublePtr}.
 * 
 * @param n the maximum number of doubles the {@link DoubleBuffer} can 
 *        read/write. This will be the {@link DoubleBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link DoubleBuffer}.
 */
public DoubleBuffer asDoubleBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 3).order(ByteOrder.nativeOrder()).asDoubleBuffer();
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns a {@link IntBuffer} which reads and writes to the same memory
 * location pointed to by this {@link IntPtr}.
 * 
 * @param n the maximum number of ints the {@link IntBuffer} can 
 *        read/write. This will be the {@link IntBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link IntBuffer}.
 */
public IntBuffer asIntBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a {@link CharBuffer} which reads and writes to the same memory
 * location pointed to by this {@link CharPtr}.
 * 
 * @param n the maximum number of chars the {@link CharBuffer} can 
 *        read/write. This will be the {@link CharBuffer}'s 
 *        <code>capacity</code>.
 * @return the {@link ShortBuffer}.
 */
public CharBuffer asCharBuffer(int n) {
  return as(BytePtr.class).asByteBuffer(n << 1).order(ByteOrder.nativeOrder()).asCharBuffer();
}

相关文章