MemoryBuffer class

From Solid Graphics Wiki

Jump to: navigation, search
MemoryBuffer class
Namespace: SKL
Base type: (None)
Include: SklCommon.h
Lib (Release): SKL.lib
Lib (Debug): SKL_D.lib

The MemoryBuffer class provides functionality of a raw binary buffer. The class provides memory allocation and deallocation (by the class destructor), as well as additional helper function, such as method for appending binary data, loading the data from a file or application-attached resource, or for compressing and decompressing the binary data (using ZLIB functions internally).


The class provides only basic constructors - a constructor with no parameters and a copy constructor.


The class has no public fields defined.


Method name Description
Allocate Allocates the memory buffer of specified capacity in bytes. If the memory buffer already has data in it then the data currently held are preserved.
Capacity Returns current capacity of the memory buffer in number of bytes.
SetData Copies specified number of bytes of binary data from specified memory pointer into the MemoryBuffer object. The Size "property" of the MemoryBuffer object is set to specified number of bytes. Before the data are copied and if needed - the MemoryBuffer object allocates enough memory to hold requested data.
SetSize Sets memory buffer size to specified length in bytes. The method also ensures that the MemoryBuffer has enough capacity to hold the data of the specified size.
Append Appends specified string data to the end of the buffer. The method grows the MemoryBuffer capacity if needed.
Data Returns char* pointer to current MemoryBuffer data. Be aware that the pointer can be later on invalidated when additional data are added to the MemoryBuffer and the buffer is reallocated to bigger size. Don't cache the returned pointer!
Size Returns size of data held in the memory buffer.
LoadFromResource Loads memory buffer data from specified application-attached resource.
LoadFromFile Loads memory buffer data from specified file.
LoadFromRegistry Loads memory buffer data from specified registry value.
CompressData Compresses current memory buffer binary data content (internally using the ZLIB functions). After the memory buffer is compressed it's Size "property" will return value less or equal than the size before the data compression.
UncompressData Uncompresses the binary data. After the memory buffer is uncompressed it's Size "property" will return value greater or equal than the size before the uncompression. The memory buffer data must be previously compressed by the CompressData method.
SaveToFile Save memory buffer data into a file.
SaveToRegistry Saves memory buffer data into a registry value.
IsEqualToFileContent Compares mmory buffer content with content of a file. Returns true if equa;, otherwise false.


= Copies one memory buffer object data to another.

See Also


SolidKit Library Documentation

Personal tools