GCC Code Coverage Report


Directory: libs/http_proto/include/boost/http_proto/
File: boost/http_proto/string_body.hpp
Date: 2023-02-02 18:17:22
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 dot falco at gmail dot 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/http_proto/buffer.hpp>
15 #include <boost/http_proto/string_view.hpp>
16 #include <string>
17 #include <utility>
18
19 namespace boost {
20 namespace http_proto {
21
22 class string_body
23 {
24 std::string s_;
25 const_buffer cb_;
26
27 public:
28 using value_type = const_buffer;
29 using const_iterator = const_buffer const*;
30
31 3 string_body(
32 string_body&& other) noexcept
33 3 : s_(std::move(other.s_))
34 3 , cb_(s_.data(), s_.size())
35 {
36 3 other.cb_ = {};
37 3 }
38
39 string_body(
40 string_body const& other) = delete;
41
42 3 string_body(
43 std::string s) noexcept
44 3 : s_(std::move(s))
45 3 , cb_(s_.data(), s_.size())
46 {
47 3 }
48
49 const_iterator
50 6 begin() const noexcept
51 {
52 6 return &cb_;
53 }
54
55 const_iterator
56 6 end() const noexcept
57 {
58 6 return &cb_ + 1;
59 }
60 };
61
62 //------------------------------------------------
63
64 } // http_proto
65 } // boost
66
67 #endif
68