LCOV - code coverage report
Current view: top level - url/impl - segments_encoded_ref.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 66 66
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 27 27

           TLA  Line data    Source code
       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_ENCODED_REF_HPP
      12                 : #define BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
      13                 : 
      14                 : #include <boost/url/detail/config.hpp>
      15                 : #include <boost/url/detail/segments_iter_impl.hpp>
      16                 : #include <boost/url/detail/any_segments_iter.hpp>
      17                 : #include <boost/url/detail/path.hpp>
      18                 : #include <type_traits>
      19                 : 
      20                 : namespace boost {
      21                 : namespace urls {
      22                 : 
      23                 : //------------------------------------------------
      24                 : //
      25                 : // Modifiers
      26                 : //
      27                 : //------------------------------------------------
      28                 : 
      29                 : template<class FwdIt>
      30                 : void
      31 HIT          24 : segments_encoded_ref::
      32                 : assign(
      33                 :     FwdIt first, FwdIt last)
      34                 : {
      35                 : /*  If you get a compile error here, it
      36                 :     means that the iterators you passed
      37                 :     do not meet the requirements stated
      38                 :     in the documentation.
      39                 : */
      40                 :     static_assert(
      41                 :         std::is_convertible<
      42                 :             typename std::iterator_traits<
      43                 :                 FwdIt>::reference,
      44                 :             core::string_view>::value,
      45                 :         "Type requirements not met");
      46                 : 
      47              42 :     u_->edit_segments(
      48              18 :         begin().it_,
      49              36 :         end().it_,
      50                 :         detail::make_segments_encoded_iter(
      51                 :             first, last));
      52              18 : }
      53                 : 
      54                 : template<class FwdIt>
      55                 : auto
      56             158 : segments_encoded_ref::
      57                 : insert(
      58                 :     iterator before,
      59                 :     FwdIt first,
      60                 :     FwdIt last) ->
      61                 :         iterator
      62                 : {
      63                 : /*  If you get a compile error here, it
      64                 :     means that the iterators you passed
      65                 :     do not meet the requirements stated
      66                 :     in the documentation.
      67                 : */
      68                 :     static_assert(
      69                 :         std::is_convertible<
      70                 :             typename std::iterator_traits<
      71                 :                 FwdIt>::reference,
      72                 :             core::string_view>::value,
      73                 :         "Type requirements not met");
      74                 : 
      75             309 :     return insert(
      76                 :         before,
      77                 :         first,
      78                 :         last,
      79                 :         typename std::iterator_traits<
      80             302 :             FwdIt>::iterator_category{});
      81                 : }
      82                 : 
      83                 : template<class FwdIt>
      84                 : auto
      85              14 : segments_encoded_ref::
      86                 : replace(
      87                 :     iterator from,
      88                 :     iterator to,
      89                 :     FwdIt first,
      90                 :     FwdIt last) ->
      91                 :         iterator
      92                 : {
      93                 : /*  If you get a compile error here, it
      94                 :     means that the iterators you passed
      95                 :     do not meet the requirements stated
      96                 :     in the documentation.
      97                 : */
      98                 :     static_assert(
      99                 :         std::is_convertible<
     100                 :             typename std::iterator_traits<
     101                 :                 FwdIt>::reference,
     102                 :             core::string_view>::value,
     103                 :         "Type requirements not met");
     104                 : 
     105              28 :     return u_->edit_segments(
     106                 :         from.it_,
     107                 :         to.it_,
     108                 :         detail::make_segments_encoded_iter(
     109              24 :             first, last));
     110                 : }
     111                 : 
     112                 : //------------------------------------------------
     113                 : 
     114                 : template<class FwdIt>
     115                 : auto
     116             158 : segments_encoded_ref::
     117                 : insert(
     118                 :     iterator before,
     119                 :     FwdIt first,
     120                 :     FwdIt last,
     121                 :     std::forward_iterator_tag) ->
     122                 :         iterator
     123                 : {
     124             309 :     return u_->edit_segments(
     125                 :         before.it_,
     126                 :         before.it_,
     127                 :         detail::make_segments_encoded_iter(
     128             302 :             first, last));
     129                 : }
     130                 : 
     131                 : //------------------------------------------------
     132                 : //
     133                 : // Special Members
     134                 : //
     135                 : //------------------------------------------------
     136                 : 
     137                 : inline
     138             467 : segments_encoded_ref::
     139                 : segments_encoded_ref(
     140             467 :     url_base& u) noexcept
     141                 :     : segments_encoded_base(
     142             934 :         detail::path_ref(u.impl_))
     143             467 :     , u_(&u)
     144                 : {
     145             467 : }
     146                 : 
     147                 : inline
     148              34 : segments_encoded_ref::
     149                 : operator
     150                 : segments_encoded_view() const noexcept
     151                 : {
     152              34 :     return segments_encoded_view(ref_);
     153                 : }
     154                 : 
     155                 : inline
     156                 : segments_encoded_ref&
     157               1 : segments_encoded_ref::
     158                 : operator=(
     159                 :     segments_encoded_ref const& other)
     160                 : {
     161               1 :     if (!ref_.alias_of(other.ref_))
     162               1 :         assign(other.begin(), other.end());
     163               1 :     return *this;
     164                 : }
     165                 : 
     166                 : inline
     167                 : segments_encoded_ref&
     168               1 : segments_encoded_ref::
     169                 : operator=(
     170                 :     segments_encoded_view const& other)
     171                 : {
     172               1 :     assign(other.begin(), other.end());
     173               1 :     return *this;
     174                 : }
     175                 : 
     176                 : inline
     177                 : segments_encoded_ref&
     178               4 : segments_encoded_ref::
     179                 : operator=(std::initializer_list<
     180                 :     pct_string_view> init)
     181                 : {
     182               4 :     assign(init.begin(), init.end());
     183               4 :     return *this;
     184                 : }
     185                 : 
     186                 : //------------------------------------------------
     187                 : //
     188                 : // Modifiers
     189                 : //
     190                 : //------------------------------------------------
     191                 : 
     192                 : inline
     193                 : void
     194               9 : segments_encoded_ref::
     195                 : clear() noexcept
     196                 : {
     197               9 :     erase(begin(), end());
     198               9 : }
     199                 : 
     200                 : inline
     201                 : void
     202               6 : segments_encoded_ref::
     203                 : assign(
     204                 :     std::initializer_list<
     205                 :         pct_string_view> init)
     206                 : {
     207               6 :     assign(init.begin(), init.end());
     208               6 : }
     209                 : 
     210                 : inline
     211                 : auto
     212              50 : segments_encoded_ref::
     213                 : insert(
     214                 :     iterator before,
     215                 :     pct_string_view s) ->
     216                 :         iterator
     217                 : {
     218              50 :     return u_->edit_segments(
     219                 :         before.it_,
     220                 :         before.it_,
     221             100 :         detail::segment_encoded_iter(s));
     222                 : }
     223                 : 
     224                 : inline
     225                 : auto
     226              14 : segments_encoded_ref::
     227                 : insert(
     228                 :     iterator before,
     229                 :     std::initializer_list<
     230                 :             pct_string_view> init) ->
     231                 :         iterator
     232                 : {
     233              14 :     return insert(
     234                 :         before,
     235                 :         init.begin(),
     236              14 :         init.end());
     237                 : }
     238                 : 
     239                 : inline
     240                 : auto
     241             152 : segments_encoded_ref::
     242                 : erase(
     243                 :     iterator first,
     244                 :     iterator last) noexcept ->
     245                 :         iterator
     246                 : {
     247             152 :     core::string_view s;
     248             152 :     return u_->edit_segments(
     249                 :         first.it_,
     250                 :         last.it_,
     251             304 :         detail::make_segments_encoded_iter(
     252             152 :             &s, &s));
     253                 : }
     254                 : 
     255                 : inline
     256                 : auto
     257              10 : segments_encoded_ref::
     258                 : replace(
     259                 :     iterator pos,
     260                 :     pct_string_view s) ->
     261                 :         iterator
     262                 : {
     263              30 :     return u_->edit_segments(
     264                 :         pos.it_,
     265              10 :         std::next(pos).it_,
     266              20 :         detail::segment_encoded_iter(s));
     267                 : }
     268                 : 
     269                 : inline
     270                 : auto
     271              12 : segments_encoded_ref::
     272                 : replace(
     273                 :     iterator from,
     274                 :     iterator to,
     275                 :     pct_string_view s) ->
     276                 :         iterator
     277                 : {
     278              12 :     return u_->edit_segments(
     279                 :         from.it_,
     280                 :         to.it_,
     281              24 :         detail::segment_encoded_iter(s));
     282                 : }
     283                 : 
     284                 : inline
     285                 : auto
     286               6 : segments_encoded_ref::
     287                 : replace(
     288                 :     iterator from,
     289                 :     iterator to,
     290                 :     std::initializer_list<
     291                 :         pct_string_view> init) ->
     292                 :     iterator
     293                 : {
     294               6 :     return replace(
     295                 :         from,
     296                 :         to,
     297                 :         init.begin(),
     298               6 :         init.end());
     299                 : }
     300                 : 
     301                 : inline
     302                 : auto
     303             137 : segments_encoded_ref::
     304                 : erase(
     305                 :     iterator pos) noexcept ->
     306                 :         iterator
     307                 : {
     308             137 :     return erase(pos, std::next(pos));
     309                 : }
     310                 : 
     311                 : inline
     312                 : void
     313              20 : segments_encoded_ref::
     314                 : push_back(
     315                 :     pct_string_view s)
     316                 : {
     317              20 :     insert(end(), s);
     318              20 : }
     319                 : 
     320                 : inline
     321                 : void
     322             125 : segments_encoded_ref::
     323                 : pop_back() noexcept
     324                 : {
     325             250 :     erase(std::prev(end()));
     326             125 : }
     327                 : 
     328                 : } // urls
     329                 : } // boost
     330                 : 
     331                 : #endif
        

Generated by: LCOV version 2.3