100.00% Lines (11/11)
100.00% Functions (2/2)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 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_PARSE_HPP | 11 | #ifndef BOOST_URL_GRAMMAR_IMPL_PARSE_HPP | |||||
| 12 | #define BOOST_URL_GRAMMAR_IMPL_PARSE_HPP | 12 | #define BOOST_URL_GRAMMAR_IMPL_PARSE_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/grammar/error.hpp> | 14 | #include <boost/url/grammar/error.hpp> | |||||
| 15 | #include <boost/url/grammar/type_traits.hpp> | 15 | #include <boost/url/grammar/type_traits.hpp> | |||||
| 16 | 16 | |||||||
| 17 | namespace boost { | 17 | namespace boost { | |||||
| 18 | namespace urls { | 18 | namespace urls { | |||||
| 19 | namespace grammar { | 19 | namespace grammar { | |||||
| 20 | 20 | |||||||
| 21 | template<BOOST_URL_CONSTRAINT(Rule) R> | 21 | template<BOOST_URL_CONSTRAINT(Rule) R> | |||||
| 22 | BOOST_URL_CXX14_CONSTEXPR | 22 | BOOST_URL_CXX14_CONSTEXPR | |||||
| 23 | auto | 23 | auto | |||||
| HITCBC | 24 | 273003 | parse( | 24 | 273035 | parse( | ||
| 25 | char const*& it, | 25 | char const*& it, | |||||
| 26 | char const* end, | 26 | char const* end, | |||||
| 27 | R const& r) -> | 27 | R const& r) -> | |||||
| 28 | system::result<typename R::value_type> | 28 | system::result<typename R::value_type> | |||||
| 29 | { | 29 | { | |||||
| 30 | // If this goes off, it means the rule | 30 | // If this goes off, it means the rule | |||||
| 31 | // passed in did not meet the requirements. | 31 | // passed in did not meet the requirements. | |||||
| 32 | // Please check the documentation. | 32 | // Please check the documentation. | |||||
| 33 | static_assert( | 33 | static_assert( | |||||
| 34 | is_rule<R>::value, | 34 | is_rule<R>::value, | |||||
| 35 | "Rule requirements not met"); | 35 | "Rule requirements not met"); | |||||
| 36 | 36 | |||||||
| HITCBC | 37 | 273003 | return r.parse(it, end); | 37 | 273035 | return r.parse(it, end); | ||
| 38 | } | 38 | } | |||||
| 39 | 39 | |||||||
| 40 | template<BOOST_URL_CONSTRAINT(Rule) R> | 40 | template<BOOST_URL_CONSTRAINT(Rule) R> | |||||
| 41 | BOOST_URL_CXX14_CONSTEXPR | 41 | BOOST_URL_CXX14_CONSTEXPR | |||||
| 42 | auto | 42 | auto | |||||
| HITCBC | 43 | 32812 | parse( | 43 | 32816 | parse( | ||
| 44 | core::string_view s, | 44 | core::string_view s, | |||||
| 45 | R const& r) -> | 45 | R const& r) -> | |||||
| 46 | system::result<typename R::value_type> | 46 | system::result<typename R::value_type> | |||||
| 47 | { | 47 | { | |||||
| 48 | // If this goes off, it means the rule | 48 | // If this goes off, it means the rule | |||||
| 49 | // passed in did not meet the requirements. | 49 | // passed in did not meet the requirements. | |||||
| 50 | // Please check the documentation. | 50 | // Please check the documentation. | |||||
| 51 | static_assert( | 51 | static_assert( | |||||
| 52 | is_rule<R>::value, | 52 | is_rule<R>::value, | |||||
| 53 | "Rule requirements not met"); | 53 | "Rule requirements not met"); | |||||
| 54 | 54 | |||||||
| HITCBC | 55 | 32812 | auto it = s.data(); | 55 | 32816 | auto it = s.data(); | ||
| HITCBC | 56 | 32812 | auto const end = it + s.size(); | 56 | 32816 | auto const end = it + s.size(); | ||
| HITCBC | 57 | 32812 | auto rv = r.parse(it, end); | 57 | 32816 | auto rv = r.parse(it, end); | ||
| HITCBC | 58 | 58137 | if( rv && | 58 | 58145 | if( rv && | ||
| HITCBC | 59 | 25325 | it != end) | 59 | 25329 | it != end) | ||
| HITCBC | 60 | 14519 | return error::leftover; | 60 | 14519 | return error::leftover; | ||
| HITCBC | 61 | 18293 | return rv; | 61 | 18297 | return rv; | ||
| HITCBC | 62 | 338 | } | 62 | 338 | } | ||
| 63 | 63 | |||||||
| 64 | } // grammar | 64 | } // grammar | |||||
| 65 | } // urls | 65 | } // urls | |||||
| 66 | } // boost | 66 | } // boost | |||||
| 67 | 67 | |||||||
| 68 | #endif | 68 | #endif | |||||