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  
//
4  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5  
// 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)
6  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
7  
//
7  
// Official repository: https://github.com/boostorg/http_proto
8  
// Official repository: https://github.com/boostorg/http_proto
8  
//
9  
//
9  

10  

10  
#ifndef BOOST_URL_IMPL_GRAMMAR_TOKEN_RULE_HPP
11  
#ifndef BOOST_URL_IMPL_GRAMMAR_TOKEN_RULE_HPP
11  
#define BOOST_URL_IMPL_GRAMMAR_TOKEN_RULE_HPP
12  
#define BOOST_URL_IMPL_GRAMMAR_TOKEN_RULE_HPP
12  

13  

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

15  

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

19  

19  
template<class CharSet>
20  
template<class CharSet>
 
21 +
BOOST_URL_CXX14_CONSTEXPR
20  
auto
22  
auto
21  
implementation_defined::token_rule_t<CharSet>::
23  
implementation_defined::token_rule_t<CharSet>::
22  
parse(
24  
parse(
23  
    char const*& it,
25  
    char const*& it,
24  
    char const* end
26  
    char const* end
25  
        ) const noexcept ->
27  
        ) const noexcept ->
26  
    system::result<value_type>
28  
    system::result<value_type>
27  
{
29  
{
28  
    auto const it0 = it;
30  
    auto const it0 = it;
29  
    if(it == end)
31  
    if(it == end)
30  
    {
32  
    {
31 -
        BOOST_URL_RETURN_EC(
33 +
        BOOST_URL_CONSTEXPR_RETURN_EC(
32  
            error::need_more);
34  
            error::need_more);
33  
    }
35  
    }
34  
    auto const& cs = this->get();
36  
    auto const& cs = this->get();
35  
    it = grammar::find_if_not(it, end, cs);
37  
    it = grammar::find_if_not(it, end, cs);
36  
    if(it != it0)
38  
    if(it != it0)
37  
        return core::string_view(it0, it - it0);
39  
        return core::string_view(it0, it - it0);
38 -
    BOOST_URL_RETURN_EC(
40 +
    BOOST_URL_CONSTEXPR_RETURN_EC(
39  
        error::mismatch);
41  
        error::mismatch);
40  
}
42  
}
41  

43  

42  
} // grammar
44  
} // grammar
43  
} // urls
45  
} // urls
44  
} // boost
46  
} // boost
45  

47  

46  
#endif
48  
#endif