1 +
//
 
2 +
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
 
3 +
// Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
 
4 +
//
 
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)
 
7 +
//
 
8 +
// Official repository: https://github.com/boostorg/url
 
9 +
//
 
10 +

 
11 +
#ifndef BOOST_URL_RFC_DETAIL_IMPL_IPVFUTURE_RULE_HPP
 
12 +
#define BOOST_URL_RFC_DETAIL_IMPL_IPVFUTURE_RULE_HPP
 
13 +

 
14 +
#include <boost/url/detail/config.hpp>
 
15 +
#include <boost/url/rfc/detail/charsets.hpp>
 
16 +
#include <boost/url/grammar/charset.hpp>
 
17 +
#include <boost/url/grammar/delim_rule.hpp>
 
18 +
#include <boost/url/grammar/error.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 +
inline BOOST_URL_CXX20_CONSTEXPR
 
29 +
auto
 
30 +
ipvfuture_rule_t::
 
31 +
parse(
 
32 +
    char const*& it,
 
33 +
    char const* const end
 
34 +
        ) const noexcept ->
 
35 +
    system::result<value_type>
 
36 +
{
 
37 +
    constexpr auto
 
38 +
        minor_chars =
 
39 +
            unreserved_chars +
 
40 +
            sub_delim_chars + ':';
 
41 +
    auto const it0 = it;
 
42 +
    auto rv = grammar::parse(
 
43 +
        it, end,
 
44 +
        grammar::tuple_rule(
 
45 +
            grammar::delim_rule('v'),
 
46 +
            grammar::token_rule(
 
47 +
                grammar::hexdig_chars),
 
48 +
            grammar::delim_rule('.'),
 
49 +
            grammar::token_rule(minor_chars)));
 
50 +
    if(! rv)
 
51 +
        return rv.error();
 
52 +
    value_type t;
 
53 +
    t.major = std::get<0>(*rv);
 
54 +
    t.minor = std::get<1>(*rv);
 
55 +
    if(t.major.empty())
 
56 +
    {
 
57 +
        BOOST_URL_CONSTEXPR_RETURN_EC(
 
58 +
            grammar::error::invalid);
 
59 +
    }
 
60 +
    if(t.minor.empty())
 
61 +
    {
 
62 +
        BOOST_URL_CONSTEXPR_RETURN_EC(
 
63 +
            grammar::error::invalid);
 
64 +
    }
 
65 +
    t.str = core::string_view(
 
66 +
        it0, it - it0);
 
67 +
    return t;
 
68 +
}
 
69 +

 
70 +
} // detail
 
71 +
} // urls
 
72 +
} // boost
 
73 +

 
74 +

 
75 +
#endif