LCOV - code coverage report
Current view: top level - url/grammar/impl - literal_rule.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 16 16
Test Date: 2026-02-25 21:00:01 Functions: 100.0 % 1 1

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3                 : // Copyright (c) 2023 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_GRAMMAR_IMPL_LITERAL_RULE_HPP
      12                 : #define BOOST_URL_GRAMMAR_IMPL_LITERAL_RULE_HPP
      13                 : 
      14                 : #include <boost/url/detail/config.hpp>
      15                 : #include <boost/url/grammar/error.hpp>
      16                 : #include <boost/assert.hpp>
      17                 : #include <cstring>
      18                 : 
      19                 : namespace boost {
      20                 : namespace urls {
      21                 : namespace grammar {
      22                 : 
      23                 : BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
      24                 : auto
      25 HIT          10 : literal_rule::
      26                 : parse(
      27                 :     char const*& it,
      28                 :     char const* end) const noexcept ->
      29                 :         system::result<value_type>
      30                 : {
      31                 :     // Can't have a literal
      32                 :     // with an empty string!
      33              10 :     BOOST_ASSERT(n_ > 0);
      34                 : 
      35              10 :     std::size_t n = end - it;
      36              10 :     if(n >= n_)
      37                 :     {
      38               4 :         if(std::memcmp(
      39               4 :             it, s_, n_) != 0)
      40                 :         {
      41                 :             // non-match
      42               1 :             BOOST_URL_CONSTEXPR_RETURN_EC(
      43                 :                 error::mismatch);
      44                 :         }
      45               3 :         it += n_;
      46               3 :         return core::string_view(
      47               3 :             it - n_, it);
      48                 :     }
      49               6 :     if(n > 0)
      50                 :     {
      51                 :         // short input
      52               5 :         if(std::memcmp(
      53               5 :             it, s_, n) != 0)
      54                 :         {
      55                 :             // non-match
      56               2 :             BOOST_URL_CONSTEXPR_RETURN_EC(
      57                 :                 error::mismatch);
      58                 :         }
      59                 :         // prefix matches
      60               3 :         BOOST_URL_CONSTEXPR_RETURN_EC(
      61                 :             error::need_more);
      62                 :     }
      63                 :     // end
      64               1 :     BOOST_URL_CONSTEXPR_RETURN_EC(
      65                 :         error::need_more);
      66                 : }
      67                 : 
      68                 : } // grammar
      69                 : } // urls
      70                 : } // boost
      71                 : 
      72                 : #endif
        

Generated by: LCOV version 2.3