1 -
//
 
2 -
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.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/parse.hpp>
 
13 -
#include <boost/url/static_url.hpp>
 
14 -
#include <boost/url/url_view.hpp>
 
15 -
#include <boost/url/detail/except.hpp>
 
16 -
#include <boost/assert.hpp>
 
17 -

 
18 -
namespace boost {
 
19 -
namespace urls {
 
20 -

 
21 -
static_url_base::
 
22 -
static_url_base(
 
23 -
    char* buf,
 
24 -
    std::size_t cap) noexcept
 
25 -
{
 
26 -
    s_ = buf;
 
27 -
    cap_ = cap;
 
28 -
    s_[0] = '\0';
 
29 -
    impl_.cs_ = s_;
 
30 -
}
 
31 -

 
32 -
static_url_base::
 
33 -
static_url_base(
 
34 -
    char* buf,
 
35 -
    std::size_t cap,
 
36 -
    core::string_view s)
 
37 -
    : static_url_base(buf, cap)
 
38 -
{
 
39 -
    copy(parse_uri_reference(s
 
40 -
        ).value(BOOST_URL_POS));
 
41 -
}
 
42 -

 
43 -
void
 
44 -
static_url_base::
 
45 -
clear_impl() noexcept
 
46 -
{
 
47 -
    impl_ = {from::url};
 
48 -
    s_[0] = '\0';
 
49 -
    impl_.cs_ = s_;
 
50 -
}
 
51 -

 
52 -
void
 
53 -
static_url_base::
 
54 -
reserve_impl(
 
55 -
    std::size_t n,
 
56 -
    op_t&)
 
57 -
{
 
58 -
    if(n <= cap_)
 
59 -
        return;
 
60 -
    detail::throw_length_error();
 
61 -
}
 
62 -

 
63 -
//----------------------------------------------------------
 
64 -

 
65 -
// LCOV_EXCL_START
 
66 -
void
 
67 -
static_url_base::
 
68 -
cleanup(op_t&)
 
69 -
{
 
70 -
    /*
 
71 -
     * The cleanup function is a blank
 
72 -
     * override as it's unreachable
 
73 -
     * for static_url_base.
 
74 -
     *
 
75 -
     * `u.cleanup()` is called by `op_t` when
 
76 -
     * the `op_t::old` string is being replaced.
 
77 -
     * This never happens for `static_url_base`
 
78 -
     * because it always uses the same buffer.
 
79 -
     *
 
80 -
     * `url::reserve_impl` is the only function
 
81 -
     * that sets the `op_t::old` string but
 
82 -
     * `static_url_base::reserve_impl` does
 
83 -
     * not touch `op_t::old`.
 
84 -
     */
 
85 -
}
 
86 -
// LCOV_EXCL_STOP
 
87 -

 
88 -
} // urls
 
89 -
} // boost
 
90 -