1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/url
7  
// Official repository: https://github.com/boostorg/url
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_URL_IMPL_ERROR_HPP
10  
#ifndef BOOST_URL_IMPL_ERROR_HPP
11  
#define BOOST_URL_IMPL_ERROR_HPP
11  
#define BOOST_URL_IMPL_ERROR_HPP
12  

12  

13  
#include <type_traits>
13  
#include <type_traits>
14  

14  

15  
namespace boost {
15  
namespace boost {
16  

16  

17  
//-----------------------------------------------
17  
//-----------------------------------------------
18  
namespace system {
18  
namespace system {
19  
template<>
19  
template<>
20  
struct is_error_code_enum<::boost::urls::error>
20  
struct is_error_code_enum<::boost::urls::error>
21  
{
21  
{
22  
    static bool const value = true;
22  
    static bool const value = true;
23  
};
23  
};
24  
} // system
24  
} // system
25  
//-----------------------------------------------
25  
//-----------------------------------------------
26  

26  

27  
namespace urls {
27  
namespace urls {
28  

28  

29  
namespace detail {
29  
namespace detail {
30  

30  

31  
struct BOOST_SYMBOL_VISIBLE
31  
struct BOOST_SYMBOL_VISIBLE
32  
    error_cat_type
32  
    error_cat_type
33  
    : system::error_category
33  
    : system::error_category
34  
{
34  
{
35  
    BOOST_URL_DECL
35  
    BOOST_URL_DECL
36  
    const char* name(
36  
    const char* name(
37  
        ) const noexcept override;
37  
        ) const noexcept override;
38  

38  

39  
    BOOST_URL_DECL
39  
    BOOST_URL_DECL
40  
    std::string message(
40  
    std::string message(
41  
        int) const override;
41  
        int) const override;
42  

42  

43  
    BOOST_URL_DECL
43  
    BOOST_URL_DECL
44  
    char const* message(
44  
    char const* message(
45  
        int, char*, std::size_t
45  
        int, char*, std::size_t
46  
            ) const noexcept override;
46  
            ) const noexcept override;
47  

47  

48  
    BOOST_URL_DECL
48  
    BOOST_URL_DECL
49  
    system::error_condition
49  
    system::error_condition
50  
        default_error_condition(
50  
        default_error_condition(
51  
            int code) const noexcept override;
51  
            int code) const noexcept override;
52  

52  

53  
    BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
53  
    BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
54  
        : error_category(0xbc15399d7a4ce829)
54  
        : error_category(0xbc15399d7a4ce829)
55  
    {
55  
    {
56  
    }
56  
    }
57  
};
57  
};
58  

58  

59  
BOOST_URL_DECL extern
59  
BOOST_URL_DECL extern
60  
    error_cat_type error_cat;
60  
    error_cat_type error_cat;
61  

61  

62  
} // detail
62  
} // detail
63  

63  

64  
inline
64  
inline
65  
BOOST_SYSTEM_CONSTEXPR
65  
BOOST_SYSTEM_CONSTEXPR
66  
system::error_code
66  
system::error_code
67  
make_error_code(
67  
make_error_code(
68  
    error ev) noexcept
68  
    error ev) noexcept
69  
{
69  
{
70  
    return system::error_code{
70  
    return system::error_code{
71  
        static_cast<std::underlying_type<
71  
        static_cast<std::underlying_type<
72  
            error>::type>(ev),
72  
            error>::type>(ev),
73  
        detail::error_cat};
73  
        detail::error_cat};
74  
}
74  
}
75  

75  

76  
} // urls
76  
} // urls
77  
} // boost
77  
} // boost
78  

78  

79  
#endif
79  
#endif