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 | |||
11 | #include <boost/url/detail/config.hpp> | ||
12 | #include <boost/url/rfc/origin_form_rule.hpp> | ||
13 | #include <boost/url/rfc/query_rule.hpp> | ||
14 | #include "boost/url/rfc/detail/path_rules.hpp" | ||
15 | #include "detail/query_part_rule.hpp" | ||
16 | #include <boost/url/grammar/delim_rule.hpp> | ||
17 | #include <boost/url/grammar/range_rule.hpp> | ||
18 | #include <boost/url/grammar/tuple_rule.hpp> | ||
19 | |||
20 | namespace boost { | ||
21 | namespace urls { | ||
22 | |||
23 | auto | ||
24 | 17 | origin_form_rule_t:: | |
25 | parse( | ||
26 | char const*& it, | ||
27 | char const* end | ||
28 | ) const noexcept -> | ||
29 | system::result<value_type> | ||
30 | { | ||
31 | 17 | detail::url_impl u(detail::url_impl::from::string); | |
32 | 17 | u.cs_ = it; | |
33 | |||
34 | { | ||
35 | auto rv = grammar::parse(it, end, | ||
36 | 17 | grammar::range_rule( | |
37 | 17 | grammar::tuple_rule( | |
38 | 17 | grammar::delim_rule('/'), | |
39 | detail::segment_rule), | ||
40 | 17 | 1)); | |
41 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 13 times.
|
17 | if(! rv) |
42 | 4 | return rv.error(); | |
43 | 13 | u.apply_path( | |
44 | rv->string(), | ||
45 | rv->size()); | ||
46 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 2 taken 4 times.
|
17 | } |
47 | |||
48 | // [ "?" query ] | ||
49 | { | ||
50 | 13 | auto rv = grammar::parse( | |
51 | it, end, detail::query_part_rule); | ||
52 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
|
13 | if(! rv) |
53 | ✗ | return rv.error(); | |
54 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
|
13 | if(rv->has_query) |
55 | { | ||
56 | // map "?" to { {} } | ||
57 | 8 | u.apply_query( | |
58 | 8 | rv->query, | |
59 | 8 | rv->count + | |
60 | 8 | rv->query.empty()); | |
61 | } | ||
62 | } | ||
63 | |||
64 | 13 | return u.construct(); | |
65 | } | ||
66 | |||
67 | } // urls | ||
68 | } // boost | ||
69 | |||
70 |