LCOV - code coverage report
Current view: top level - boost/url/impl - params_base.hpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 23 23 100.0 %
Date: 2024-03-13 19:32:03 Functions: 8 8 100.0 %

          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_BASE_HPP
      12             : #define BOOST_URL_IMPL_PARAMS_BASE_HPP
      13             : 
      14             : #include <boost/url/detail/params_iter_impl.hpp>
      15             : #include <iterator>
      16             : 
      17             : namespace boost {
      18             : namespace urls {
      19             : 
      20             : //------------------------------------------------
      21             : 
      22             : class BOOST_URL_DECL params_base::iterator
      23             : {
      24             :     detail::params_iter_impl it_;
      25             :     bool space_as_plus_ = true;
      26             : 
      27             :     friend class params_base;
      28             :     friend class params_ref;
      29             : 
      30             :     iterator(
      31             :         detail::query_ref const& ref,
      32             :         encoding_opts opt) noexcept;
      33             : 
      34             :     iterator(
      35             :         detail::query_ref const& impl,
      36             :         encoding_opts opt,
      37             :         int) noexcept;
      38             : 
      39         173 :     iterator(
      40             :         detail::params_iter_impl const& it,
      41             :         encoding_opts opt) noexcept
      42         173 :         : it_(it)
      43         173 :         , space_as_plus_(opt.space_as_plus)
      44             :     {
      45         173 :     }
      46             : 
      47             : public:
      48             :     using value_type = params_base::value_type;
      49             :     using reference = params_base::reference;
      50             :     using pointer = reference;
      51             :     using difference_type =
      52             :         params_base::difference_type;
      53             :     using iterator_category =
      54             :         std::bidirectional_iterator_tag;
      55             : 
      56           4 :     iterator() = default;
      57             :     iterator(iterator const&) = default;
      58             :     iterator& operator=(
      59             :         iterator const&) noexcept = default;
      60             : 
      61             :     iterator&
      62         805 :     operator++() noexcept
      63             :     {
      64         805 :         it_.increment();
      65         805 :         return *this;
      66             :     }
      67             : 
      68             :     iterator
      69         349 :     operator++(int) noexcept
      70             :     {
      71         349 :         auto tmp = *this;
      72         349 :         ++*this;
      73         349 :         return tmp;
      74             :     }
      75             : 
      76             :     iterator&
      77         694 :     operator--() noexcept
      78             :     {
      79         694 :         it_.decrement();
      80         694 :         return *this;
      81             :     }
      82             : 
      83             :     iterator
      84         347 :     operator--(int) noexcept
      85             :     {
      86         347 :         auto tmp = *this;
      87         347 :         --*this;
      88         347 :         return tmp;
      89             :     }
      90             : 
      91             :     reference
      92             :     operator*() const;
      93             : 
      94             :     // the return value is too expensive
      95             :     pointer operator->() const = delete;
      96             : 
      97             :     bool
      98         730 :     operator==(
      99             :         iterator const& other) const noexcept
     100             :     {
     101         730 :         return it_.equal(other.it_);
     102             :     }
     103             : 
     104             :     bool
     105          89 :     operator!=(
     106             :         iterator const& other) const noexcept
     107             :     {
     108          89 :         return ! it_.equal(other.it_);
     109             :     }
     110             : };
     111             : 
     112             : 
     113             : } // urls
     114             : } // boost
     115             : 
     116             : #endif

Generated by: LCOV version 1.15