| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | 33 | static_url_base:: | |
| 22 | static_url_base( | ||
| 23 | char* buf, | ||
| 24 | 33 | std::size_t cap) noexcept | |
| 25 | { | ||
| 26 | 33 | s_ = buf; | |
| 27 | 33 | cap_ = cap; | |
| 28 | 33 | s_[0] = '\0'; | |
| 29 | 33 | impl_.cs_ = s_; | |
| 30 | 33 | } | |
| 31 | |||
| 32 | 18 | static_url_base:: | |
| 33 | static_url_base( | ||
| 34 | char* buf, | ||
| 35 | std::size_t cap, | ||
| 36 | 18 | core::string_view s) | |
| 37 | 18 | : static_url_base(buf, cap) | |
| 38 | { | ||
| 39 |
3/4✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 1 times.
|
37 | copy(parse_uri_reference(s |
| 40 |
2/2✓ Branch 2 taken 17 times.
✓ Branch 3 taken 1 times.
|
21 | ).value(BOOST_URL_POS)); |
| 41 | 18 | } | |
| 42 | |||
| 43 | void | ||
| 44 | 1 | static_url_base:: | |
| 45 | clear_impl() noexcept | ||
| 46 | { | ||
| 47 | 1 | impl_ = {from::url}; | |
| 48 | 1 | s_[0] = '\0'; | |
| 49 | 1 | impl_.cs_ = s_; | |
| 50 | 1 | } | |
| 51 | |||
| 52 | void | ||
| 53 | 41 | static_url_base:: | |
| 54 | reserve_impl( | ||
| 55 | std::size_t n, | ||
| 56 | op_t&) | ||
| 57 | { | ||
| 58 |
2/2✓ Branch 0 taken 37 times.
✓ Branch 1 taken 4 times.
|
41 | if(n <= cap_) |
| 59 | 37 | return; | |
| 60 | 4 | 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 | |||
| 91 |