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 "scheme_rule.hpp"
 
13 -
#include <boost/url/grammar/alpha_chars.hpp>
 
14 -
#include <boost/url/grammar/delim_rule.hpp>
 
15 -
#include <boost/url/grammar/lut_chars.hpp>
 
16 -
#include <boost/url/grammar/parse.hpp>
 
17 -
#include <boost/url/grammar/tuple_rule.hpp>
 
18 -

 
19 -
namespace boost {
 
20 -
namespace urls {
 
21 -
namespace detail {
 
22 -

 
23 -
auto
 
24 -
scheme_rule::
 
25 -
parse(
 
26 -
    char const*& it,
 
27 -
    char const* end) const noexcept ->
 
28 -
        system::result<value_type>
 
29 -
{
 
30 -
    auto const start = it;
 
31 -
    if(it == end)
 
32 -
    {
 
33 -
        // end
 
34 -
        BOOST_URL_RETURN_EC(
 
35 -
            grammar::error::mismatch);
 
36 -
    }
 
37 -
    if(! grammar::alpha_chars(*it))
 
38 -
    {
 
39 -
        // expected alpha
 
40 -
        BOOST_URL_RETURN_EC(
 
41 -
            grammar::error::mismatch);
 
42 -
    }
 
43 -

 
44 -
    static
 
45 -
    constexpr
 
46 -
    grammar::lut_chars scheme_chars(
 
47 -
        "0123456789" "+-."
 
48 -
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
49 -
        "abcdefghijklmnopqrstuvwxyz");
 
50 -
    it = grammar::find_if_not(
 
51 -
        it + 1, end, scheme_chars);
 
52 -
    value_type t;
 
53 -
    t.scheme = core::string_view(
 
54 -
        start, it - start);
 
55 -
    t.scheme_id = string_to_scheme(
 
56 -
        t.scheme);
 
57 -
    return t;
 
58 -
}
 
59 -

 
60 -
} // detail
 
61 -
} // urls
 
62 -
} // boost
 
63 -