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  
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
3  
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
4  
//
4  
//
5  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
6  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  
//
7  
//
8  
// Official repository: https://github.com/boostorg/url
8  
// Official repository: https://github.com/boostorg/url
9  
//
9  
//
10  

10  

11  
#ifndef BOOST_URL_GRAMMAR_IMPL_NOT_EMPTY_RULE_HPP
11  
#ifndef BOOST_URL_GRAMMAR_IMPL_NOT_EMPTY_RULE_HPP
12  
#define BOOST_URL_GRAMMAR_IMPL_NOT_EMPTY_RULE_HPP
12  
#define BOOST_URL_GRAMMAR_IMPL_NOT_EMPTY_RULE_HPP
13  

13  

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

16  

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

20  

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

54  

55  
} // grammar
55  
} // grammar
56  
} // urls
56  
} // urls
57  
} // boost
57  
} // boost
58  

58  

59  
#endif
59  
#endif