LCOV - code coverage report
Current view: top level - libs/url/src/rfc/detail/h16_rule.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 97.0 % 33 32
Test Date: 2024-08-19 20:08:54 Functions: 100.0 % 1 1

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot 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 <boost/url/detail/config.hpp>
      11              : #include "h16_rule.hpp"
      12              : #include <boost/url/grammar/charset.hpp>
      13              : #include <boost/url/grammar/error.hpp>
      14              : #include <boost/url/grammar/hexdig_chars.hpp>
      15              : #include <boost/assert.hpp>
      16              : 
      17              : namespace boost {
      18              : namespace urls {
      19              : namespace detail {
      20              : 
      21              : auto
      22          932 : h16_rule_t::
      23              : parse(
      24              :     char const*& it,
      25              :     char const* end
      26              :         ) const noexcept ->
      27              :     system::result<value_type>
      28              : {
      29              :     // VFALCO it might be impossible for
      30              :     // this condition to be true (coverage)
      31          932 :     if(it == end)
      32              :     {
      33              :         // end
      34            0 :         BOOST_URL_RETURN_EC(
      35              :             grammar::error::invalid);
      36              :     }
      37              : 
      38              :     std::uint16_t v;
      39              :     for(;;)
      40              :     {
      41          932 :         auto d = grammar::hexdig_value(*it);
      42          932 :         if(d < 0)
      43              :         {
      44              :             // expected HEXDIG
      45           25 :             BOOST_URL_RETURN_EC(
      46              :                 grammar::error::invalid);
      47              :         }
      48          907 :         v = d;
      49          907 :         ++it;
      50          907 :         if(it == end)
      51           75 :             break;
      52          832 :         d = grammar::hexdig_value(*it);
      53          832 :         if(d < 0)
      54          556 :             break;
      55          276 :         v = (16 * v) + d;
      56          276 :         ++it;
      57          276 :         if(it == end)
      58            4 :             break;
      59          272 :         d = grammar::hexdig_value(*it);
      60          272 :         if(d < 0)
      61            4 :             break;
      62          268 :         v = (16 * v) + d;
      63          268 :         ++it;
      64          268 :         if(it == end)
      65            4 :             break;
      66          264 :         d = grammar::hexdig_value(*it);
      67          264 :         if(d < 0)
      68           51 :             break;
      69          213 :         v = (16 * v) + d;
      70          213 :         ++it;
      71          213 :         break;
      72              :     }
      73          907 :     return value_type{
      74              :         static_cast<
      75          907 :             unsigned char>(v / 256),
      76              :         static_cast<
      77          907 :             unsigned char>(v % 256)};
      78              : }
      79              : 
      80              : } // detail
      81              : } // urls
      82              : } // boost
      83              : 
        

Generated by: LCOV version 2.1