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_DETAIL_IMPL_IPVFUTURE_RULE_IPP | ||
11 | #define BOOST_URL_DETAIL_IMPL_IPVFUTURE_RULE_IPP | ||
12 | |||
13 | #include <boost/url/detail/config.hpp> | ||
14 | #include <boost/url/rfc/detail/ipvfuture_rule.hpp> | ||
15 | #include <boost/url/error.hpp> | ||
16 | #include <boost/url/rfc/detail/charsets.hpp> | ||
17 | #include <boost/url/grammar/charset.hpp> | ||
18 | #include <boost/url/grammar/delim_rule.hpp> | ||
19 | #include <boost/url/grammar/hexdig_chars.hpp> | ||
20 | #include <boost/url/grammar/parse.hpp> | ||
21 | #include <boost/url/grammar/token_rule.hpp> | ||
22 | #include <boost/url/grammar/tuple_rule.hpp> | ||
23 | |||
24 | namespace boost { | ||
25 | namespace urls { | ||
26 | namespace detail { | ||
27 | |||
28 | auto | ||
29 | 38 | ipvfuture_rule_t:: | |
30 | parse( | ||
31 | char const*& it, | ||
32 | char const* const end | ||
33 | ) const noexcept -> | ||
34 | system::result<value_type> | ||
35 | { | ||
36 | static constexpr auto | ||
37 | minor_chars = | ||
38 | unreserved_chars + | ||
39 | sub_delim_chars + ':'; | ||
40 | 38 | auto const it0 = it; | |
41 | auto rv = grammar::parse( | ||
42 | it, end, | ||
43 | 38 | grammar::tuple_rule( | |
44 | 38 | grammar::delim_rule('v'), | |
45 | 38 | grammar::token_rule( | |
46 | 38 | grammar::hexdig_chars), | |
47 | 38 | grammar::delim_rule('.'), | |
48 | 76 | grammar::token_rule(minor_chars))); | |
49 |
2/2✓ Branch 1 taken 23 times.
✓ Branch 2 taken 15 times.
|
38 | if(! rv) |
50 | 23 | return rv.error(); | |
51 | 15 | value_type t; | |
52 | 15 | t.major = std::get<0>(*rv); | |
53 | 15 | t.minor = std::get<1>(*rv); | |
54 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if(t.major.empty()) |
55 | { | ||
56 | // can't be empty | ||
57 | ✗ | BOOST_URL_RETURN_EC( | |
58 | grammar::error::invalid); | ||
59 | } | ||
60 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
|
15 | if(t.minor.empty()) |
61 | { | ||
62 | // can't be empty | ||
63 | ✗ | BOOST_URL_RETURN_EC( | |
64 | grammar::error::invalid); | ||
65 | } | ||
66 | 30 | t.str = core::string_view( | |
67 | 15 | it0, it - it0); | |
68 | 15 | return t; | |
69 | } | ||
70 | |||
71 | } // detail | ||
72 | } // urls | ||
73 | } // boost | ||
74 | |||
75 | #endif | ||
76 |