============================================================================== \brief A class for managing memory ranges (binary data in memory) */
| 15 | |
| 16 | */ |
| 17 | class CtrlrLuaMemoryBlock |
| 18 | { |
| 19 | public: |
| 20 | CtrlrLuaMemoryBlock(const MemoryBlock &other); |
| 21 | CtrlrLuaMemoryBlock(); |
| 22 | CtrlrLuaMemoryBlock(const int initialSize, bool zeroData); |
| 23 | CtrlrLuaMemoryBlock(const void *dataToInitialiseFrom, int sizeInBytes); |
| 24 | |
| 25 | /** @brief Constructor that copies data from a LUA array |
| 26 | |
| 27 | @param initialData LUA array to read the data from |
| 28 | */ |
| 29 | CtrlrLuaMemoryBlock(luabind::object const &initialData); |
| 30 | |
| 31 | /** @brief Destructor |
| 32 | |
| 33 | */ |
| 34 | ~CtrlrLuaMemoryBlock(); |
| 35 | |
| 36 | /** @brief Internal |
| 37 | |
| 38 | */ |
| 39 | static void wrapForLua(lua_State *L); |
| 40 | |
| 41 | /** @brief Append some data to this block |
| 42 | |
| 43 | @param dataToAppend array of data to append |
| 44 | */ |
| 45 | void append(const CtrlrLuaObjectWrapper &dataToAppend); |
| 46 | |
| 47 | /** @brief Append a byte to the block |
| 48 | |
| 49 | @param byte the byte to append |
| 50 | */ |
| 51 | void append(const uint8 byte); |
| 52 | |
| 53 | /** @brief Get a range of bytes from this block as a MemoryBlock |
| 54 | |
| 55 | @param startByte starting byte |
| 56 | @param numBytes number of bytes |
| 57 | */ |
| 58 | const CtrlrLuaMemoryBlock getRange(const int startByte, const int numBytes) const; |
| 59 | |
| 60 | /** @brief Convert the block to a HEX string |
| 61 | |
| 62 | @param groupSize byte groups |
| 63 | */ |
| 64 | const String toHexString(const int groupSize=1) const; |
| 65 | |
| 66 | /** @brief Get one byte from the block |
| 67 | |
| 68 | @param bytePosition byte position |
| 69 | */ |
| 70 | const int getByte(const int bytePosition) const; |
| 71 | |
| 72 | /** @brief Set one of the bytes in the block |
| 73 | |
| 74 | @param bytePosition byte position |