1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
3  
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
4  
//
4  
//
5  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
6  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  
//
7  
//
8  
// Official repository: https://github.com/boostorg/url
8  
// Official repository: https://github.com/boostorg/url
9  
//
9  
//
10  

10  

11  

11  

12  
#include <boost/url/detail/config.hpp>
12  
#include <boost/url/detail/config.hpp>
13  
#include <boost/url/url_view.hpp>
13  
#include <boost/url/url_view.hpp>
14  
#include <boost/url/parse.hpp>
14  
#include <boost/url/parse.hpp>
15  
#include <boost/url/detail/except.hpp>
15  
#include <boost/url/detail/except.hpp>
16  

16  

17  
namespace boost {
17  
namespace boost {
18  
namespace urls {
18  
namespace urls {
19  

19  

20  
namespace detail {
20  
namespace detail {
21  

21  

22  
url_view
22  
url_view
23  
url_impl::
23  
url_impl::
24  
construct() const noexcept
24  
construct() const noexcept
25  
{
25  
{
26  
    return url_view(*this);
26  
    return url_view(*this);
27  
}
27  
}
28  

28  

29  
} // detail
29  
} // detail
30  

30  

31  
//------------------------------------------------
31  
//------------------------------------------------
32  

32  

33  
url_view::
33  
url_view::
34  
url_view() noexcept = default;
34  
url_view() noexcept = default;
35  

35  

36  
url_view::
36  
url_view::
37  
url_view(core::string_view s)
37  
url_view(core::string_view s)
38  
    : url_view(parse_uri_reference(s
38  
    : url_view(parse_uri_reference(s
39  
        ).value(BOOST_URL_POS))
39  
        ).value(BOOST_URL_POS))
40  
{
40  
{
41  
}
41  
}
42  

42  

43  
url_view::
43  
url_view::
44  
url_view(
44  
url_view(
45  
    url_view_base const& u) noexcept
45  
    url_view_base const& u) noexcept
46  
    : url_view_base(u.impl_)
46  
    : url_view_base(u.impl_)
47  
{
47  
{
48  
    if (u.pi_->from_ == from::url)
48  
    if (u.pi_->from_ == from::url)
49  
    {
49  
    {
50  
        pi_ = u.pi_;
50  
        pi_ = u.pi_;
51  
    }
51  
    }
52  
    else
52  
    else
53  
    {
53  
    {
54  
        impl_ = u.impl_;
54  
        impl_ = u.impl_;
55  
        pi_ = &impl_;
55  
        pi_ = &impl_;
56  
    }
56  
    }
57  
}
57  
}
58  

58  

59  
url_view&
59  
url_view&
60  
url_view::
60  
url_view::
61  
operator=(
61  
operator=(
62  
    url_view_base const& u) noexcept
62  
    url_view_base const& u) noexcept
63  
{
63  
{
64  
    if (pi_ == u.pi_)
64  
    if (pi_ == u.pi_)
65  
        return *this;
65  
        return *this;
66  

66  

67  
    if (u.pi_->from_ == from::url)
67  
    if (u.pi_->from_ == from::url)
68  
    {
68  
    {
69  
        pi_ = u.pi_;
69  
        pi_ = u.pi_;
70  
    }
70  
    }
71  
    else
71  
    else
72  
    {
72  
    {
73  
        impl_ = u.impl_;
73  
        impl_ = u.impl_;
74  
        pi_ = &impl_;
74  
        pi_ = &impl_;
75  
    }
75  
    }
76  
    return *this;
76  
    return *this;
77  
}
77  
}
78  

78  

79  
} // urls
79  
} // urls
80  
} // boost
80  
} // boost
81  

81