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

SaveC Class Reference

Demopaja output stream. More...

#include <SaveC.h>

List of all members.

Public Methods

 SaveC ()
 Default constructor.

virtual ~SaveC ()
 Default destructor.

virtual PajaTypes::uint32 open (const char *szName, const PajaTypes::int8 *pSignature, PajaTypes::int32 i32SignatureSize)
 Opens output stream.

virtual PajaTypes::uint32 close ()
 Flushes all buffers and closes output stream.

virtual PajaTypes::uint32 begin_chunk (PajaTypes::uint32 ui32ID, PajaTypes::uint32 ui32Version)
 Begins a chunk a data.

virtual PajaTypes::uint32 end_chunk ()
 Closes a chunk.

virtual PajaTypes::uint32 write (const void *pBuffer, PajaTypes::uint32 ui32Len)
 Writes a buffer to the stream.

virtual PajaTypes::uint32 write_str (const char *szStr)
 Writes string to the stream.

virtual PajaTypes::uint32 get_error ()
 Returns current error code.


Detailed Description

Demopaja output stream.

SaveC is used to save the information in Demopaja into a chunk based file format. The data in the output stream is serialized in chunk based format. Each begin_chunk() call should be closed with a call to the end_chunk() method.

This class is implemented by the system.

Example of save() method of an effect class:

        uint32
        TestEffectC::save( SaveC* pSave )
        {
            uint32  ui32Error = IO_OK;

            // EffectI stuff
            pSave->begin_chunk( CHUNK_TESTEFFECT_BASE, TESTEFFECT_VERSION );
                ui32Error = EffectI::save( pSave );
            pSave->end_chunk();

            // Save transform gizmo
            pSave->begin_chunk( CHUNK_TESTEFFECT_TRANSGIZMO, TESTEFFECT_VERSION );
                ui32Error = m_pTransGizmo->save( pSave );
            pSave->end_chunk();

            // Save attribute gizmo
            pSave->begin_chunk( CHUNK_TESTEFFECT_ATTRIBGIZMO, TESTEFFECT_VERSION );
                ui32Error = m_pAttribGizmo->save( pSave );
            pSave->end_chunk();

            return ui32Error;
        }

See also:
LoadC


Constructor & Destructor Documentation

SaveC  
 

Default constructor.

virtual ~SaveC   [virtual]
 

Default destructor.


Member Function Documentation

virtual PajaTypes::uint32 begin_chunk PajaTypes::uint32    ui32ID,
PajaTypes::uint32    ui32Version
[virtual]
 

Begins a chunk a data.

Parameters:
ui32ID  ID of the chunk.
ui32Version  Version of the chunk.
Returns :
IO_OK if everything went ok, error otherwise.
The versionin of chunks enables to easy modification to the format of the stored data in the file. The ID and Version info are available when the chunk is read back from the file.

Example:

            ...
            // Begin new chunk of data.
            pSave->begin_chunk( CHUNK_TGAIMPORT_NAME, TGAIMPORT_VERSION );
                // Write data to a chunk.
                sStr = m_sFileName;
                if( sStr.size() > 255 )
                    sStr.resize( 255 );
                ui32Error = pSave->write_str( sStr.c_str() );
            // Close data chunk.
            pSave->end_chunk();
            ...

virtual PajaTypes::uint32 close   [virtual]
 

Flushes all buffers and closes output stream.

virtual PajaTypes::uint32 end_chunk   [virtual]
 

Closes a chunk.

Calls to this method are hierarchial. There can be many chunks open at the same time. The chunk opened by the last call to begin_chunck() is closed.

Returns :
IO_OK if everything went ok, error otherwise.

virtual PajaTypes::uint32 get_error   [virtual]
 

Returns current error code.

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

Opens output stream.

See FileIOErrorsE for more information on the error codes.

Parameters:
szName  NULL terminated name of the output 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.

virtual PajaTypes::uint32 write const void *    pBuffer,
PajaTypes::uint32    ui32Len
[virtual]
 

Writes a buffer to the stream.

Parameters:
pBuffer  pointer to the buffer containing all the data.
ui32Len  length of the buffer in bytes.
Returns :
IO_OK if everything went ok, error otherwise.

virtual PajaTypes::uint32 write_str const char *    szStr [virtual]
 

Writes string to the stream.

Returns :
IO_OK if everything went ok, error otherwise.


Moppi Demopaja SDK Documentation -- Copyright © 2000-2002 Moppi Productions