LCOV - code coverage report
Current view: top level - /jenkins/workspace/boost-root/libs/url/src - segments_ref.cpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 52 52
Test Date: 2026-02-13 15:53:22 Functions: 100.0 % 16 16

            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              : 
      12              : #include <boost/url/detail/config.hpp>
      13              : #include <boost/url/segments_ref.hpp>
      14              : #include <boost/url/url.hpp>
      15              : #include <boost/url/detail/path.hpp>
      16              : #include <boost/assert.hpp>
      17              : 
      18              : namespace boost {
      19              : namespace urls {
      20              : 
      21              : //------------------------------------------------
      22              : //
      23              : // Special Members
      24              : //
      25              : //------------------------------------------------
      26              : 
      27          267 : segments_ref::
      28              : segments_ref(
      29          267 :     url_base& u) noexcept
      30              :     : segments_base(
      31          534 :         detail::path_ref(u.impl_))
      32          267 :     , u_(&u)
      33              : {
      34          267 : }
      35              : 
      36            1 : segments_ref::
      37              : operator
      38              : segments_view() const noexcept
      39              : {
      40            1 :     return segments_view(ref_);
      41              : }
      42              : 
      43              : segments_ref&
      44            1 : segments_ref::
      45              : operator=(segments_ref const& other)
      46              : {
      47            1 :     if (!ref_.alias_of(other.ref_))
      48            1 :         assign(other.begin(), other.end());
      49            1 :     return *this;
      50              : }
      51              : 
      52              : segments_ref&
      53            1 : segments_ref::
      54              : operator=(segments_view const& other)
      55              : {
      56            1 :     assign(other.begin(), other.end());
      57            1 :     return *this;
      58              : }
      59              : 
      60              : segments_ref&
      61           17 : segments_ref::
      62              : operator=(std::initializer_list<
      63              :     core::string_view> init)
      64              : {
      65           17 :     assign(init.begin(), init.end());
      66           17 :     return *this;
      67              : }
      68              : 
      69              : //------------------------------------------------
      70              : //
      71              : // Modifiers
      72              : //
      73              : //------------------------------------------------
      74              : 
      75              : void
      76            9 : segments_ref::
      77              : clear() noexcept
      78              : {
      79            9 :     erase(begin(), end());
      80            9 : }
      81              : 
      82              : void
      83            8 : segments_ref::
      84              : assign(std::initializer_list<
      85              :     core::string_view> init)
      86              : {
      87            8 :     assign(init.begin(), init.end());
      88            8 : }
      89              : 
      90              : auto
      91           46 : segments_ref::
      92              : insert(
      93              :     iterator before,
      94              :     core::string_view s) ->
      95              :         iterator
      96              : {
      97           46 :     return u_->edit_segments(
      98              :         before.it_,
      99              :         before.it_,
     100           92 :         detail::segment_iter(s));
     101              : }
     102              : 
     103              : auto
     104           16 : segments_ref::
     105              : insert(
     106              :     iterator before,
     107              :     std::initializer_list<
     108              :             core::string_view> init) ->
     109              :         iterator
     110              : {
     111           16 :     return insert(
     112              :         before,
     113              :         init.begin(),
     114           16 :         init.end());
     115              : }
     116              : 
     117              : auto
     118           37 : segments_ref::
     119              : erase(
     120              :     iterator first,
     121              :     iterator last) noexcept ->
     122              :         iterator
     123              : {
     124           37 :     core::string_view s;
     125           37 :     return u_->edit_segments(
     126              :         first.it_,
     127              :         last.it_,
     128           74 :         detail::make_segments_encoded_iter(
     129           37 :             &s, &s));
     130              : }
     131              : 
     132              : auto
     133           16 : segments_ref::
     134              : replace(
     135              :     iterator pos,
     136              :     core::string_view s) ->
     137              :         iterator
     138              : {
     139           48 :     return u_->edit_segments(
     140              :         pos.it_,
     141           16 :         std::next(pos).it_,
     142           32 :         detail::segment_iter(s));
     143              : }
     144              : 
     145              : auto
     146           13 : segments_ref::
     147              : replace(
     148              :     iterator from,
     149              :     iterator to,
     150              :     core::string_view s) ->
     151              :         iterator
     152              : {
     153           13 :     return u_->edit_segments(
     154              :         from.it_,
     155              :         to.it_,
     156           26 :         detail::segment_iter(s));
     157              : }
     158              : 
     159              : auto
     160            7 : segments_ref::
     161              : replace(
     162              :     iterator from,
     163              :     iterator to,
     164              :     std::initializer_list<
     165              :         core::string_view> init) ->
     166              :     iterator
     167              : {
     168            7 :     return replace(
     169              :         from,
     170              :         to,
     171              :         init.begin(),
     172            7 :         init.end());
     173              : }
     174              : 
     175              : auto
     176           22 : segments_ref::
     177              : erase(
     178              :     iterator pos) noexcept ->
     179              :         iterator
     180              : {
     181           22 :     return erase(pos, std::next(pos));
     182              : }
     183              : 
     184              : void
     185           14 : segments_ref::
     186              : push_back(
     187              :     core::string_view s)
     188              : {
     189           14 :     insert(end(), s);
     190           14 : }
     191              : 
     192              : void
     193            7 : segments_ref::
     194              : pop_back() noexcept
     195              : {
     196           14 :     erase(std::prev(end()));
     197            7 : }
     198              : 
     199              : } // urls
     200              : } // boost
     201              : 
        

Generated by: LCOV version 2.3