GCC Code Coverage Report


Directory: libs/http_proto/
File: include/boost/http_proto/detail/file_stdio.hpp
Date: 2025-09-21 18:08:15
Exec Total Coverage
Lines: 4 4 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.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/cppalliance/http_proto
8 //
9
10 #ifndef BOOST_HTTP_PROTO_DETAIL_FILE_STDIO_HPP
11 #define BOOST_HTTP_PROTO_DETAIL_FILE_STDIO_HPP
12
13 #include <boost/http_proto/detail/config.hpp>
14 #include <boost/http_proto/error.hpp>
15 #include <boost/http_proto/file_mode.hpp>
16 #include <cstdio>
17 #include <cstdint>
18
19 namespace boost {
20 namespace http_proto {
21 namespace detail {
22
23 // Implementation of File which uses cstdio.
24 class file_stdio
25 {
26 std::FILE* f_ = nullptr;
27
28 public:
29 using native_handle_type = std::FILE*;
30
31 BOOST_HTTP_PROTO_DECL
32 ~file_stdio();
33
34 file_stdio() = default;
35
36 BOOST_HTTP_PROTO_DECL
37 file_stdio(file_stdio&& other) noexcept;
38
39 BOOST_HTTP_PROTO_DECL
40 file_stdio&
41 operator=(file_stdio&& other) noexcept;
42
43 std::FILE*
44 2 native_handle() const
45 {
46 2 return f_;
47 }
48
49 BOOST_HTTP_PROTO_DECL
50 void
51 native_handle(std::FILE* f);
52
53 bool
54 10 is_open() const
55 {
56 10 return f_ != nullptr;
57 }
58
59 BOOST_HTTP_PROTO_DECL
60 void
61 close(system::error_code& ec);
62
63 BOOST_HTTP_PROTO_DECL
64 void
65 open(char const* path, file_mode mode, system::error_code& ec);
66
67 BOOST_HTTP_PROTO_DECL
68 std::uint64_t
69 size(system::error_code& ec) const;
70
71 BOOST_HTTP_PROTO_DECL
72 std::uint64_t
73 pos(system::error_code& ec) const;
74
75 BOOST_HTTP_PROTO_DECL
76 void
77 seek(std::uint64_t offset, system::error_code& ec);
78
79 BOOST_HTTP_PROTO_DECL
80 std::size_t
81 read(void* buffer, std::size_t n, system::error_code& ec);
82
83 BOOST_HTTP_PROTO_DECL
84 std::size_t
85 write(void const* buffer, std::size_t n, system::error_code& ec);
86 };
87
88 } // detail
89 } // http_proto
90 } // boost
91
92 #endif
93