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

12  

13  
#include <boost/url/grammar/error.hpp>
13  
#include <boost/url/grammar/error.hpp>
14  
#include <boost/url/grammar/parse.hpp>
14  
#include <boost/url/grammar/parse.hpp>
15  

15  

16  
namespace boost {
16  
namespace boost {
17  
namespace urls {
17  
namespace urls {
18  
namespace grammar {
18  
namespace grammar {
19  

19  

20  
namespace implementation_defined {
20  
namespace implementation_defined {
21  
template<class R>
21  
template<class R>
22  
auto
22  
auto
23  
not_empty_rule_t<R>::
23  
not_empty_rule_t<R>::
24  
parse(
24  
parse(
25  
    char const*& it,
25  
    char const*& it,
26  
    char const* end) const ->
26  
    char const* end) const ->
27  
        system::result<value_type>
27  
        system::result<value_type>
28  
{
28  
{
29  
    if(it == end)
29  
    if(it == end)
30  
    {
30  
    {
31  
        // empty
31  
        // empty
32  
        BOOST_URL_RETURN_EC(
32  
        BOOST_URL_RETURN_EC(
33  
            error::mismatch);
33  
            error::mismatch);
34  
    }
34  
    }
35  
    auto const it0 = it;
35  
    auto const it0 = it;
36  
    auto rv = r_.parse(it, end);
36  
    auto rv = r_.parse(it, end);
37  
    if(  !rv )
37  
    if(  !rv )
38  
    {
38  
    {
39  
        // error
39  
        // error
40  
        return rv;
40  
        return rv;
41  
    }
41  
    }
42  
    if(it == it0)
42  
    if(it == it0)
43  
    {
43  
    {
44  
        // empty
44  
        // empty
45  
        BOOST_URL_RETURN_EC(
45  
        BOOST_URL_RETURN_EC(
46  
            error::mismatch);
46  
            error::mismatch);
47  
    }
47  
    }
48  
    // value
48  
    // value
49  
    return rv;
49  
    return rv;
50  
}
50  
}
51  
}
51  
}
52  

52  

53  
} // grammar
53  
} // grammar
54  
} // urls
54  
} // urls
55  
} // boost
55  
} // boost
56  

56  

57  
#endif
57  
#endif