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

Definition at line 57 of file djv_chunkdiag.h.


Member Enumeration Documentation

enum Celartem::DjVu::IFFErrorRecoveryHandler::Action

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.

Definition at line 63 of file djv_chunkdiag.h.


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 automatically generated using doxygen 1.5.4 at Fri Jun 27 18:23:25 2008.