LCOV - code coverage report
Current view: top level - http_proto/impl - parser.hpp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 7 8 87.5 %
Date: 2023-03-01 04:29:22 Functions: 1 1 100.0 %

          Line data    Source code
       1             : //
       2             : // Copyright (c) 2019 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_IMPL_PARSER_HPP
      11             : #define BOOST_HTTP_PROTO_IMPL_PARSER_HPP
      12             : 
      13             : #include <cstdlib>
      14             : 
      15             : namespace boost {
      16             : namespace http_proto {
      17             : 
      18             : //------------------------------------------------
      19             : 
      20             : template<class DynamicBuffer, class>
      21             : typename std::decay<
      22             :     DynamicBuffer>::type&
      23        6775 : parser::
      24             : set_body(
      25             :     DynamicBuffer&& b)
      26             : {
      27             :     // body type already chosen
      28        6775 :     if(how_ != how::in_place)
      29           0 :         detail::throw_logic_error();
      30             : 
      31        6775 :     auto& dyn = ws_.push(
      32             :         buffers::any_dynamic_buffer_impl<typename
      33             :             std::decay<DynamicBuffer>::type,
      34             :                 buffers_N>(std::forward<
      35             :                     DynamicBuffer>(b)));
      36        6775 :     dyn_ = &dyn;
      37        6775 :     how_ = how::dynamic;
      38        6775 :     on_set_body();
      39        6775 :     return dyn.buffer();
      40             : }
      41             : 
      42             : //------------------------------------------------
      43             : 
      44             : template<class Sink>
      45             : typename std::enable_if<
      46             :     is_sink<Sink>::value,
      47             :     typename std::decay<Sink>::type
      48             :         >::type
      49             : parser::
      50             : set_body(
      51             :     Sink&& sink)
      52             : {
      53             :     // body type already chosen
      54             :     if(how_ != how::in_place)
      55             :         detail::throw_logic_error();
      56             : 
      57             :     auto& s = ws_.push(
      58             :         std::forward<
      59             :             Sink>(sink));
      60             :     sink_ = &s;
      61             :     how_ = how::sink;
      62             :     on_set_body();
      63             :     return s;
      64             : }
      65             : 
      66             : } // http_proto
      67             : } // boost
      68             : 
      69             : #endif

Generated by: LCOV version 1.15