Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
CFilePacker Class Reference

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

Definition at line 52 of file FileIo.h.

Constructor & Destructor Documentation

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.

Definition at line 45 of file FileIo.cpp.

CFilePacker::~CFilePacker ( )

Definition at line 57 of file FileIo.cpp.

Member Function Documentation

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

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

Definition at line 78 of file FileIo.cpp.

void CFilePacker::PackSize ( size_t  value)

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

Definition at line 83 of file FileIo.cpp.

void CFilePacker::PackString ( const CStr &  str)

pack a string onto the end of the data stream (encoded as a 32-bit length followed by the characters)

Definition at line 89 of file FileIo.cpp.

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.

Definition at line 62 of file FileIo.cpp.

Member Data Documentation

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.

Definition at line 93 of file FileIo.h.


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