error.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/url
  8. //
  9. #ifndef BOOST_URL_IMPL_ERROR_HPP
  10. #define BOOST_URL_IMPL_ERROR_HPP
  11. #include <type_traits>
  12. namespace boost {
  13. //-----------------------------------------------
  14. namespace system {
  15. template<>
  16. struct is_error_code_enum<::boost::urls::error>
  17. {
  18. static bool const value = true;
  19. };
  20. } // system
  21. //-----------------------------------------------
  22. namespace urls {
  23. namespace detail {
  24. struct BOOST_SYMBOL_VISIBLE
  25. error_cat_type
  26. : system::error_category
  27. {
  28. BOOST_URL_DECL
  29. const char* name(
  30. ) const noexcept override;
  31. BOOST_URL_DECL
  32. std::string message(
  33. int) const override;
  34. BOOST_URL_DECL
  35. char const* message(
  36. int, char*, std::size_t
  37. ) const noexcept override;
  38. BOOST_URL_DECL
  39. system::error_condition
  40. default_error_condition(
  41. int code) const noexcept override;
  42. BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
  43. : error_category(0xbc15399d7a4ce829)
  44. {
  45. }
  46. };
  47. BOOST_URL_DECL extern
  48. error_cat_type error_cat;
  49. } // detail
  50. inline
  51. BOOST_SYSTEM_CONSTEXPR
  52. system::error_code
  53. make_error_code(
  54. error ev) noexcept
  55. {
  56. return system::error_code{
  57. static_cast<std::underlying_type<
  58. error>::type>(ev),
  59. detail::error_cat};
  60. }
  61. } // urls
  62. } // boost
  63. #endif