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

9  

10  
#ifndef BOOST_URL_STATIC_URL_HPP
10  
#ifndef BOOST_URL_STATIC_URL_HPP
11  
#define BOOST_URL_STATIC_URL_HPP
11  
#define BOOST_URL_STATIC_URL_HPP
12  

12  

13  
#include <boost/url/detail/config.hpp>
13  
#include <boost/url/detail/config.hpp>
14  
#include <boost/url/url_base.hpp>
14  
#include <boost/url/url_base.hpp>
15  
#include <boost/align/align_up.hpp>
15  
#include <boost/align/align_up.hpp>
16  
#include <boost/core/detail/static_assert.hpp>
16  
#include <boost/core/detail/static_assert.hpp>
17  
#include <cstddef>
17  
#include <cstddef>
18  

18  

19  
namespace boost {
19  
namespace boost {
20  
namespace urls {
20  
namespace urls {
21  

21  

22  
#ifndef BOOST_URL_DOCS
22  
#ifndef BOOST_URL_DOCS
23  
template<std::size_t Capacity>
23  
template<std::size_t Capacity>
24  
class static_url;
24  
class static_url;
25  
#endif
25  
#endif
26  

26  

27  
// VFALCO This class is for reducing
27  
// VFALCO This class is for reducing
28  
// the number of template instantiations,
28  
// the number of template instantiations,
29  
// and keep definitions in the library
29  
// and keep definitions in the library
30  

30  

31  
/** Common implementation for all static URLs
31  
/** Common implementation for all static URLs
32  

32  

33  
    This base class is used by the library
33  
    This base class is used by the library
34  
    to provide common functionality for
34  
    to provide common functionality for
35  
    static URLs. Users should not use this
35  
    static URLs. Users should not use this
36  
    class directly. Instead, construct an
36  
    class directly. Instead, construct an
37  
    instance of one of the containers
37  
    instance of one of the containers
38  
    or call a parsing function.
38  
    or call a parsing function.
39  

39  

40  
    @par Containers
40  
    @par Containers
41  
        @li @ref url
41  
        @li @ref url
42  
        @li @ref url_view
42  
        @li @ref url_view
43  
        @li @ref static_url
43  
        @li @ref static_url
44  

44  

45  
    @par Parsing Functions
45  
    @par Parsing Functions
46  
        @li @ref parse_absolute_uri
46  
        @li @ref parse_absolute_uri
47  
        @li @ref parse_origin_form
47  
        @li @ref parse_origin_form
48  
        @li @ref parse_relative_ref
48  
        @li @ref parse_relative_ref
49  
        @li @ref parse_uri
49  
        @li @ref parse_uri
50  
        @li @ref parse_uri_reference
50  
        @li @ref parse_uri_reference
51  
*/
51  
*/
52 -
class BOOST_URL_DECL
52 +
class static_url_base
53 -
    static_url_base
 
54  
    : public url_base
53  
    : public url_base
55  
{
54  
{
56  
    template<std::size_t>
55  
    template<std::size_t>
57  
    friend class static_url;
56  
    friend class static_url;
58  

57  

59  
    ~static_url_base() = default;
58  
    ~static_url_base() = default;
60  
    static_url_base(
59  
    static_url_base(
61  
        char* buf, std::size_t cap) noexcept;
60  
        char* buf, std::size_t cap) noexcept;
62  
    static_url_base(
61  
    static_url_base(
63  
        char* buf, std::size_t cap, core::string_view s);
62  
        char* buf, std::size_t cap, core::string_view s);
64  
    void clear_impl() noexcept override;
63  
    void clear_impl() noexcept override;
65  
    void reserve_impl(std::size_t, op_t&) override;
64  
    void reserve_impl(std::size_t, op_t&) override;
66  
    void cleanup(op_t&) override;
65  
    void cleanup(op_t&) override;
67  

66  

68  
    void
67  
    void
69  
    copy(url_view_base const& u)
68  
    copy(url_view_base const& u)
70  
    {
69  
    {
71  
        this->url_base::copy(u);
70  
        this->url_base::copy(u);
72  
    }
71  
    }
73  

72  

74  
};
73  
};
75  

74  

76  
//------------------------------------------------
75  
//------------------------------------------------
77  

76  

78  
/** A modifiable container for a URL.
77  
/** A modifiable container for a URL.
79  

78  

80  
    This container owns a url, represented
79  
    This container owns a url, represented
81  
    by an inline, null-terminated character
80  
    by an inline, null-terminated character
82  
    buffer with fixed capacity.
81  
    buffer with fixed capacity.
83  
    The contents may be inspected and modified,
82  
    The contents may be inspected and modified,
84  
    and the implementation maintains a useful
83  
    and the implementation maintains a useful
85  
    invariant: changes to the url always
84  
    invariant: changes to the url always
86  
    leave it in a valid state.
85  
    leave it in a valid state.
87  

86  

88  
    @par Example
87  
    @par Example
89  
    @code
88  
    @code
90  
    static_url< 1024 > u( "https://www.example.com" );
89  
    static_url< 1024 > u( "https://www.example.com" );
91  
    @endcode
90  
    @endcode
92  

91  

93  
    @par Invariants
92  
    @par Invariants
94  
    @code
93  
    @code
95  
    this->capacity() == Capacity + 1
94  
    this->capacity() == Capacity + 1
96  
    @endcode
95  
    @endcode
97  

96  

98  
    @tparam Capacity The maximum capacity
97  
    @tparam Capacity The maximum capacity
99  
    in characters, not including the
98  
    in characters, not including the
100  
    null terminator.
99  
    null terminator.
101  

100  

102  
    @see
101  
    @see
103  
        @ref url,
102  
        @ref url,
104  
        @ref url_view.
103  
        @ref url_view.
105  
*/
104  
*/
106  
template<std::size_t Capacity>
105  
template<std::size_t Capacity>
107  
class static_url
106  
class static_url
108  
    : public static_url_base
107  
    : public static_url_base
109  
{
108  
{
110  
    char buf_[Capacity + 1];
109  
    char buf_[Capacity + 1];
111  

110  

112  
    friend std::hash<static_url>;
111  
    friend std::hash<static_url>;
113  
    using url_view_base::digest;
112  
    using url_view_base::digest;
114  

113  

115  
public:
114  
public:
116  
    //--------------------------------------------
115  
    //--------------------------------------------
117  
    //
116  
    //
118  
    // Special Members
117  
    // Special Members
119  
    //
118  
    //
120  
    //--------------------------------------------
119  
    //--------------------------------------------
121  

120  

122  
    /** Destructor
121  
    /** Destructor
123  

122  

124  
        Any params, segments, iterators, or
123  
        Any params, segments, iterators, or
125  
        views which reference this object are
124  
        views which reference this object are
126  
        invalidated. The underlying character
125  
        invalidated. The underlying character
127  
        buffer is destroyed, invalidating all
126  
        buffer is destroyed, invalidating all
128  
        references to it.
127  
        references to it.
129  
    */
128  
    */
130  
    ~static_url() = default;
129  
    ~static_url() = default;
131  

130  

132  
    /** Constructor
131  
    /** Constructor
133  

132  

134  
        Default constructed urls contain
133  
        Default constructed urls contain
135  
        a zero-length string. This matches
134  
        a zero-length string. This matches
136  
        the grammar for a relative-ref with
135  
        the grammar for a relative-ref with
137  
        an empty path and no query or
136  
        an empty path and no query or
138  
        fragment.
137  
        fragment.
139  

138  

140  
        @par Example
139  
        @par Example
141  
        @code
140  
        @code
142  
        static_url< 1024 > u;
141  
        static_url< 1024 > u;
143  
        @endcode
142  
        @endcode
144  

143  

145  
        @par Postconditions
144  
        @par Postconditions
146  
        @code
145  
        @code
147  
        this->empty() == true
146  
        this->empty() == true
148  
        @endcode
147  
        @endcode
149  

148  

150  
        @par Complexity
149  
        @par Complexity
151  
        Constant.
150  
        Constant.
152  

151  

153  
        @par Exception Safety
152  
        @par Exception Safety
154  
        Throws nothing.
153  
        Throws nothing.
155  

154  

156  
        @par BNF
155  
        @par BNF
157  
        @code
156  
        @code
158  
        relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
157  
        relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
159  
        @endcode
158  
        @endcode
160  

159  

161  
        @par Specification
160  
        @par Specification
162  
        <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.2"
161  
        <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.2"
163  
            >4.2. Relative Reference (rfc3986)</a>
162  
            >4.2. Relative Reference (rfc3986)</a>
164  
    */
163  
    */
165  
    static_url() noexcept
164  
    static_url() noexcept
166  
        : static_url_base(
165  
        : static_url_base(
167  
            buf_, sizeof(buf_))
166  
            buf_, sizeof(buf_))
168  
    {
167  
    {
169  
    }
168  
    }
170  

169  

171  
    /** Constructor
170  
    /** Constructor
172  

171  

173  
        This function constructs a url from
172  
        This function constructs a url from
174  
        the string `s`, which must contain a
173  
        the string `s`, which must contain a
175  
        valid <em>URI</em> or <em>relative-ref</em>
174  
        valid <em>URI</em> or <em>relative-ref</em>
176  
        or else an exception is thrown.
175  
        or else an exception is thrown.
177  
        The new url retains ownership by
176  
        The new url retains ownership by
178  
        making a copy of the passed string.
177  
        making a copy of the passed string.
179  

178  

180  
        @par Example
179  
        @par Example
181  
        @code
180  
        @code
182  
        static_url< 1024 > u( "https://www.example.com" );
181  
        static_url< 1024 > u( "https://www.example.com" );
183  
        @endcode
182  
        @endcode
184  

183  

185  
        @par Effects
184  
        @par Effects
186  
        @code
185  
        @code
187  
        return static_url( parse_uri_reference( s ).value() );
186  
        return static_url( parse_uri_reference( s ).value() );
188  
        @endcode
187  
        @endcode
189  

188  

190  
        @par Postconditions
189  
        @par Postconditions
191  
        @code
190  
        @code
192  
        this->buffer().data() != s.data()
191  
        this->buffer().data() != s.data()
193  
        @endcode
192  
        @endcode
194  

193  

195  
        @par Complexity
194  
        @par Complexity
196  
        Linear in `s.size()`.
195  
        Linear in `s.size()`.
197  

196  

198  
        @par Exception Safety
197  
        @par Exception Safety
199  
        Exceptions thrown on invalid input.
198  
        Exceptions thrown on invalid input.
200  

199  

201  
        @throw system_error
200  
        @throw system_error
202  
        The input does not contain a valid url.
201  
        The input does not contain a valid url.
203  

202  

204  
        @param s The string to parse.
203  
        @param s The string to parse.
205  

204  

206  
        @par BNF
205  
        @par BNF
207  
        @code
206  
        @code
208  
        URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
207  
        URI           = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
209  

208  

210  
        relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
209  
        relative-ref  = relative-part [ "?" query ] [ "#" fragment ]
211  
        @endcode
210  
        @endcode
212  

211  

213  
        @par Specification
212  
        @par Specification
214  
        @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.1"
213  
        @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.1"
215  
            >4.1. URI Reference</a>
214  
            >4.1. URI Reference</a>
216  
    */
215  
    */
217  
    explicit
216  
    explicit
218  
    static_url(
217  
    static_url(
219  
        core::string_view s)
218  
        core::string_view s)
220  
        : static_url_base(
219  
        : static_url_base(
221  
            buf_, sizeof(buf_), s)
220  
            buf_, sizeof(buf_), s)
222  
    {
221  
    {
223  
    }
222  
    }
224  

223  

225  
    /** Constructor
224  
    /** Constructor
226  

225  

227  
        The newly constructed object contains
226  
        The newly constructed object contains
228  
        a copy of `u`.
227  
        a copy of `u`.
229  

228  

230  
        @par Postconditions
229  
        @par Postconditions
231  
        @code
230  
        @code
232  
        this->buffer() == u.buffer() && this->buffer.data() != u.buffer().data()
231  
        this->buffer() == u.buffer() && this->buffer.data() != u.buffer().data()
233  
        @endcode
232  
        @endcode
234  

233  

235  
        @par Complexity
234  
        @par Complexity
236  
        Linear in `u.size()`.
235  
        Linear in `u.size()`.
237  

236  

238  
        @par Exception Safety
237  
        @par Exception Safety
239  
        Throws nothing.
238  
        Throws nothing.
240  

239  

241  
        @param u The url to copy.
240  
        @param u The url to copy.
242  
    */
241  
    */
243  
    static_url(
242  
    static_url(
244  
        static_url const& u) noexcept
243  
        static_url const& u) noexcept
245  
        : static_url()
244  
        : static_url()
246  
    {
245  
    {
247  
        copy(u);
246  
        copy(u);
248  
    }
247  
    }
249  

248  

250  
    /** Constructor
249  
    /** Constructor
251  

250  

252  
        The newly constructed object contains
251  
        The newly constructed object contains
253  
        a copy of `u`.
252  
        a copy of `u`.
254  

253  

255  
        @par Postconditions
254  
        @par Postconditions
256  
        @code
255  
        @code
257  
        this->buffer() == u.buffer() && this->buffer.data() != u.buffer().data()
256  
        this->buffer() == u.buffer() && this->buffer.data() != u.buffer().data()
258  
        @endcode
257  
        @endcode
259  

258  

260  
        @par Complexity
259  
        @par Complexity
261  
        Linear in `u.size()`.
260  
        Linear in `u.size()`.
262  

261  

263  
        @par Exception Safety
262  
        @par Exception Safety
264  
        Exception thrown if capacity exceeded.
263  
        Exception thrown if capacity exceeded.
265  

264  

266  
        @throw system_error
265  
        @throw system_error
267  
        Capacity would be exceeded.
266  
        Capacity would be exceeded.
268  

267  

269  
        @param u The url to copy.
268  
        @param u The url to copy.
270  
    */
269  
    */
271  
    static_url(
270  
    static_url(
272  
        url_view_base const& u)
271  
        url_view_base const& u)
273  
        : static_url()
272  
        : static_url()
274  
    {
273  
    {
275  
        copy(u);
274  
        copy(u);
276  
    }
275  
    }
277  

276  

278  
    /** Assignment
277  
    /** Assignment
279  

278  

280  
        The contents of `u` are copied and
279  
        The contents of `u` are copied and
281  
        the previous contents of `this` are
280  
        the previous contents of `this` are
282  
        discarded.
281  
        discarded.
283  
        Capacity remains unchanged.
282  
        Capacity remains unchanged.
284  

283  

285  
        @par Postconditions
284  
        @par Postconditions
286  
        @code
285  
        @code
287  
        this->buffer() == u.buffer() && this->buffer().data() != u.buffer().data()
286  
        this->buffer() == u.buffer() && this->buffer().data() != u.buffer().data()
288  
        @endcode
287  
        @endcode
289  

288  

290  
        @par Complexity
289  
        @par Complexity
291  
        Linear in `u.size()`.
290  
        Linear in `u.size()`.
292  

291  

293  
        @par Exception Safety
292  
        @par Exception Safety
294  
        Throws nothing.
293  
        Throws nothing.
295  

294  

296  
        @param u The url to copy.
295  
        @param u The url to copy.
297  
        @return A reference to this object.
296  
        @return A reference to this object.
298  
    */
297  
    */
299  
    static_url&
298  
    static_url&
300  
    operator=(
299  
    operator=(
301  
        static_url const& u) noexcept
300  
        static_url const& u) noexcept
302  
    {
301  
    {
303  
        if (this != &u)
302  
        if (this != &u)
304  
            copy(u);
303  
            copy(u);
305  
        return *this;
304  
        return *this;
306  
    }
305  
    }
307  

306  

308  
    /** Assignment
307  
    /** Assignment
309  

308  

310  
        The contents of `u` are copied and
309  
        The contents of `u` are copied and
311  
        the previous contents of `this` are
310  
        the previous contents of `this` are
312  
        discarded.
311  
        discarded.
313  

312  

314  
        @par Postconditions
313  
        @par Postconditions
315  
        @code
314  
        @code
316  
        this->buffer() == u.buffer() && this->buffer().data() != u.buffer().data()
315  
        this->buffer() == u.buffer() && this->buffer().data() != u.buffer().data()
317  
        @endcode
316  
        @endcode
318  

317  

319  
        @par Complexity
318  
        @par Complexity
320  
        Linear in `u.size()`.
319  
        Linear in `u.size()`.
321  

320  

322  
        @par Exception Safety
321  
        @par Exception Safety
323  
        Strong guarantee.
322  
        Strong guarantee.
324  
        Exception thrown if capacity exceeded.
323  
        Exception thrown if capacity exceeded.
325  

324  

326  
        @throw system_error
325  
        @throw system_error
327  
        Capacity would be exceeded.
326  
        Capacity would be exceeded.
328  

327  

329  
        @param u The url to copy.
328  
        @param u The url to copy.
330  
        @return A reference to this object.
329  
        @return A reference to this object.
331  
    */
330  
    */
332  
    static_url&
331  
    static_url&
333  
    operator=(
332  
    operator=(
334  
        url_view_base const& u)
333  
        url_view_base const& u)
335  
    {
334  
    {
336  
        copy(u);
335  
        copy(u);
337  
        return *this;
336  
        return *this;
338  
    }
337  
    }
339  

338  

340  

339  

341  
    //--------------------------------------------
340  
    //--------------------------------------------
342  
    //
341  
    //
343  
    // fluent api
342  
    // fluent api
344  
    //
343  
    //
345  

344  

346  
    /// @copydoc url_base::set_scheme
345  
    /// @copydoc url_base::set_scheme
347  
    static_url& set_scheme(core::string_view s) { url_base::set_scheme(s); return *this; }
346  
    static_url& set_scheme(core::string_view s) { url_base::set_scheme(s); return *this; }
348  
    /// @copydoc url_base::set_scheme_id
347  
    /// @copydoc url_base::set_scheme_id
349  
    static_url& set_scheme_id(urls::scheme id) { url_base::set_scheme_id(id); return *this; }
348  
    static_url& set_scheme_id(urls::scheme id) { url_base::set_scheme_id(id); return *this; }
350  
    /// @copydoc url_base::remove_scheme
349  
    /// @copydoc url_base::remove_scheme
351  
    static_url& remove_scheme() { url_base::remove_scheme(); return *this; }
350  
    static_url& remove_scheme() { url_base::remove_scheme(); return *this; }
352  

351  

353  
    /// @copydoc url_base::set_encoded_authority
352  
    /// @copydoc url_base::set_encoded_authority
354  
    static_url& set_encoded_authority(pct_string_view s) { url_base::set_encoded_authority(s); return *this; }
353  
    static_url& set_encoded_authority(pct_string_view s) { url_base::set_encoded_authority(s); return *this; }
355  
    /// @copydoc url_base::remove_authority
354  
    /// @copydoc url_base::remove_authority
356  
    static_url& remove_authority() { url_base::remove_authority(); return *this; }
355  
    static_url& remove_authority() { url_base::remove_authority(); return *this; }
357  

356  

358  
    /// @copydoc url_base::set_userinfo
357  
    /// @copydoc url_base::set_userinfo
359  
    static_url& set_userinfo(core::string_view s) { url_base::set_userinfo(s); return *this; }
358  
    static_url& set_userinfo(core::string_view s) { url_base::set_userinfo(s); return *this; }
360  
    /// @copydoc url_base::set_encoded_userinfo
359  
    /// @copydoc url_base::set_encoded_userinfo
361  
    static_url& set_encoded_userinfo(pct_string_view s) { url_base::set_encoded_userinfo(s); return *this; }
360  
    static_url& set_encoded_userinfo(pct_string_view s) { url_base::set_encoded_userinfo(s); return *this; }
362  
    /// @copydoc url_base::remove_userinfo
361  
    /// @copydoc url_base::remove_userinfo
363  
    static_url& remove_userinfo() noexcept { url_base::remove_userinfo(); return *this; }
362  
    static_url& remove_userinfo() noexcept { url_base::remove_userinfo(); return *this; }
364  
    /// @copydoc url_base::set_user
363  
    /// @copydoc url_base::set_user
365  
    static_url& set_user(core::string_view s) { url_base::set_user(s); return *this; }
364  
    static_url& set_user(core::string_view s) { url_base::set_user(s); return *this; }
366  
    /// @copydoc url_base::set_encoded_user
365  
    /// @copydoc url_base::set_encoded_user
367  
    static_url& set_encoded_user(pct_string_view s) { url_base::set_encoded_user(s); return *this; }
366  
    static_url& set_encoded_user(pct_string_view s) { url_base::set_encoded_user(s); return *this; }
368  
    /// @copydoc url_base::set_password
367  
    /// @copydoc url_base::set_password
369  
    static_url& set_password(core::string_view s) { url_base::set_password(s); return *this; }
368  
    static_url& set_password(core::string_view s) { url_base::set_password(s); return *this; }
370  
    /// @copydoc url_base::set_encoded_password
369  
    /// @copydoc url_base::set_encoded_password
371  
    static_url& set_encoded_password(pct_string_view s) { url_base::set_encoded_password(s); return *this; }
370  
    static_url& set_encoded_password(pct_string_view s) { url_base::set_encoded_password(s); return *this; }
372  
    /// @copydoc url_base::remove_password
371  
    /// @copydoc url_base::remove_password
373  
    static_url& remove_password() noexcept { url_base::remove_password(); return *this; }
372  
    static_url& remove_password() noexcept { url_base::remove_password(); return *this; }
374  

373  

375  
    /// @copydoc url_base::set_host
374  
    /// @copydoc url_base::set_host
376  
    static_url& set_host(core::string_view s) { url_base::set_host(s); return *this; }
375  
    static_url& set_host(core::string_view s) { url_base::set_host(s); return *this; }
377  
    /// @copydoc url_base::set_encoded_host
376  
    /// @copydoc url_base::set_encoded_host
378  
    static_url& set_encoded_host(pct_string_view s) { url_base::set_encoded_host(s); return *this; }
377  
    static_url& set_encoded_host(pct_string_view s) { url_base::set_encoded_host(s); return *this; }
379  
    /// @copydoc url_base::set_host_address
378  
    /// @copydoc url_base::set_host_address
380  
    static_url& set_host_address(core::string_view s) { url_base::set_host_address(s); return *this; }
379  
    static_url& set_host_address(core::string_view s) { url_base::set_host_address(s); return *this; }
381  
    /// @copydoc url_base::set_encoded_host_address
380  
    /// @copydoc url_base::set_encoded_host_address
382  
    static_url& set_encoded_host_address(pct_string_view s) { url_base::set_encoded_host_address(s); return *this; }
381  
    static_url& set_encoded_host_address(pct_string_view s) { url_base::set_encoded_host_address(s); return *this; }
383  
    /// @copydoc url_base::set_host_ipv4
382  
    /// @copydoc url_base::set_host_ipv4
384  
    static_url& set_host_ipv4(ipv4_address const& addr) { url_base::set_host_ipv4(addr); return *this; }
383  
    static_url& set_host_ipv4(ipv4_address const& addr) { url_base::set_host_ipv4(addr); return *this; }
385  
    /// @copydoc url_base::set_host_ipv6
384  
    /// @copydoc url_base::set_host_ipv6
386  
    static_url& set_host_ipv6(ipv6_address const& addr) { url_base::set_host_ipv6(addr); return *this; }
385  
    static_url& set_host_ipv6(ipv6_address const& addr) { url_base::set_host_ipv6(addr); return *this; }
387  
    /// @copydoc url_base::set_zone_id
386  
    /// @copydoc url_base::set_zone_id
388  
    static_url& set_zone_id(core::string_view s) { url_base::set_zone_id(s); return *this; }
387  
    static_url& set_zone_id(core::string_view s) { url_base::set_zone_id(s); return *this; }
389  
    /// @copydoc url_base::set_encoded_zone_id
388  
    /// @copydoc url_base::set_encoded_zone_id
390  
    static_url& set_encoded_zone_id(pct_string_view const& s) { url_base::set_encoded_zone_id(s); return *this; }
389  
    static_url& set_encoded_zone_id(pct_string_view const& s) { url_base::set_encoded_zone_id(s); return *this; }
391  
    /// @copydoc url_base::set_host_ipvfuture
390  
    /// @copydoc url_base::set_host_ipvfuture
392  
    static_url& set_host_ipvfuture(core::string_view s) { url_base::set_host_ipvfuture(s); return *this; }
391  
    static_url& set_host_ipvfuture(core::string_view s) { url_base::set_host_ipvfuture(s); return *this; }
393  
    /// @copydoc url_base::set_host_name
392  
    /// @copydoc url_base::set_host_name
394  
    static_url& set_host_name(core::string_view s) { url_base::set_host_name(s); return *this; }
393  
    static_url& set_host_name(core::string_view s) { url_base::set_host_name(s); return *this; }
395  
    /// @copydoc url_base::set_encoded_host_name
394  
    /// @copydoc url_base::set_encoded_host_name
396  
    static_url& set_encoded_host_name(pct_string_view s) { url_base::set_encoded_host_name(s); return *this; }
395  
    static_url& set_encoded_host_name(pct_string_view s) { url_base::set_encoded_host_name(s); return *this; }
397  
    /// @copydoc url_base::set_port_number
396  
    /// @copydoc url_base::set_port_number
398  
    static_url& set_port_number(std::uint16_t n) { url_base::set_port_number(n); return *this; }
397  
    static_url& set_port_number(std::uint16_t n) { url_base::set_port_number(n); return *this; }
399  
    /// @copydoc url_base::set_port
398  
    /// @copydoc url_base::set_port
400  
    static_url& set_port(core::string_view s) { url_base::set_port(s); return *this; }
399  
    static_url& set_port(core::string_view s) { url_base::set_port(s); return *this; }
401  
    /// @copydoc url_base::remove_port
400  
    /// @copydoc url_base::remove_port
402  
    static_url& remove_port() noexcept { url_base::remove_port(); return *this; }
401  
    static_url& remove_port() noexcept { url_base::remove_port(); return *this; }
403  

402  

404  
    /// @copydoc url_base::set_path_absolute
403  
    /// @copydoc url_base::set_path_absolute
405  
    //bool set_path_absolute(bool absolute);
404  
    //bool set_path_absolute(bool absolute);
406  
    /// @copydoc url_base::set_path
405  
    /// @copydoc url_base::set_path
407  
    static_url& set_path(core::string_view s) { url_base::set_path(s); return *this; }
406  
    static_url& set_path(core::string_view s) { url_base::set_path(s); return *this; }
408  
    /// @copydoc url_base::set_encoded_path
407  
    /// @copydoc url_base::set_encoded_path
409  
    static_url& set_encoded_path(pct_string_view s) { url_base::set_encoded_path(s); return *this; }
408  
    static_url& set_encoded_path(pct_string_view s) { url_base::set_encoded_path(s); return *this; }
410  

409  

411  
    /// @copydoc url_base::set_query
410  
    /// @copydoc url_base::set_query
412  
    static_url& set_query(core::string_view s) { url_base::set_query(s); return *this; }
411  
    static_url& set_query(core::string_view s) { url_base::set_query(s); return *this; }
413  
    /// @copydoc url_base::set_encoded_query
412  
    /// @copydoc url_base::set_encoded_query
414  
    static_url& set_encoded_query(pct_string_view s) { url_base::set_encoded_query(s); return *this; }
413  
    static_url& set_encoded_query(pct_string_view s) { url_base::set_encoded_query(s); return *this; }
415  
    /// @copydoc url_base::set_params
414  
    /// @copydoc url_base::set_params
416  
    static_url& set_params(std::initializer_list<param_view> ps, encoding_opts opts = {}) { url_base::set_params(ps, opts); return *this; }
415  
    static_url& set_params(std::initializer_list<param_view> ps, encoding_opts opts = {}) { url_base::set_params(ps, opts); return *this; }
417  
    /// @copydoc url_base::remove_query
416  
    /// @copydoc url_base::remove_query
418  
    static_url& remove_query() noexcept { url_base::remove_query(); return *this; }
417  
    static_url& remove_query() noexcept { url_base::remove_query(); return *this; }
419  

418  

420  
    /// @copydoc url_base::remove_fragment
419  
    /// @copydoc url_base::remove_fragment
421  
    static_url& remove_fragment() noexcept { url_base::remove_fragment(); return *this; }
420  
    static_url& remove_fragment() noexcept { url_base::remove_fragment(); return *this; }
422  
    /// @copydoc url_base::set_fragment
421  
    /// @copydoc url_base::set_fragment
423  
    static_url& set_fragment(core::string_view s) { url_base::set_fragment(s); return *this; }
422  
    static_url& set_fragment(core::string_view s) { url_base::set_fragment(s); return *this; }
424  
    /// @copydoc url_base::set_encoded_fragment
423  
    /// @copydoc url_base::set_encoded_fragment
425  
    static_url& set_encoded_fragment(pct_string_view s) { url_base::set_encoded_fragment(s); return *this; }
424  
    static_url& set_encoded_fragment(pct_string_view s) { url_base::set_encoded_fragment(s); return *this; }
426  

425  

427  
    /// @copydoc url_base::remove_origin
426  
    /// @copydoc url_base::remove_origin
428  
    static_url& remove_origin() { url_base::remove_origin(); return *this; }
427  
    static_url& remove_origin() { url_base::remove_origin(); return *this; }
429  

428  

430  
    /// @copydoc url_base::normalize
429  
    /// @copydoc url_base::normalize
431  
    static_url& normalize() { url_base::normalize(); return *this; }
430  
    static_url& normalize() { url_base::normalize(); return *this; }
432  
    /// @copydoc url_base::normalize_scheme
431  
    /// @copydoc url_base::normalize_scheme
433  
    static_url& normalize_scheme() { url_base::normalize_scheme(); return *this; }
432  
    static_url& normalize_scheme() { url_base::normalize_scheme(); return *this; }
434  
    /// @copydoc url_base::normalize_authority
433  
    /// @copydoc url_base::normalize_authority
435  
    static_url& normalize_authority() { url_base::normalize_authority(); return *this; }
434  
    static_url& normalize_authority() { url_base::normalize_authority(); return *this; }
436  
    /// @copydoc url_base::normalize_path
435  
    /// @copydoc url_base::normalize_path
437  
    static_url& normalize_path() { url_base::normalize_path(); return *this; }
436  
    static_url& normalize_path() { url_base::normalize_path(); return *this; }
438  
    /// @copydoc url_base::normalize_query
437  
    /// @copydoc url_base::normalize_query
439  
    static_url& normalize_query() { url_base::normalize_query(); return *this; }
438  
    static_url& normalize_query() { url_base::normalize_query(); return *this; }
440  
    /// @copydoc url_base::normalize_fragment
439  
    /// @copydoc url_base::normalize_fragment
441  
    static_url& normalize_fragment() { url_base::normalize_fragment(); return *this; }
440  
    static_url& normalize_fragment() { url_base::normalize_fragment(); return *this; }
442  

441  

443  
    //--------------------------------------------
442  
    //--------------------------------------------
444  
};
443  
};
445  

444  

446  
} // urls
445  
} // urls
447  
} // boost
446  
} // boost
448  

447  

449  
//------------------------------------------------
448  
//------------------------------------------------
450  

449  

451  
// std::hash specialization
450  
// std::hash specialization
452  
#ifndef BOOST_URL_DOCS
451  
#ifndef BOOST_URL_DOCS
453  
namespace std {
452  
namespace std {
454  
template<std::size_t N>
453  
template<std::size_t N>
455  
struct hash< ::boost::urls::static_url<N> >
454  
struct hash< ::boost::urls::static_url<N> >
456  
{
455  
{
457  
    hash() = default;
456  
    hash() = default;
458  
    hash(hash const&) = default;
457  
    hash(hash const&) = default;
459  
    hash& operator=(hash const&) = default;
458  
    hash& operator=(hash const&) = default;
460  

459  

461  
    explicit
460  
    explicit
462  
    hash(std::size_t salt) noexcept
461  
    hash(std::size_t salt) noexcept
463  
        : salt_(salt)
462  
        : salt_(salt)
464  
    {
463  
    {
465  
    }
464  
    }
466  

465  

467  
    std::size_t
466  
    std::size_t
468  
    operator()(::boost::urls::static_url<N> const& u) const noexcept
467  
    operator()(::boost::urls::static_url<N> const& u) const noexcept
469  
    {
468  
    {
470  
        return u.digest(salt_);
469  
        return u.digest(salt_);
471  
    }
470  
    }
472  

471  

473  
private:
472  
private:
474  
    std::size_t salt_ = 0;
473  
    std::size_t salt_ = 0;
475  
};
474  
};
476  
} // std
475  
} // std
477  
#endif
476  
#endif
 
477 +

 
478 +
#include <boost/url/parse.hpp>
 
479 +
#include <boost/url/impl/static_url.hpp>
478  

480  

479  
#endif
481  
#endif