src/corosio/src/local_endpoint.cpp

100.0% Lines (18/18) 100.0% List of functions (2/2) 100.0% Branches (6/6)
local_endpoint.cpp
f(x) Functions (2)
Line Branch TLA Hits Source Code
1 //
2 // Copyright (c) 2026 Michael Vandeberg
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/corosio
8 //
9
10 #include <boost/corosio/local_endpoint.hpp>
11 #include <boost/corosio/detail/except.hpp>
12
13 #include <cstring>
14 #include <ostream>
15 #include <system_error>
16
17 namespace boost::corosio {
18
19 2038x local_endpoint::local_endpoint(std::string_view path)
20 1019x {
21
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 4 times.
1019x if (path.size() > max_path_length)
22 4x detail::throw_system_error(
23 4x std::make_error_code(std::errc::filename_too_long),
24 "local_endpoint");
25 1015x std::memcpy(path_, path.data(), path.size());
26 1015x len_ = static_cast<std::uint8_t>(path.size());
27 1019x }
28
29 std::ostream&
30 6x operator<<(std::ostream& os, local_endpoint const& ep)
31 {
32
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6x if (ep.empty())
33 2x return os;
34
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4x if (ep.is_abstract())
35 {
36 // Skip the leading null byte; print the rest as the name
37 2x os << "[abstract:" << std::string_view(ep.path_ + 1, ep.len_ - 1)
38 2x << ']';
39 2x }
40 else
41 {
42 2x os << ep.path();
43 }
44 4x return os;
45 6x }
46
47 } // namespace boost::corosio
48