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  

10  

11  
#include <boost/url/detail/config.hpp>
11  
#include <boost/url/detail/config.hpp>
12  
#include <boost/url/error.hpp>
12  
#include <boost/url/error.hpp>
13  
#include <boost/url/grammar/error.hpp>
13  
#include <boost/url/grammar/error.hpp>
14  

14  

15  
namespace boost {
15  
namespace boost {
16  
namespace urls {
16  
namespace urls {
17  

17  

18  
namespace detail {
18  
namespace detail {
19  

19  

20  
const char*
20  
const char*
21  
error_cat_type::
21  
error_cat_type::
22  
name() const noexcept
22  
name() const noexcept
23  
{
23  
{
24  
    return "boost.url";
24  
    return "boost.url";
25  
}
25  
}
26  

26  

27  
std::string
27  
std::string
28  
error_cat_type::
28  
error_cat_type::
29  
message(int code) const
29  
message(int code) const
30  
{
30  
{
31  
    return message(code, nullptr, 0);
31  
    return message(code, nullptr, 0);
32  
}
32  
}
33  

33  

34  
char const*
34  
char const*
35  
error_cat_type::
35  
error_cat_type::
36  
message(
36  
message(
37  
    int code,
37  
    int code,
38  
    char*,
38  
    char*,
39  
    std::size_t) const noexcept
39  
    std::size_t) const noexcept
40  
{
40  
{
41  
    switch(static_cast<error>(code))
41  
    switch(static_cast<error>(code))
42  
    {
42  
    {
43  
case error::success: return "success";
43  
case error::success: return "success";
44  
case error::illegal_null: return "illegal null";
44  
case error::illegal_null: return "illegal null";
45  
case error::illegal_reserved_char: return "illegal reserved char";
45  
case error::illegal_reserved_char: return "illegal reserved char";
46  
case error::non_canonical: return "non canonical";
46  
case error::non_canonical: return "non canonical";
47  

47  

48  
case error::bad_pct_hexdig: return "bad hexdig in pct-encoding";
48  
case error::bad_pct_hexdig: return "bad hexdig in pct-encoding";
49  
case error::incomplete_encoding: return "incomplete pct-encoding";
49  
case error::incomplete_encoding: return "incomplete pct-encoding";
50  
case error::missing_pct_hexdig: return "missing hexdig in pct-encoding";
50  
case error::missing_pct_hexdig: return "missing hexdig in pct-encoding";
51  
case error::no_space: return "no space";
51  
case error::no_space: return "no space";
52  
case error::not_a_base: return "not a base";
52  
case error::not_a_base: return "not a base";
53  
    }
53  
    }
54  
    return "";
54  
    return "";
55  
}
55  
}
56  

56  

57  
system::error_condition
57  
system::error_condition
58  
error_cat_type::
58  
error_cat_type::
59  
default_error_condition(
59  
default_error_condition(
60  
    int ev) const noexcept
60  
    int ev) const noexcept
61  
{
61  
{
62  
    switch(static_cast<error>(ev))
62  
    switch(static_cast<error>(ev))
63  
    {
63  
    {
64  
    default:
64  
    default:
65  
        return {ev, *this};
65  
        return {ev, *this};
66  

66  

67  
case error::bad_pct_hexdig:
67  
case error::bad_pct_hexdig:
68  
case error::incomplete_encoding:
68  
case error::incomplete_encoding:
69  
case error::missing_pct_hexdig:
69  
case error::missing_pct_hexdig:
70  
        return grammar::condition::fatal;
70  
        return grammar::condition::fatal;
71  
    }
71  
    }
72  
}
72  
}
73  

73  

74  
//-----------------------------------------------
74  
//-----------------------------------------------
75  

75  

76  
// msvc 14.0 has a bug that warns about inability
76  
// msvc 14.0 has a bug that warns about inability
77  
// to use constexpr construction here, even though
77  
// to use constexpr construction here, even though
78  
// there's no constexpr construction
78  
// there's no constexpr construction
79  
#if defined(_MSC_VER) && _MSC_VER <= 1900
79  
#if defined(_MSC_VER) && _MSC_VER <= 1900
80  
# pragma warning( push )
80  
# pragma warning( push )
81  
# pragma warning( disable : 4592 )
81  
# pragma warning( disable : 4592 )
82  
#endif
82  
#endif
83  

83  

84  
error_cat_type error_cat;
84  
error_cat_type error_cat;
85  

85  

86  
#if defined(_MSC_VER) && _MSC_VER <= 1900
86  
#if defined(_MSC_VER) && _MSC_VER <= 1900
87  
# pragma warning( pop )
87  
# pragma warning( pop )
88  
#endif
88  
#endif
89  

89  

90  
} // detail
90  
} // detail
91  

91  

92  
} // urls
92  
} // urls
93  
} // boost
93  
} // boost
94  

94