1  
//
1  
//
2  
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
2  
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot 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/rfc/uri_reference_rule.hpp>
12  
#include <boost/url/rfc/uri_reference_rule.hpp>
13  
#include <boost/url/rfc/uri_rule.hpp>
13  
#include <boost/url/rfc/uri_rule.hpp>
14  
#include <boost/url/rfc/relative_ref_rule.hpp>
14  
#include <boost/url/rfc/relative_ref_rule.hpp>
15  
#include <boost/url/grammar/parse.hpp>
15  
#include <boost/url/grammar/parse.hpp>
16  
#include <boost/url/grammar/variant_rule.hpp>
16  
#include <boost/url/grammar/variant_rule.hpp>
17  
#include <boost/variant2/variant.hpp>
17  
#include <boost/variant2/variant.hpp>
18  

18  

19  
namespace boost {
19  
namespace boost {
20  
namespace urls {
20  
namespace urls {
21  

21  

22  
auto
22  
auto
23  
implementation_defined::uri_reference_rule_t::
23  
implementation_defined::uri_reference_rule_t::
24  
parse(
24  
parse(
25  
    char const*& it,
25  
    char const*& it,
26  
    char const* const end
26  
    char const* const end
27  
        ) const noexcept ->
27  
        ) const noexcept ->
28  
    system::result<value_type>
28  
    system::result<value_type>
29  
{
29  
{
30  
    auto rv = grammar::parse(
30  
    auto rv = grammar::parse(
31  
        it, end,
31  
        it, end,
32  
        grammar::variant_rule(
32  
        grammar::variant_rule(
33  
            uri_rule,
33  
            uri_rule,
34  
            relative_ref_rule));
34  
            relative_ref_rule));
35  
    if(! rv)
35  
    if(! rv)
36  
        return rv.error();
36  
        return rv.error();
37  
    switch(rv->index())
37  
    switch(rv->index())
38  
    {
38  
    {
39  
    default:
39  
    default:
40  
    case 0:
40  
    case 0:
41  
        return boost::variant2::get<0>(*rv);
41  
        return boost::variant2::get<0>(*rv);
42  
    case 1:
42  
    case 1:
43  
        return boost::variant2::get<1>(*rv);
43  
        return boost::variant2::get<1>(*rv);
44  
    }
44  
    }
45  
}
45  
}
46  

46  

47  
} // urls
47  
} // urls
48  
} // boost
48  
} // boost
49  

49