holds arbitrary blocks of memory More...
Public Member Functions | |
number | getByte (uint i) |
get a single byte from an specific location in the block More... | |
BinaryString | getBytes (uint start, uint len) |
get a subset of the memory block More... | |
BinaryString | getData () |
get the data as a JavaScript string More... | |
number | getDataSize () |
get the number of bytes in the block More... | |
Buffer | toBuffer () |
convert MemBlock to Node.js Buffer object More... | |
holds arbitrary blocks of memory
Many functions of PDG, such as Image and Resource data, Streaming I/O, and Networking deal with blocks of memory. Since JavaScript has no way to natively deal with these, PDG adds the MemBlock class to pass those blocks of data between various parts of the PDG libraries.
This class is very similar to the Node.js Buffer class, but has no Node.js dependencies.
getByte | ( | uint | i | ) |
get a single byte from an specific location in the block
i | the offset to the desired byte within the block |
getBytes | ( | uint | start, |
uint | len | ||
) |
get a subset of the memory block
The data is returned as a JavaScript string with binary data (values from 0..255 represented in JavaScript's native 2 byte per char string format). Use pdg.log.binaryDump() to see the data contents in a human readable hex-dump form.
start | the offset in the block to start from |
len | then number of bytes to fetch |
getData | ( | ) |
get the data as a JavaScript string
The data is returned as a JavaScript string with binary data (values from 0..255 represented in JavaScript's native 2 byte per char string format). Use pdg.log.binaryDump() to see the data contents in a human readable hex-dump form.
getDataSize | ( | ) |
get the number of bytes in the block