Line data Source code
1 : //
2 : // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 : // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
4 : //
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)
7 : //
8 : // Official repository: https://github.com/boostorg/url
9 : //
10 :
11 : #ifndef BOOST_URL_GRAMMAR_IMPL_NOT_EMPTY_RULE_HPP
12 : #define BOOST_URL_GRAMMAR_IMPL_NOT_EMPTY_RULE_HPP
13 :
14 : #include <boost/url/grammar/error.hpp>
15 : #include <boost/url/grammar/parse.hpp>
16 :
17 : namespace boost {
18 : namespace urls {
19 : namespace grammar {
20 :
21 : namespace implementation_defined {
22 : template<class R>
23 : BOOST_URL_CXX14_CONSTEXPR
24 : auto
25 8 : not_empty_rule_t<R>::
26 : parse(
27 : char const*& it,
28 : char const* end) const ->
29 : system::result<value_type>
30 : {
31 8 : if(it == end)
32 : {
33 : // empty
34 1 : BOOST_URL_CONSTEXPR_RETURN_EC(
35 : error::mismatch);
36 : }
37 7 : auto const it0 = it;
38 7 : auto rv = r_.parse(it, end);
39 7 : if( !rv )
40 : {
41 : // error
42 3 : return rv;
43 : }
44 4 : if(it == it0)
45 : {
46 : // empty
47 1 : BOOST_URL_CONSTEXPR_RETURN_EC(
48 : error::mismatch);
49 : }
50 : // value
51 3 : return rv;
52 : }
53 : }
54 :
55 : } // grammar
56 : } // urls
57 : } // boost
58 :
59 : #endif
|