Public Types | Public Member Functions

Celartem::DjVu::IFFErrorRecoveryHandler Class Reference

#include <djv_chunkdiag.h>

Inheritance diagram for Celartem::DjVu::IFFErrorRecoveryHandler:
Inheritance graph
[legend]

List of all members.

Public Types

enum  Action { ThrowException = 0, IgnoreThisChunk = 1, IgnoreThisAndTrailingChunks = 2 }

Public Member Functions

virtual Action handleError (Chunk *inParentChunk, const String &inNewChunkId, Storage *inStorage, uint64_t inChunkOffset, size_t inChunkLength, const Exception &inException)=0

Detailed Description

This class is used to control error handling during IFF::deserialize method.
By default, IFF::deserialize throws an exception when it encounters the error on loading a chunk. This class is to recover from such kind of errors.
All you have to do is inherit this class and implement handleError method. Please note that this class should initialized with new. The following is a sample use of this class:

class MyErrorRecovery : public IFFErrorRecoveryHandler
{
public:
    virtual Action handleError(
        Chunk* inParentChunk,
        const String& inNewChunkId,
        Storage* inStorage,
        uint64_t inChunkOffset,
        size_t inChunkLength,
        const Exception& inException)
    {
        // This method ignores chunks with loading errors.
        return IgnoreThisChunk;
    }
};

...

AutoPtr<MyErrorRecovery> recvHandler = new MyErrorRecovery();
AutoPtr<Chunk> chunk = IFF::deserialize(
    storage, NULL, NULL, NULL, NULL, recvHandler);

Member Enumeration Documentation

This enumeration is used to determine how to treat the error.

Enumerator:
ThrowException 

Throw the exception.

IgnoreThisChunk 

Ignore only this broken chunk.

IgnoreThisAndTrailingChunks 

Ignore this and the trailing chunks.


Member Function Documentation

virtual Action Celartem::DjVu::IFFErrorRecoveryHandler::handleError ( Chunk inParentChunk,
const String inNewChunkId,
Storage inStorage,
uint64_t  inChunkOffset,
size_t  inChunkLength,
const Exception inException 
) [pure virtual]

This method determines how to treat the error occured during deserialization.
You can also access to the Storage which contains the actual data which causes the loading problem.

Parameters:
inParentChunk Pointer to the chunk which has been planed to contain the error chunk.
inNewChunkId The Id of the error chunk. If the error was occured on decoding the chunk Id, this may be NullString.
inStorage The Storage instance which contains the data of the error chunk. You can call readBytes, setPos, and several information methods on this and the caller is responsible for restoring the original state after your code.
inChunkOffset The offset of the chunk on inStorage Storage instance.
inChunkLength The size of the chunk on inStorage Storage instance. This may be NULL depending on the error cause.
inException The exception being thrown.
Returns:
One of Action enumeration values which determines the recovery process.

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

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:19.
Caminova Logo