SophiaFramework UNIVERSE 5.3 |
The SFXMemory class is used to read / write data from / into the memory storage.
Data can be read from /written into the memory storage using the SFXMemory class as follows:
How to use the SFXMemory class
Memory pointer | |
---|---|
The SFXMemory class has the memory pointer. The SFXMemory::Read / SFXMemory::Write function reads / writes data from / into the memory storage through the memory pointer, which will advance by the amount of the read / written data. It is possible to move the memory pointer with the SFXMemory::Seek / SFXMemory::SeekStart / SFXMemory::SeekEnd. Or, when data is read or written using the stream, the file pointer will advance by the amount of the read / written data too. Or, when data is read or written using the stream, the memory pointer will advance by the amount of the read / written data too. |
Example 18.6. Initiate
SFXMemory memory; // open empty memory (size = 0) memory.Open(); // open memory that has specified value in internal buffer memory.Open("data buffer", 11); // get streams memory.GetStreamReader(&reader); memory.GetStreamWriter(&writer); // read and write data through streams
Note | |
---|---|
There are two methods to create the SFXMemory instance and open the memory. |
When closing memory, its content can be stored into the specified variable as the code below.
Example 18.8. Terminate 2
SFXBuffer buffer; // buffer to store the content of the memory storage SFCError error; // error value // close memory(internal buffer will be empty after copying its content to the buffer variable) // * note that SFXMemory::Close() returns error value in this case error = memory.Close(&buffer);
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |