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 +
#ifndef BOOST_URL_IMPL_STATIC_URL_HPP
 
11 +
#define BOOST_URL_IMPL_STATIC_URL_HPP
 
12 +

 
13 +
#include <boost/url/detail/except.hpp>
 
14 +
#include <boost/assert.hpp>
 
15 +

 
16 +
namespace boost {
 
17 +
namespace urls {
 
18 +

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

 
31 +
inline
 
32 +
void
 
33 +
static_url_base::
 
34 +
clear_impl() noexcept
 
35 +
{
 
36 +
    impl_ = {from::url};
 
37 +
    s_[0] = '\0';
 
38 +
    impl_.cs_ = s_;
 
39 +
}
 
40 +

 
41 +
inline
 
42 +
void
 
43 +
static_url_base::
 
44 +
reserve_impl(
 
45 +
    std::size_t n,
 
46 +
    op_t&)
 
47 +
{
 
48 +
    if(n <= cap_)
 
49 +
        return;
 
50 +
    detail::throw_length_error();
 
51 +
}
 
52 +

 
53 +
//----------------------------------------------------------
 
54 +

 
55 +
// LCOV_EXCL_START
 
56 +
inline
 
57 +
void
 
58 +
static_url_base::
 
59 +
cleanup(op_t&)
 
60 +
{
 
61 +
    /*
 
62 +
     * The cleanup function is a blank
 
63 +
     * override as it's unreachable
 
64 +
     * for static_url_base.
 
65 +
     *
 
66 +
     * `u.cleanup()` is called by `op_t` when
 
67 +
     * the `op_t::old` string is being replaced.
 
68 +
     * This never happens for `static_url_base`
 
69 +
     * because it always uses the same buffer.
 
70 +
     *
 
71 +
     * `url::reserve_impl` is the only function
 
72 +
     * that sets the `op_t::old` string but
 
73 +
     * `static_url_base::reserve_impl` does
 
74 +
     * not touch `op_t::old`.
 
75 +
     */
 
76 +
}
 
77 +
// LCOV_EXCL_STOP
 
78 +

 
79 +
inline
 
80 +
static_url_base::
 
81 +
static_url_base(
 
82 +
    char* buf,
 
83 +
    std::size_t cap,
 
84 +
    core::string_view s)
 
85 +
    : static_url_base(buf, cap)
 
86 +
{
 
87 +
    copy(parse_uri_reference(s
 
88 +
        ).value(BOOST_URL_POS));
 
89 +
}
 
90 +

 
91 +
} // urls
 
92 +
} // boost
 
93 +

 
94 +
#endif