#include <LoadC.h>
Public Methods | |
LoadC (PluginClass::FactoryC *pFactory) | |
Default constructor. | |
virtual | ~LoadC () |
Default destructor. | |
virtual PajaTypes::uint32 | open (const char *szName, const PajaTypes::int8 *pSignature, PajaTypes::int32 i32SignatureSize) |
Opens input stream. | |
virtual PajaTypes::uint32 | close () |
Closes the input stream. | |
virtual PajaTypes::uint32 | open_chunk () |
Opens a chunk for read. | |
virtual PajaTypes::uint32 | get_chunk_id () |
Returns the ID if the currently open chunk, this value is used to determine different chunks. | |
virtual PajaTypes::uint32 | get_chunk_version () |
Returns the Version of the currently open chunk. | |
virtual PajaTypes::uint32 | get_chunk_size () |
Returns the size of the currently open chunk. | |
virtual PajaTypes::uint32 | get_chunk_indent () |
Returns the indentation level of the currently open chunk. | |
virtual PajaTypes::uint32 | peek_next_chunk () |
Goes to the next chunk in this indentation level. | |
virtual PajaTypes::uint32 | close_chunk () |
Closes a chunk and goes to the next chunk in the indentation level. | |
virtual PajaTypes::uint32 | read (void *pBuffer, PajaTypes::uint32 ui32Size) |
Reads uiSize bytes to the specified buffer from the stream. | |
virtual PajaTypes::uint32 | read_str (char *szStr) |
Reads a string from the stream. | |
virtual PajaTypes::uint32 | get_error () |
Returns current error. | |
virtual void | add_file_handle_patch (void **pPointer, PajaTypes::uint32 ui32HandleId) |
Adds file handle patch. | |
virtual PajaTypes::uint32 | get_file_handle_patch_count () |
Returns number of file handle patched (used internally). | |
virtual void ** | get_file_handle_patch_pointer (PajaTypes::uint32 ui32Index) |
Returns pointer to patch (used internally). | |
virtual PajaTypes::uint32 | get_file_handle_patch_id (PajaTypes::uint32 ui32Index) |
Returns ID of the pointer to patch (used internally). | |
virtual PluginClass::FactoryC * | get_factory () const |
Returns factory class attached to the LoadC. | |
virtual PajaTypes::uint32 | get_error_message_count () |
Returns number of error messages (used internally). | |
virtual const char * | get_error_message (PajaTypes::uint32 ui32Index) |
Returns error message at given index (used internally). | |
virtual void | add_error_message (const char *szMessage) |
Adds new error message. | |
virtual PajaTypes::uint32 | get_file_size () const |
Returns the size of the file. | |
virtual PajaTypes::uint32 | get_read_pos () const |
Returns the current read position. |
LoadC is used to load the information in Demopaja from a chunk based file format. The data in the output stream is serialized in chunk based format. The read phase consist of opening a chunk, determining the chunk and the version of the chunk, and then reading the data aout of the chunk.
The close_chunk() method skips from the opened chunk to the next chunk even if the whole chunk wasn't read.
This class is implemented by the system.
Example of load() method on effect class:
uint32 TestEffectC::load( LoadC* pLoad ) { uint32 ui32Error = IO_OK; // Open new chunk for read. while( (ui32Error = pLoad->open_chunk()) == IO_OK ) { // Determine which chunk to read. switch( pLoad->get_chunk_id() ) { case CHUNK_TESTEFFECT_BASE: if( pLoad->get_chunk_version() == TESTEFFECT_VERSION ) ui32Error = EffectI::load( pLoad ); break; case CHUNK_TESTEFFECT_TRANSGIZMO: if( pLoad->get_chunk_version() == TESTEFFECT_VERSION ) ui32Error = m_pTransGizmo->load( pLoad ); break; case CHUNK_TESTEFFECT_ATTRIBGIZMO: if( pLoad->get_chunk_version() == TESTEFFECT_VERSION ) ui32Error = m_pAttribGizmo->load( pLoad ); break; default: // Report illegal chunks. assert( 0 ); } // Goto next chunk pLoad->close_chunk(); // Check for errors if( ui32Error != IO_OK && ui32Error != IO_END ) return ui32Error; } return ui32Error; }
|
Default constructor.
|
|
Default destructor.
|
|
Adds new error message. On load the plugin class can report errors via this method. Adding a error message does not stop reading the file. The errors are reported after the file load is completed. |
|
Adds file handle patch.
Since the file referencing is done via file parameter, the system takes care of all the file handle patching in effect classes. Importer classes have to use this file handle patching mechanism. Example of writing file handle: Import::FileHandleC* m_pTextureHandle; uint32 ui32ID; // Write texture handle. if( m_pTextureHandle ) ui32ID = m_pTextureHandle->get_id(); else ui32ID = 0xffffffff; // NULL ID. ui32Error = pSave->write( &ui32ID, sizeof( ui32ID ) ); Example of reading file handle saved in previous example: Import::FileHandleC* m_pTextureHandle; uint32 ui32ID = 0xffffffff; // Read texture handle. ui32Error = pLoad->read( &ui32ID, sizeof( ui32ID) ); if( ui32ID != 0xffffffff ) pLoad->add_file_handle_patch( (void**)&m_pTextureHandle, ui32ID ); |
|
Closes the input stream.
|
|
Closes a chunk and goes to the next chunk in the indentation level. close_chunk uses peek_next_chunk to go to the next chunk. |
|
Returns the ID if the currently open chunk, this value is used to determine different chunks.
|
|
Returns the indentation level of the currently open chunk.
|
|
Returns the size of the currently open chunk.
|
|
Returns the Version of the currently open chunk.
|
|
Returns current error.
|
|
Returns error message at given index (used internally).
|
|
Returns number of error messages (used internally).
|
|
Returns factory class attached to the LoadC.
|
|
Returns number of file handle patched (used internally).
|
|
Returns ID of the pointer to patch (used internally).
|
|
Returns pointer to patch (used internally).
|
|
Returns the size of the file.
|
|
Returns the current read position.
|
|
Opens input stream. See FileIOErrorsE for more information on the error codes. If the signature of the opened file doe not match the given signature the error IO_ERROR_FORMAT is returned.
|
|
Opens a chunk for read. The open_chunk method returns IO_OK if opening succeed. Since the chunks can be hierarchial (that is, chunks stored inside chunks) IO_END is returned if the load() method should not continue to read the data. |
|
Goes to the next chunk in this indentation level.
|
|
Reads uiSize bytes to the specified buffer from the stream.
|
|
Reads a string from the stream.
|