LCOV - code coverage report
Current view: top level - http_proto - string_body.hpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 13 13 100.0 %
Date: 2023-01-26 23:44:13 Functions: 4 4 100.0 %

          Line data    Source code
       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 const_iterator = 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             : } // http_proto
      62             : } // boost
      63             : 
      64             : #endif

Generated by: LCOV version 1.15