LCOV - code coverage report
Current view: top level - libs/http_proto/src/rfc - parameter.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 94.1 % 17 16
Test Date: 2025-12-23 17:59:40 Functions: 100.0 % 2 2

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2021 Vinnie Falco (vinnie.falco@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/cppalliance/http_proto
       8              : //
       9              : 
      10              : #include <boost/http_proto/rfc/parameter.hpp>
      11              : #include <boost/http_proto/rfc/token_rule.hpp>
      12              : #include <boost/http_proto/rfc/quoted_token_rule.hpp>
      13              : #include <boost/http_proto/rfc/detail/ws.hpp>
      14              : 
      15              : #include <boost/url/grammar/parse.hpp>
      16              : #include <boost/url/grammar/optional_rule.hpp>
      17              : #include <boost/url/grammar/tuple_rule.hpp>
      18              : #include <boost/url/grammar/literal_rule.hpp>
      19              : 
      20              : namespace boost {
      21              : namespace http_proto {
      22              : namespace implementation_defined {
      23              : auto
      24           32 : parameter_rule_t::
      25              : parse(
      26              :     char const*& it,
      27              :     char const* end) const noexcept ->
      28              :         system::result<value_type>
      29              : {
      30           32 :     auto name = grammar::parse(it, end, token_rule);
      31           32 :     if(!name)
      32            5 :         return name.error();
      33              : 
      34           27 :     if(it == end)
      35            1 :         BOOST_HTTP_PROTO_RETURN_EC(
      36              :             grammar::error::need_more);
      37              : 
      38           26 :     if(*it++ != '=')
      39            0 :         BOOST_HTTP_PROTO_RETURN_EC(
      40              :             grammar::error::mismatch);
      41              : 
      42           26 :     auto value = grammar::parse(
      43              :         it, end, quoted_token_rule);
      44           26 :     if(!value)
      45            1 :         return value.error();
      46              : 
      47           25 :     return value_type{ *name, *value };
      48              : }
      49              : 
      50              : auto
      51           18 : parameters_rule_t::
      52              : parse(
      53              :     char const*& it,
      54              :     char const* end) const noexcept ->
      55              :         system::result<value_type>
      56              : {
      57              :     constexpr auto ows = grammar::squelch(
      58              :         grammar::optional_rule(
      59              :             grammar::token_rule(detail::ws)));
      60              : 
      61              :     return grammar::parse(
      62           18 :         it, end, grammar::range_rule(
      63           18 :             grammar::tuple_rule(
      64              :                 ows,
      65           36 :                 grammar::squelch(grammar::literal_rule(";")),
      66              :                 ows,
      67           18 :                 parameter_rule)));
      68              : }
      69              : } // implementation_defined
      70              : } // http_proto
      71              : } // boost
        

Generated by: LCOV version 2.1