LCOV - code coverage report
Current view: top level - http_proto/rfc/impl - combine_field_values.ipp (source / functions) Hit Total Coverage
Test: coverage_filtered.info Lines: 25 27 92.6 %
Date: 2023-01-15 07:18:31 Functions: 1 1 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_RFC_COMBINE_FIELD_VALUES_IPP
      11             : #define BOOST_HTTP_PROTO_RFC_COMBINE_FIELD_VALUES_IPP
      12             : 
      13             : #include <boost/http_proto/rfc/combine_field_values.hpp>
      14             : 
      15             : namespace boost {
      16             : namespace http_proto {
      17             : 
      18             : string_view
      19           8 : combine_field_values(
      20             :     fields_view_base::subrange const& vr,
      21             :     grammar::recycled_ptr<std::string>& temp)
      22             : {
      23           8 :     string_view result;
      24           8 :     bool acquired = false;
      25          19 :     for(auto s : vr)
      26             :     {
      27          11 :         if(s.empty())
      28           0 :             continue;
      29          11 :         if(result.empty())
      30             :         {
      31           7 :             result = s;
      32             :         }
      33           4 :         else if(! acquired)
      34             :         {
      35           3 :             acquired = true;
      36           3 :             if(temp.empty())
      37           0 :                 temp.acquire();
      38           3 :             temp->clear();
      39           3 :             temp->reserve(
      40           3 :                 result.size() +
      41           3 :                 1 + s.size());
      42           3 :             *temp = result;
      43           3 :             temp->push_back(',');
      44             :             temp->append(
      45           3 :                 s.data(), s.size());
      46           3 :             result = *temp;
      47             :         }
      48             :         else
      49             :         {
      50           1 :             temp->reserve(
      51           1 :                 temp->size() +
      52           1 :                 1 + s.size());
      53           1 :             temp->push_back(',');
      54             :             temp->append(
      55           1 :                 s.data(), s.size());
      56           1 :             result = *temp;
      57             :         }
      58             :     }
      59           8 :     return result;
      60             : }
      61             : 
      62             : } // http_proto
      63             : } // boost
      64             : 
      65             : #endif

Generated by: LCOV version 1.15