]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/serialization/src/archive_exception.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / serialization / src / archive_exception.cpp
1 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
2 // archive_exception.cpp:
3
4 // (C) Copyright 2009 Robert Ramey - http://www.rrsd.com .
5 // Use, modification and distribution is subject to the Boost Software
6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 // See http://www.boost.org for updates, documentation, and revision history.
10
11 #if (defined _MSC_VER) && (_MSC_VER == 1200)
12 # pragma warning (disable : 4786) // too long name, harmless warning
13 #endif
14
15 #include <exception>
16 #include <string>
17 #include <cstring>
18
19 #define BOOST_ARCHIVE_SOURCE
20 #include <boost/serialization/config.hpp>
21 #include <boost/archive/archive_exception.hpp>
22
23 namespace boost {
24 namespace archive {
25
26 BOOST_ARCHIVE_DECL
27 unsigned int
28 archive_exception::append(unsigned int l, const char * a){
29 while(l < (sizeof(m_buffer) - 1)){
30 char c = *a++;
31 if('\0' == c)
32 break;
33 m_buffer[l++] = c;
34 }
35 m_buffer[l] = '\0';
36 return l;
37 }
38
39 BOOST_ARCHIVE_DECL
40 archive_exception::archive_exception(
41 exception_code c,
42 const char * e1,
43 const char * e2
44 ) BOOST_NOEXCEPT :
45 code(c)
46 {
47 unsigned int length = 0;
48 switch(code){
49 case no_exception:
50 length = append(length, "uninitialized exception");
51 break;
52 case unregistered_class:
53 length = append(length, "unregistered class");
54 if(NULL != e1){
55 length = append(length, " - ");
56 length = append(length, e1);
57 }
58 break;
59 case invalid_signature:
60 length = append(length, "invalid signature");
61 break;
62 case unsupported_version:
63 length = append(length, "unsupported version");
64 break;
65 case pointer_conflict:
66 length = append(length, "pointer conflict");
67 break;
68 case incompatible_native_format:
69 length = append(length, "incompatible native format");
70 if(NULL != e1){
71 length = append(length, " - ");
72 length = append(length, e1);
73 }
74 break;
75 case array_size_too_short:
76 length = append(length, "array size too short");
77 break;
78 case input_stream_error:
79 length = append(length, "input stream error");
80 break;
81 case invalid_class_name:
82 length = append(length, "class name too long");
83 break;
84 case unregistered_cast:
85 length = append(length, "unregistered void cast ");
86 length = append(length, (NULL != e1) ? e1 : "?");
87 length = append(length, "<-");
88 length = append(length, (NULL != e2) ? e2 : "?");
89 break;
90 case unsupported_class_version:
91 length = append(length, "class version ");
92 length = append(length, (NULL != e1) ? e1 : "<unknown class>");
93 break;
94 case other_exception:
95 // if get here - it indicates a derived exception
96 // was sliced by passing by value in catch
97 length = append(length, "unknown derived exception");
98 break;
99 case multiple_code_instantiation:
100 length = append(length, "code instantiated in more than one module");
101 if(NULL != e1){
102 length = append(length, " - ");
103 length = append(length, e1);
104 }
105 break;
106 case output_stream_error:
107 length = append(length, "output stream error");
108 break;
109 default:
110 BOOST_ASSERT(false);
111 length = append(length, "programming error");
112 break;
113 }
114 }
115
116 BOOST_ARCHIVE_DECL
117 archive_exception::archive_exception(archive_exception const & oth) BOOST_NOEXCEPT :
118 std::exception(oth),
119 code(oth.code)
120 {
121 std::memcpy(m_buffer,oth.m_buffer,sizeof m_buffer);
122 }
123
124 BOOST_ARCHIVE_DECL
125 archive_exception::~archive_exception() BOOST_NOEXCEPT_OR_NOTHROW {}
126
127 BOOST_ARCHIVE_DECL const char *
128 archive_exception::what() const BOOST_NOEXCEPT_OR_NOTHROW {
129 return m_buffer;
130 }
131
132 BOOST_ARCHIVE_DECL
133 archive_exception::archive_exception() BOOST_NOEXCEPT :
134 code(no_exception)
135 {}
136
137 } // archive
138 } // boost