GCC Code Coverage Report


Directory: libs/http_proto/
File: boost/http_proto/string_body.hpp
Date: 2024-03-04 15:37:43
Exec Total Coverage
Lines: 13 13 100.0%
Functions: 4 4 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2021 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_STRING_BODY_HPP
11 #define BOOST_HTTP_PROTO_STRING_BODY_HPP
12
13 #include <boost/http_proto/detail/config.hpp>
14 #include <boost/buffers/const_buffer.hpp>
15 #include <string>
16 #include <utility>
17
18 namespace boost {
19 namespace http_proto {
20
21 class string_body
22 {
23 std::string s_;
24 buffers::const_buffer cb_;
25
26 public:
27 using value_type = buffers::const_buffer;
28 using const_iterator = buffers::const_buffer const*;
29
30 3 string_body(
31 string_body&& other) noexcept
32 3 : s_(std::move(other.s_))
33 3 , cb_(s_.data(), s_.size())
34 {
35 3 other.cb_ = {};
36 3 }
37
38 string_body(
39 string_body const& other) = delete;
40
41 3 string_body(
42 std::string s) noexcept
43 3 : s_(std::move(s))
44 3 , cb_(s_.data(), s_.size())
45 {
46 3 }
47
48 const_iterator
49 6 begin() const noexcept
50 {
51 6 return &cb_;
52 }
53
54 const_iterator
55 6 end() const noexcept
56 {
57 6 return &cb_ + 1;
58 }
59 };
60
61 //------------------------------------------------
62
63 } // http_proto
64 } // boost
65
66 #endif
67