williamr@2: #ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP williamr@2: #define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP williamr@2: williamr@2: // MS compatible compilers support #pragma once williamr@2: #if defined(_MSC_VER) && (_MSC_VER >= 1020) williamr@2: # pragma once williamr@2: #endif williamr@2: williamr@2: /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8 williamr@2: // archive/archive_exception.hpp: williamr@2: williamr@2: // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . williamr@2: // Use, modification and distribution is subject to the Boost Software williamr@2: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at williamr@2: // http://www.boost.org/LICENSE_1_0.txt) williamr@2: williamr@2: // See http://www.boost.org for updates, documentation, and revision history. williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: namespace boost { williamr@2: namespace archive { williamr@2: williamr@2: ////////////////////////////////////////////////////////////////////// williamr@2: // exceptions thrown by archives williamr@2: // williamr@2: class archive_exception : williamr@2: public virtual std::exception williamr@2: { williamr@2: public: williamr@2: typedef enum { williamr@2: no_exception, // initialized without code williamr@2: other_exception, // any excepton not listed below williamr@2: unregistered_class, // attempt to serialize a pointer of an williamr@2: // an unregistered class williamr@2: invalid_signature, // first line of archive does not contain williamr@2: // expected string williamr@2: unsupported_version,// archive created with library version williamr@2: // subsequent to this one williamr@2: pointer_conflict, // an attempt has been made to directly williamr@2: // serialization::detail an object williamr@2: // after having already serialzed the same williamr@2: // object through a pointer. Were this permited, williamr@2: // it the archive load would result in the williamr@2: // creation of an extra copy of the obect. williamr@2: incompatible_native_format, // attempt to read native binary format williamr@2: // on incompatible platform williamr@2: array_size_too_short,// array being loaded doesn't fit in array allocated williamr@2: stream_error, // i/o error on stream williamr@2: invalid_class_name, // class name greater than the maximum permitted. williamr@2: // most likely a corrupted archive or an attempt williamr@2: // to insert virus via buffer overrun method. williamr@2: unregistered_cast // base - derived relationship not registered with williamr@2: // void_cast_register williamr@2: } exception_code; williamr@2: exception_code code; williamr@2: archive_exception(exception_code c) : williamr@2: code(c) williamr@2: {} williamr@2: virtual const char *what( ) const throw( ) williamr@2: { williamr@2: const char *msg = "programming error"; williamr@2: switch(code){ williamr@2: case no_exception: williamr@2: msg = "uninitialized exception"; williamr@2: break; williamr@2: case unregistered_class: williamr@2: msg = "unregistered class"; williamr@2: break; williamr@2: case invalid_signature: williamr@2: msg = "invalid signature"; williamr@2: break; williamr@2: case unsupported_version: williamr@2: msg = "unsupported version"; williamr@2: break; williamr@2: case pointer_conflict: williamr@2: msg = "pointer conflict"; williamr@2: break; williamr@2: case incompatible_native_format: williamr@2: msg = "incompatible native format"; williamr@2: break; williamr@2: case array_size_too_short: williamr@2: msg = "array size too short"; williamr@2: break; williamr@2: case stream_error: williamr@2: msg = "stream error"; williamr@2: break; williamr@2: case invalid_class_name: williamr@2: msg = "class name too long"; williamr@2: break; williamr@2: case unregistered_cast: williamr@2: msg = "unregistered void cast"; williamr@2: break; williamr@2: case other_exception: williamr@2: // if get here - it indicates a derived exception williamr@2: // was sliced by passing by value in catch williamr@2: msg = "unknown derived exception"; williamr@2: break; williamr@2: default: williamr@2: assert(false); williamr@2: break; williamr@2: } williamr@2: return msg; williamr@2: } williamr@2: protected: williamr@2: archive_exception() : williamr@2: code(no_exception) williamr@2: {} williamr@2: }; williamr@2: williamr@2: }// namespace archive williamr@2: }// namespace boost williamr@2: williamr@2: #endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP