LCOV - code coverage report
Current view: top level - boost/url/impl/segments_encoded_ref.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 25 25
Test Date: 2024-08-19 20:08:54 Functions: 100.0 % 15 15

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

Generated by: LCOV version 2.1