The MemBuffer objects allow you to create a reserved memory space which can contain various binary values. MemBuffers are intended to be used in conjunction with external DLL libraries. Using MemBuffers you can define a structure with several values and pass the entire structure to and from a DLL function. The MemBuffer object can be created using the following syntax:
var Buffer = new MemBuffer(256); // create a memory buffer 256 bytes large |
MemBuffer | Creates a new memory buffer of a specified size. |
Operations | |
SetSize | Resizes the memory buffer to the desired size. |
Reading values | |
GetBool | Reads a boolean value (1 byte) from memory buffer. |
GetByte | Reads an 8-bit integer value from memory buffer. |
GetShort | Reads a 16-bit integer value from memory buffer. |
GetInt | Reads a 32-bit integer value from memory buffer. |
GetFloat | Reads a 16-bit floating point value from memory buffer. |
GetDouble | Reads a 32-bit floating point value from memory buffer. |
GetString | Reads a string value from memory buffer. |
GetPointer | Reads a 32-bit memory-pointer value from memory buffer. |
Storing values | |
SetBool | Writes a boolean value (1 byte) to a memory buffer. |
SetByte | Writes an 8-bit integer value to a memory buffer. |
SetShort | Writes a 16-bit integer value to a memory buffer. |
SetInt | Writes a 32-bit integer value to a memory buffer. |
SetFloat | Writes a 16-bit floating point value to a memory buffer. |
SetDouble | Writes a 32-bit floating point value to a memory buffer. |
SetString | Writes a string value to a memory buffer. |
SetPointer | Writes a 32-bit memory pointer to a memory buffer. |
Type (read only) | Returns always "membuffer" |
Length (read only) | Returns the current length of the associated memory space. |
Creates a new memory buffer of a specified size.
Resizes the memory buffer to the desired size.
Returns true if the buffer has been successfuly resized.
Resizing buffer to zero will free all memory associated with the buffer.
Reads a boolean value (1 byte) from memory buffer.
Returns the value or null if Position is outside the buffer.
Reads an 8-bit integer value from memory buffer.
Returns the value or null if Position is outside the buffer.
Reads a 16-bit integer value from memory buffer.
Returns the value or null if Position is outside the buffer.
Reads a 32-bit integer value from memory buffer.
Returns the value or null if Position is outside the buffer.
Reads a 16-bit floating point value from memory buffer.
Returns the value or null if Position is outside the buffer.
Reads a 32-bit floating point value from memory buffer.
Returns the value or null if Position is outside the buffer.
Reads a string value from memory buffer.
Returns the value or null if Position is outside the buffer.
If you don't specify the Length parameter the string is read until terminating zero or end of buffer is encountered (whichever comes first).
Reads a 32-bit memory-pointer value from memory buffer.
Returns a new MemBuffer object encapsulating the memory pointer or null if Position is outside the buffer.
MemBuffer objects created by this method cannot be bound-checked, resized or saved. Be very careful when working with them.
Writes a boolean value (1 byte) to a memory buffer.
Returns true if the value has been successfuly written.
Writes an 8-bit integer value to a memory buffer.
Returns true if the value has been successfuly written.
Writes a 16-bit integer value to a memory buffer.
Returns true if the value has been successfuly written.
Writes a 32-bit integer value to a memory buffer.
Returns true if the value has been successfuly written.
Writes a 16-bit floating point value to a memory buffer.
Returns true if the value has been successfuly written.
Writes a 32-bit floating point value to a memory buffer.
Returns true if the value has been successfuly written.
Writes a string value to a memory buffer.
Returns true if the value has been successfuly written.
The string is copied to the buffer including its zero terminating character.
Writes a 32-bit memory pointer to a memory buffer.
Returns true if the value has been successfuly written.