LCOV - code coverage report
Current view: top level - boost/url/impl/params_encoded_base.hpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 51 51
Test Date: 2025-11-13 05:23:41 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              : #ifndef BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
      12              : #define BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
      13              : 
      14              : #include <boost/url/detail/params_iter_impl.hpp>
      15              : 
      16              : namespace boost {
      17              : namespace urls {
      18              : 
      19              : #ifndef BOOST_URL_DOCS
      20              : class params_ref;
      21              : #endif
      22              : 
      23              : //------------------------------------------------
      24              : 
      25              : class params_encoded_base::iterator
      26              : {
      27              :     detail::params_iter_impl it_;
      28              : 
      29              :     friend class params_encoded_base;
      30              :     friend class params_encoded_ref;
      31              : 
      32              :     iterator(detail::query_ref const& ref) noexcept;
      33              :     iterator(detail::query_ref const& ref, int) noexcept;
      34          159 :     iterator(
      35              :         detail::params_iter_impl const& it)
      36          159 :         : it_(it)
      37              :     {
      38          159 :     }
      39              : 
      40              : public:
      41              :     using value_type =
      42              :         params_encoded_base::value_type;
      43              :     using reference =
      44              :         params_encoded_base::reference;
      45              :     using pointer = reference;
      46              :     using difference_type = std::ptrdiff_t;
      47              :     using iterator_category =
      48              :         std::bidirectional_iterator_tag;
      49              : 
      50            4 :     iterator() = default;
      51              :     iterator(iterator const&) = default;
      52              :     iterator& operator=(
      53              :         iterator const&) = default;
      54              : 
      55              :     iterator&
      56          696 :     operator++() noexcept
      57              :     {
      58          696 :         it_.increment();
      59          696 :         return *this;
      60              :     }
      61              : 
      62              :     iterator
      63          292 :     operator++(int) noexcept
      64              :     {
      65          292 :         auto tmp = *this;
      66          292 :         ++*this;
      67          292 :         return tmp;
      68              :     }
      69              : 
      70              :     iterator&
      71          580 :     operator--() noexcept
      72              :     {
      73          580 :         it_.decrement();
      74          580 :         return *this;
      75              :     }
      76              : 
      77              :     iterator
      78          290 :     operator--(int) noexcept
      79              :     {
      80          290 :         auto tmp = *this;
      81          290 :         --*this;
      82          290 :         return tmp;
      83              :     }
      84              : 
      85              :     reference
      86          622 :     operator*() const
      87              :     {
      88          622 :         return it_.dereference();
      89              :     }
      90              : 
      91              :     pointer
      92           21 :     operator->() const
      93              :     {
      94           21 :         return it_.dereference();
      95              :     }
      96              : 
      97              :     friend
      98              :     bool
      99          617 :     operator==(
     100              :         iterator const& it0,
     101              :         iterator const& it1) noexcept
     102              :     {
     103          617 :         return it0.it_.equal(it1.it_);
     104              :     }
     105              : 
     106              :     friend
     107              :     bool
     108          111 :     operator!=(
     109              :         iterator const& it0,
     110              :         iterator const& it1) noexcept
     111              :     {
     112          111 :         return ! it0.it_.equal(it1.it_);
     113              :     }
     114              : };
     115              : 
     116              : //------------------------------------------------
     117              : //
     118              : // Observers
     119              : //
     120              : //------------------------------------------------
     121              : 
     122              : inline
     123              : bool
     124           28 : params_encoded_base::
     125              : contains(
     126              :     pct_string_view key,
     127              :     ignore_case_param ic) const noexcept
     128              : {
     129           28 :     return find_impl(
     130           56 :         begin().it_, key, ic) != end();
     131              : }
     132              : 
     133              : inline
     134              : pct_string_view
     135            7 : params_encoded_base::
     136              : get_or(
     137              :     pct_string_view key,
     138              :     pct_string_view value,
     139              :     ignore_case_param ic) const noexcept
     140              : {
     141            7 :     auto it = find_impl(
     142            7 :         begin().it_, key, ic);
     143            7 :     detail::params_iter_impl end_(ref_, 0);
     144            7 :     if(it.equal(end_))
     145            2 :         return value;
     146              : 
     147            5 :     param_pct_view const p = it.dereference();
     148            5 :     if(! p.has_value)
     149            1 :         return pct_string_view();
     150              : 
     151            4 :     return p.value;
     152              : }
     153              : 
     154              : inline
     155              : auto
     156           38 : params_encoded_base::
     157              : find(
     158              :     pct_string_view key,
     159              :     ignore_case_param ic) const noexcept ->
     160              :         iterator
     161              : {
     162           38 :     return find_impl(
     163           76 :         begin().it_, key, ic);
     164              : }
     165              : 
     166              : inline
     167              : auto
     168           32 : params_encoded_base::
     169              : find(
     170              :     iterator it,
     171              :     pct_string_view key,
     172              :     ignore_case_param ic) const noexcept ->
     173              :         iterator
     174              : {
     175           64 :     return find_impl(
     176           32 :         it.it_, key, ic);
     177              : }
     178              : 
     179              : inline
     180              : auto
     181            4 : params_encoded_base::
     182              : find_last(
     183              :     pct_string_view key,
     184              :     ignore_case_param ic) const noexcept ->
     185              :         iterator
     186              : {
     187            4 :     return find_last_impl(
     188            8 :         end().it_, key, ic);
     189              : }
     190              : 
     191              : inline
     192              : auto
     193            9 : params_encoded_base::
     194              : find_last(
     195              :     iterator it,
     196              :     pct_string_view key,
     197              :     ignore_case_param ic) const noexcept ->
     198              :         iterator
     199              : {
     200           18 :     return find_last_impl(
     201            9 :         it.it_, key, ic);
     202              : }
     203              : 
     204              : } // urls
     205              : } // boost
     206              : 
     207              : #endif
        

Generated by: LCOV version 2.1