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