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_GRAMMAR_IMPL_ERROR_HPP
10  
#ifndef BOOST_URL_GRAMMAR_IMPL_ERROR_HPP
11  
#define BOOST_URL_GRAMMAR_IMPL_ERROR_HPP
11  
#define BOOST_URL_GRAMMAR_IMPL_ERROR_HPP
12  

12  

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

14  

15  
namespace boost {
15  
namespace boost {
16  
namespace system {
16  
namespace system {
17  
template<>
17  
template<>
18  
struct is_error_code_enum<
18  
struct is_error_code_enum<
19  
    ::boost::urls::grammar::error>
19  
    ::boost::urls::grammar::error>
20  
{
20  
{
21  
    static bool const value = true;
21  
    static bool const value = true;
22  
};
22  
};
23  
template<>
23  
template<>
24  
struct is_error_condition_enum<
24  
struct is_error_condition_enum<
25  
    ::boost::urls::grammar::condition>
25  
    ::boost::urls::grammar::condition>
26  
{
26  
{
27  
    static bool const value = true;
27  
    static bool const value = true;
28  
};
28  
};
29  
} // system
29  
} // system
30  
} // boost
30  
} // boost
31  

31  

32  
namespace boost {
32  
namespace boost {
33  
namespace urls {
33  
namespace urls {
34  
namespace grammar {
34  
namespace grammar {
35  

35  

36  
namespace detail {
36  
namespace detail {
37  

37  

38  
struct BOOST_SYMBOL_VISIBLE
38  
struct BOOST_SYMBOL_VISIBLE
39  
    error_cat_type
39  
    error_cat_type
40  
    : system::error_category
40  
    : system::error_category
41  
{
41  
{
42  
    BOOST_URL_DECL
42  
    BOOST_URL_DECL
43  
    const char* name(
43  
    const char* name(
44  
        ) const noexcept override;
44  
        ) const noexcept override;
45  

45  

46  
    BOOST_URL_DECL
46  
    BOOST_URL_DECL
47  
    std::string message(
47  
    std::string message(
48  
        int) const override;
48  
        int) const override;
49  

49  

50  
    BOOST_URL_DECL
50  
    BOOST_URL_DECL
51  
    char const* message(
51  
    char const* message(
52  
        int, char*, std::size_t
52  
        int, char*, std::size_t
53  
            ) const noexcept override;
53  
            ) const noexcept override;
54  

54  

55  
    BOOST_URL_DECL
55  
    BOOST_URL_DECL
56  
    system::error_condition
56  
    system::error_condition
57  
        default_error_condition(
57  
        default_error_condition(
58  
            int code) const noexcept override;
58  
            int code) const noexcept override;
59  

59  

60  
    BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
60  
    BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept
61  
        : error_category(0x0536e50a30f9e9f2)
61  
        : error_category(0x0536e50a30f9e9f2)
62  
    {
62  
    {
63  
    }
63  
    }
64  
};
64  
};
65  

65  

66  
struct BOOST_SYMBOL_VISIBLE
66  
struct BOOST_SYMBOL_VISIBLE
67  
    condition_cat_type
67  
    condition_cat_type
68  
    : system::error_category
68  
    : system::error_category
69  
{
69  
{
70  
    BOOST_URL_DECL
70  
    BOOST_URL_DECL
71  
    const char* name(
71  
    const char* name(
72  
        ) const noexcept override;
72  
        ) const noexcept override;
73  

73  

74  
    BOOST_URL_DECL
74  
    BOOST_URL_DECL
75  
    std::string message(
75  
    std::string message(
76  
        int) const override;
76  
        int) const override;
77  

77  

78  
    BOOST_URL_DECL
78  
    BOOST_URL_DECL
79  
    char const* message(
79  
    char const* message(
80  
        int, char*, std::size_t
80  
        int, char*, std::size_t
81  
            ) const noexcept override;
81  
            ) const noexcept override;
82  

82  

83  
    BOOST_SYSTEM_CONSTEXPR condition_cat_type()
83  
    BOOST_SYSTEM_CONSTEXPR condition_cat_type()
84  
        : error_category(0x0536e50a30f9e9f2)
84  
        : error_category(0x0536e50a30f9e9f2)
85  
    {
85  
    {
86  
    }
86  
    }
87  
};
87  
};
88  

88  

89  
BOOST_URL_DECL extern
89  
BOOST_URL_DECL extern
90  
    error_cat_type error_cat;
90  
    error_cat_type error_cat;
91  

91  

92  
BOOST_URL_DECL extern
92  
BOOST_URL_DECL extern
93  
    condition_cat_type condition_cat;
93  
    condition_cat_type condition_cat;
94  

94  

95  
} // detail
95  
} // detail
96  

96  

97  
inline
97  
inline
98  
system::error_code
98  
system::error_code
99  
make_error_code(
99  
make_error_code(
100  
    error ev) noexcept
100  
    error ev) noexcept
101  
{
101  
{
102  
    return system::error_code{
102  
    return system::error_code{
103  
        static_cast<std::underlying_type<
103  
        static_cast<std::underlying_type<
104  
            error>::type>(ev),
104  
            error>::type>(ev),
105  
                detail::error_cat};
105  
                detail::error_cat};
106  
}
106  
}
107  

107  

108  
inline
108  
inline
109  
system::error_condition
109  
system::error_condition
110  
make_error_condition(
110  
make_error_condition(
111  
    condition c) noexcept
111  
    condition c) noexcept
112  
{
112  
{
113  
    return system::error_condition{
113  
    return system::error_condition{
114  
        static_cast<std::underlying_type<
114  
        static_cast<std::underlying_type<
115  
            condition>::type>(c),
115  
            condition>::type>(c),
116  
                detail::condition_cat};
116  
                detail::condition_cat};
117  
}
117  
}
118  

118  

119  
} // grammar
119  
} // grammar
120  
} // urls
120  
} // urls
121  
} // boost
121  
} // boost
122  

122  

123  
#endif
123  
#endif