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

12  

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  
namespace grammar {
17  
namespace grammar {
18  

18  

19  
template<class R>
19  
template<class R>
20  
auto
20  
auto
21  
implementation_defined::optional_rule_t<R>::
21  
implementation_defined::optional_rule_t<R>::
22  
parse(
22  
parse(
23  
    char const*& it,
23  
    char const*& it,
24  
    char const* end) const ->
24  
    char const* end) const ->
25  
        system::result<value_type>
25  
        system::result<value_type>
26  
{
26  
{
27  
    if(it == end)
27  
    if(it == end)
28  
        return boost::none;
28  
        return boost::none;
29  
    auto const it0 = it;
29  
    auto const it0 = it;
30  
    auto rv =
30  
    auto rv =
31  
        this->get().parse(it, end);
31  
        this->get().parse(it, end);
32  
    if(rv)
32  
    if(rv)
33  
        return value_type(*rv);
33  
        return value_type(*rv);
34  
    it = it0;
34  
    it = it0;
35  
    return boost::none;
35  
    return boost::none;
36  
}
36  
}
37  

37  

38  
} // grammar
38  
} // grammar
39  
} // urls
39  
} // urls
40  
} // boost
40  
} // boost
41  

41  

42  
#endif
42  
#endif