archive_exception.hpp 4.0 KB

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