Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CFilePacker Class Reference

helper class for writing binary files. More...

#include <FileIo.h>

Collaboration diagram for CFilePacker:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CFilePacker()

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::~CFilePacker ( )

Member Function Documentation

◆ PackRaw()

void CFilePacker::PackRaw ( const void *  rawData,
size_t  rawDataSize 
)

pack given number of bytes onto the end of the data stream

◆ PackSize()

void CFilePacker::PackSize ( size_t  value)

convenience: convert a number (almost always a size type) to little-endian u32 and pack that.

◆ PackString()

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)

◆ Write()

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.

Member Data Documentation

◆ m_writeBuffer

WriteBuffer CFilePacker::m_writeBuffer
private

the output data stream built during pack operations.

contains the header, so we can write this out in one go.


The documentation for this class was generated from the following files: