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

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
       3             : // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
       4             : //
       5             : // Distributed under the Boost Software License, Version 1.0. (See accompanying
       6             : // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
       7             : //
       8             : // Official repository: https://github.com/CPPAlliance/url
       9             : //
      10             : 
      11             : #ifndef BOOST_URL_IMPL_PARSE_QUERY_IPP
      12             : #define BOOST_URL_IMPL_PARSE_QUERY_IPP
      13             : 
      14             : #include <boost/url/detail/config.hpp>
      15             : #include <boost/url/parse_query.hpp>
      16             : #include <boost/url/rfc/query_rule.hpp>
      17             : #include <boost/url/grammar/parse.hpp>
      18             : 
      19             : #include <boost/url/error.hpp>
      20             : 
      21             : namespace boost {
      22             : namespace urls {
      23             : 
      24             : system::result<params_encoded_view>
      25         137 : parse_query(core::string_view s) noexcept
      26             : {
      27             :     // Handle empty strings differently.
      28             :     // We produce {}, versus empty but
      29             :     // present query in URL (e.g. "http:?")
      30             :     // which produces {{"", none}}.
      31         137 :     if(s.empty())
      32           8 :         return params_encoded_view(
      33          16 :             detail::query_ref(
      34           8 :                 s.data(), 0, 0));
      35         129 :     auto rv = grammar::parse(s, query_rule);
      36         129 :     if(! rv)
      37          12 :         return rv.error();
      38         117 :     return params_encoded_view(
      39         234 :         detail::query_ref(
      40         234 :             s, s.size(), rv->size()));
      41             : }
      42             : 
      43             : } // urls
      44             : } // boost
      45             : 
      46             : #endif

Generated by: LCOV version 1.15