encoding_errors.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <boost/locale/definitions.hpp>
  11. #ifdef BOOST_MSVC
  12. # pragma warning(push)
  13. # pragma warning(disable : 4275 4251 4231 4660)
  14. #endif
  15. #include <stdexcept>
  16. namespace boost {
  17. namespace locale {
  18. namespace conv {
  19. ///
  20. /// \addtogroup codepage
  21. ///
  22. /// @{
  23. ///
  24. /// \brief The excepton that is thrown in case of conversion error
  25. ///
  26. class BOOST_SYMBOL_VISIBLE conversion_error : public std::runtime_error {
  27. public:
  28. conversion_error() : std::runtime_error("Conversion failed") {}
  29. };
  30. ///
  31. /// \brief This exception is thrown in case of use of unsupported
  32. /// or invalid character set
  33. ///
  34. class BOOST_SYMBOL_VISIBLE invalid_charset_error : public std::runtime_error {
  35. public:
  36. /// Create an error for charset \a charset
  37. invalid_charset_error(std::string charset) :
  38. std::runtime_error("Invalid or unsupported charset:" + charset)
  39. {
  40. }
  41. };
  42. ///
  43. /// enum that defines conversion policy
  44. ///
  45. typedef enum {
  46. skip = 0, ///< Skip illegal/unconvertable characters
  47. stop = 1, ///< Stop conversion and throw conversion_error
  48. default_method = skip ///< Default method - skip
  49. } method_type;
  50. /// @}
  51. } // conv
  52. } // locale
  53. } // boost
  54. #ifdef BOOST_MSVC
  55. #pragma warning(pop)
  56. #endif
  57. #endif
  58. // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4