Pyrogenesis  trunk
Public Member Functions | Private Attributes | List of all members
CFileUnpacker Class Reference

helper class for reading binary files More...

#include <FileIo.h>

Collaboration diagram for CFileUnpacker:
Collaboration graph
[legend]

Public Member Functions

 CFileUnpacker ()
 
 ~CFileUnpacker ()
 
void Read (const VfsPath &filename, const char magic[4])
 open and read in given file, check magic bits against those given; throw variety of exceptions if open failed / version incorrect, etc. More...
 
u32 GetVersion () const
 
void UnpackRaw (void *rawData, size_t rawDataSize)
 unpack given number of bytes from the input into the given array. More...
 
size_t UnpackSize ()
 use UnpackRaw to retrieve 32-bits; returns their value as size_t after converting from little endian to native byte order. More...
 
void UnpackString (CStr8 &result)
 unpack a string from the raw data stream. More...
 

Private Attributes

shared_ptr< u8m_buf
 
size_t m_bufSize
 
size_t m_unpackPos
 
u32 m_version
 current unpack position in stream More...
 

Detailed Description

helper class for reading binary files

Constructor & Destructor Documentation

CFileUnpacker::CFileUnpacker ( )
CFileUnpacker::~CFileUnpacker ( )

Member Function Documentation

u32 CFileUnpacker::GetVersion ( ) const
inline
Returns
version number that was stored in the file's header.
void CFileUnpacker::Read ( const VfsPath filename,
const char  magic[4] 
)

open and read in given file, check magic bits against those given; throw variety of exceptions if open failed / version incorrect, etc.

void CFileUnpacker::UnpackRaw ( void *  rawData,
size_t  rawDataSize 
)

unpack given number of bytes from the input into the given array.

throws PSERROR_File_UnexpectedEOF if the end of the data stream is reached before the given number of bytes have been read.

size_t CFileUnpacker::UnpackSize ( )

use UnpackRaw to retrieve 32-bits; returns their value as size_t after converting from little endian to native byte order.

void CFileUnpacker::UnpackString ( CStr8 &  result)

unpack a string from the raw data stream.

Parameters
resultis assigned a newly constructed CStr8 holding the string read from the input stream.

Member Data Documentation

shared_ptr<u8> CFileUnpacker::m_buf
private
size_t CFileUnpacker::m_bufSize
private
size_t CFileUnpacker::m_unpackPos
private
u32 CFileUnpacker::m_version
private

current unpack position in stream


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