LCOV - code coverage report
Current view: top level - http_proto/rfc/impl - upgrade_rule.ipp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 14 15 93.3 %
Date: 2023-12-22 17:54:30 Functions: 1 1 100.0 %

          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             : #ifndef BOOST_HTTP_PROTO_RFC_IMPL_UPGRADE_RULE_IPP
      11             : #define BOOST_HTTP_PROTO_RFC_IMPL_UPGRADE_RULE_IPP
      12             : 
      13             : #include <boost/http_proto/rfc/upgrade_rule.hpp>
      14             : #include <boost/http_proto/rfc/token_rule.hpp>
      15             : #include <boost/url/grammar/error.hpp>
      16             : #include <boost/url/grammar/parse.hpp>
      17             : 
      18             : namespace boost {
      19             : namespace http_proto {
      20             : 
      21             : auto
      22          41 : upgrade_protocol_rule_t::
      23             : parse(
      24             :     char const*& it,
      25             :     char const* end) const noexcept ->
      26             :         system::result<value_type>
      27             : {
      28          41 :     value_type t;
      29             :     // token
      30             :     {
      31             :         auto rv = grammar::parse(
      32          41 :             it, end, token_rule);
      33          41 :         if(! rv)
      34           3 :             return rv.error();
      35          38 :         t.name = *rv;
      36             :     }
      37             :     // [ "/" token ]
      38          38 :     if( it == end ||
      39           8 :         *it != '/')
      40          31 :         return t;
      41           7 :     ++it;
      42             :     auto rv = grammar::parse(
      43           7 :         it, end, token_rule);
      44           7 :     if(! rv)
      45           0 :         return rv.error();
      46           7 :     t.version = *rv;
      47           7 :     return t;
      48             : }
      49             : 
      50             : } // http_proto
      51             : } // boost
      52             : 
      53             : #endif

Generated by: LCOV version 1.15