dataflow_exception.hpp 2.2 KB

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