LCOV - code coverage report
Current view: top level - libs/url/example/router/impl/matches.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 27 27
Test Date: 2024-08-19 20:08:54 Functions: 100.0 % 8 8

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
       3              : //
       4              : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       5              : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       6              : //
       7              : // Official repository: https://github.com/boostorg/url
       8              : //
       9              : 
      10              : #include "../matches.hpp"
      11              : 
      12              : namespace boost {
      13              : namespace urls {
      14              : 
      15              : auto
      16          196 : matches_base::
      17              : at( size_type pos ) const
      18              :     -> const_reference
      19              : {
      20          196 :     if (pos < size())
      21              :     {
      22          120 :         return matches()[pos];
      23              :     }
      24           76 :     boost::throw_exception(
      25          152 :         std::out_of_range(""));
      26              : }
      27              : 
      28              : auto
      29          120 : matches_base::
      30              : operator[]( size_type pos ) const
      31              :     -> const_reference
      32              : {
      33          120 :     BOOST_ASSERT(pos < size());
      34          120 :     return matches()[pos];
      35              : }
      36              : 
      37              : auto
      38          312 : matches_base::
      39              : at( core::string_view id ) const
      40              :     -> const_reference
      41              : {
      42          564 :     for (std::size_t i = 0; i < size(); ++i)
      43              :     {
      44          488 :         if (ids()[i] == id)
      45          236 :             return matches()[i];
      46              :     }
      47           76 :     boost::throw_exception(
      48          152 :         std::out_of_range(""));
      49              : }
      50              : 
      51              : auto
      52          118 : matches_base::
      53              : operator[]( core::string_view id ) const
      54              :     -> const_reference
      55              : {
      56          118 :     return at(id);
      57              : }
      58              : 
      59              : auto
      60          194 : matches_base::
      61              : find( core::string_view id ) const
      62              :     -> const_iterator
      63              : {
      64          380 :     for (std::size_t i = 0; i < size(); ++i)
      65              :     {
      66          304 :         if (ids()[i] == id)
      67          118 :             return matches() + i;
      68              :     }
      69           76 :     return matches() + size();
      70              : }
      71              : 
      72              : auto
      73           76 : matches_base::
      74              : begin() const
      75              :     -> const_iterator
      76              : {
      77           76 :     return &matches()[0];
      78              : }
      79              : 
      80              : auto
      81          270 : matches_base::
      82              : end() const
      83              :     -> const_iterator
      84              : {
      85          270 :     return &matches()[size()];
      86              : }
      87              : 
      88              : auto
      89           76 : matches_base::
      90              : empty() const noexcept
      91              :     -> bool
      92              : {
      93           76 :     return size() == 0;
      94              : }
      95              : 
      96              : } // urls
      97              : } // boost
      98              : 
        

Generated by: LCOV version 2.1