| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | ||
| 4 | // | ||
| 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) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/boostorg/url | ||
| 9 | // | ||
| 10 | |||
| 11 | #ifndef BOOST_URL_IMPL_SEGMENTS_REF_HPP | ||
| 12 | #define BOOST_URL_IMPL_SEGMENTS_REF_HPP | ||
| 13 | |||
| 14 | #include <boost/url/detail/config.hpp> | ||
| 15 | #include <boost/url/detail/any_segments_iter.hpp> | ||
| 16 | #include <boost/url/detail/segments_iter_impl.hpp> | ||
| 17 | #include <type_traits> | ||
| 18 | |||
| 19 | namespace boost { | ||
| 20 | namespace urls { | ||
| 21 | |||
| 22 | //------------------------------------------------ | ||
| 23 | // | ||
| 24 | // Modifiers | ||
| 25 | // | ||
| 26 | //------------------------------------------------ | ||
| 27 | |||
| 28 | inline | ||
| 29 | void | ||
| 30 | 9 | segments_ref:: | |
| 31 | clear() noexcept | ||
| 32 | { | ||
| 33 | 9 | erase(begin(), end()); | |
| 34 | 9 | } | |
| 35 | |||
| 36 | template<class FwdIt> | ||
| 37 | void | ||
| 38 | 61 | segments_ref:: | |
| 39 | assign(FwdIt first, FwdIt last) | ||
| 40 | { | ||
| 41 | /* If you get a compile error here, it | ||
| 42 | means that the iterators you passed | ||
| 43 | do not meet the requirements stated | ||
| 44 | in the documentation. | ||
| 45 | */ | ||
| 46 | static_assert( | ||
| 47 | std::is_convertible< | ||
| 48 | typename std::iterator_traits< | ||
| 49 | FwdIt>::reference, | ||
| 50 | core::string_view>::value, | ||
| 51 | "Type requirements not met"); | ||
| 52 | |||
| 53 |
1/2✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
|
122 | u_->edit_segments( |
| 54 | 61 | begin().it_, | |
| 55 | 122 | end().it_, | |
| 56 | detail::make_segments_iter( | ||
| 57 | first, last)); | ||
| 58 | 61 | } | |
| 59 | |||
| 60 | template<class FwdIt> | ||
| 61 | auto | ||
| 62 | 31 | segments_ref:: | |
| 63 | insert( | ||
| 64 | iterator before, | ||
| 65 | FwdIt first, | ||
| 66 | FwdIt last) -> | ||
| 67 | iterator | ||
| 68 | { | ||
| 69 | /* If you get a compile error here, it | ||
| 70 | means that the iterators you passed | ||
| 71 | do not meet the requirements stated | ||
| 72 | in the documentation. | ||
| 73 | */ | ||
| 74 | static_assert( | ||
| 75 | std::is_convertible< | ||
| 76 | typename std::iterator_traits< | ||
| 77 | FwdIt>::reference, | ||
| 78 | core::string_view>::value, | ||
| 79 | "Type requirements not met"); | ||
| 80 | |||
| 81 |
1/2✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
|
62 | return insert( |
| 82 | before, | ||
| 83 | first, | ||
| 84 | last, | ||
| 85 | typename std::iterator_traits< | ||
| 86 | 62 | FwdIt>::iterator_category{}); | |
| 87 | } | ||
| 88 | |||
| 89 | inline | ||
| 90 | auto | ||
| 91 | 22 | segments_ref:: | |
| 92 | erase( | ||
| 93 | iterator pos) noexcept -> | ||
| 94 | iterator | ||
| 95 | { | ||
| 96 | 22 | return erase(pos, std::next(pos)); | |
| 97 | } | ||
| 98 | |||
| 99 | template<class FwdIt> | ||
| 100 | auto | ||
| 101 | 14 | segments_ref:: | |
| 102 | replace( | ||
| 103 | iterator from, | ||
| 104 | iterator to, | ||
| 105 | FwdIt first, | ||
| 106 | FwdIt last) -> | ||
| 107 | iterator | ||
| 108 | { | ||
| 109 | /* If you get a compile error here, it | ||
| 110 | means that the iterators you passed | ||
| 111 | do not meet the requirements stated | ||
| 112 | in the documentation. | ||
| 113 | */ | ||
| 114 | static_assert( | ||
| 115 | std::is_convertible< | ||
| 116 | typename std::iterator_traits< | ||
| 117 | FwdIt>::reference, | ||
| 118 | core::string_view>::value, | ||
| 119 | "Type requirements not met"); | ||
| 120 | |||
| 121 |
1/2✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
28 | return u_->edit_segments( |
| 122 | from.it_, | ||
| 123 | to.it_, | ||
| 124 | detail::make_segments_iter( | ||
| 125 | 28 | first, last)); | |
| 126 | } | ||
| 127 | |||
| 128 | //------------------------------------------------ | ||
| 129 | |||
| 130 | inline | ||
| 131 | void | ||
| 132 | 14 | segments_ref:: | |
| 133 | push_back( | ||
| 134 | core::string_view s) | ||
| 135 | { | ||
| 136 |
1/2✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
14 | insert(end(), s); |
| 137 | 14 | } | |
| 138 | |||
| 139 | inline | ||
| 140 | void | ||
| 141 | 7 | segments_ref:: | |
| 142 | pop_back() noexcept | ||
| 143 | { | ||
| 144 | 14 | erase(std::prev(end())); | |
| 145 | 7 | } | |
| 146 | |||
| 147 | //------------------------------------------------ | ||
| 148 | |||
| 149 | template<class FwdIt> | ||
| 150 | auto | ||
| 151 | 31 | segments_ref:: | |
| 152 | insert( | ||
| 153 | iterator before, | ||
| 154 | FwdIt first, | ||
| 155 | FwdIt last, | ||
| 156 | std::forward_iterator_tag) -> | ||
| 157 | iterator | ||
| 158 | { | ||
| 159 |
1/2✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
|
62 | return u_->edit_segments( |
| 160 | before.it_, | ||
| 161 | before.it_, | ||
| 162 | detail::make_segments_iter( | ||
| 163 | 62 | first, last)); | |
| 164 | } | ||
| 165 | |||
| 166 | } // urls | ||
| 167 | } // boost | ||
| 168 | |||
| 169 | #endif | ||
| 170 |