GCC Code Coverage Report


Directory: ./
File: libs/capy/include/boost/capy/buffers/to_string.hpp
Date: 2026-01-15 23:24:40
Exec Total Coverage
Lines: 8 9 88.9%
Functions: 3 3 100.0%
Branches: 5 5 100.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2025 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/capy
8 //
9
10 #ifndef BOOST_CAPY_BUFFERS_TO_STRING_HPP
11 #define BOOST_CAPY_BUFFERS_TO_STRING_HPP
12
13 #include <boost/capy/detail/config.hpp>
14 #include <boost/capy/buffers.hpp>
15 #include <string>
16
17 namespace boost {
18 namespace capy {
19
20 /** Convert a buffer sequence to a string
21
22 This function constructs a string from the bytes in the
23 buffer sequence `bs`.
24
25 @par Constraints
26 @code
27 const_buffer_sequence<ConstBufferSequence>
28 @endcode
29
30 @param bs The buffer sequence
31
32 @return A string holding the bytes from the buffer sequence
33 */
34 template<const_buffer_sequence ConstBufferSequence>
35 std::string
36 109 to_string(ConstBufferSequence const& bs)
37 {
38 109 std::string s;
39 109 auto const e = end(bs);
40
4/4
✓ Branch 3 taken 301 times.
✓ Branch 4 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 39 times.
788 for(auto it = begin(bs); it != e; ++it)
41 {
42 679 const_buffer b(*it);
43
1/1
✓ Branch 2 taken 340 times.
1358 s.append(
44 679 static_cast<char const*>(b.data()),
45 b.size());
46 }
47 141 return s;
48 }
49
50 } // capy
51 } // boost
52
53 #endif
54