Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) | ||
3 | // | ||
4 | // 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 | // | ||
7 | // Official repository: https://github.com/boostorg/url | ||
8 | // | ||
9 | |||
10 | #ifndef BOOST_URL_RFC_DETAIL_QUERY_PART_RULE_HPP | ||
11 | #define BOOST_URL_RFC_DETAIL_QUERY_PART_RULE_HPP | ||
12 | |||
13 | #include <boost/url/detail/config.hpp> | ||
14 | #include <boost/url/error_types.hpp> | ||
15 | #include <boost/url/pct_string_view.hpp> | ||
16 | #include <boost/url/rfc/query_rule.hpp> | ||
17 | #include <boost/url/grammar/parse.hpp> | ||
18 | #include <cstdlib> | ||
19 | |||
20 | namespace boost { | ||
21 | namespace urls { | ||
22 | namespace detail { | ||
23 | |||
24 | /** Rule for query-part | ||
25 | |||
26 | @par BNF | ||
27 | @code | ||
28 | query-part = [ "?" query ] | ||
29 | @endcode | ||
30 | */ | ||
31 | struct query_part_rule_t | ||
32 | { | ||
33 | struct value_type | ||
34 | { | ||
35 | pct_string_view query; | ||
36 | std::size_t count = 0; | ||
37 | bool has_query = false; | ||
38 | }; | ||
39 | |||
40 | auto | ||
41 | 3499 | parse( | |
42 | char const*& it, | ||
43 | char const* end | ||
44 | ) const noexcept -> | ||
45 | system::result<value_type> | ||
46 | { | ||
47 |
2/2✓ Branch 0 taken 649 times.
✓ Branch 1 taken 2850 times.
|
3499 | if( it == end || |
48 |
2/2✓ Branch 0 taken 225 times.
✓ Branch 1 taken 424 times.
|
649 | *it != '?') |
49 | 3075 | return {}; | |
50 | 424 | ++it; | |
51 | auto rv = grammar::parse( | ||
52 | 424 | it, end, query_rule); | |
53 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 422 times.
|
424 | if(! rv) |
54 | 2 | return rv.error(); | |
55 | 422 | value_type t; | |
56 | 422 | t.query = rv->buffer(); | |
57 | 422 | t.count = rv->size(); | |
58 | 422 | t.has_query = true; | |
59 | 422 | return t; | |
60 | } | ||
61 | }; | ||
62 | |||
63 | constexpr query_part_rule_t query_part_rule{}; | ||
64 | |||
65 | } // detail | ||
66 | } // urls | ||
67 | } // boost | ||
68 | |||
69 | #endif | ||
70 |