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-02-29 20:02:55 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             : #ifndef BOOST_URL_DETAIL_IMPL_IPVFUTURE_RULE_IPP
      11             : #define BOOST_URL_DETAIL_IMPL_IPVFUTURE_RULE_IPP
      12             : 
      13             : #include <boost/url/detail/config.hpp>
      14             : #include "ipvfuture_rule.hpp"
      15             : #include <boost/url/error.hpp>
      16             : #include "charsets.hpp"
      17             : #include <boost/url/grammar/charset.hpp>
      18             : #include <boost/url/grammar/delim_rule.hpp>
      19             : #include <boost/url/grammar/hexdig_chars.hpp>
      20             : #include <boost/url/grammar/parse.hpp>
      21             : #include <boost/url/grammar/token_rule.hpp>
      22             : #include <boost/url/grammar/tuple_rule.hpp>
      23             : 
      24             : namespace boost {
      25             : namespace urls {
      26             : namespace detail {
      27             : 
      28             : auto
      29          38 : ipvfuture_rule_t::
      30             : parse(
      31             :     char const*& it,
      32             :     char const* const end
      33             :         ) const noexcept ->
      34             :     system::result<value_type>
      35             : {
      36             :     static constexpr auto
      37             :         minor_chars = 
      38             :             unreserved_chars +
      39             :             sub_delim_chars + ':';
      40          38 :     auto const it0 = it;
      41             :     auto rv = grammar::parse(
      42             :         it, end,
      43          38 :         grammar::tuple_rule(
      44          38 :             grammar::delim_rule('v'),
      45          38 :             grammar::token_rule(
      46          38 :                 grammar::hexdig_chars),
      47          38 :             grammar::delim_rule('.'),
      48          76 :             grammar::token_rule(minor_chars)));
      49          38 :     if(! rv)
      50          23 :         return rv.error();
      51          15 :     value_type t;
      52          15 :     t.major = std::get<0>(*rv);
      53          15 :     t.minor = std::get<1>(*rv);
      54          15 :     if(t.major.empty())
      55             :     {
      56             :         // can't be empty
      57           0 :         BOOST_URL_RETURN_EC(
      58             :             grammar::error::invalid);
      59             :     }
      60          15 :     if(t.minor.empty())
      61             :     {
      62             :         // can't be empty
      63           0 :         BOOST_URL_RETURN_EC(
      64             :             grammar::error::invalid);
      65             :     }
      66          30 :     t.str = core::string_view(
      67          15 :         it0, it - it0);
      68          15 :     return t;
      69             : }
      70             : 
      71             : } // detail
      72             : } // urls
      73             : } // boost
      74             : 
      75             : #endif

Generated by: LCOV version 1.15