Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
helper class for writing binary files. More...
#include <FileIo.h>
Public Member Functions | |
CFilePacker (u32 version, const char magic[4]) | |
adds version and signature (i.e. More... | |
~CFilePacker () | |
void | Write (const VfsPath &filename) |
write out to file all packed data added so far. More... | |
void | PackRaw (const void *rawData, size_t rawDataSize) |
pack given number of bytes onto the end of the data stream More... | |
void | PackSize (size_t value) |
convenience: convert a number (almost always a size type) to little-endian u32 and pack that. More... | |
void | PackString (const CStr8 &str) |
pack a string onto the end of the data stream (encoded as a 32-bit length followed by the characters) More... | |
Private Attributes | |
WriteBuffer | m_writeBuffer |
the output data stream built during pack operations. More... | |
helper class for writing binary files.
this is basically a resizable buffer that allows adding raw data and strings; upon calling Write(), everything is written out to disk.
CFilePacker::CFilePacker | ( | u32 | version, |
const char | magic[4] | ||
) |
adds version and signature (i.e.
the header) to the buffer. this means Write() can write the entire buffer to file in one go, which is simpler and more efficient than writing in pieces.
CFilePacker::~CFilePacker | ( | ) |
void CFilePacker::PackRaw | ( | const void * | rawData, |
size_t | rawDataSize | ||
) |
pack given number of bytes onto the end of the data stream
void CFilePacker::PackSize | ( | size_t | value | ) |
convenience: convert a number (almost always a size type) to little-endian u32 and pack that.
void CFilePacker::PackString | ( | const CStr8 & | str | ) |
pack a string onto the end of the data stream (encoded as a 32-bit length followed by the characters)
void CFilePacker::Write | ( | const VfsPath & | filename | ) |
write out to file all packed data added so far.
it's safe to call this multiple times, but typically would only be done once.
|
private |
the output data stream built during pack operations.
contains the header, so we can write this out in one go.