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 "ipvfuture_rule.hpp"
 
13 -
#include <boost/url/error.hpp>
 
14 -
#include "charsets.hpp"
 
15 -
#include <boost/url/grammar/charset.hpp>
 
16 -
#include <boost/url/grammar/delim_rule.hpp>
 
17 -
#include <boost/url/grammar/hexdig_chars.hpp>
 
18 -
#include <boost/url/grammar/parse.hpp>
 
19 -
#include <boost/url/grammar/token_rule.hpp>
 
20 -
#include <boost/url/grammar/tuple_rule.hpp>
 
21 -

 
22 -
namespace boost {
 
23 -
namespace urls {
 
24 -
namespace detail {
 
25 -

 
26 -
auto
 
27 -
ipvfuture_rule_t::
 
28 -
parse(
 
29 -
    char const*& it,
 
30 -
    char const* const end
 
31 -
        ) const noexcept ->
 
32 -
    system::result<value_type>
 
33 -
{
 
34 -
    static constexpr auto
 
35 -
        minor_chars = 
 
36 -
            unreserved_chars +
 
37 -
            sub_delim_chars + ':';
 
38 -
    auto const it0 = it;
 
39 -
    auto rv = grammar::parse(
 
40 -
        it, end,
 
41 -
        grammar::tuple_rule(
 
42 -
            grammar::delim_rule('v'),
 
43 -
            grammar::token_rule(
 
44 -
                grammar::hexdig_chars),
 
45 -
            grammar::delim_rule('.'),
 
46 -
            grammar::token_rule(minor_chars)));
 
47 -
    if(! rv)
 
48 -
        return rv.error();
 
49 -
    value_type t;
 
50 -
    t.major = std::get<0>(*rv);
 
51 -
    t.minor = std::get<1>(*rv);
 
52 -
    if(t.major.empty())
 
53 -
    {
 
54 -
        // can't be empty
 
55 -
        BOOST_URL_RETURN_EC(
 
56 -
            grammar::error::invalid);
 
57 -
    }
 
58 -
    if(t.minor.empty())
 
59 -
    {
 
60 -
        // can't be empty
 
61 -
        BOOST_URL_RETURN_EC(
 
62 -
            grammar::error::invalid);
 
63 -
    }
 
64 -
    t.str = core::string_view(
 
65 -
        it0, it - it0);
 
66 -
    return t;
 
67 -
}
 
68 -

 
69 -
} // detail
 
70 -
} // urls
 
71 -
} // boost
 
72 -