exception.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // boost/filesystem/exception.hpp -----------------------------------------------------//
  2. // Copyright Beman Dawes 2003
  3. // Copyright Andrey Semashev 2019
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // See http://www.boost.org/LICENSE_1_0.txt
  6. // Library home page: http://www.boost.org/libs/filesystem
  7. #ifndef BOOST_FILESYSTEM3_EXCEPTION_HPP
  8. #define BOOST_FILESYSTEM3_EXCEPTION_HPP
  9. #include <boost/config.hpp>
  10. # if defined( BOOST_NO_STD_WSTRING )
  11. # error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
  12. # endif
  13. #include <boost/filesystem/config.hpp>
  14. #include <boost/filesystem/path.hpp>
  15. #include <string>
  16. #include <boost/system/error_code.hpp>
  17. #include <boost/system/system_error.hpp>
  18. #include <boost/smart_ptr/intrusive_ptr.hpp>
  19. #include <boost/smart_ptr/intrusive_ref_counter.hpp>
  20. #include <boost/config/abi_prefix.hpp> // must be the last #include
  21. #if defined(BOOST_MSVC)
  22. #pragma warning(push)
  23. // 'm_A' : class 'A' needs to have dll-interface to be used by clients of class 'B'
  24. #pragma warning(disable: 4251)
  25. // non dll-interface class 'A' used as base for dll-interface class 'B'
  26. #pragma warning(disable: 4275)
  27. #endif
  28. namespace boost {
  29. namespace filesystem {
  30. //--------------------------------------------------------------------------------------//
  31. // //
  32. // class filesystem_error //
  33. // //
  34. //--------------------------------------------------------------------------------------//
  35. class BOOST_FILESYSTEM_DECL filesystem_error :
  36. public system::system_error
  37. {
  38. // see http://www.boost.org/more/error_handling.html for design rationale
  39. public:
  40. filesystem_error(const std::string& what_arg, system::error_code ec);
  41. filesystem_error(const std::string& what_arg, const path& path1_arg, system::error_code ec);
  42. filesystem_error(const std::string& what_arg, const path& path1_arg, const path& path2_arg, system::error_code ec);
  43. filesystem_error(filesystem_error const& that);
  44. filesystem_error& operator= (filesystem_error const& that);
  45. ~filesystem_error() BOOST_NOEXCEPT_OR_NOTHROW;
  46. const path& path1() const BOOST_NOEXCEPT
  47. {
  48. return m_imp_ptr.get() ? m_imp_ptr->m_path1 : get_empty_path();
  49. }
  50. const path& path2() const BOOST_NOEXCEPT
  51. {
  52. return m_imp_ptr.get() ? m_imp_ptr->m_path2 : get_empty_path();
  53. }
  54. const char* what() const BOOST_NOEXCEPT_OR_NOTHROW;
  55. private:
  56. static const path& get_empty_path() BOOST_NOEXCEPT;
  57. private:
  58. struct impl :
  59. public boost::intrusive_ref_counter< impl >
  60. {
  61. path m_path1; // may be empty()
  62. path m_path2; // may be empty()
  63. std::string m_what; // not built until needed
  64. BOOST_DEFAULTED_FUNCTION(impl(), {})
  65. explicit impl(path const& path1) : m_path1(path1) {}
  66. impl(path const& path1, path const& path2) : m_path1(path1), m_path2(path2) {}
  67. };
  68. boost::intrusive_ptr< impl > m_imp_ptr;
  69. };
  70. } // namespace filesystem
  71. } // namespace boost
  72. #if defined(BOOST_MSVC)
  73. #pragma warning(pop)
  74. #endif
  75. #include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
  76. #endif // BOOST_FILESYSTEM3_EXCEPTION_HPP