LCOV - code coverage report
Current view: top level - libs/url/src/rfc/origin_form_rule.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 95.0 % 20 19
Test Date: 2024-08-19 20:08:54 Functions: 100.0 % 1 1

            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 <boost/url/rfc/origin_form_rule.hpp>
      13              : #include <boost/url/rfc/query_rule.hpp>
      14              : #include "boost/url/rfc/detail/path_rules.hpp"
      15              : #include "detail/query_part_rule.hpp"
      16              : #include <boost/url/grammar/delim_rule.hpp>
      17              : #include <boost/url/grammar/range_rule.hpp>
      18              : #include <boost/url/grammar/tuple_rule.hpp>
      19              : 
      20              : namespace boost {
      21              : namespace urls {
      22              : 
      23              : auto
      24           17 : origin_form_rule_t::
      25              : parse(
      26              :     char const*& it,
      27              :     char const* end
      28              :         ) const noexcept ->
      29              :     system::result<value_type>
      30              : {
      31           17 :     detail::url_impl u(detail::url_impl::from::string);
      32           17 :     u.cs_ = it;
      33              : 
      34              :     {
      35              :         auto rv = grammar::parse(it, end,
      36           17 :             grammar::range_rule(
      37           17 :                 grammar::tuple_rule(
      38           17 :                     grammar::delim_rule('/'),
      39              :                     detail::segment_rule),
      40           17 :                 1));
      41           17 :         if(! rv)
      42            4 :             return rv.error();
      43           13 :         u.apply_path(
      44              :             rv->string(),
      45              :             rv->size());
      46           17 :     }
      47              : 
      48              :     // [ "?" query ]
      49              :     {
      50           13 :         auto rv = grammar::parse(
      51              :             it, end, detail::query_part_rule);
      52           13 :         if(! rv)
      53            0 :             return rv.error();
      54           13 :         if(rv->has_query)
      55              :         {
      56              :             // map "?" to { {} }
      57            8 :             u.apply_query(
      58            8 :                 rv->query,
      59            8 :                 rv->count +
      60            8 :                     rv->query.empty());
      61              :         }
      62              :     }
      63              : 
      64           13 :     return u.construct();
      65              : }
      66              : 
      67              : } // urls
      68              : } // boost
      69              : 
        

Generated by: LCOV version 2.1