LCOV - code coverage report
Current view: top level - libs/url/src/segments_ref.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 41 41
Test Date: 2024-08-19 20:08:54 Functions: 100.0 % 12 12

            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 "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          266 : segments_ref::
      28              : segments_ref(
      29          266 :     url_base& u) noexcept
      30              :     : segments_base(
      31          532 :         detail::path_ref(u.impl_))
      32          266 :     , u_(&u)
      33              : {
      34          266 : }
      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            8 : segments_ref::
      77              : assign(std::initializer_list<
      78              :     core::string_view> init)
      79              : {
      80            8 :     assign(init.begin(), init.end());
      81            8 : }
      82              : 
      83              : auto
      84           45 : segments_ref::
      85              : insert(
      86              :     iterator before,
      87              :     core::string_view s) ->
      88              :         iterator
      89              : {
      90           45 :     return u_->edit_segments(
      91              :         before.it_,
      92              :         before.it_,
      93           90 :         detail::segment_iter(s));
      94              : }
      95              : 
      96              : auto
      97           16 : segments_ref::
      98              : insert(
      99              :     iterator before,
     100              :     std::initializer_list<
     101              :             core::string_view> init) ->
     102              :         iterator
     103              : {
     104           16 :     return insert(
     105              :         before,
     106              :         init.begin(),
     107           16 :         init.end());
     108              : }
     109              : 
     110              : auto
     111           37 : segments_ref::
     112              : segments_ref::
     113              : erase(
     114              :     iterator first,
     115              :     iterator last) noexcept ->
     116              :         iterator
     117              : {
     118           37 :     core::string_view s;
     119           37 :     return u_->edit_segments(
     120              :         first.it_,
     121              :         last.it_,
     122           74 :         detail::make_segments_encoded_iter(
     123           37 :             &s, &s));
     124              : }
     125              : 
     126              : auto
     127           16 : segments_ref::
     128              : replace(
     129              :     iterator pos,
     130              :     core::string_view s) ->
     131              :         iterator
     132              : {
     133           16 :     return u_->edit_segments(
     134              :         pos.it_,
     135           16 :         std::next(pos).it_,
     136           32 :         detail::segment_iter(s));
     137              : }
     138              : 
     139              : auto
     140           13 : segments_ref::
     141              : replace(
     142              :     iterator from,
     143              :     iterator to,
     144              :     core::string_view s) ->
     145              :         iterator
     146              : {
     147           13 :     return u_->edit_segments(
     148              :         from.it_,
     149              :         to.it_,
     150           26 :         detail::segment_iter(s));
     151              : }
     152              : 
     153              : auto
     154            7 : segments_ref::
     155              : replace(
     156              :     iterator from,
     157              :     iterator to,
     158              :     std::initializer_list<
     159              :         core::string_view> init) ->
     160              :     iterator
     161              : {
     162            7 :     return replace(
     163              :         from,
     164              :         to,
     165              :         init.begin(),
     166            7 :         init.end());
     167              : }
     168              : 
     169              : } // urls
     170              : } // boost
     171              : 
        

Generated by: LCOV version 2.1