encoding_errors.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #ifndef BOOST_LOCALE_ENCODING_ERRORS_HPP_INCLUDED
  7. #define BOOST_LOCALE_ENCODING_ERRORS_HPP_INCLUDED
  8. #include <boost/locale/config.hpp>
  9. #include <stdexcept>
  10. #include <string>
  11. #ifdef BOOST_MSVC
  12. # pragma warning(push)
  13. # pragma warning(disable : 4275 4251 4231 4660)
  14. #endif
  15. namespace boost { namespace locale { namespace conv {
  16. /// \addtogroup codepage
  17. ///
  18. /// @{
  19. /// \brief The exception that is thrown in case of conversion error
  20. class BOOST_SYMBOL_VISIBLE conversion_error : public std::runtime_error {
  21. public:
  22. conversion_error() : std::runtime_error("Conversion failed") {}
  23. };
  24. /// \brief This exception is thrown in case of use of unsupported
  25. /// or invalid character set
  26. class BOOST_SYMBOL_VISIBLE invalid_charset_error : public std::runtime_error {
  27. public:
  28. /// Create an error for charset \a charset
  29. invalid_charset_error(const std::string& charset) :
  30. std::runtime_error("Invalid or unsupported charset: " + charset)
  31. {}
  32. };
  33. /// enum that defines conversion policy
  34. enum method_type {
  35. skip = 0, ///< Skip illegal/unconvertible characters
  36. stop = 1, ///< Stop conversion and throw conversion_error
  37. default_method = skip ///< Default method - skip
  38. };
  39. /// @}
  40. }}} // namespace boost::locale::conv
  41. #ifdef BOOST_MSVC
  42. # pragma warning(pop)
  43. #endif
  44. #endif