include/boost/url/grammar/impl/optional_rule.hpp

100.0% Lines (9/9) 66.7% Functions (2/4) 83.3% Branches (5/6)
include/boost/url/grammar/impl/optional_rule.hpp
Line Branch Hits 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_OPTIONAL_RULE_HPP
12 #define BOOST_URL_GRAMMAR_IMPL_OPTIONAL_RULE_HPP
13
14 #include <boost/url/grammar/error.hpp>
15
16 namespace boost {
17 namespace urls {
18 namespace grammar {
19
20 template<class R>
21 BOOST_URL_CXX14_CONSTEXPR
22 auto
23 4316 implementation_defined::optional_rule_t<R>::
24 parse(
25 char const*& it,
26 char const* end) const ->
27 system::result<value_type>
28 {
29
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 1968 times.
4316 if(it == end)
30 256 return boost::none;
31 4060 auto const it0 = it;
32 auto rv =
33
0/1
✗ Branch 2 not taken.
4060 this->get().parse(it, end);
34
2/2
✓ Branch 1 taken 406 times.
✓ Branch 2 taken 1562 times.
4060 if(rv)
35
1/1
✓ Branch 2 taken 406 times.
1624 return value_type(*rv);
36 2436 it = it0;
37 2436 return boost::none;
38 }
39
40 } // grammar
41 } // urls
42 } // boost
43
44 #endif
45