Main Page Namespace List Class Hierarchy Alphabetical List Compound List Namespace Members Compound Members Related Pages

# FileIO::LoadC Class Reference

Demopaja input stream. More...

`#include <LoadC.h>`

List of all members.

## Public Methods

- LoadC ( PluginClass::FactoryC* pFactory )
- virtual ~LoadC ()
- virtual PajaTypes::uint32 open ( const char* szName, const PajaTypes::int8* pSignature, PajaTypes::int32 i32SignatureSize )
- virtual PajaTypes::uint32 close ()
- virtual PajaTypes::uint32 open_chunk ()
- virtual PajaTypes::uint32 get_chunk_id ()
- virtual PajaTypes::uint32 get_chunk_version ()
- virtual PajaTypes::uint32 get_chunk_size ()
- virtual PajaTypes::uint32 get_chunk_indent ()
- virtual PajaTypes::uint32 peek_next_chunk ()
- virtual PajaTypes::uint32 close_chunk ()
- virtual PajaTypes::uint32 read ( void* pBuffer, PajaTypes::uint32 ui32Size )
- virtual PajaTypes::uint32 read_str ( char* szStr )
- virtual PajaTypes::uint32 get_error ()
- virtual void add_file_handle_patch ( void** pPointer, PajaTypes::uint32 ui32HandleId )
- virtual PajaTypes::uint32 get_file_handle_patch_count ()
- virtual void** get_file_handle_patch_pointer ( PajaTypes::uint32 ui32Index )
- virtual PajaTypes::uint32 get_file_handle_patch_id ( PajaTypes::uint32 ui32Index )
- virtual PluginClass::FactoryC* get_factory () const
- virtual PajaTypes::uint32 get_error_message_count ()
- virtual const char* get_error_message ( PajaTypes::uint32 ui32Index )
- virtual void add_error_message ( const char* szMessage )

## Detailed Description

Demopaja input stream.

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;
            }

See also:
  SaveC

## Constructor & Destructor Documentation

LoadC ( | PluginClass::FactoryC * pFactory )

| Default constructor.

~LoadC ( | )`[virtual]`

| Default destructor.

## Member Function Documentation

void add_error_message ( | const char * szMessage )`[virtual]`

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

void add_file_handle_patch ( | void ** pPointer,
| PajaTypes::uint32 ui32HandleId )`[virtual]`

  | Adds file handle patch. Parameters:
  pPointer | pointer of the file handle pointer.
  ui32HandleId | The ID returned by Import::FileHandleC::get_id().
Via this method a file handle pointer can be set to patched when the data is available. The file handle is patched before the initialize method of effect class is called. Therefore file handle parameters cannot be copied sooner than in the initialize method of the effect class. 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 );

PajaTypes::uint32 close ( | )`[virtual]`

| Closes the input stream.

PajaTypes::uint32 close_chunk ( | )`[virtual]`

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

PajaTypes::uint32 get_chunk_id ( | )`[virtual]`

| Returns the ID if the currently open chunk, this value is used to determine different chunks.

PajaTypes::uint32 get_chunk_indent ( | )`[virtual]`

| Returns the indentation level of the currently open chunk.

PajaTypes::uint32 get_chunk_size ( | )`[virtual]`

| Returns the size of the currently open chunk.

PajaTypes::uint32 get_chunk_version ( | )`[virtual]`

| Returns the Version of the currently open chunk.

PajaTypes::uint32 get_error ( | )`[virtual]`

| Returns current error.

const char * get_error_message ( | PajaTypes::uint32 ui32Index )`[virtual]`

| Returns error message at given index (used internally).

PajaTypes::uint32 get_error_message_count ( | )`[virtual]`

| Returns number of error messages (used internally).

PluginClass::FactoryC * get_factory ( | ) const`[virtual]`

| Returns factory class attached to the LoadC.

PajaTypes::uint32 get_file_handle_patch_count ( | )`[virtual]`

| Returns number of file handle patched (used internally).

PajaTypes::uint32 get_file_handle_patch_id ( | PajaTypes::uint32 ui32Index )`[virtual]`

| Returns ID of the pointer to patch (used internally).

void ** get_file_handle_patch_pointer ( | PajaTypes::uint32 ui32Index )`[virtual]`

| Returns pointer to patch (used internally).

PajaTypes::uint32 open ( | const char * szName,
| const PajaTypes::int8 * pSignature,
| PajaTypes::int32 i32SignatureSize )`[virtual]`

  | 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. Parameters:
  szName | NULL terminated name of the input file.
  pSignature | pointer to array of bytes describing the signature of the file.
  length | of the signature in bytes.
Returns: IO_OK if everything went ok, error otherwise.

PajaTypes::uint32 open_chunk ( | )`[virtual]`

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

PajaTypes::uint32 peek_next_chunk ( | )`[virtual]`

| Goes to the next chunk in this indentation level.

PajaTypes::uint32 read ( | void * pBuffer,
| PajaTypes::uint32 ui32Size )`[virtual]`

| Reads uiSize bytes to the specified buffer from the stream.

PajaTypes::uint32 read_str ( | char * szStr )`[virtual]`

| Reads a string from the stream.

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

- LoadC.h