LCOV - code coverage report
Current view: top level - libs/url/src/rfc - ipv4_address_rule.cpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 13 13 100.0 %
Date: 2024-02-29 20:02:55 Functions: 1 1 100.0 %

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2022 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/boostorg/url
       8             : //
       9             : 
      10             : #ifndef BOOST_URL_RFC_IMPL_IPV4_ADDRESS_RULE_IPP
      11             : #define BOOST_URL_RFC_IMPL_IPV4_ADDRESS_RULE_IPP
      12             : 
      13             : #include <boost/url/detail/config.hpp>
      14             : #include <boost/url/rfc/ipv4_address_rule.hpp>
      15             : #include <boost/url/grammar/delim_rule.hpp>
      16             : #include <boost/url/grammar/dec_octet_rule.hpp>
      17             : #include <boost/url/grammar/parse.hpp>
      18             : #include <boost/url/grammar/tuple_rule.hpp>
      19             : 
      20             : namespace boost {
      21             : namespace urls {
      22             : 
      23             : auto
      24        1823 : ipv4_address_rule_t::
      25             : parse(
      26             :     char const*& it,
      27             :     char const* end
      28             :         ) const noexcept ->
      29             :     system::result<value_type>
      30             : {
      31             :     using namespace grammar;
      32             :     auto rv = grammar::parse(
      33        1823 :         it, end, tuple_rule(
      34        1823 :             dec_octet_rule, squelch(delim_rule('.')),
      35        1823 :             dec_octet_rule, squelch(delim_rule('.')),
      36        1823 :             dec_octet_rule, squelch(delim_rule('.')),
      37        1823 :             dec_octet_rule));
      38        1823 :     if(! rv)
      39        1710 :         return rv.error();
      40             :     std::array<unsigned char, 4> v;
      41         113 :     v[0] = std::get<0>(*rv);
      42         113 :     v[1] = std::get<1>(*rv);
      43         113 :     v[2] = std::get<2>(*rv);
      44         113 :     v[3] = std::get<3>(*rv);
      45         113 :     return ipv4_address(v);
      46             : }
      47             : 
      48             : } // urls
      49             : } // boost
      50             : 
      51             : #endif

Generated by: LCOV version 1.15