LCOV - code coverage report
Current view: top level - libs/http_proto/src_zlib/service/deflate_service.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 0.0 % 52 0
Test Date: 2025-05-26 06:53:20 Functions: 0.0 % 18 0

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 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              : #include <boost/http_proto/service/deflate_service.hpp>
      11              : #include <zlib.h>
      12              : #include "src_zlib/service/stream_cast.hpp"
      13              : 
      14              : #include <boost/static_assert.hpp>
      15              : 
      16              : namespace boost {
      17              : namespace http_proto {
      18              : namespace zlib {
      19              : 
      20              : BOOST_STATIC_ASSERT(sizeof(stream_t) == sizeof(z_stream_s));
      21              : BOOST_STATIC_ASSERT(is_layout_identical<stream_t, z_stream_s>());
      22              : 
      23              : //------------------------------------------------
      24              : 
      25              : class deflate_service_impl
      26              :     : public deflate_service
      27              :     , public http_proto::service
      28              : {
      29              : public:
      30              :     using key_type = deflate_service;
      31              : 
      32              :     explicit
      33            0 :     deflate_service_impl(
      34              :         http_proto::context&) noexcept
      35            0 :     {
      36            0 :     }
      37              : 
      38            0 :     ~deflate_service_impl()
      39            0 :     {
      40            0 :     }
      41              : 
      42              :     char const*
      43            0 :     version() const noexcept override
      44              :     {
      45            0 :         return zlibVersion();
      46              :     }
      47              : 
      48              :     int
      49            0 :     init(
      50              :         stream_t& st,
      51              :         int level) const override
      52              :     {
      53            0 :         stream_cast sc(st);
      54            0 :         return deflateInit(sc.get(), level);
      55              :     }
      56              : 
      57              :     int
      58            0 :     init2(
      59              :         stream_t& st,
      60              :         int level,
      61              :         int method,
      62              :         int windowBits,
      63              :         int memLevel,
      64              :         int strategy) const override
      65              :     {
      66            0 :         stream_cast sc(st);
      67            0 :         return deflateInit2(sc.get(),
      68              :             level, method, windowBits,
      69              :             memLevel, strategy);
      70              :     }
      71              : 
      72              :     int
      73            0 :     set_dict(
      74              :         stream_t& st,
      75              :         unsigned char const* dict,
      76              :         unsigned len) const override
      77              :     {
      78            0 :         stream_cast sc(st);
      79            0 :         return deflateSetDictionary(sc.get(), dict, len);
      80              :     }
      81              : 
      82              :     int
      83            0 :     get_dict(
      84              :         stream_t& st,
      85              :         unsigned char* dest,
      86              :         unsigned* len) const override
      87              :     {
      88            0 :         stream_cast sc(st);
      89            0 :         return deflateGetDictionary(sc.get(), dest, len);
      90              :     }
      91              : 
      92              :     int
      93            0 :     dup(
      94              :         stream_t& dest,
      95              :         stream_t& src) const override
      96              :     {
      97            0 :         stream_cast sc0(dest);
      98            0 :         stream_cast sc1(src);
      99            0 :         return deflateCopy(sc0.get(), sc1.get());
     100              :     }
     101              : 
     102              :     int
     103            0 :     deflate(
     104              :         stream_t& st,
     105              :         int flush) const override
     106              :     {
     107            0 :         stream_cast sc(st);
     108            0 :         return ::deflate(sc.get(), flush);
     109              :     }
     110              : 
     111              :     int
     112            0 :     deflate_end(
     113              :         stream_t& st) const override
     114              :     {
     115            0 :         stream_cast sc(st);
     116            0 :         return deflateEnd(sc.get());
     117              :     }
     118              : 
     119              :     int
     120            0 :     reset(
     121              :         stream_t& st) const override
     122              :     {
     123            0 :         stream_cast sc(st);
     124            0 :         return deflateReset(sc.get());
     125              :     }
     126              : 
     127              :     int
     128            0 :     params(
     129              :         stream_t& st,
     130              :         int level,
     131              :         int strategy) const override
     132              :     {
     133            0 :         stream_cast sc(st);
     134            0 :         return deflateParams(sc.get(), level, strategy);
     135              :     }
     136              : 
     137              :     std::size_t
     138            0 :     bound(
     139              :         stream_t& st,
     140              :         unsigned long sourceLen) const override
     141              :     {
     142            0 :         stream_cast sc(st);
     143            0 :         return deflateBound(sc.get(), sourceLen);
     144              :     }
     145              : 
     146              :     int
     147            0 :     pending(
     148              :         stream_t& st,
     149              :         unsigned* pending,
     150              :         int* bits) const override
     151              :     {
     152            0 :         stream_cast sc(st);
     153            0 :         return deflatePending(sc.get(), pending, bits);
     154              :     }
     155              : 
     156              :     int
     157            0 :     prime(
     158              :         stream_t& st,
     159              :         int bits,
     160              :         int value) const override
     161              :     {
     162            0 :         stream_cast sc(st);
     163            0 :         return deflatePrime(sc.get(), bits, value);
     164              :     }
     165              : 
     166              :     int
     167            0 :     set_header(
     168              :         stream_t& st,
     169              :         void* header) const override
     170              :     {
     171            0 :         stream_cast sc(st);
     172            0 :         return deflateSetHeader(sc.get(),
     173            0 :             reinterpret_cast<gz_header*>(header));
     174              :     }
     175              : };
     176              : 
     177              : void
     178            0 : install_deflate_service(context& ctx)
     179              : {
     180            0 :     ctx.make_service<deflate_service_impl>();
     181            0 : }
     182              : 
     183              : } // zlib
     184              : } // http_proto
     185              : } // boost
        

Generated by: LCOV version 2.1