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 -
implementation_defined::origin_form_rule_t::
 
25 -
parse(
 
26 -
    char const*& it,
 
27 -
    char const* end
 
28 -
        ) const noexcept ->
 
29 -
    system::result<value_type>
 
30 -
{
 
31 -
    detail::url_impl u(detail::url_impl::from::string);
 
32 -
    u.cs_ = it;
 
33 -

 
34 -
    {
 
35 -
        auto rv = grammar::parse(it, end,
 
36 -
            grammar::range_rule(
 
37 -
                grammar::tuple_rule(
 
38 -
                    grammar::delim_rule('/'),
 
39 -
                    detail::segment_rule),
 
40 -
                1));
 
41 -
        if(! rv)
 
42 -
            return rv.error();
 
43 -
        u.apply_path(
 
44 -
            rv->string(),
 
45 -
            rv->size());
 
46 -
    }
 
47 -

 
48 -
    // [ "?" query ]
 
49 -
    {
 
50 -
        auto rv = grammar::parse(
 
51 -
            it, end, detail::query_part_rule);
 
52 -
        if(! rv)
 
53 -
            return rv.error();
 
54 -
        if(rv->has_query)
 
55 -
        {
 
56 -
            // map "?" to { {} }
 
57 -
            u.apply_query(
 
58 -
                rv->query,
 
59 -
                rv->count);
 
60 -
        }
 
61 -
    }
 
62 -

 
63 -
    return u.construct();
 
64 -
}
 
65 -

 
66 -
} // urls
 
67 -
} // boost
 
68 -