ArchiveError.h

// ArchiveError.h
//
// Author David Barrett-Lennard
// (C)opyright Cedanet Pty Ltd 2008

#pragma once
#ifndef Ceda_cxUtils_ArchiveError_H
#define Ceda_cxUtils_ArchiveError_H

#include "Archive.h"
#include "IException.h"
#include "ExceptionBase.h"

namespace ceda
{
const ssize_t MAX_ALLOCATION_SIZE = 1000*1024*1024;

#define SERIALISE_ASSERT(expr) \
        do { if (!(expr)) \
             { \
                 ceda::ThrowDeserialisationError(); \
             } \
           } while (0)

#define SERIALISE_ASSERT2(expr,msg) \
        do { if (!(expr)) \
             { \
                 ceda::ThrowDeserialisationError(msg); \
             } \
           } while (0)

cxUtils_API void ThrowDeserialisationError();
cxUtils_API void ThrowDeserialisationError(ConstStringZ msg);

///////////////////////////////////////////////////////////////////////////////////////////////////
// DeserialisationException

struct DeserialisationException : public ExceptionBase
{
    DeserialisationException(ConstStringZ description) : ExceptionBase(description) {}
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// EndOfStreamException

struct cxUtils_API EndOfStreamException : public IException
{
    virtual void Write(xostream& os) const;
};

} // namespace ceda

#endif // include guard