GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/parse_query.cpp
Date: 2024-01-19 15:42:54
Exec Total Coverage
Lines: 11 11 100.0%
Functions: 1 1 100.0%
Branches: 4 4 100.0%

Line Branch Exec Source
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
2/2
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 129 times.
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
2/2
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 117 times.
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
47