Chris@16
|
1 #ifndef BOOST_ARCHIVE_ITERATORS_BASE64_EXCEPTION_HPP
|
Chris@16
|
2 #define BOOST_ARCHIVE_ITERATORS_BASE64_EXCEPTION_HPP
|
Chris@16
|
3
|
Chris@16
|
4 // MS compatible compilers support #pragma once
|
Chris@101
|
5 #if defined(_MSC_VER)
|
Chris@16
|
6 # pragma once
|
Chris@16
|
7 #endif
|
Chris@16
|
8
|
Chris@16
|
9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
|
Chris@16
|
10 // base64_exception.hpp:
|
Chris@16
|
11
|
Chris@16
|
12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
|
Chris@16
|
13 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
15 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
16
|
Chris@16
|
17 // See http://www.boost.org for updates, documentation, and revision history.
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/config.hpp>
|
Chris@16
|
20 #ifndef BOOST_NO_EXCEPTIONS
|
Chris@16
|
21 #include <exception>
|
Chris@16
|
22
|
Chris@16
|
23 #include <boost/assert.hpp>
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26 namespace archive {
|
Chris@16
|
27 namespace iterators {
|
Chris@16
|
28
|
Chris@16
|
29 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
30 // exceptions thrown by base64s
|
Chris@16
|
31 //
|
Chris@16
|
32 class base64_exception : public std::exception
|
Chris@16
|
33 {
|
Chris@16
|
34 public:
|
Chris@16
|
35 typedef enum {
|
Chris@16
|
36 invalid_code, // attempt to encode a value > 6 bits
|
Chris@16
|
37 invalid_character, // decode a value not in base64 char set
|
Chris@16
|
38 other_exception
|
Chris@16
|
39 } exception_code;
|
Chris@16
|
40 exception_code code;
|
Chris@16
|
41
|
Chris@16
|
42 base64_exception(exception_code c = other_exception) : code(c)
|
Chris@16
|
43 {}
|
Chris@16
|
44
|
Chris@16
|
45 virtual const char *what( ) const throw( )
|
Chris@16
|
46 {
|
Chris@16
|
47 const char *msg = "unknown exception code";
|
Chris@16
|
48 switch(code){
|
Chris@16
|
49 case invalid_code:
|
Chris@16
|
50 msg = "attempt to encode a value > 6 bits";
|
Chris@16
|
51 break;
|
Chris@16
|
52 case invalid_character:
|
Chris@16
|
53 msg = "attempt to decode a value not in base64 char set";
|
Chris@16
|
54 break;
|
Chris@16
|
55 default:
|
Chris@16
|
56 BOOST_ASSERT(false);
|
Chris@16
|
57 break;
|
Chris@16
|
58 }
|
Chris@16
|
59 return msg;
|
Chris@16
|
60 }
|
Chris@16
|
61 };
|
Chris@16
|
62
|
Chris@16
|
63 } // namespace iterators
|
Chris@16
|
64 } // namespace archive
|
Chris@16
|
65 } // namespace boost
|
Chris@16
|
66
|
Chris@16
|
67 #endif //BOOST_NO_EXCEPTIONS
|
Chris@16
|
68 #endif //BOOST_ARCHIVE_ITERATORS_ARCHIVE_EXCEPTION_HPP
|