LCOV - code coverage report
Current view: top level - libs/url/src/rfc/detail - scheme_rule.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 13 13 100.0 %
Date: 2024-03-15 21:27:27 Functions: 1 1 100.0 %

          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             : 
      11             : #include <boost/url/detail/config.hpp>
      12             : #include "scheme_rule.hpp"
      13             : #include <boost/url/grammar/alpha_chars.hpp>
      14             : #include <boost/url/grammar/delim_rule.hpp>
      15             : #include <boost/url/grammar/lut_chars.hpp>
      16             : #include <boost/url/grammar/parse.hpp>
      17             : #include <boost/url/grammar/tuple_rule.hpp>
      18             : 
      19             : namespace boost {
      20             : namespace urls {
      21             : namespace detail {
      22             : 
      23             : auto
      24        3542 : scheme_rule::
      25             : parse(
      26             :     char const*& it,
      27             :     char const* end) const noexcept ->
      28             :         system::result<value_type>
      29             : {
      30        3542 :     auto const start = it;
      31        3542 :     if(it == end)
      32             :     {
      33             :         // end
      34         124 :         BOOST_URL_RETURN_EC(
      35             :             grammar::error::mismatch);
      36             :     }
      37        3418 :     if(! grammar::alpha_chars(*it))
      38             :     {
      39             :         // expected alpha
      40         843 :         BOOST_URL_RETURN_EC(
      41             :             grammar::error::mismatch);
      42             :     }
      43             : 
      44             :     static
      45             :     constexpr
      46             :     grammar::lut_chars scheme_chars(
      47             :         "0123456789" "+-."
      48             :         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
      49             :         "abcdefghijklmnopqrstuvwxyz");
      50        5150 :     it = grammar::find_if_not(
      51        2575 :         it + 1, end, scheme_chars);
      52        2575 :     value_type t;
      53        5150 :     t.scheme = core::string_view(
      54        2575 :         start, it - start);
      55        2575 :     t.scheme_id = string_to_scheme(
      56             :         t.scheme);
      57        2575 :     return t;
      58             : }
      59             : 
      60             : } // detail
      61             : } // urls
      62             : } // boost
      63             : 

Generated by: LCOV version 1.15