LCOV - code coverage report
Current view: top level - libs/url/src/rfc/detail - ipvfuture_rule.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 18 20 90.0 %
Date: 2024-03-15 19:37:08 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 "ipvfuture_rule.hpp"
      13             : #include <boost/url/error.hpp>
      14             : #include "charsets.hpp"
      15             : #include <boost/url/grammar/charset.hpp>
      16             : #include <boost/url/grammar/delim_rule.hpp>
      17             : #include <boost/url/grammar/hexdig_chars.hpp>
      18             : #include <boost/url/grammar/parse.hpp>
      19             : #include <boost/url/grammar/token_rule.hpp>
      20             : #include <boost/url/grammar/tuple_rule.hpp>
      21             : 
      22             : namespace boost {
      23             : namespace urls {
      24             : namespace detail {
      25             : 
      26             : auto
      27          38 : ipvfuture_rule_t::
      28             : parse(
      29             :     char const*& it,
      30             :     char const* const end
      31             :         ) const noexcept ->
      32             :     system::result<value_type>
      33             : {
      34             :     static constexpr auto
      35             :         minor_chars = 
      36             :             unreserved_chars +
      37             :             sub_delim_chars + ':';
      38          38 :     auto const it0 = it;
      39             :     auto rv = grammar::parse(
      40             :         it, end,
      41          38 :         grammar::tuple_rule(
      42          38 :             grammar::delim_rule('v'),
      43          38 :             grammar::token_rule(
      44          38 :                 grammar::hexdig_chars),
      45          38 :             grammar::delim_rule('.'),
      46          76 :             grammar::token_rule(minor_chars)));
      47          38 :     if(! rv)
      48          23 :         return rv.error();
      49          15 :     value_type t;
      50          15 :     t.major = std::get<0>(*rv);
      51          15 :     t.minor = std::get<1>(*rv);
      52          15 :     if(t.major.empty())
      53             :     {
      54             :         // can't be empty
      55           0 :         BOOST_URL_RETURN_EC(
      56             :             grammar::error::invalid);
      57             :     }
      58          15 :     if(t.minor.empty())
      59             :     {
      60             :         // can't be empty
      61           0 :         BOOST_URL_RETURN_EC(
      62             :             grammar::error::invalid);
      63             :     }
      64          30 :     t.str = core::string_view(
      65          15 :         it0, it - it0);
      66          15 :     return t;
      67             : }
      68             : 
      69             : } // detail
      70             : } // urls
      71             : } // boost
      72             : 

Generated by: LCOV version 1.15