src/detail/util.hpp
75.0% Lines (3/4)
100.0% List of functions (1/1)
50.0% Branches (1/2)
Functions (1)
Function
Calls
Lines
Branches
Blocks
unsigned long boost::burl::detail::clamp<unsigned long>(unsigned long, unsigned long)
:31
7x
75.0%
50.0%
75.0%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2026 Mohammad Nejati | |||
| 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/cppalliance/burl | |||
| 8 | // | |||
| 9 | ||||
| 10 | #ifndef BOOST_BURL_SRC_DETAIL_UTIL_HPP | |||
| 11 | #define BOOST_BURL_SRC_DETAIL_UTIL_HPP | |||
| 12 | ||||
| 13 | #include <cstddef> | |||
| 14 | #include <filesystem> | |||
| 15 | #include <limits> | |||
| 16 | #include <string_view> | |||
| 17 | #include <optional> | |||
| 18 | ||||
| 19 | namespace boost | |||
| 20 | { | |||
| 21 | namespace burl | |||
| 22 | { | |||
| 23 | ||||
| 24 | class response; | |||
| 25 | ||||
| 26 | namespace detail | |||
| 27 | { | |||
| 28 | ||||
| 29 | template<class UInt> | |||
| 30 | std::size_t | |||
| 31 | 7x | clamp( | ||
| 32 | UInt x, | |||
| 33 | std::size_t limit = (std::numeric_limits<std::size_t>::max)()) noexcept | |||
| 34 | { | |||
| 35 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7x | if(x >= limit) | |
| 36 | 7x | return limit; | ||
| 37 | ✗ | return static_cast<std::size_t>(x); | ||
| 38 | } | |||
| 39 | ||||
| 40 | std::optional<std::string> | |||
| 41 | extract_filename_form_content_disposition(std::string_view sv); | |||
| 42 | ||||
| 43 | // Resolve the destination path for writing a response body. If `dest` is a | |||
| 44 | // directory, derive a filename from the Content-Disposition header, falling | |||
| 45 | // back to the URL's last path segment, then to "index.html". Otherwise `dest` | |||
| 46 | // is returned unchanged. | |||
| 47 | std::filesystem::path | |||
| 48 | resolve_dest(response& resp, std::filesystem::path dest); | |||
| 49 | ||||
| 50 | } // namespace detail | |||
| 51 | } // namespace burl | |||
| 52 | } // namespace boost | |||
| 53 | ||||
| 54 | #endif | |||
| 55 |