public abstract class MemoryIO extends Object
This abstracts read/write operations to either a native memory area, or a java ByteBuffer.
Modifier and Type | Field and Description |
---|---|
protected long |
address |
protected boolean |
isDirect |
Modifier | Constructor and Description |
---|---|
protected |
MemoryIO(boolean direct,
long address) |
Modifier and Type | Method and Description |
---|---|
long |
address()
Gets the native address of this memory region.
|
abstract Object |
array() |
abstract int |
arrayLength() |
abstract int |
arrayOffset() |
abstract ByteBuffer |
asByteBuffer()
Creates a view of this memory object as a java NIO byte buffer.
|
abstract MemoryIO |
dup()
Duplicates this MemoryIO, including its contents.
|
abstract void |
get(long offset,
byte[] dst,
int off,
int len)
Reads an array of bytes from the memory area at the specified offset.
|
abstract void |
get(long offset,
double[] dst,
int off,
int len)
Reads an array of doubles from the memory area at the specified offset.
|
abstract void |
get(long offset,
float[] dst,
int off,
int len)
Reads an array of floats from the memory area at the specified offset.
|
abstract void |
get(long offset,
int[] dst,
int off,
int len)
Reads an array of ints from the memory area at the specified offset.
|
abstract void |
get(long offset,
long[] dst,
int off,
int len)
Reads an array of longs from the memory area at the specified offset.
|
abstract void |
get(long offset,
short[] dst,
int off,
int len)
Reads an array of shorts from the memory area at the specified offset.
|
abstract long |
getAddress(long offset)
Reads a pointer value at the specified offset within the memory area.
|
abstract byte |
getByte(long offset)
Reads an 8 bit integer value from the memory area.
|
abstract double |
getDouble(long offset)
Reads a double value from the memory area.
|
abstract float |
getFloat(long offset)
Reads a float value from the memory area.
|
abstract int |
getInt(long offset)
Reads a 32 bit integer value from the memory area.
|
abstract long |
getLong(long offset)
Reads a 64 bit integer value from the memory area.
|
abstract MemoryIO |
getMemoryIO(long offset)
Reads a pointer value at the specified offset within the memory area, and
wraps it in an abstract memory accessor.
|
abstract long |
getNativeLong(long offset)
Reads a native long integer value from the memory area.
|
abstract short |
getShort(long offset)
Reads a 16 bit integer value from the memory area.
|
abstract byte[] |
getZeroTerminatedByteArray(long offset)
Reads a zero terminated byte array (e.g.
|
abstract byte[] |
getZeroTerminatedByteArray(long offset,
int maxlen)
Reads a zero terminated byte array (e.g.
|
abstract int |
indexOf(long offset,
byte value)
Gets the first index within the memory area of a particular 8 bit value.
|
abstract int |
indexOf(long offset,
byte value,
int maxlen)
Gets the first index within the memory area of a particular 8 bit value.
|
boolean |
isDirect()
Checks if the memory area is a native memory pointer.
|
boolean |
isNull()
Checks if the memory area is NULL.
|
abstract ByteOrder |
order()
Gets the
ByteOrder this MemoryIO instance will read/write
values to memory in. |
abstract void |
put(long offset,
byte[] src,
int off,
int len)
Writes an array of bytes to the memory area at the specified offset.
|
abstract void |
put(long offset,
double[] src,
int off,
int len)
Writes an array of doubles to the memory area at the specified offset.
|
abstract void |
put(long offset,
float[] src,
int off,
int len)
Writes an array of floats to the memory area at the specified offset.
|
abstract void |
put(long offset,
int[] src,
int off,
int len)
Writes an array of ints to the memory area at the specified offset.
|
abstract void |
put(long offset,
long[] src,
int off,
int len)
Writes an array of longs to the memory area at the specified offset.
|
abstract void |
put(long offset,
short[] src,
int off,
int len)
Writes an array of shorts to the memory area at the specified offset.
|
abstract void |
putAddress(long offset,
long value)
Writes a pointer value to the memory area at the specified offset.
|
abstract void |
putByte(long offset,
byte value)
Writes an 8 bit integer value to the memory area at the specified offset.
|
abstract void |
putDouble(long offset,
double value)
Writes a 64 bit float value to the memory area at the specified offset.
|
abstract void |
putFloat(long offset,
float value)
Writes a 32 bit float value to the memory area at the specified offset.
|
abstract void |
putInt(long offset,
int value)
Writes a 32 bit integer value to the memory area at the specified offset.
|
abstract void |
putLong(long offset,
long value)
Writes a 64 bit integer value to the memory area at the specified offset.
|
abstract void |
putMemoryIO(long offset,
MemoryIO value)
Writes a pointer value to the memory area at the specified offset.
|
abstract void |
putNativeLong(long offset,
long value)
Writes a native long integer value to the memory area at the specified offset.
|
abstract void |
putShort(long offset,
short value)
Writes a 16 bit integer value to the memory area at the specified offset.
|
abstract void |
putZeroTerminatedByteArray(long offset,
byte[] bytes,
int off,
int len)
Writes a byte array to memory, and appends a zero terminator
|
abstract void |
setMemory(long offset,
long size,
byte value)
Sets the contents of the memory area to the value.
|
abstract MemoryIO |
slice(long offset)
Creates a new MemoryIO pointing to a subset of the memory area of this
MemoryIO.
|
abstract MemoryIO |
slice(long offset,
long size)
Creates a new MemoryIO pointing to a subset of the memory area of this
MemoryIO.
|
public final boolean isNull()
public final boolean isDirect()
public final long address()
public abstract Object array()
public abstract int arrayOffset()
public abstract int arrayLength()
public abstract ByteOrder order()
ByteOrder
this MemoryIO
instance will read/write
values to memory in.public abstract MemoryIO slice(long offset)
offset
- The offset within the existing memory area to start the
new MemoryIO at.public abstract MemoryIO slice(long offset, long size)
offset
- The offset within the existing memory area to start the
new MemoryIO at.size
- The size of the new slice.public abstract MemoryIO dup()
public abstract ByteBuffer asByteBuffer()
public abstract byte getByte(long offset)
offset
- The offset within the memory area to read the value.public abstract short getShort(long offset)
offset
- The offset within the memory area to read the value.public abstract int getInt(long offset)
offset
- The offset within the memory area to read the value.public abstract long getLong(long offset)
offset
- The offset within the memory area to read the value.public abstract long getNativeLong(long offset)
A native long is 32bits on either ILP32 or LLP64 architectures, and 64 bits on an LP64 architecture.
This means that it will always read a 32bit value on Windows, but on Unix systems such as MacOS or Linux, it will read a 32bit value on 32bit systems, and a 64bit value on 64bit systems.
offset
- The offset within the memory area to read the value.public abstract float getFloat(long offset)
offset
- The offset within the memory area to read the value.public abstract double getDouble(long offset)
offset
- The offset within the memory area to read the value.public abstract long getAddress(long offset)
offset
- The offset within the memory area to read the value.public abstract MemoryIO getMemoryIO(long offset)
offset
- The offset within the memory area to read the value.public abstract void putByte(long offset, byte value)
offset
- The offset within the memory area to write the value.value
- The 8 bit integer value to write to the memory location.public abstract void putShort(long offset, short value)
offset
- The offset within the memory area to write the value.value
- The 16 bit integer value to write to the memory location.public abstract void putInt(long offset, int value)
offset
- The offset within the memory area to write the value.value
- The 32 bit integer value to write to the memory location.public abstract void putLong(long offset, long value)
offset
- The offset within the memory area to write the value.value
- The 64 bit integer value to write to the memory location.public abstract void putNativeLong(long offset, long value)
offset
- The offset within the memory area to write the value.value
- The native long integer value to write to the memory location.public abstract void putFloat(long offset, float value)
offset
- The offset within the memory area to write the value.value
- The 32 bit float value to write to the memory location.public abstract void putDouble(long offset, double value)
offset
- The offset within the memory area to write the value.value
- The 64 bit float value to write to the memory location.public abstract void putMemoryIO(long offset, MemoryIO value)
offset
- The offset within the memory area to write the value.value
- The pointer value to write to the memory location.public abstract void putAddress(long offset, long value)
offset
- The offset within the memory area to write the value.value
- The pointer value to write to the memory location.public abstract void get(long offset, byte[] dst, int off, int len)
offset
- The offset within the memory area to read the bytes.dst
- The output byte array to place the data.off
- The offset within the byte array to start copying.len
- The length of data to read.public abstract void put(long offset, byte[] src, int off, int len)
offset
- The offset within the memory area to start writing the bytes.src
- The byte array to write to the memory area.off
- The offset within the byte array to start copying.len
- The length of data to write.public abstract void get(long offset, short[] dst, int off, int len)
offset
- The offset within the memory area to read the shorts.dst
- The output array to place the data in.off
- The offset within the array to start copying.len
- The number of shorts to read.public abstract void put(long offset, short[] src, int off, int len)
offset
- The offset within the memory area to start writing the shorts.src
- The array to write to the memory area.off
- The offset within the array to start copying.len
- The number of shorts to write.public abstract void get(long offset, int[] dst, int off, int len)
offset
- The offset within the memory area to read the ints.dst
- The output array to place the data in.off
- The offset within the array to start copying.len
- The number of ints to read.public abstract void put(long offset, int[] src, int off, int len)
offset
- The offset within the memory area to start writing the ints.src
- The array to write to the memory area.off
- The offset within the array to start copying.len
- The number of ints to write.public abstract void get(long offset, long[] dst, int off, int len)
offset
- The offset within the memory area to read the longs.dst
- The output array to place the data in.off
- The offset within the array to start copying.len
- The number of longs to read.public abstract void put(long offset, long[] src, int off, int len)
offset
- The offset within the memory area to start writing the longs.src
- The array to write to the memory area.off
- The offset within the array to start copying.len
- The number of longs to write.public abstract void get(long offset, float[] dst, int off, int len)
offset
- The offset within the memory area to read the floats.dst
- The output array to place the data in.off
- The offset within the array to start copying.len
- The number of floats to read.public abstract void put(long offset, float[] src, int off, int len)
offset
- The offset within the memory area to start writing the floats.src
- The array to write to the memory area.off
- The offset within the array to start copying.len
- The number of floats to write.public abstract void get(long offset, double[] dst, int off, int len)
offset
- The offset within the memory area to read the doubles.dst
- The output array to place the data in.off
- The offset within the array to start copying.len
- The number of doubles to read.public abstract void put(long offset, double[] src, int off, int len)
offset
- The offset within the memory area to start writing the doubles.src
- The array to write to the memory area.off
- The offset within the array to start copying.len
- The number of doubles to write.public abstract int indexOf(long offset, byte value)
offset
- The offset within the memory area to start searching.value
- The value to search for.public abstract int indexOf(long offset, byte value, int maxlen)
offset
- The offset within the memory area to start searching.value
- The value to search for.public abstract void setMemory(long offset, long size, byte value)
offset
- The offset within the memory area to start writing.size
- The number of bytes to set to the value.value
- The value to set each byte to.public abstract byte[] getZeroTerminatedByteArray(long offset)
offset
- The offset within the memory area of the start of the string.public abstract byte[] getZeroTerminatedByteArray(long offset, int maxlen)
offset
- The offset within the memory area of the start of the string.maxlen
- The maximum length to search for the zero byte terminator.public abstract void putZeroTerminatedByteArray(long offset, byte[] bytes, int off, int len)
offset
- The offset within the memory area of the start of the string.bytes
- The byte array to write to the memory.off
- The offset with the byte array to start copying.maxlen
- The number of bytes of the byte array to write to the memory area. (not including zero byte)Copyright © 2001-2015 JRuby. All Rights Reserved.