src/detail/util.hpp

75.0% Lines (3/4) 100.0% List of functions (1/1) 50.0% Branches (1/2)
util.hpp
f(x) Functions (1)
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 #if 0
41
42 std::optional<std::string>
43 extract_filename_form_content_disposition(std::string_view sv);
44
45 // Resolve the destination path for writing a response body. If `dest` is a
46 // directory, derive a filename from the Content-Disposition header, falling
47 // back to the URL's last path segment, then to "index.html". Otherwise `dest`
48 // is returned unchanged.
49 std::filesystem::path
50 resolve_dest(response& resp, std::filesystem::path dest);
51
52 #endif
53 } // namespace detail
54 } // namespace burl
55 } // namespace boost
56
57 #endif
58