• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
2 #define BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
3 
4 // MS compatible compilers support #pragma once
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8 
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
10 // archive/archive_exception.hpp:
11 
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
13 // Use, modification and distribution is subject to the Boost Software
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
16 
17 //  See http://www.boost.org for updates, documentation, and revision history.
18 
19 #include <exception>
20 #include <boost/assert.hpp>
21 #include <string>
22 
23 #include <boost/config.hpp>
24 #include <boost/archive/detail/decl.hpp>
25 
26 // note: the only reason this is in here is that windows header
27 // includes #define exception_code _exception_code (arrrgghhhh!).
28 // the most expedient way to address this is be sure that this
29 // header is always included whenever this header file is included.
30 #if defined(BOOST_WINDOWS)
31 #include <excpt.h>
32 #endif
33 
34 #include <boost/archive/detail/abi_prefix.hpp> // must be the last header
35 
36 namespace boost {
37 namespace archive {
38 
39 //////////////////////////////////////////////////////////////////////
40 // exceptions thrown by archives
41 //
42 class BOOST_SYMBOL_VISIBLE archive_exception :
43     public virtual std::exception
44 {
45 private:
46     char m_buffer[128];
47 protected:
48     BOOST_ARCHIVE_DECL unsigned int
49     append(unsigned int l, const char * a);
50     BOOST_ARCHIVE_DECL
51     archive_exception() BOOST_NOEXCEPT;
52 public:
53     typedef enum {
54         no_exception,       // initialized without code
55         other_exception,    // any exception not listed below
56         unregistered_class, // attempt to serialize a pointer of
57                             // an unregistered class
58         invalid_signature,  // first line of archive does not contain
59                             // expected string
60         unsupported_version,// archive created with library version
61                             // subsequent to this one
62         pointer_conflict,   // an attempt has been made to directly
63                             // serialize an object which has
64                             // already been serialized through a pointer.
65                             // Were this permitted, the archive load would result
66                             // in the creation of an extra copy of the object.
67         incompatible_native_format, // attempt to read native binary format
68                             // on incompatible platform
69         array_size_too_short,// array being loaded doesn't fit in array allocated
70         input_stream_error, // error on input stream
71         invalid_class_name, // class name greater than the maximum permitted.
72                             // most likely a corrupted archive or an attempt
73                             // to insert virus via buffer overrun method.
74         unregistered_cast,   // base - derived relationship not registered with
75                             // void_cast_register
76         unsupported_class_version, // type saved with a version # greater than the
77                             // one used by the program.  This indicates that the program
78                             // needs to be rebuilt.
79         multiple_code_instantiation, // code for implementing serialization for some
80                             // type has been instantiated in more than one module.
81         output_stream_error // error on input stream
82     } exception_code;
83     exception_code code;
84 
85     BOOST_ARCHIVE_DECL archive_exception(
86         exception_code c,
87         const char * e1 = NULL,
88         const char * e2 = NULL
89     ) BOOST_NOEXCEPT;
90     BOOST_ARCHIVE_DECL archive_exception(archive_exception const &) BOOST_NOEXCEPT;
91     BOOST_ARCHIVE_DECL ~archive_exception() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE;
92     BOOST_ARCHIVE_DECL const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE;
93 };
94 
95 }// namespace archive
96 }// namespace boost
97 
98 #include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas
99 
100 #endif //BOOST_ARCHIVE_ARCHIVE_EXCEPTION_HPP
101