1 //
2 //  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 //  Distributed under the Boost Software License, Version 1.0. (See
5 //  accompanying file LICENSE_1_0.txt or copy at
6 //  http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_LOCALE_ENCODING_ERRORS_HPP_INCLUDED
9 #define BOOST_LOCALE_ENCODING_ERRORS_HPP_INCLUDED
10 
11 #include <boost/locale/definitions.hpp>
12 #ifdef BOOST_MSVC
13 #  pragma warning(push)
14 #  pragma warning(disable : 4275 4251 4231 4660)
15 #endif
16 #include <stdexcept>
17 
18 
19 
20 namespace boost {
21     namespace locale {
22         namespace conv {
23             ///
24             /// \addtogroup codepage
25             ///
26             /// @{
27 
28             ///
29             /// \brief The excepton that is thrown in case of conversion error
30             ///
31             class BOOST_SYMBOL_VISIBLE conversion_error : public std::runtime_error {
32             public:
conversion_error()33                 conversion_error() : std::runtime_error("Conversion failed") {}
34             };
35 
36             ///
37             /// \brief This exception is thrown in case of use of unsupported
38             /// or invalid character set
39             ///
40             class BOOST_SYMBOL_VISIBLE invalid_charset_error : public std::runtime_error {
41             public:
42 
43                 /// Create an error for charset \a charset
invalid_charset_error(std::string charset)44                 invalid_charset_error(std::string charset) :
45                     std::runtime_error("Invalid or unsupported charset:" + charset)
46                 {
47                 }
48             };
49 
50 
51             ///
52             /// enum that defines conversion policy
53             ///
54             typedef enum {
55                 skip            = 0,    ///< Skip illegal/unconvertable characters
56                 stop            = 1,    ///< Stop conversion and throw conversion_error
57                 default_method  = skip  ///< Default method - skip
58             } method_type;
59 
60 
61             /// @}
62 
63         } // conv
64 
65     } // locale
66 } // boost
67 
68 #ifdef BOOST_MSVC
69 #pragma warning(pop)
70 #endif
71 
72 #endif
73 
74 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
75 
76